Skip to content

Commit 113f01a

Browse files
authored
[PowerPC] Implement AES Acceleration Instructions (#157725)
Implement AES Acceleration Instructions: * xxaesencp * xxaesdecp * xxaesgenlkp * xxgfmul128
1 parent 70bd610 commit 113f01a

File tree

4 files changed

+155
-0
lines changed

4 files changed

+155
-0
lines changed

llvm/lib/Target/PowerPC/PPCInstrFuture.td

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,74 @@ class VXForm_VRTAB5<bits<11> xo, dag OOL, dag IOL, string asmstr,
120120
let Inst{21...31} = xo;
121121
}
122122

123+
class XX3Form_XTBp5_M2<bits<9> xo, dag OOL, dag IOL, string asmstr,
124+
list<dag> pattern>
125+
: I<60, OOL, IOL, asmstr, NoItinerary> {
126+
127+
bits<5> XTp;
128+
bits<5> XBp;
129+
bits<2> M;
130+
131+
let Pattern = pattern;
132+
133+
let Inst{6...9} = XTp{3...0};
134+
let Inst {10} = XTp{4};
135+
let Inst{15} = M{0};
136+
let Inst{16...19} = XBp{3...0};
137+
let Inst{20} = M{1};
138+
let Inst{21...29} = xo;
139+
let Inst{30} = XBp{4};
140+
}
141+
142+
class XX3Form_XTABp5_M2<bits<8> xo, dag OOL, dag IOL, string asmstr,
143+
list<dag> pattern>
144+
: I<60, OOL, IOL, asmstr, NoItinerary> {
145+
146+
bits<5> XTp;
147+
bits<5> XAp;
148+
bits<5> XBp;
149+
bits<2> M;
150+
151+
let Pattern = pattern;
152+
153+
let Inst{6...9} = XTp{3...0};
154+
let Inst{10} = XTp{4};
155+
let Inst{11...14} = XAp{3...0};
156+
let Inst{15} = M{0};
157+
let Inst{16...19} = XBp{3...0};
158+
let Inst{20} = M{1};
159+
let Inst{21...28} = xo;
160+
let Inst{29} = XAp{4};
161+
let Inst{30} = XBp{4};
162+
}
163+
164+
class XX3Form_XTAB6_P1<bits<5> xo, dag OOL, dag IOL, string asmstr,
165+
list<dag> pattern>
166+
: I<60, OOL, IOL, asmstr, NoItinerary> {
167+
168+
bits<6> XT;
169+
bits<6> XA;
170+
bits<6> XB;
171+
bits<1> P;
172+
173+
let Pattern = pattern;
174+
175+
let Inst{6...10} = XT{4...0};
176+
let Inst{11...15} = XA{4...0};
177+
let Inst{16...20} = XB{4...0};
178+
let Inst{21...22} = 3;
179+
let Inst{23} = P;
180+
let Inst{24...28} = xo;
181+
let Inst{29} = XA{5};
182+
let Inst{30} = XB{5};
183+
let Inst{31} = XT{5};
184+
}
185+
186+
//-------------------------- Instruction definitions -------------------------//
187+
// Predicate combinations available:
188+
// [IsISAFuture]
189+
// [HasVSX, IsISAFuture]
190+
123191
let Predicates = [IsISAFuture] in {
124192
defm SUBFUS : XOForm_RTAB5_L1r<31, 72, (outs g8rc:$RT),
125193
(ins g8rc:$RA, g8rc:$RB, u1imm:$L), "subfus",
@@ -191,6 +259,53 @@ let Predicates = [HasVSX, IsISAFuture] in {
191259
def VUCMPRLH
192260
: VXForm_VRTAB5<323, (outs vrrc:$VRT), (ins vrrc:$VRA, vrrc:$VRB),
193261
"vucmprlh $VRT, $VRA, $VRB", []>;
262+
263+
// AES Acceleration Instructions
264+
def XXAESENCP : XX3Form_XTABp5_M2<194, (outs vsrprc:$XTp),
265+
(ins vsrprc:$XAp, vsrprc:$XBp, u2imm:$M),
266+
"xxaesencp $XTp, $XAp, $XBp, $M", []>;
267+
def XXAESDECP : XX3Form_XTABp5_M2<202, (outs vsrprc:$XTp),
268+
(ins vsrprc:$XAp, vsrprc:$XBp, u2imm:$M),
269+
"xxaesdecp $XTp, $XAp, $XBp, $M", []>;
270+
def XXAESGENLKP : XX3Form_XTBp5_M2<420, (outs vsrprc:$XTp),
271+
(ins vsrprc:$XBp, u2imm:$M),
272+
"xxaesgenlkp $XTp, $XBp, $M", []>;
273+
def XXGFMUL128 : XX3Form_XTAB6_P1<26, (outs vsrc:$XT),
274+
(ins vsrc:$XA, vsrc:$XB, u1imm:$P),
275+
"xxgfmul128 $XT, $XA, $XB, $P", []>;
276+
}
277+
278+
//---------------------------- Anonymous Patterns ----------------------------//
279+
// Predicate combinations available:
280+
281+
282+
//---------------------------- Instruction aliases ---------------------------//
283+
// Predicate combinations available:
284+
// [HasVSX, IsISAFuture]
285+
286+
let Predicates = [HasVSX, IsISAFuture] in {
287+
def : InstAlias<"xxaes128encp $XTp, $XAp, $XBp",
288+
(XXAESENCP vsrprc:$XTp, vsrprc:$XAp, vsrprc:$XBp, 0)>;
289+
def : InstAlias<"xxaes192encp $XTp, $XAp, $XBp",
290+
(XXAESENCP vsrprc:$XTp, vsrprc:$XAp, vsrprc:$XBp, 1)>;
291+
def : InstAlias<"xxaes256encp $XTp, $XAp, $XBp",
292+
(XXAESENCP vsrprc:$XTp, vsrprc:$XAp, vsrprc:$XBp, 2)>;
293+
def : InstAlias<"xxaes128decp $XTp, $XAp, $XBp",
294+
(XXAESDECP vsrprc:$XTp, vsrprc:$XAp, vsrprc:$XBp, 0)>;
295+
def : InstAlias<"xxaes192decp $XTp, $XAp, $XBp",
296+
(XXAESDECP vsrprc:$XTp, vsrprc:$XAp, vsrprc:$XBp, 1)>;
297+
def : InstAlias<"xxaes256decp $XTp, $XAp, $XBp",
298+
(XXAESDECP vsrprc:$XTp, vsrprc:$XAp, vsrprc:$XBp, 2)>;
299+
def : InstAlias<"xxaes128genlkp $XTp, $XBp", (XXAESGENLKP vsrprc:$XTp,
300+
vsrprc:$XBp, 0)>;
301+
def : InstAlias<"xxaes192genlkp $XTp, $XBp", (XXAESGENLKP vsrprc:$XTp,
302+
vsrprc:$XBp, 1)>;
303+
def : InstAlias<"xxaes256genlkp $XTp, $XBp", (XXAESGENLKP vsrprc:$XTp,
304+
vsrprc:$XBp, 2)>;
305+
def : InstAlias<"xxgfmul128gcm $XT, $XA, $XB", (XXGFMUL128 vsrc:$XT, vsrc:$XA,
306+
vsrc:$XB, 0)>;
307+
def : InstAlias<"xxgfmul128xts $XT, $XA, $XB", (XXGFMUL128 vsrc:$XT, vsrc:$XA,
308+
vsrc:$XB, 1)>;
194309
}
195310

196311
//---------------------------- Anonymous Patterns ----------------------------//

llvm/test/MC/Disassembler/PowerPC/ppc-encoding-ISAFuture.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,15 @@
231231

232232
#CHECK: vucmprhh 1, 3, 6
233233
0x10,0x23,0x31,0x03
234+
235+
#CHECK: xxaes192encp 8, 10, 14
236+
0xf1,0x0b,0x76,0x10
237+
238+
#CHECK: xxaes256decp 14, 10, 6
239+
0xf1,0xca,0x3e,0x50
240+
241+
#CHECK: xxaes128genlkp 4, 8
242+
0xf0,0x80,0x46,0x90
243+
244+
#CHECK: xxgfmul128gcm 7, 5, 4
245+
0xf0,0xe5,0x26,0xd0

llvm/test/MC/Disassembler/PowerPC/ppc64le-encoding-ISAFuture.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,15 @@
225225

226226
#CHECK: vucmprhh 1, 3, 6
227227
0x03,0x31,0x23,0x10
228+
229+
#CHECK: xxaes192encp 8, 10, 14
230+
0x10,0x76,0x0b,0xf1
231+
232+
#CHECK: xxaes256decp 14, 10, 6
233+
0x50,0x3e,0xca,0xf1
234+
235+
#CHECK: xxaes128genlkp 4, 8
236+
0x90,0x46,0x80,0xf0
237+
238+
#CHECK: xxgfmul128gcm 7, 5, 4
239+
0xd0,0x26,0xe5,0xf0

llvm/test/MC/PowerPC/ppc-encoding-ISAFuture.s

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,3 +330,19 @@
330330
vucmprhh 1, 3, 6
331331
#CHECK-BE: vucmprhh 1, 3, 6 # encoding: [0x10,0x23,0x31,0x03]
332332
#CHECK-LE: vucmprhh 1, 3, 6 # encoding: [0x03,0x31,0x23,0x10]
333+
334+
xxaes192encp 8, 10, 14
335+
#CHECK-BE: xxaes192encp 8, 10, 14 # encoding: [0xf1,0x0b,0x76,0x10]
336+
#CHECK-LE: xxaes192encp 8, 10, 14 # encoding: [0x10,0x76,0x0b,0xf1]
337+
338+
xxaes256decp 14, 10, 6
339+
#CHECK-BE: xxaes256decp 14, 10, 6 # encoding: [0xf1,0xca,0x3e,0x50]
340+
#CHECK-LE: xxaes256decp 14, 10, 6 # encoding: [0x50,0x3e,0xca,0xf1]
341+
342+
xxaes128genlkp 4, 8
343+
#CHECK-BE: xxaes128genlkp 4, 8 # encoding: [0xf0,0x80,0x46,0x90]
344+
#CHECK-LE: xxaes128genlkp 4, 8 # encoding: [0x90,0x46,0x80,0xf0]
345+
346+
xxgfmul128gcm 7, 5, 4
347+
#CHECK-BE: xxgfmul128gcm 7, 5, 4 # encoding: [0xf0,0xe5,0x26,0xd0]
348+
#CHECK-LE: xxgfmul128gcm 7, 5, 4 # encoding: [0xd0,0x26,0xe5,0xf0]

0 commit comments

Comments
 (0)