Skip to content

Commit 715ea15

Browse files
jthackrayrgwott
andcommitted
[AArch64][llvm] Add support for Permission Overlays Extension 2 (FEAT_S1POE2)
Add assembly/disassembly support for AArch64 FEAT_S1POE2 (Stage 1 Permission Overlays Extension 2), as documented here: https://developer.arm.com/documentation/109697/2025_09/Future-Architecture-Technologies Co-authored-by: Rodolfo Wottrich <[email protected]>
1 parent 33609bd commit 715ea15

File tree

17 files changed

+4018
-6
lines changed

17 files changed

+4018
-6
lines changed

clang/test/Driver/aarch64-vfat.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// ===== Features supported on aarch64 =====
2+
3+
// FAT features (Future Architecture Technologies)
4+
5+
// RUN: %clang -target aarch64 -march=armv9.7a+poe2 -### -c %s 2>&1 | FileCheck -check-prefix=VFAT-POE2 %s
6+
// RUN: %clang -target aarch64 -march=armv9.7-a+poe2 -### -c %s 2>&1 | FileCheck -check-prefix=VFAT-POE2 %s
7+
// VFAT-POE2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" "-target-feature" "+v9.7a"{{.*}} "-target-feature" "+poe2"
8+
9+
// RUN: %clang -target aarch64 -march=armv9.7a+tev -### -c %s 2>&1 | FileCheck -check-prefix=VFAT-TEV %s
10+
// RUN: %clang -target aarch64 -march=armv9.7-a+tev -### -c %s 2>&1 | FileCheck -check-prefix=VFAT-TEV %s
11+
// VFAT-TEV: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" "-target-feature" "+v9.7a"{{.*}} "-target-feature" "+tev"
12+
13+
// RUN: %clang -target aarch64 -march=armv9.7a+btie -### -c %s 2>&1 | FileCheck -check-prefix=VFAT-BTIE %s
14+
// RUN: %clang -target aarch64 -march=armv9.7-a+btie -### -c %s 2>&1 | FileCheck -check-prefix=VFAT-BTIE %s
15+
// VFAT-BTIE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" "-target-feature" "+v9.7a"{{.*}} "-target-feature" "+btie"

clang/test/Driver/print-supported-extensions-aarch64.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// CHECK-NEXT: bf16 FEAT_BF16 Enable BFloat16 Extension
99
// CHECK-NEXT: brbe FEAT_BRBE Enable Branch Record Buffer Extension
1010
// CHECK-NEXT: bti FEAT_BTI Enable Branch Target Identification
11+
// CHECK-NEXT: btie FEAT_BTIE Enable Enhanced Branch Target Identification extension
1112
// CHECK-NEXT: cmh FEAT_CMH Enable Armv9.7-A Contention Management Hints
1213
// CHECK-NEXT: cmpbr FEAT_CMPBR Enable Armv9.6-A base compare and branch instructions
1314
// CHECK-NEXT: fcma FEAT_FCMA Enable Armv8.3-A Floating-point complex number support
@@ -58,6 +59,7 @@
5859
// CHECK-NEXT: pauth-lr FEAT_PAuth_LR Enable Armv9.5-A PAC enhancements
5960
// CHECK-NEXT: pcdphint FEAT_PCDPHINT Enable Armv9.6-A Producer Consumer Data Placement hints
6061
// CHECK-NEXT: pmuv3 FEAT_PMUv3 Enable Armv8.0-A PMUv3 Performance Monitors extension
62+
// CHECK-NEXT: poe2 FEAT_S1POE2 Enable Stage 1 Permission Overlays Extension 2 instructions
6163
// CHECK-NEXT: pops FEAT_PoPS Enable Armv9.6-A Point Of Physical Storage (PoPS) DC instructions
6264
// CHECK-NEXT: predres FEAT_SPECRES Enable Armv8.5-A execution and data prediction invalidation instructions
6365
// CHECK-NEXT: rng FEAT_RNG Enable Random Number generation instructions
@@ -112,6 +114,7 @@
112114
// CHECK-NEXT: sve2p1 FEAT_SVE2p1 Enable Scalable Vector Extension 2.1 instructions
113115
// CHECK-NEXT: sve2p2 FEAT_SVE2p2 Enable Armv9.6-A Scalable Vector Extension 2.2 instructions
114116
// CHECK-NEXT: sve2p3 FEAT_SVE2p3 Enable Armv9.7-A Scalable Vector Extension 2.3 instructions
117+
// CHECK-NEXT: tev FEAT_TEV Enable TIndex Exception-like Vector instructions
115118
// CHECK-NEXT: the FEAT_THE Enable Armv8.9-A Translation Hardening Extension
116119
// CHECK-NEXT: tlbid FEAT_TLBID Enable Armv9.7-A TLBI Domains extension
117120
// CHECK-NEXT: tlbiw FEAT_TLBIW Enable Armv9.5-A TLBI VMALL for Dirty State

