-
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
base: dev
Are you sure you want to change the base?
Changes from 1 commit
c23f037
8c1b90c
423b758
40de332
ee5ab1b
2abcb04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1554,3 +1554,21 @@ 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, IsRV64] in { | ||||||
def CGetVersion : Cheri_r<0x13, "cgetversion">; | ||||||
def CSetVersion : Cheri_rr<0x2, "csetversion">; | ||||||
let mayLoad = 1 in | ||||||
{ | ||||||
rmn30 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
def CLoadVersion : Cheri_r<0x14, "cloadversion">; | ||||||
def CLoadVersions : Cheri_r<0x15, "cloadversions">; | ||||||
} | ||||||
let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in | ||||||
def CStoreVersion : RVInstCheriTwoSrc<0x7e, 0x2, 0, OPC_CHERI, (outs), | ||||||
(ins GPR:$rs1, GPCR:$rs2), | ||||||
rmn30 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
"cstoreversion", "$rs1, $rs2">; | ||||||
let mayLoad = 1, mayStore = 1 in | ||||||
def CAmoCDecVersion : Cheri_rr<0x3, "camocdecversion", GPR>; | ||||||
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. Is it important to indicate that
Suggested change
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. I believe that type exists only to allow using 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. I've not seen that before, but in other back ends you never specify anything explicitly on operands to indicate that they are the memory addresses for atomics. 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. Yes it's solely a parser thing. RISC-V's atomic operands are the only memory-accessing instructions that don't take an immediate, and have 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. This being the case I am tempted to (ab)use 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. Yeah, that's what I would do, then it matches the explicit loads/stores. Maybe one day I'll rename it to something more general (and do so upstream too, even if it currently makes less sense, but I think the hypervisor load/store-as-guest instructions are also immediate-less and will end up wanting the same syntax). |
||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# RUN: llvm-mc %s -triple=riscv64 -mattr=+xcheri -show-encoding \ | ||
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. These belong in rv64xcheri-valid.s as it stands 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. (though a separate extension means rv64xname-valid.s for some other name) |
||
# RUN: | FileCheck %s | ||
|
||
# CHECK: cgetversion gp, csp | ||
# CHECK: encoding: [0xdb,0x01,0x31,0xff] | ||
CGetVersion x3, c2 | ||
rmn30 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# CHECK: csetversion cra, csp, gp | ||
# CHECK: encoding: [0xdb,0x00,0x31,0x04] | ||
CSetVersion c1, c2, x3 | ||
# CHECK: cloadversion sp, cra | ||
# CHECK: encoding: [0x5b,0x81,0x40,0xff] | ||
CloadVersion x2, c1 | ||
# CHECK: cloadversions sp, cra | ||
# CHECK: encoding: [0x5b,0x81,0x50,0xff] | ||
CloadVersions x2, c1 | ||
# CHECK: cstoreversion ra, ctp | ||
# CHECK: encoding: [0x5b,0x81,0x40,0xfc] | ||
CStoreVersion x1, c4 | ||
# CHECK: camocdecversion ra, csp, gp | ||
# CHECK: encoding: [0xdb,0x00,0x31,0x06] | ||
CAmoCDecVersion x1, c2, x3 | ||
|
||
|
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)