Skip to content

Commit fe4af84

Browse files
committed
[CHERIoT] Convert a few places from checking the subarch to checking for the XCheriot ISA feature.
1 parent 9674650 commit fe4af84

File tree

4 files changed

+3
-14
lines changed

4 files changed

+3
-14
lines changed

clang/lib/Basic/Targets/RISCV.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts,
245245
}
246246

247247
// Macros for use with the set and get permissions builtins.
248-
if (getTriple().getSubArch() == llvm::Triple::RISCV32SubArch_cheriot_v1) {
248+
if (ISAInfo->hasExtension("xcheriot")) {
249249
// Expose CHERI-compatible macros for permissions that overlap with other
250250
// CHERI implementations.
251251
Builder.defineMacro("__CHERI_CAP_PERMISSION_GLOBAL__", Twine(1 << 0));
@@ -379,6 +379,7 @@ bool RISCVTargetInfo::initFeatureMap(
379379

380380
if (getTriple().getSubArch() == llvm::Triple::RISCV32SubArch_cheriot_v1) {
381381
Features["xcheri"] = true;
382+
Features["xcheriot"] = true;
382383
Features["xcheripurecap"] = true;
383384
Features["c"] = true;
384385
Features["e"] = true;

clang/test/CodeGen/cheri/cheriot-struct-ret.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -808,8 +808,3 @@ __attribute__((cheri_compartment("example"))) void CheckOnePtr () {
808808
// CHECK: ret void
809809
return;
810810
}
811-
812-
813-
// CHECK: attributes #0 = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(readwrite, argmem: none, inaccessiblemem: none) "cheri-compartment"="example" "interrupt-state"="enabled" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+32bit,+c,+e,+m,+xcheri,+xcheripurecap" }
814-
// CHECK: attributes #1 = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) "cheri-compartment"="example" "interrupt-state"="enabled" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+32bit,+c,+e,+m,+xcheri,+xcheripurecap" }
815-
// CHECK: attributes #2 = { mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) "cheri-compartment"="example" "interrupt-state"="enabled" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+32bit,+c,+e,+m,+xcheri,+xcheripurecap" }

clang/test/CodeGen/cheri/riscv/cheriot-static-sealed-value-attr.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,3 @@ void func() {
4040

4141
// CHECK: declare void @doSomething(ptr addrspace(200) noundef) local_unnamed_addr addrspace(200) #2
4242
// CHECK: declare void @doSomething2(ptr addrspace(200) noundef) local_unnamed_addr addrspace(200) #2
43-
44-
// CHECK: attributes #0 = { "cheriot_sealed_value" }
45-
// CHECK: attributes #1 = { minsize nounwind optsize "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+32bit,+c,+e,+m,+xcheri,+xcheripurecap" }
46-
// CHECK: attributes #2 = { minsize optsize "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+32bit,+c,+e,+m,+xcheri,+xcheripurecap" }
47-
// CHECK: attributes #3 = { minsize nounwind optsize }

llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFObjectWriter.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ unsigned RISCVELFObjectWriter::getRelocType(MCContext &Ctx,
108108
return ELF::R_RISCV_CHERI_CJAL;
109109
case RISCV::fixup_riscv_ccall: {
110110
const auto *STI = Ctx.getSubtargetInfo();
111-
if (STI->hasFeature(RISCV::FeatureVendorXCheriot) ||
112-
STI->getTargetTriple().getSubArch() ==
113-
Triple::RISCV32SubArch_cheriot_v1)
111+
if (STI->hasFeature(RISCV::FeatureVendorXCheriot))
114112
return ELF::R_RISCV_CHERIOT_CCALL;
115113
return ELF::R_RISCV_CHERI_CCALL;
116114
}

0 commit comments

Comments
 (0)