Skip to content

Commit 3c7d062

Browse files
author
Diogo N. Sampaio
committed
[NFC][AArch64] Split out backend features
This patch splits backend features currently hidden behind architecture versions. For example, currently the only way to activate complex numbers extension is targeting an v8.3 architecture, where after the patch this extension can be added separately. This refactoring is required by the new command lines proposal: http://lists.llvm.org/pipermail/llvm-dev/2018-September/126346.html Reviewers: DavidSpickett, olista01, t.p.northover Subscribers: kristof.beyls, bryanpkc, javed.absar, pbarrio Differential revision: https://reviews.llvm.org/D54633 llvm-svn: 348121
1 parent b3301b3 commit 3c7d062

16 files changed

+716
-386
lines changed

llvm/lib/Target/AArch64/AArch64.td

Lines changed: 95 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,18 @@ def FeatureLSE : SubtargetFeature<"lse", "HasLSE", "true",
6565
def FeatureRDM : SubtargetFeature<"rdm", "HasRDM", "true",
6666
"Enable ARMv8.1 Rounding Double Multiply Add/Subtract instructions">;
6767

68+
def FeaturePAN : SubtargetFeature<
69+
"pan", "HasPAN", "true",
70+
"Enables ARM v8.1 Privileged Access-Never extension">;
71+
72+
def FeatureLOR : SubtargetFeature<
73+
"lor", "HasLOR", "true",
74+
"Enables ARM v8.1 Limited Ordering Regions extension">;
75+
76+
def FeatureVH : SubtargetFeature<
77+
"vh", "HasVH", "true",
78+
"Enables ARM v8.1 Virtual Host extension">;
79+
6880
def FeaturePerfMon : SubtargetFeature<"perfmon", "HasPerfMon", "true",
6981
"Enable ARMv8 PMUv3 Performance Monitors extension">;
7082

@@ -77,6 +89,18 @@ def FeatureFP16FML : SubtargetFeature<"fp16fml", "HasFP16FML", "true",
7789
def FeatureSPE : SubtargetFeature<"spe", "HasSPE", "true",
7890
"Enable Statistical Profiling extension">;
7991

92+
def FeaturePAN_RWV : SubtargetFeature<
93+
"pan-rwv", "HasPAN_RWV", "true",
94+
"Enable v8.2 PAN s1e1R and s1e1W Variants",
95+
[FeaturePAN]>;
96+
97+
// UAO PState
98+
def FeaturePsUAO : SubtargetFeature< "uaops", "HasPsUAO", "true",
99+
"Enable v8.2 UAO PState">;
100+
101+
def FeatureCCPP : SubtargetFeature<"ccpp", "HasCCPP",
102+
"true", "Enable v8.2 data Cache Clean to Point of Persistence" >;
103+
80104
def FeatureSVE : SubtargetFeature<"sve", "HasSVE", "true",
81105
"Enable Scalable Vector Extension (SVE) instructions">;
82106

@@ -195,6 +219,66 @@ def FeatureDotProd : SubtargetFeature<
195219
"dotprod", "HasDotProd", "true",
196220
"Enable dot product support">;
197221

