Skip to content

Commit fd09919

Browse files
committed
[CHERIoT] Make operand predicates more lenient in places where it is needed to enable ct-prefixed instruction mnemonics.
1 parent 5bda199 commit fd09919

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfo.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ def simm12 : RISCVSImmLeafOp<12> {
263263
int64_t Imm;
264264
if (MCOp.evaluateAsConstantImm(Imm))
265265
return isInt<12>(Imm);
266+
// Needed to make CHERIOT mnemonic aliases work.
267+
if (STI.hasFeature(RISCV::FeatureVendorXCheriot) &&
268+
MCOp.isExpr())
269+
return true;
266270
return MCOp.isBareSymbolRef();
267271
}];
268272
}
@@ -292,6 +296,10 @@ class UImm20OperandMaybeSym : RISCVUImmOp<20> {
292296
int64_t Imm;
293297
if (MCOp.evaluateAsConstantImm(Imm))
294298
return isUInt<20>(Imm);
299+
// Needed to make CHERIOT mnemonic aliases work.
300+
if (STI.hasFeature(RISCV::FeatureVendorXCheriot) &&
301+
MCOp.isExpr())
302+
return true;
295303
return MCOp.isBareSymbolRef();
296304
}];
297305
}

llvm/lib/Target/RISCV/RISCVInstrInfoXCheri.td

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2056,9 +2056,8 @@ def PseudoCTAIL : Pseudo<(outs), (ins cap_call_symbol:$dst), []> {
20562056
let AsmString = "ctail\t$dst";
20572057
}
20582058

2059-
let Predicates = [HasCheriot] in def : InstAlias<
2060-
"ct.ctail $dst",
2061-
(PseudoCTAIL cap_call_symbol:$dst)>;
2059+
let Predicates = [HasCheriot] in
2060+
def : InstAlias<"ct.ctail $dst", (PseudoCTAIL cap_call_symbol:$dst)>;
20622061

20632062
let Predicates = [HasCheri, IsCapMode, IsPureCapABI],
20642063
isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [C2] in
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// NOTE: Assertions have been autogenerated by utils/update_mc_test_checks.py UTC_ARGS: --version 5
2+
// RUN: llvm-mc %s -triple=riscv32cheriot -mcpu=cheriot -mattr=+xcheri,+xcheriot | FileCheck %s -check-prefixes=CHERIOT
3+
4+
foo:
5+
// CHERIOT: foo:
6+
auipcc ct3, %cheriot_compartment_hi(foo)
7+
// CHERIOT: ct.auipcc ct3, %cheriot_compartment_hi(foo)
8+
clc ct2, %cheriot_compartment_lo_i(foo)(ct2)
9+
// CHERIOT: ct.clc ct2, %cheriot_compartment_lo_i(foo)(ct2)

llvm/test/MC/RISCV/cheri/cheriot.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,4 @@ ctestsubset x7, ca5, ca3
119119
// CHERI: ctestsubset t2, ca5, ca3 # encoding: [0xdb,0x83,0xd7,0x40]
120120
cunseal ca5, ca3, ca1
121121
// CHERIOT: ct.cunseal ca5, ca3, ca1 # encoding: [0xdb,0x87,0xb6,0x18]
122-
// CHERI: cunseal ca5, ca3, ca1 # encoding: [0xdb,0x87,0xb6,0x18]
122+
// CHERI: cunseal ca5, ca3, ca1 # encoding: [0xdb,0x87,0xb6,0x18]

0 commit comments

Comments
 (0)