Skip to content

Commit 58a6b7b

Browse files
committed
[VE] Add missing BCR format
Add missing "BCR %sy, 0, target" format instruction and a regression test for this format. Reviewed By: simoll Differential Revision: https://reviews.llvm.org/D90387
1 parent 637c77f commit 58a6b7b

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

llvm/lib/Target/VE/VEInstrInfo.td

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ def mimm : Operand<i32>, PatLeaf<(imm), [{
205205
let PrintMethod = "printMImmOperand";
206206
}
207207

208+
// zerofp - Generic fp immediate zero value.
209+
def zerofp : Operand<i32>, PatLeaf<(fpimm), [{
210+
return getFpImmVal(N) == 0; }]> {
211+
let ParserMatchClass = ZeroAsmOperand;
212+
}
213+
208214
// simm7fp - Generic fp immediate value.
209215
def simm7fp : Operand<i32>, PatLeaf<(fpimm), [{
210216
return isInt<7>(getFpImmVal(N));
@@ -827,10 +833,17 @@ multiclass BCRbpfm<string opcStr, string cmpStr, bits<8> opc, dag cond> {
827833
!strconcat(opcStr, ".t ", cmpStr, "$imm32")>;
828834
}
829835
multiclass BCRm<string opcStr, string opcStrAt, string opcStrAf, bits<8> opc,
830-
RegisterClass RC, Operand immOp> {
836+
RegisterClass RC, Operand immOp, Operand zeroOp> {
831837
defm rr : BCRbpfm<opcStr, "$sy, $sz, ", opc, (ins CCOp:$cf, RC:$sy, RC:$sz)>;
832838
let cy = 0 in
833-
defm ir : BCRbpfm<opcStr, "$sy, $sz, ", opc, (ins CCOp:$cf, immOp:$sy, RC:$sz)>;
839+
defm ir : BCRbpfm<opcStr, "$sy, $sz, ", opc, (ins CCOp:$cf, immOp:$sy,
840+
RC:$sz)>;
841+
let cz = 0 in
842+
defm rz : BCRbpfm<opcStr, "$sy, $sz, ", opc, (ins CCOp:$cf, RC:$sy,
843+
zeroOp:$sz)>;
844+
let cy = 0, cz = 0 in
845+
defm iz : BCRbpfm<opcStr, "$sy, $sz, ", opc, (ins CCOp:$cf, immOp:$sy,
846+
zeroOp:$sz)>;
834847
let cy = 0, sy = 0, cz = 0, sz = 0, cf = 15 /* AT */, isBarrier = 1 in
835848
defm a : BCRbpfm<opcStrAt, "", opc, (ins)>;
836849
let cy = 0, sy = 0, cz = 0, sz = 0, cf = 0 /* AF */ in
@@ -1409,13 +1422,13 @@ defm BCFS : BCm<"b${cond}.s", "b.s", "baf.s", 0x1C, F32, simm7fp>;
14091422

14101423
// Section 8.8.4 - BCR (Branch on Condition Relative)
14111424
let cx = 0, cx2 = 0 in
1412-
defm BRCFL : BCRm<"br${cf}.l", "br.l", "braf.l", 0x18, I64, simm7>;
1425+
defm BRCFL : BCRm<"br${cf}.l", "br.l", "braf.l", 0x18, I64, simm7, zero>;
14131426
let cx = 1, cx2 = 0 in
1414-
defm BRCFW : BCRm<"br${cf}.w", "br.w", "braf.w", 0x18, I32, simm7>;
1427+
defm BRCFW : BCRm<"br${cf}.w", "br.w", "braf.w", 0x18, I32, simm7, zero>;
14151428
let cx = 0, cx2 = 1 in
1416-
defm BRCFD : BCRm<"br${cf}.d", "br.d", "braf.d", 0x18, I64, simm7fp>;
1429+
defm BRCFD : BCRm<"br${cf}.d", "br.d", "braf.d", 0x18, I64, simm7fp, zerofp>;
14171430
let cx = 1, cx2 = 1 in
1418-
defm BRCFS : BCRm<"br${cf}.s", "br.s", "braf.s", 0x18, F32, simm7fp>;
1431+
defm BRCFS : BCRm<"br${cf}.s", "br.s", "braf.s", 0x18, F32, simm7fp, zerofp>;
14191432

14201433
// Section 8.8.5 - BSIC (Branch and Save IC)
14211434
let isCall = 1, hasSideEffects = 0, DecoderMethod = "DecodeCall" in

llvm/test/MC/VE/BCR.s

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ braf.d.nt 224
1919
# CHECK-ENCODING: encoding: [0xe0,0x00,0x00,0x00,0x94,0x17,0xc1,0x18]
2020
brgt.s 23, %s20, 224
2121

22+
# CHECK-INST: brlt.l %s18, 0, -224
23+
# CHECK-ENCODING: encoding: [0x20,0xff,0xff,0xff,0x00,0x92,0x02,0x18]
24+
brlt.l %s18, 0, -224
25+
2226
# CHECK-INST: brlt.l.t 23, %s20, -224
2327
# CHECK-ENCODING: encoding: [0x20,0xff,0xff,0xff,0x94,0x17,0x32,0x18]
2428
brlt.l.t 23, %s20, -224
@@ -31,6 +35,10 @@ brne.w.nt 23, %s20, 8192
3135
# CHECK-ENCODING: encoding: [0x20,0xff,0xff,0xff,0x94,0x17,0x44,0x18]
3236
breq.d 23, %s20, -224
3337

38+
# CHECK-INST: breq.d %s20, 0, -224
39+
# CHECK-ENCODING: encoding: [0x20,0xff,0xff,0xff,0x00,0x94,0x44,0x18]
40+
breq.d %s20, 0, -224
41+
3442
# CHECK-INST: brge.s.t 23, %s20, 8192
3543
# CHECK-ENCODING: encoding: [0x00,0x20,0x00,0x00,0x94,0x17,0xf5,0x18]
3644
brge.s.t 23, %s20, 8192

0 commit comments

Comments
 (0)