222+
def FeaturePA : SubtargetFeature<
223+
"pa", "HasPA", "true",
224+
"Enable v8.3-A Pointer Authentication enchancement">;
225+
226+
def FeatureJS : SubtargetFeature<
227+
"jsconv", "HasJS", "true",
228+
"Enable v8.3-A JavaScript FP conversion enchancement",
229+
[FeatureFPARMv8]>;
230+
231+
def FeatureCCIDX : SubtargetFeature<
232+
"ccidx", "HasCCIDX", "true",
233+
"Enable v8.3-A Extend of the CCSIDR number of sets">;
234+
235+
def FeatureComplxNum : SubtargetFeature<
236+
"complxnum", "HasComplxNum", "true",
237+
"Enable v8.3-A Floating-point complex number support",
238+
[FeatureNEON]>;
239+
240+
def FeatureNV : SubtargetFeature<
241+
"nv", "HasNV", "true",
242+
"Enable v8.4-A Nested Virtualization Enchancement">;
243+
244+
def FeatureRASv8_4 : SubtargetFeature<
245+
"rasv8_4", "HasRASv8_4", "true",
246+
"Enable v8.4-A Reliability, Availability and Serviceability extension",
247+
[FeatureRAS]>;
248+
249+
def FeatureMPAM : SubtargetFeature<
250+
"mpam", "HasMPAM", "true",
251+
"Enable v8.4-A Memory system Partitioning and Monitoring extension">;
252+
253+
def FeatureDIT : SubtargetFeature<
254+
"dit", "HasDIT", "true",
255+
"Enable v8.4-A Data Independent Timing instructions">;
256+
257+
def FeatureTRACEV8_4 : SubtargetFeature<
258+
"tracev8.4", "HasTRACEV8_4", "true",
259+
"Enable v8.4-A Trace extension">;
260+
261+
def FeatureAM : SubtargetFeature<
262+
"am", "HasAM", "true",
263+
"Enable v8.4-A Activity Monitors extension">;
264+
265+
def FeatureSEL2 : SubtargetFeature<
266+
"sel2", "HasSEL2", "true",
267+
"Enable v8.4-A Secure Exception Level 2 extension">;
268+
269+
def FeatureTLB_RMI : SubtargetFeature<
270+
"tlb-rmi", "HasTLB_RMI", "true",
271+
"Enable v8.4-A TLB Range and Maintenance Instructions">;
272+
273+
def FeatureFMI : SubtargetFeature<
274+
"fmi", "HasFMI", "true",
275+
"Enable v8.4-A Flag Manipulation Instructions">;
276+
277+
// 8.4 RCPC enchancements: LDAPR & STLR instructions with Immediate Offset
278+
def FeatureRCPC_IMMO : SubtargetFeature<"rcpc-immo", "HasRCPC_IMMO", "true",
279+
"Enable v8.4-A RCPC instructions with Immediate Offsets",
280+
[FeatureRCPC]>;
281+
198282
def FeatureNoNegativeImmediates : SubtargetFeature<"no-neg-immediates",
199283
"NegativeImmediates", "false",
200284
"Convert immediates and instructions "
@@ -229,7 +313,7 @@ def FeaturePredCtrl : SubtargetFeature<"predctrl", "HasPredCtrl", "true",
229313
"Enable execution and data prediction invalidation instructions" >;
230314

231315
def FeatureCacheDeepPersist : SubtargetFeature<"ccdp", "HasCCDP",
232-
"true", "Enable Cache Clean to Point of Deep Persistence" >;
316+
"true", "Enable v8.5 Cache Clean to Point of Deep Persistence" >;
233317

234318
def FeatureBranchTargetId : SubtargetFeature<"bti", "HasBTI",
235319
"true", "Enable Branch Target Identification" >;
@@ -245,16 +329,22 @@ def FeatureMTE : SubtargetFeature<"mte", "HasMTE",
245329
//
246330

247331
def HasV8_1aOps : SubtargetFeature<"v8.1a", "HasV8_1aOps", "true",
248-
"Support ARM v8.1a instructions", [FeatureCRC, FeatureLSE, FeatureRDM]>;
332+
"Support ARM v8.1a instructions", [FeatureCRC, FeatureLSE, FeatureRDM,
333+
FeaturePAN, FeatureLOR, FeatureVH]>;
249334

250335
def HasV8_2aOps : SubtargetFeature<"v8.2a", "HasV8_2aOps", "true",
251-
"Support ARM v8.2a instructions", [HasV8_1aOps, FeatureRAS]>;
336+
"Support ARM v8.2a instructions", [HasV8_1aOps, FeaturePsUAO,
337+
FeaturePAN_RWV, FeatureRAS, FeatureCCPP]>;
252338

253339
def HasV8_3aOps : SubtargetFeature<"v8.3a", "HasV8_3aOps", "true",
254-
"Support ARM v8.3a instructions", [HasV8_2aOps, FeatureRCPC]>;
340+
"Support ARM v8.3a instructions", [HasV8_2aOps, FeatureRCPC, FeaturePA,
341+
FeatureJS, FeatureCCIDX, FeatureComplxNum]>;
255342

256343
def HasV8_4aOps : SubtargetFeature<"v8.4a", "HasV8_4aOps", "true",
257-
"Support ARM v8.4a instructions", [HasV8_3aOps, FeatureDotProd]>;
344+
"Support ARM v8.4a instructions", [HasV8_3aOps, FeatureDotProd,
345+
FeatureNV, FeatureRASv8_4, FeatureMPAM, FeatureDIT,
346+
FeatureTRACEV8_4, FeatureAM, FeatureSEL2, FeatureTLB_RMI,
347+
FeatureFMI, FeatureRCPC_IMMO]>;
258348

259349
def HasV8_5aOps : SubtargetFeature<
260350
"v8.5a", "HasV8_5aOps", "true", "Support ARM v8.5a instructions",

