Skip to content

Commit 23e7da8

Browse files
[PowerPC] Add the SCV instruction. (#68063)
The SCV instruciton was added on PowerPC on Power 9. This patch adds the SCV so that it may be used as part of inline asm but does not provide patterns for it or scheduling information. Co-authored-by: Stefan Pintilie <[email protected]>
1 parent 6e594ef commit 23e7da8

File tree

5 files changed

+32
-4
lines changed

5 files changed

+32
-4
lines changed

llvm/lib/Target/PowerPC/PPCInstrFormats.td

+3-2
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ BForm_4<bits<6> opcode, bits<5> bo, bit aa, bit lk,
220220
}
221221

222222
// 1.7.3 SC-Form
223-
class SCForm<bits<6> opcode, bits<1> xo,
223+
class SCForm<bits<6> opcode, bits<1> xo1, bits<1> xo2,
224224
dag OOL, dag IOL, string asmstr, InstrItinClass itin,
225225
list<dag> pattern>
226226
: I<opcode, OOL, IOL, asmstr, itin> {
@@ -229,7 +229,8 @@ class SCForm<bits<6> opcode, bits<1> xo,
229229
let Pattern = pattern;
230230

231231
let Inst{20-26} = LEV;
232-
let Inst{30} = xo;
232+
let Inst{30} = xo1;
233+
let Inst{31} = xo2;
233234
}
234235

235236
// 1.7.4 D-Form

llvm/lib/Target/PowerPC/PPCInstrInfo.td

+9-1
Original file line numberDiff line numberDiff line change
@@ -1641,10 +1641,18 @@ let isBranch = 1, isTerminator = 1, Size = 0 in {
16411641

16421642
// System call.
16431643
let PPC970_Unit = 7 in {
1644-
def SC : SCForm<17, 1, (outs), (ins i32imm:$LEV),
1644+
def SC : SCForm<17, 1, 0, (outs), (ins i32imm:$LEV),
16451645
"sc $LEV", IIC_BrB, [(PPCsc (i32 imm:$LEV))]>;
16461646
}
16471647

1648+
// We mark SCV as having no scheduling model since it is only meant to be used
1649+
// as inline assembly. If we implement a builtin pattern for it we will need to
1650+
// add it to the P9 and P10 scheduling models.
1651+
let Predicates = [IsISA3_0], hasNoSchedulingInfo = 1 in {
1652+
def SCV : SCForm<17, 0, 1, (outs), (ins i32imm:$LEV),
1653+
"scv $LEV", IIC_BrB, []>;
1654+
}
1655+
16481656
// Branch history rolling buffer.
16491657
def CLRBHRB : XForm_0<31, 430, (outs), (ins), "clrbhrb", IIC_BrB,
16501658
[(PPCclrbhrb)]>,

llvm/test/MC/Disassembler/PowerPC/ppc64-encoding.txt

+6
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@
7373
# CHECK: sc
7474
0x44 0x00 0x00 0x02
7575

76+
# CHECK: scv 1
77+
0x44 0x00 0x00 0x21
78+
79+
# CHECK: scv 2
80+
0x44 0x00 0x00 0x41
81+
7682
# CHECK: clrbhrb
7783
0x7c 0x00 0x03 0x5c
7884

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

+6
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@
7373
# CHECK: sc
7474
0x02 0x00 0x00 0x44
7575

76+
# CHECK: scv 1
77+
0x21 0x00 0x00 0x44
78+
79+
# CHECK: scv 2
80+
0x41 0x00 0x00 0x44
81+
7682
# CHECK: clrbhrb
7783
0x5c 0x03 0x00 0x7c
7884

llvm/test/MC/PowerPC/ppc64-encoding.s

+8-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
# CHECK-LE: mcrf 2, 3 # encoding: [0x00,0x00,0x0c,0x4d]
145145
mcrf 2, 3
146146

147-
# System call instruction
147+
# System call instructions
148148

149149
# CHECK-BE: sc 1 # encoding: [0x44,0x00,0x00,0x22]
150150
# CHECK-LE: sc 1 # encoding: [0x22,0x00,0x00,0x44]
@@ -153,6 +153,13 @@
153153
# CHECK-LE: sc # encoding: [0x02,0x00,0x00,0x44]
154154
sc
155155

156+
# CHECK-BE: scv 1 # encoding: [0x44,0x00,0x00,0x21]
157+
# CHECK-LE: scv 1 # encoding: [0x21,0x00,0x00,0x44]
158+
scv 1
159+
# CHECK-BE: scv 2 # encoding: [0x44,0x00,0x00,0x41]
160+
# CHECK-LE: scv 2 # encoding: [0x41,0x00,0x00,0x44]
161+
scv 2
162+
156163
# Branch history rolling buffer
157164

158165
# CHECK-BE: clrbhrb # encoding: [0x7c,0x00,0x03,0x5c]

0 commit comments

Comments
 (0)