llvm/lib/Target/AArch64/AArch64Features.td

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,19 @@ def FeatureF16F32DOT : ExtensionWithMArch<"f16f32dot", "F16F32DOT", "FEAT_F16F32
625625
def FeatureF16F32MM : ExtensionWithMArch<"f16f32mm", "F16F32MM", "FEAT_F16F32MM",
626626
"Enable Armv9.7-A Advanced SIMD half-precision matrix multiply-accumulate to single-precision", [FeatureNEON, FeatureFullFP16]>;
627627

628+
//===----------------------------------------------------------------------===//
629+
// Future Architecture Technologies
630+
//===----------------------------------------------------------------------===//
631+
632+
def FeatureBTIE: ExtensionWithMArch<"btie", "BTIE", "FEAT_BTIE",
633+
"Enable Enhanced Branch Target Identification extension">;
634+
635+
def FeatureS1POE2: ExtensionWithMArch<"poe2", "POE2", "FEAT_S1POE2",
636+
"Enable Stage 1 Permission Overlays Extension 2 instructions", [FeatureBTIE]>;
637+
638+
def FeatureTEV: ExtensionWithMArch<"tev", "TEV", "FEAT_TEV",
639+
"Enable TIndex Exception-like Vector instructions">;
640+
628641
//===----------------------------------------------------------------------===//
629642
// Other Features
630643
//===----------------------------------------------------------------------===//

llvm/lib/Target/AArch64/AArch64InstrFormats.td

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,6 +1909,21 @@ def CMHPriorityHint_op : Operand<i32> {
19091909
}];
19101910
}
19111911

1912+
def TIndexHintOperand : AsmOperandClass {
1913+
let Name = "TIndexHint";
1914+
let ParserMethod = "tryParseTIndexHint";
1915+
}
1916+
1917+
def TIndexhint_op : Operand<i32> {
1918+
let ParserMatchClass = TIndexHintOperand;
1919+
let PrintMethod = "printTIndexHintOp";
1920+
let MCOperandPredicate = [{
1921+
if (!MCOp.isImm())
1922+
return false;
1923+
return AArch64TIndexHint::lookupTIndexByEncoding(MCOp.getImm()) != nullptr;
1924+
}];
1925+
}
1926+
19121927
class MRSI : RtSystemI<1, (outs GPR64:$Rt), (ins mrs_sysreg_op:$systemreg),
19131928
"mrs", "\t$Rt, $systemreg"> {
19141929
bits<16> systemreg;
@@ -13338,3 +13353,86 @@ class STCPHInst<string asm> : I<
1333813353
let Inst{7-5} = 0b100;
1333913354
let Inst{4-0} = 0b11111;
1334013355
}
13356+
13357+
//---
13358+
// Permission Overlays Extension 2 (FEAT_S1POE2)
13359+
//---
13360+
13361+
class TCHANGERegInst<string asm, bit isB> : I<
13362+
(outs GPR64:$Xd),
13363+
(ins GPR64:$Xn, TIndexhint_op:$nb),
13364+
asm, "\t$Xd, $Xn, $nb", "", []>, Sched<[]> {
13365+
bits<5> Xd;
13366+
bits<5> Xn;
13367+
bits<1> nb;
13368+
let Inst{31-19} = 0b1101010110000;
13369+
let Inst{18} = isB;
13370+
let Inst{17} = nb;
13371+
let Inst{16-10} = 0b0000000;
13372+
let Inst{9-5} = Xn;
13373+
let Inst{4-0} = Xd;
13374+
}
13375+
13376+
class TCHANGEImmInst<string asm, bit isB> : I<
13377+
(outs GPR64:$Xd),
13378+
(ins imm0_127:$imm, TIndexhint_op:$nb),
13379+
asm, "\t$Xd, $imm, $nb", "", []>, Sched<[]> {
13380+
bits<5> Xd;
13381+
bits<7> imm;
13382+
bits<1> nb;
13383+
let Inst{31-19} = 0b1101010110010;
13384+
let Inst{18} = isB;
13385+
let Inst{17} = nb;
13386+
let Inst{16-12} = 0b00000;
13387+
let Inst{11-5} = imm;
13388+
let Inst{4-0} = Xd;
13389+
}
13390+
13391+
class TENTERInst<string asm> : I<
13392+
(outs),
13393+
(ins imm0_127:$imm, TIndexhint_op:$nb),
13394+
asm, "\t$imm, $nb", "", []>, Sched<[]> {
13395+
bits<7> imm;
13396+
bits<1> nb;
13397+
let Inst{31-20} = 0b110101001110;
13398+
let Inst{19-18} = 0b00;
13399+
let Inst{17} = nb;
13400+
let Inst{16-12} = 0b00000;
13401+
let Inst{11-5} = imm;
13402+
let Inst{4-0} = 0b00000;
13403+
}
13404+
13405+
class TEXITInst<string asm> : I<
13406+
(outs),
13407+
(ins TIndexhint_op:$nb),
13408+
asm, "\t$nb", "", []>, Sched<[]> {
13409+
bits<1> nb;
13410+
let Inst{31-13} = 0b1101011011111111000;
13411+
let Inst{12-11} = 0b00;
13412+
let Inst{10} = nb;
13413+
let Inst{9-0} = 0b1111100000;
13414+
}
13415+
13416+
13417+
multiclass TCHANGEReg<string asm , bit isB> {
13418+
def NAME : TCHANGERegInst<asm, isB>;
13419+
def : InstAlias<asm # "\t$Xd, $Xn",
13420+
(!cast<Instruction>(NAME) GPR64:$Xd, GPR64:$Xn, 0), 1>;
13421+
}
13422+
13423+
multiclass TCHANGEImm<string asm, bit isB> {
13424+
def NAME : TCHANGEImmInst<asm, isB>;
13425+
def : InstAlias<asm # "\t$Xd, $Xn",
13426+
(!cast<Instruction>(NAME) GPR64:$Xd, imm0_127:$Xn, 0), 1>;
13427+
}
13428+
13429+
multiclass TENTER<string asm> {
13430+
def NAME : TENTERInst<asm>;
13431+
def : InstAlias<asm # "\t$imm",
13432+
(!cast<Instruction>(NAME) imm0_127:$imm, 0), 1>;
13433+
}
13434+
13435+
multiclass TEXIT<string asm> {
13436+
def NAME : TEXITInst<asm>;
13437+
def : InstAlias<asm, (!cast<Instruction>(NAME) 0), 1>;
13438+
}