llvm/lib/Target/AArch64/AArch64InstrFormats.td

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9989,9 +9989,10 @@ class BaseSIMDThreeSameVectorComplex<bit Q, bit U, bits<2> size, bits<3> opcode,
99899989
let Inst{4-0} = Rd;
99909990
}
99919991

9992+
//8.3 CompNum - Floating-point complex number support
99929993
multiclass SIMDThreeSameVectorComplexHSD<bit U, bits<3> opcode, Operand rottype,
99939994
string asm, SDPatternOperator OpNode>{
9994-
let Predicates = [HasV8_3a, HasNEON, HasFullFP16] in {
9995+
let Predicates = [HasComplxNum, HasNEON, HasFullFP16] in {
99959996
def v4f16 : BaseSIMDThreeSameVectorComplex<0, U, 0b01, opcode, V64, rottype,
99969997
asm, ".4h",
99979998
[(set (v4f16 V64:$dst), (OpNode (v4f16 V64:$Rd),
@@ -10007,7 +10008,7 @@ multiclass SIMDThreeSameVectorComplexHSD<bit U, bits<3> opcode, Operand rottype,
1000710008
(rottype i32:$rot)))]>;
1000810009
}
1000910010

10010-
let Predicates = [HasV8_3a, HasNEON] in {
10011+
let Predicates = [HasComplxNum, HasNEON] in {
1001110012
def v2f32 : BaseSIMDThreeSameVectorComplex<0, U, 0b10, opcode, V64, rottype,
1001210013
asm, ".2s",
1001310014
[(set (v2f32 V64:$dst), (OpNode (v2f32 V64:$Rd),
@@ -10063,7 +10064,7 @@ class BaseSIMDThreeSameVectorTiedComplex<bit Q, bit U, bits<2> size,
1006310064
multiclass SIMDThreeSameVectorTiedComplexHSD<bit U, bits<3> opcode,
1006410065
Operand rottype, string asm,
1006510066
SDPatternOperator OpNode> {
10066-
let Predicates = [HasV8_3a, HasNEON, HasFullFP16] in {
10067+
let Predicates = [HasComplxNum, HasNEON, HasFullFP16] in {
1006710068
def v4f16 : BaseSIMDThreeSameVectorTiedComplex<0, U, 0b01, opcode, V64,
1006810069
rottype, asm, ".4h",
1006910070
[(set (v4f16 V64:$dst), (OpNode (v4f16 V64:$Rd),
@@ -10079,7 +10080,7 @@ multiclass SIMDThreeSameVectorTiedComplexHSD<bit U, bits<3> opcode,
1007910080
(rottype i32:$rot)))]>;
1008010081
}
1008110082

10082-
let Predicates = [HasV8_3a, HasNEON] in {
10083+
let Predicates = [HasComplxNum, HasNEON] in {
1008310084
def v2f32 : BaseSIMDThreeSameVectorTiedComplex<0, U, 0b10, opcode, V64,
1008410085
rottype, asm, ".2s",
1008510086
[(set (v2f32 V64:$dst), (OpNode (v2f32 V64:$Rd),
@@ -10145,7 +10146,7 @@ class BaseSIMDIndexedTiedComplex<bit Q, bit U, bit Scalar, bits<2> size,
1014510146
// classes.
1014610147
multiclass SIMDIndexedTiedComplexHSD<bit U, bit opc1, bit opc2, Operand rottype,
1014710148
string asm, SDPatternOperator OpNode> {
10148-
let Predicates = [HasV8_3a,HasNEON,HasFullFP16] in {
10149+
let Predicates = [HasComplxNum, HasNEON, HasFullFP16] in {
1014910150
def v4f16_indexed : BaseSIMDIndexedTiedComplex<0, 1, 0, 0b01, opc1, opc2, V64,
1015010151
V64, V128, VectorIndexD, rottype, asm, ".4h", ".4h",
1015110152
".4h", ".h", []> {
@@ -10161,17 +10162,17 @@ multiclass SIMDIndexedTiedComplexHSD<bit U, bit opc1, bit opc2, Operand rottype,
1016110162
let Inst{11} = idx{1};
1016210163
let Inst{21} = idx{0};
1016310164
}
10164-
} // Predicates = [HasV8_3a,HasNEON,HasFullFP16]
10165+
} // Predicates = HasComplxNum, HasNEON, HasFullFP16]
1016510166

10166-
let Predicates = [HasV8_3a,HasNEON] in {
10167+
let Predicates = [HasComplxNum, HasNEON] in {
1016710168
def v4f32_indexed : BaseSIMDIndexedTiedComplex<1, 1, 0, 0b10, opc1, opc2,
1016810169
V128, V128, V128, VectorIndexD, rottype, asm, ".4s",
1016910170
".4s", ".4s", ".s", []> {
1017010171
bits<1> idx;
1017110172
let Inst{11} = idx{0};
1017210173
let Inst{21} = 0;
1017310174
}
10174-
} // Predicates = [HasV8_3a,HasNEON]
10175+
} // Predicates = [HasComplxNum, HasNEON]
1017510176
}
1017610177

1017710178
//----------------------------------------------------------------------------

llvm/lib/Target/AArch64/AArch64InstrInfo.td

Lines changed: 63 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,54 @@ def HasV8_4a : Predicate<"Subtarget->hasV8_4aOps()">,
2424
AssemblerPredicate<"HasV8_4aOps", "armv8.4a">;
2525
def HasV8_5a : Predicate<"Subtarget->hasV8_5aOps()">,
2626
AssemblerPredicate<"HasV8_5aOps", "armv8.5a">;
27+
def HasVH : Predicate<"Subtarget->hasVH()">,
28+
AssemblerPredicate<"FeatureVH", "vh">;
29+
30+
def HasLOR : Predicate<"Subtarget->hasLOR()">,
31+
AssemblerPredicate<"FeatureLOR", "lor">;
32+
33+
def HasPA : Predicate<"Subtarget->hasPA()">,
34+
AssemblerPredicate<"FeaturePA", "pa">;
35+
36+
def HasJS : Predicate<"Subtarget->hasJS()">,
37+
AssemblerPredicate<"FeatureJS", "jsconv">;
38+
39+
def HasCCIDX : Predicate<"Subtarget->hasCCIDX()">,
40+
AssemblerPredicate<"FeatureCCIDX", "ccidx">;
41+
42+
def HasComplxNum : Predicate<"Subtarget->hasComplxNum()">,
43+
AssemblerPredicate<"FeatureComplxNum", "complxnum">;
44+
45+
def HasNV : Predicate<"Subtarget->hasNV()">,
46+
AssemblerPredicate<"FeatureNV", "nv">;
47+
48+
def HasRASv8_4 : Predicate<"Subtarget->hasRASv8_4()">,
49+
AssemblerPredicate<"FeatureRASv8_4", "rasv8_4">;
50+
51+
def HasMPAM : Predicate<"Subtarget->hasMPAM()">,
52+
AssemblerPredicate<"FeatureMPAM", "mpam">;
53+
54+
def HasDIT : Predicate<"Subtarget->hasDIT()">,
55+
AssemblerPredicate<"FeatureDIT", "dit">;
56+
57+
def HasTRACEV8_4 : Predicate<"Subtarget->hasTRACEV8_4()">,
58+
AssemblerPredicate<"FeatureTRACEV8_4", "tracev8.4">;
59+
60+
def HasAM : Predicate<"Subtarget->hasAM()">,
61+
AssemblerPredicate<"FeatureAM", "am">;
62+
63+
def HasSEL2 : Predicate<"Subtarget->hasSEL2()">,
64+
AssemblerPredicate<"FeatureSEL2", "sel2">;
65+
66+
def HasTLB_RMI : Predicate<"Subtarget->hasTLB_RMI()">,
67+
AssemblerPredicate<"FeatureTLB_RMI", "tlb-rmi">;
68+
69+
def HasFMI : Predicate<"Subtarget->hasFMI()">,
70+
AssemblerPredicate<"FeatureFMI", "fmi">;
71+
72+
def HasRCPC_IMMO : Predicate<"Subtarget->hasRCPCImm()">,
73+
AssemblerPredicate<"FeatureRCPC_IMMO", "rcpc-immo">;
74+
2775
def HasFPARMv8 : Predicate<"Subtarget->hasFPARMv8()">,
2876
AssemblerPredicate<"FeatureFPARMv8", "fp-armv8">;
2977
def HasNEON : Predicate<"Subtarget->hasNEON()">,
@@ -510,7 +558,7 @@ def ISB : CRmSystemI<barrier_op, 0b110, "isb",
510558
def TSB : CRmSystemI<barrier_op, 0b010, "tsb", []> {
511559
let CRm = 0b0010;
512560
let Inst{12} = 0;
513-
let Predicates = [HasV8_4a];
561+
let Predicates = [HasTRACEV8_4];
514562
}
515563
}
516564

@@ -602,7 +650,7 @@ let Uses = [LR], Defs = [LR], CRm = 0b0000 in {
602650
}
603651

604652
// These pointer authentication isntructions require armv8.3a
605-
let Predicates = [HasV8_3a] in {
653+
let Predicates = [HasPA] in {
606654
multiclass SignAuth<bits<3> prefix, bits<3> prefix_z, string asm> {
607655
def IA : SignAuthOneData<prefix, 0b00, !strconcat(asm, "ia")>;
608656
def IB : SignAuthOneData<prefix, 0b01, !strconcat(asm, "ib")>;
@@ -642,25 +690,25 @@ let Predicates = [HasV8_3a] in {
642690
defm LDRAA : AuthLoad<0, "ldraa", simm10Scaled>;
643691
defm LDRAB : AuthLoad<1, "ldrab", simm10Scaled>;
644692

645-
// v8.3a floating point conversion for javascript
646-
let Predicates = [HasV8_3a, HasFPARMv8] in
647-
def FJCVTZS : BaseFPToIntegerUnscaled<0b01, 0b11, 0b110, FPR64, GPR32,
648-
"fjcvtzs", []> {
649-
let Inst{31} = 0;
650-
}
693+
}
651694

652-
} // HasV8_3a
695+
// v8.3a floating point conversion for javascript
696+
let Predicates = [HasJS, HasFPARMv8] in
697+
def FJCVTZS : BaseFPToIntegerUnscaled<0b01, 0b11, 0b110, FPR64, GPR32,
698+
"fjcvtzs", []> {
699+
let Inst{31} = 0;
700+
} // HasJS, HasFPARMv8
653701

654702
// v8.4 Flag manipulation instructions
655-
let Predicates = [HasV8_4a] in {
703+
let Predicates = [HasFMI] in {
656704
def CFINV : SimpleSystemI<0, (ins), "cfinv", "">, Sched<[WriteSys]> {
657705
let Inst{20-5} = 0b0000001000000000;
658706
}
659707
def SETF8 : BaseFlagManipulation<0, 0, (ins GPR32:$Rn), "setf8", "{\t$Rn}">;
660708
def SETF16 : BaseFlagManipulation<0, 1, (ins GPR32:$Rn), "setf16", "{\t$Rn}">;
661709
def RMIF : FlagRotate<(ins GPR64:$Rn, uimm6:$imm, imm0_15:$mask), "rmif",
662710
"{\t$Rn, $imm, $mask}">;
663-
} // HasV8_4a
711+
} // HasFMI
664712

665713
// v8.5 flag manipulation instructions
666714
let Predicates = [HasAltNZCV], Uses = [NZCV], Defs = [NZCV] in {
@@ -2629,8 +2677,9 @@ defm STURBB : StoreUnscaled<0b00, 0, 0b00, GPR32z, "sturb",
26292677
[(truncstorei8 GPR32z:$Rt,
26302678
(am_unscaled8 GPR64sp:$Rn, simm9:$offset))]>;
26312679

2632-
// Armv8.4 LDAPR & STLR with Immediate Offset instruction
2633-
let Predicates = [HasV8_4a] in {
2680+
// Armv8.4 Weaker Release Consistency enhancements
2681+
// LDAPR & STLR with Immediate Offset instructions
2682+
let Predicates = [HasRCPC_IMMO] in {
26342683
defm STLURB : BaseStoreUnscaleV84<"stlurb", 0b00, 0b00, GPR32>;
26352684
defm STLURH : BaseStoreUnscaleV84<"stlurh", 0b01, 0b00, GPR32>;
26362685
defm STLURW : BaseStoreUnscaleV84<"stlur", 0b10, 0b00, GPR32>;
@@ -2915,7 +2964,7 @@ def STLXPX : StoreExclusivePair<0b11, 0, 0, 1, 1, GPR64, "stlxp">;
29152964
def STXPW : StoreExclusivePair<0b10, 0, 0, 1, 0, GPR32, "stxp">;
29162965
def STXPX : StoreExclusivePair<0b11, 0, 0, 1, 0, GPR64, "stxp">;
29172966

2918-
let Predicates = [HasV8_1a] in {
2967+
let Predicates = [HasLOR] in {
29192968
// v8.1a "Limited Order Region" extension load-acquire instructions
29202969
def LDLARW : LoadAcquire <0b10, 1, 1, 0, 0, GPR32, "ldlar">;
29212970
def LDLARX : LoadAcquire <0b11, 1, 1, 0, 0, GPR64, "ldlar">;

0 commit comments

Comments
 (0)