-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MC support for CHERI memory colouring instructions. #508
Open
davidchisnall
wants to merge
6
commits into
dev
Choose a base branch
from
cheri-colours
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+64
−0
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c23f037
Add MC support for CHERI memory colouring instructions.
davidchisnall 8c1b90c
Disable CHERI memory colouring instructions by default.
davidchisnall 423b758
Updates to memory versioning instructions.
ronorton 40de332
Minor formatting changes requested by jrtc27.
ronorton ee5ab1b
Add brackets around memory operand for cloadversion(s), cstoreversion…
ronorton 2abcb04
Change encoding of cloadversion after jalr.pcc was accidentally alloc…
ronorton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1554,3 +1554,26 @@ let Predicates = [HasCheri, IsRV64, IsCapMode] in { | |||||
defm : CheriLdPat<load, CLC_128>; | ||||||
defm : CheriStPat<store, CSC_128, GPCR>; | ||||||
} // Predicates = [HasCheri, IsRV64, IsCapMode] | ||||||
|
||||||
|
||||||
/// CHERI memory colouring extensions | ||||||
let Predicates = [HasCheri, HasCheriMemVersion] in { | ||||||
def CGetVersion : Cheri_r<0x13, "cgetversion">; | ||||||
def CSetVersion : Cheri_rr<0x2, "csetversion">; | ||||||
let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in { | ||||||
def CLoadVersion : RVInstCheriSrcDst<0x7f, 0x16, 0, OPC_CHERI, (outs GPR:$rd), | ||||||
(ins GPCRMemAtomic:$rs1), | ||||||
"cloadversion", "$rd, $rs1">; | ||||||
def CLoadVersions : RVInstCheriSrcDst<0x7f, 0x15, 0, OPC_CHERI, (outs GPR:$rd), | ||||||
(ins GPCRMemAtomic:$rs1), | ||||||
"cloadversions", "$rd, $rs1">; | ||||||
} | ||||||
let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in | ||||||
def CStoreVersion : RVInstCheriTwoSrc<0x7e, 0x2, 0, OPC_CHERI, (outs), | ||||||
(ins GPCRMemAtomic:$rs1, GPR:$rs2), | ||||||
"cstoreversion", "$rs2, $rs1">; | ||||||
let mayLoad = 1, mayStore = 1, hasSideEffects = 0 in | ||||||
def CAmoCDecVersion : RVInstR<0x3, 0, OPC_CHERI, (outs GPR:$rd), | ||||||
(ins GPCRMemAtomic:$rs1, GPCR:$rs2), | ||||||
"camocdecversion", "$rd, $rs1, $rs2">; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
to match stores and atomics |
||||||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# RUN: llvm-mc %s -triple=riscv64 -mattr=+xcheri,+xcherimemversion -show-encoding \ | ||
# RUN: | FileCheck %s | ||
# RUN: not llvm-mc %s -triple=riscv64 -mattr=+xcheri -show-encoding \ | ||
# RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-DISABLED | ||
|
||
# CHECK: cgetversion gp, csp | ||
# CHECK: encoding: [0xdb,0x01,0x31,0xff] | ||
# CHECK-DISABLED: error: instruction requires the following: CHERI Extension with memory versioning | ||
cgetversion x3, c2 | ||
# CHECK: csetversion cra, csp, gp | ||
# CHECK: encoding: [0xdb,0x00,0x31,0x04] | ||
# CHECK-DISABLED: error: instruction requires the following: CHERI Extension with memory versioning | ||
csetversion c1, c2, x3 | ||
# CHECK: cloadversion sp, (cra) | ||
# CHECK: encoding: [0x5b,0x81,0x60,0xff] | ||
# CHECK-DISABLED: error: instruction requires the following: CHERI Extension with memory versioning | ||
cloadversion x2, (c1) | ||
# CHECK: cloadversions sp, (cra) | ||
# CHECK: encoding: [0x5b,0x81,0x50,0xff] | ||
# CHECK-DISABLED: error: instruction requires the following: CHERI Extension with memory versioning | ||
cloadversions x2, (c1) | ||
# CHECK: cstoreversion ra, (ctp) | ||
# CHECK: encoding: [0x5b,0x01,0x12,0xfc] | ||
# CHECK-DISABLED: error: instruction requires the following: CHERI Extension with memory versioning | ||
cstoreversion x1, (c4) | ||
# CHECK: camocdecversion ra, (csp), cgp | ||
# CHECK: encoding: [0xdb,0x00,0x31,0x06] | ||
# CHECK-DISABLED: error: instruction requires the following: CHERI Extension with memory versioning | ||
camocdecversion x1, (c2), c3 | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instructions go in the first half of the file to keep MC and CodeGen cleanly separated*
(* pseudos are more complicated, but placed based on whether they're used for assembly or just CodeGen)