llvm/lib/Target/AArch64/AArch64InstrInfo.td

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,8 @@ def HasCCDP : Predicate<"Subtarget->hasCCDP()">,
346346
AssemblerPredicateWithAll<(all_of FeatureCacheDeepPersist), "ccdp">;
347347
def HasBTI : Predicate<"Subtarget->hasBTI()">,
348348
AssemblerPredicateWithAll<(all_of FeatureBranchTargetId), "bti">;
349+
def HasBTIE : Predicate<"Subtarget->hasBTIE()">,
350+
AssemblerPredicateWithAll<(all_of FeatureBTIE), "btie">;
349351
def HasMTE : Predicate<"Subtarget->hasMTE()">,
350352
AssemblerPredicateWithAll<(all_of FeatureMTE), "mte">;
351353
def HasTME : Predicate<"Subtarget->hasTME()">,
@@ -405,6 +407,10 @@ def HasMTETC : Predicate<"Subtarget->hasMTETC()">,
405407
AssemblerPredicateWithAll<(all_of FeatureMTETC), "mtetc">;
406408
def HasGCIE : Predicate<"Subtarget->hasGCIE()">,
407409
AssemblerPredicateWithAll<(all_of FeatureGCIE), "gcie">;
410+
def HasS1POE2 : Predicate<"Subtarget->hasS1POE2()">,
411+
AssemblerPredicateWithAll<(all_of FeatureS1POE2), "poe2">;
412+
def HasTEV : Predicate<"Subtarget->hasTEV()">,
413+
AssemblerPredicateWithAll<(all_of FeatureTEV), "tev">;
408414
def IsLE : Predicate<"Subtarget->isLittleEndian()">;
409415
def IsBE : Predicate<"!Subtarget->isLittleEndian()">;
410416
def IsWindows : Predicate<"Subtarget->isTargetWindows()">;
@@ -1540,6 +1546,7 @@ let Predicates = [HasPCDPHINT] in {
15401546
// should not emit these mnemonics unless BTI is enabled.
15411547
def : InstAlias<"bti", (HINT 32), 0>;
15421548
def : InstAlias<"bti $op", (HINT btihint_op:$op), 0>;
1549+
def : InstAlias<"bti r", (HINT 32)>, Requires<[HasBTIE]>;
15431550
def : InstAlias<"bti", (HINT 32)>, Requires<[HasBTI]>;
15441551
def : InstAlias<"bti $op", (HINT btihint_op:$op)>, Requires<[HasBTI]>;
15451552

@@ -11426,6 +11433,26 @@ let Predicates = [HasCMH] in {
1142611433
def STCPH : STCPHInst<"stcph">; // Store Concurrent Priority Hint instruction
1142711434
}
1142811435

11436+
//===----------------------------------------------------------------------===//
11437+
// Permission Overlays Extension 2 (FEAT_S1POE2)
11438+
//===----------------------------------------------------------------------===//
11439+
11440+
let Predicates = [HasS1POE2] in {
11441+
defm TCHANGEBrr : TCHANGEReg<"tchangeb", true>;
11442+
defm TCHANGEFrr : TCHANGEReg<"tchangef", false>;
11443+
defm TCHANGEBri : TCHANGEImm<"tchangeb", true>;
11444+
defm TCHANGEFri : TCHANGEImm<"tchangef", false>;
11445+
}
11446+
11447+
//===----------------------------------------------------------------------===//
11448+
// TIndex Exception-like Vector (FEAT_TEV)
11449+
//===----------------------------------------------------------------------===//
11450+
11451+
let Predicates = [HasTEV] in {
11452+
defm TENTER : TENTER<"tenter">;
11453+
defm TEXIT : TEXIT<"texit">;
11454+
}
11455+
1142911456
include "AArch64InstrAtomics.td"
1143011457
include "AArch64SVEInstrInfo.td"
1143111458
include "AArch64SMEInstrInfo.td"

0 commit comments

Comments
 (0)