Skip to content

Commit 4873b72

Browse files
committed
Add compress patterns for qc.extu and qc.mveqi
Change-Id: Id277974a325d22c1975bbab0b1ccf918938dc9aa
1 parent a5d48db commit 4873b72

File tree

3 files changed

+46
-6
lines changed

3 files changed

+46
-6
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ def uimm5_plus1 : RISCVOp, ImmLeaf<XLenVT,
4040
let EncoderMethod = "getImmOpValueMinus1";
4141
let DecoderMethod = "decodeUImmPlus1Operand<5>";
4242
let OperandType = "OPERAND_UIMM5_PLUS1";
43+
let MCOperandPredicate = [{
44+
int64_t Imm;
45+
if (MCOp.evaluateAsConstantImm(Imm))
46+
return (isUInt<5>(Imm) && (Imm != 0)) || (Imm == 32);
47+
return MCOp.isBareSymbolRef();
48+
}];
49+
4350
}
4451

4552
def uimm5ge6_plus1 : RISCVOp<XLenVT>, ImmLeaf<XLenVT,
@@ -48,6 +55,12 @@ def uimm5ge6_plus1 : RISCVOp<XLenVT>, ImmLeaf<XLenVT,
4855
let EncoderMethod = "getImmOpValueMinus1";
4956
let DecoderMethod = "decodeUImmPlus1OperandGE<5,6>";
5057
let OperandType = "OPERAND_UIMM5_GE6_PLUS1";
58+
let MCOperandPredicate = [{
59+
int64_t Imm;
60+
if (MCOp.evaluateAsConstantImm(Imm))
61+
return (Imm >= 6) && (isUInt<5>(Imm) || (Imm == 32));
62+
return MCOp.isBareSymbolRef();
63+
}];
5164
}
5265

5366
def uimm5slist : RISCVOp<XLenVT>, ImmLeaf<XLenVT,
@@ -1369,3 +1382,13 @@ def : CompressPat<(QC_E_SH GPR:$rs2, GPRMem:$rs1, simm12:$imm12),
13691382
def : CompressPat<(QC_E_SW GPR:$rs2, GPRMem:$rs1, simm12:$imm12),
13701383
(SW GPR:$rs2, GPRMem:$rs1, simm12:$imm12)>;
13711384
} // isCompressOnly = true, Predicates = [HasVendorXqcilo, IsRV32]
1385+
1386+
let Predicates = [HasVendorXqcicm, IsRV32] in {
1387+
def : CompressPat<(QC_MVEQI GPRC:$rd, GPRC:$rd, 0, GPRC:$rs1),
1388+
(QC_C_MVEQZ GPRC:$rd, GPRC:$rs1)>;
1389+
}
1390+
1391+
let Predicates = [HasVendorXqcibm, IsRV32] in {
1392+
def : CompressPat<(QC_EXTU GPRNoX0:$rd, GPRNoX0:$rd, uimm5ge6_plus1:$width, 0),
1393+
(QC_C_EXTU GPRNoX0:$rd, uimm5ge6_plus1:$width)>;
1394+
}

llvm/test/MC/RISCV/xqcibm-valid.s

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Xqcibm - Qualcomm uC Bit Manipulation Extension
22
# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-xqcibm -M no-aliases -show-encoding \
3-
# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST %s
3+
# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST,CHECK-NOALIAS %s
44
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-xqcibm < %s \
55
# RUN: | llvm-objdump --mattr=+experimental-xqcibm -M no-aliases --no-print-imm-hex -d - \
66
# RUN: | FileCheck -check-prefix=CHECK-INST %s
77
# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-xqcibm -show-encoding \
8-
# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST %s
8+
# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST,CHECK-ALIAS %s
99
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-xqcibm < %s \
1010
# RUN: | llvm-objdump --mattr=+experimental-xqcibm --no-print-imm-hex -d - \
1111
# RUN: | FileCheck -check-prefix=CHECK-INST %s
@@ -118,6 +118,14 @@ qc.c.bexti x9, 8
118118
# CHECK-ENC: encoding: [0x41,0x96]
119119
qc.c.bseti x12, 16
120120

121-
# CHECK-INST: qc.c.extu a5, 32
121+
# CHECK-NOALIAS: qc.c.extu a5, 32
122+
# CHECK-ALIAS: qc.extu a5, a5, 32, 0
122123
# CHECK-ENC: encoding: [0xfe,0x17]
123124
qc.c.extu x15, 32
125+
126+
# Check that compress pattern for qc.extu works
127+
128+
# CHECK-NOALIAS: qc.c.extu a1, 11
129+
# CHECK-ALIAS: qc.extu a1, a1, 11, 0
130+
# CHECK-ENC: encoding: [0xaa,0x15]
131+
qc.extu x11, x11, 11, 0

llvm/test/MC/RISCV/xqcicm-valid.s

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
# Xqcicm - Qualcomm uC Conditional Move Extension
22
# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-xqcicm -M no-aliases -show-encoding \
3-
# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST %s
3+
# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST,CHECK-NOALIAS %s
44
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-xqcicm < %s \
55
# RUN: | llvm-objdump --mattr=+experimental-xqcicm -M no-aliases --no-print-imm-hex -d - \
66
# RUN: | FileCheck -check-prefix=CHECK-INST %s
77
# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-xqcicm -show-encoding \
8-
# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST %s
8+
# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST,CHECK-ALIAS %s
99
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-xqcicm < %s \
1010
# RUN: | llvm-objdump --mattr=+experimental-xqcicm --no-print-imm-hex -d - \
1111
# RUN: | FileCheck -check-prefix=CHECK-INST %s
1212

13-
# CHECK-INST: qc.c.mveqz s1, a0
13+
# CHECK-NOALIAS: qc.c.mveqz s1, a0
14+
# CHECK-ALIAS: qc.mveqi s1, s1, 0, a0
1415
# CHECK-ENC: encoding: [0x06,0xad]
1516
qc.c.mveqz x9, x10
1617

@@ -121,3 +122,11 @@ qc.mvgeui x9, x10, 0, x12
121122
# CHECK-INST: qc.mvgeui s1, a0, 31, a2
122123
# CHECK-ENC: encoding: [0xdb,0x74,0xf5,0x65]
123124
qc.mvgeui x9, x10, 31, x12
125+
126+
# Check that compress pattern for qc.mveqi works
127+
128+
# CHECK-NOALIAS: qc.c.mveqz s1, a2
129+
# CHECK-ALIAS: qc.mveqi s1, s1, 0, a2
130+
# CHECK-ENC: encoding: [0x06,0xae]
131+
qc.mveqi x9, x9, 0, x12
132+

0 commit comments

Comments
 (0)