Skip to content

Commit ccda73d

Browse files
committed
fixup! [AArch64][llvm] Armv9.7-A: Add support for GICv5 (FEAT_GCIE)
Optimisations suggested in CR.
1 parent b0b8236 commit ccda73d

File tree

4 files changed

+65
-34
lines changed

4 files changed

+65
-34
lines changed

llvm/lib/Target/AArch64/AArch64SystemOperands.td

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2586,14 +2586,14 @@ foreach n=0-15 in {
25862586
//===----------------------------------------------------------------------===//
25872587

25882588
// GIC
2589-
class GIC<string name, bits<3> op1, bits<4> crn, bits<4> crm, bits<3> op2, bit needsreg> {
2589+
class GIC<string name, bits<3> op1, bits<4> crn, bits<4> crm, bits<3> op2> {
25902590
string Name = name;
25912591
bits<14> Encoding;
25922592
let Encoding{13-11} = op1;
25932593
let Encoding{10-7} = crn;
25942594
let Encoding{6-3} = crm;
25952595
let Encoding{2-0} = op2;
2596-
bit NeedsReg = needsreg;
2596+
bit NeedsReg = 1;
25972597
string RequiresStr = [{ {AArch64::FeatureGCIE} }];
25982598
}
25992599

@@ -2609,14 +2609,14 @@ class GSB<string name, bits<3> op1, bits<4> crn, bits<4> crm, bits<3> op2> {
26092609
}
26102610

26112611
// GICR
2612-
class GICR<string name, bits<3> op1, bits<4> crn, bits<4> crm, bits<3> op2, bit needsreg> {
2612+
class GICR<string name, bits<3> op1, bits<4> crn, bits<4> crm, bits<3> op2> {
26132613
string Name = name;
26142614
bits<14> Encoding;
26152615
let Encoding{13-11} = op1;
26162616
let Encoding{10-7} = crn;
26172617
let Encoding{6-3} = crm;
26182618
let Encoding{2-0} = op2;
2619-
bit NeedsReg = needsreg;
2619+
bit NeedsReg = 1;
26202620
string RequiresStr = [{ {AArch64::FeatureGCIE} }];
26212621
}
26222622

@@ -2666,31 +2666,33 @@ def lookupGICRByName : SearchIndex {
26662666
def : GSB<"sys", 0b000, 0b1100, 0b0000, 0b000>;
26672667
def : GSB<"ack", 0b000, 0b1100, 0b0000, 0b001>;
26682668

2669-
// Op1 CRn CRm Op2 needsReg
2670-
def : GIC<"cdaff", 0b000, 0b1100, 0b0001, 0b011, 1>;
2671-
def : GIC<"cddi", 0b000, 0b1100, 0b0010, 0b000, 1>;
2672-
def : GIC<"cddis", 0b000, 0b1100, 0b0001, 0b000, 1>;
2673-
def : GIC<"cden", 0b000, 0b1100, 0b0001, 0b001, 1>;
2674-
def : GIC<"cdeoi", 0b000, 0b1100, 0b0001, 0b111, 1>;
2675-
def : GIC<"cdhm", 0b000, 0b1100, 0b0010, 0b001, 1>;
2676-
def : GIC<"cdpend", 0b000, 0b1100, 0b0001, 0b100, 1>;
2677-
def : GIC<"cdpri", 0b000, 0b1100, 0b0001, 0b010, 1>;
2678-
def : GIC<"cdrcfg", 0b000, 0b1100, 0b0001, 0b101, 1>;
2679-
def : GICR<"cdia", 0b000, 0b1100, 0b0011, 0b000, 1>;
2680-
def : GICR<"cdnmia", 0b000, 0b1100, 0b0011, 0b001, 1>;
2681-
def : GIC<"vdaff", 0b100, 0b1100, 0b0001, 0b011, 1>;
2682-
def : GIC<"vddi", 0b100, 0b1100, 0b0010, 0b000, 1>;
2683-
def : GIC<"vddis", 0b100, 0b1100, 0b0001, 0b000, 1>;
2684-
def : GIC<"vden", 0b100, 0b1100, 0b0001, 0b001, 1>;
2685-
def : GIC<"vdhm", 0b100, 0b1100, 0b0010, 0b001, 1>;
2686-
def : GIC<"vdpend", 0b100, 0b1100, 0b0001, 0b100, 1>;
2687-
def : GIC<"vdpri", 0b100, 0b1100, 0b0001, 0b010, 1>;
2688-
def : GIC<"vdrcfg", 0b100, 0b1100, 0b0001, 0b101, 1>;
2689-
def : GIC<"ldaff", 0b110, 0b1100, 0b0001, 0b011, 1>;
2690-
def : GIC<"lddi", 0b110, 0b1100, 0b0010, 0b000, 1>;
2691-
def : GIC<"lddis", 0b110, 0b1100, 0b0001, 0b000, 1>;
2692-
def : GIC<"lden", 0b110, 0b1100, 0b0001, 0b001, 1>;
2693-
def : GIC<"ldhm", 0b110, 0b1100, 0b0010, 0b001, 1>;
2694-
def : GIC<"ldpend", 0b110, 0b1100, 0b0001, 0b100, 1>;
2695-
def : GIC<"ldpri", 0b110, 0b1100, 0b0001, 0b010, 1>;
2696-
def : GIC<"ldrcfg", 0b110, 0b1100, 0b0001, 0b101, 1>;
2669+
// Op1 CRn CRm Op2
2670+
def : GICR<"cdia", 0b000, 0b1100, 0b0011, 0b000>;
2671+
def : GICR<"cdnmia", 0b000, 0b1100, 0b0011, 0b001>;
2672+
2673+
// Op1 CRn CRm Op2
2674+
def : GIC<"cdaff", 0b000, 0b1100, 0b0001, 0b011>;
2675+
def : GIC<"cddi", 0b000, 0b1100, 0b0010, 0b000>;
2676+
def : GIC<"cddis", 0b000, 0b1100, 0b0001, 0b000>;
2677+
def : GIC<"cden", 0b000, 0b1100, 0b0001, 0b001>;
2678+
def : GIC<"cdeoi", 0b000, 0b1100, 0b0001, 0b111>;
2679+
def : GIC<"cdhm", 0b000, 0b1100, 0b0010, 0b001>;
2680+
def : GIC<"cdpend", 0b000, 0b1100, 0b0001, 0b100>;
2681+
def : GIC<"cdpri", 0b000, 0b1100, 0b0001, 0b010>;
2682+
def : GIC<"cdrcfg", 0b000, 0b1100, 0b0001, 0b101>;
2683+
def : GIC<"vdaff", 0b100, 0b1100, 0b0001, 0b011>;
2684+
def : GIC<"vddi", 0b100, 0b1100, 0b0010, 0b000>;
2685+
def : GIC<"vddis", 0b100, 0b1100, 0b0001, 0b000>;
2686+
def : GIC<"vden", 0b100, 0b1100, 0b0001, 0b001>;
2687+
def : GIC<"vdhm", 0b100, 0b1100, 0b0010, 0b001>;
2688+
def : GIC<"vdpend", 0b100, 0b1100, 0b0001, 0b100>;
2689+
def : GIC<"vdpri", 0b100, 0b1100, 0b0001, 0b010>;
2690+
def : GIC<"vdrcfg", 0b100, 0b1100, 0b0001, 0b101>;
2691+
def : GIC<"ldaff", 0b110, 0b1100, 0b0001, 0b011>;
2692+
def : GIC<"lddi", 0b110, 0b1100, 0b0010, 0b000>;
2693+
def : GIC<"lddis", 0b110, 0b1100, 0b0001, 0b000>;
2694+
def : GIC<"lden", 0b110, 0b1100, 0b0001, 0b001>;
2695+
def : GIC<"ldhm", 0b110, 0b1100, 0b0010, 0b001>;
2696+
def : GIC<"ldpend", 0b110, 0b1100, 0b0001, 0b100>;
2697+
def : GIC<"ldpri", 0b110, 0b1100, 0b0001, 0b010>;
2698+
def : GIC<"ldrcfg", 0b110, 0b1100, 0b0001, 0b101>;

llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4046,7 +4046,7 @@ bool AArch64AsmParser::parseSysAlias(StringRef Name, SMLoc NameLoc,
40464046
setRequiredFeatureString(GIC->getRequiredFeatures(), Str);
40474047
return TokError(Str);
40484048
}
4049-
ExpectRegister = GIC->NeedsReg;
4049+
ExpectRegister = true;
40504050
createSysAlias(GIC->Encoding, Operands, S);
40514051
} else if (Mnemonic == "gsb") {
40524052
const AArch64GSB::GSB *GSB = AArch64GSB::lookupGSBByName(Op);

llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ bool AArch64InstPrinter::printSysAlias(const MCInst *MI,
10341034
if (!GIC || !GIC->haveFeatures(STI.getFeatureBits()))
10351035
return false;
10361036

1037-
NeedsReg = GIC->NeedsReg;
1037+
NeedsReg = true;
10381038
Ins = "gic\t";
10391039
Name = std::string(GIC->Name);
10401040
} else {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: not llvm-mc -triple=aarch64 -mattr=+gcie -show-encoding < %s 2>&1 \
2+
// RUN: | FileCheck %s --check-prefix=CHECK-ERROR
3+
// RUN: not llvm-mc -triple=aarch64 -show-encoding < %s 2>&1 \
4+
// RUN: | FileCheck %s --check-prefix=CHECK-REQUIRES-GCIE
5+
6+
//------------------------------------------------------------------------------
7+
// FEAT_GCIE instructions
8+
//------------------------------------------------------------------------------
9+
10+
gsb
11+
// CHECK-ERROR: error: invalid operand for GSB instruction
12+
13+
gsb ack
14+
// CHECK-REQUIRES-GCIE: GSB ack requires: gcie
15+
16+
gicr
17+
// CHECK-ERROR: error: expected register operand
18+
19+
gicr x3, foo
20+
// CHECK-ERROR: error: invalid operand for GICR instruction
21+
22+
gicr x3, cdnmia
23+
// CHECK-REQUIRES-GCIE: GICR cdnmia requires: gcie
24+
25+
gic cdaff
26+
// CHECK-ERROR: error: specified gic op requires a register
27+
28+
gic cdaff, x3
29+
// CHECK-REQUIRES-GCIE: GIC cdaff requires: gcie

0 commit comments

Comments
 (0)