Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td
Original file line number Diff line number Diff line change
Expand Up @@ -1407,3 +1407,33 @@ let Predicates = [HasVendorXqcibm, IsRV32] in {
def : CompressPat<(QC_EXTU GPRNoX0:$rd, GPRNoX0:$rd, uimm5ge6_plus1:$width, 0),
(QC_C_EXTU GPRNoX0:$rd, uimm5ge6_plus1:$width)>;
}

let Predicates = [HasVendorXqcibm, HasStdExtZbs, IsRV32] in {
def : CompressPat<(BSETI GPRC:$rs1, GPRC:$rs1, uimmlog2xlennonzero:$shamt),
(QC_C_BSETI GPRC:$rs1, uimmlog2xlennonzero:$shamt)>;
def : CompressPat<(BEXTI GPRC:$rs1, GPRC:$rs1, uimmlog2xlennonzero:$shamt),
(QC_C_BEXTI GPRC:$rs1, uimmlog2xlennonzero:$shamt)>;
} // Predicates = [HasVendorXqcibm, HasStdExtZbs, IsRV32]

let isCompressOnly = true, Predicates = [HasVendorXqcilb, IsRV32] in {
def : CompressPat<(QC_E_J bare_simm12_lsb0:$offset),
(C_J bare_simm12_lsb0:$offset)>;
def : CompressPat<(QC_E_JAL bare_simm12_lsb0:$offset),
(C_JAL bare_simm12_lsb0:$offset)>;
} // isCompressOnly = true, Predicates = [HasVendorXqcilb, IsRV32]

let Predicates = [HasVendorXqcili, IsRV32] in {
def : CompressPat<(QC_LI GPRNoX0:$rd, simm6:$imm),
(C_LI GPRNoX0:$rd, simm6:$imm)>;

let isCompressOnly = true in
def : CompressPat<(QC_E_LI GPRNoX0:$rd, simm6:$imm),
(C_LI GPRNoX0:$rd, simm6:$imm)>;
} // Predicates = [HasVendorXqcili, IsRV32]

let isCompressOnly = true, Predicates = [HasVendorXqcilia, IsRV32] in {
def : CompressPat<(QC_E_ADDI GPRNoX0:$rs1, GPRNoX0:$rs1, simm6nonzero:$imm),
(C_ADDI GPRNoX0:$rs1, simm6nonzero:$imm)>;
def : CompressPat<(QC_E_ANDI GPRC:$rs1, GPRC:$rs1, simm6:$imm),
(C_ANDI GPRC:$rs1, simm6:$imm)>;
} // let isCompressOnly = true, Predicates = [HasVendorXqcilia, IsRV32]
33 changes: 23 additions & 10 deletions llvm/test/MC/RISCV/xqcibm-valid.s
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Xqcibm - Qualcomm uC Bit Manipulation Extension
# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-xqcibm -M no-aliases -show-encoding \
# Zbs is needed for checking compress instructions patterns for bexti/bseti
# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-xqcibm,+zbs -M no-aliases -show-encoding \
# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST,CHECK-NOALIAS %s
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-xqcibm < %s \
# RUN: | llvm-objdump --mattr=+experimental-xqcibm -M no-aliases --no-print-imm-hex -d - \
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-xqcibm,+zbs < %s \
# RUN: | llvm-objdump --mattr=+experimental-xqcibm,+zbs -M no-aliases --no-print-imm-hex -d - \
# RUN: | FileCheck -check-prefix=CHECK-INST %s
# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-xqcibm -show-encoding \
# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-xqcibm,+zbs -show-encoding \
# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST,CHECK-ALIAS %s
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-xqcibm < %s \
# RUN: | llvm-objdump --mattr=+experimental-xqcibm --no-print-imm-hex -d - \
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-xqcibm,+zbs < %s \
# RUN: | llvm-objdump --mattr=+experimental-xqcibm,+zbs --no-print-imm-hex -d - \
# RUN: | FileCheck -check-prefix=CHECK-INST %s

# CHECK-INST: qc.compress2 t2, t0
Expand Down Expand Up @@ -110,11 +111,13 @@ qc.extdpr x1, x4, x15
# CHECK-ENC: encoding: [0x0b,0x33,0x9c,0x13]
qc.extdprh x6, x24, x25

# CHECK-INST: qc.c.bexti s1, 8
# CHECK-NOALIAS: qc.c.bexti s1, 8
# CHECK-ALIAS: bexti s1, s1, 8
# CHECK-ENC: encoding: [0xa1,0x90]
qc.c.bexti x9, 8

# CHECK-INST: qc.c.bseti a2, 16
# CHECK-NOALIAS: qc.c.bseti a2, 16
# CHECK-ALIAS: bseti a2, a2, 16
# CHECK-ENC: encoding: [0x41,0x96]
qc.c.bseti x12, 16

Expand All @@ -123,9 +126,19 @@ qc.c.bseti x12, 16
# CHECK-ENC: encoding: [0xfe,0x17]
qc.c.extu x15, 32

# Check that compress pattern for qc.extu works
# Check that compress patterns work as expected

# CHECK-NOALIAS: qc.c.extu a1, 11
# CHECK-ALIAS: qc.extu a1, a1, 11, 0
# CHECK-ENC: encoding: [0xaa,0x15]
qc.extu x11, x11, 11, 0
qc.extu x11, x11, 11, 0

# CHECK-NOALIAS: qc.c.bexti s1, 8
# CHECK-ALIAS: bexti s1, s1, 8
# CHECK-ENC-ZBS: encoding: [0xa1,0x90]
bexti x9, x9, 8

# CHECK-NOALIAS: qc.c.bseti a2, 16
# CHECK-ALIAS: bseti a2, a2, 16
# CHECK-ENC: encoding: [0x41,0x96]
bseti x12, x12, 16
4 changes: 4 additions & 0 deletions llvm/test/MC/RISCV/xqcilb-relocations.s
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

.text

.option exact

qc.e.j foo
# RELOC: R_RISCV_CUSTOM195 foo 0x0
# INSTR: qc.e.j foo
Expand All @@ -33,6 +35,8 @@ qc.e.j .L1
qc.e.jal .L1
# INSTR:qc.e.jal .L1

.option noexact

.L1:
ret

Expand Down
25 changes: 18 additions & 7 deletions llvm/test/MC/RISCV/xqcilb-valid.s
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Xqcilb - Qualcomm uC Long Branch Extension
# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-xqcilb -M no-aliases -show-encoding \
# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST %s
# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST,CHECK-NOALIAS %s
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-xqcilb < %s \
# RUN: | llvm-objdump --mattr=+experimental-xqcilb -M no-aliases --no-print-imm-hex -d - \
# RUN: | FileCheck -check-prefix=CHECK-OBJ %s
# RUN: | FileCheck -check-prefixes=CHECK-OBJ,CHECK-OBJ-NOALIAS %s
# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-xqcilb -show-encoding \
# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST %s
# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST,CHECK-ALIAS %s
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-xqcilb < %s \
# RUN: | llvm-objdump --mattr=+experimental-xqcilb --no-print-imm-hex -d - \
# RUN: | FileCheck -check-prefix=CHECK-OBJ %s
# RUN: | FileCheck -check-prefixes=CHECK-OBJ,CHECK-OBJ-ALIAS %s

# CHECK-INST: qc.e.j -2147483648
# CHECK-OBJ: qc.e.j 0x80000000
Expand All @@ -20,7 +20,18 @@ qc.e.j -2147483648
# CHECK-ENC: encoding: [0x9f,0xcc,0x0e,0xfe,0xff,0x7f]
qc.e.jal 2147483640

# CHECK-INST: qc.e.jal -116
# CHECK-OBJ: qc.e.jal 0xffffff98
# CHECK-ENC: encoding: [0x9f,0xc6,0x0e,0xf8,0xff,0xff]
# Check that compress patterns work as expected

# CHECK-NOALIAS: c.jal -116
# CHECK-ALIAS: jal -116
# CHECK-OBJ-NOALIAS: c.jal 0xffffff98
# CHECK-OBJ-ALIAS: jal 0xffffff98
# CHECK-ENC: encoding: [0x71,0x37]
qc.e.jal 0xffffff8c

# CHECK-NOALIAS: c.j 1024
# CHECK-ALIAS: j 1024
# CHECK-OBJ-NOALIAS: c.j 0x40e
# CHECK-OBJ-ALIAS: j 0x40e
# CHECK-ENC: encoding: [0x01,0xa1]
qc.e.j 1024
4 changes: 4 additions & 0 deletions llvm/test/MC/RISCV/xqcili-relocations.s
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

.text

.option exact

qc.li x4, %qc.abs20(foo)
# RELOC: R_RISCV_CUSTOM192 foo 0x0
# INSTR: qc.li tp, %qc.abs20(foo)
Expand All @@ -33,6 +35,8 @@ qc.li x7, %qc.abs20(.L1)
qc.e.li x6, .L1
# INSTR: qc.e.li t1, .L1

.option noexact

.L1:
ret

Expand Down
19 changes: 14 additions & 5 deletions llvm/test/MC/RISCV/xqcili-valid.s
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
# Xqcili - Qualcomm uC Load Large Immediate Extension
# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-xqcili -M no-aliases -show-encoding \
# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST %s
# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST,CHECK-NOALIAS %s

# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-xqcili < %s \
# RUN: | llvm-objdump --mattr=+experimental-xqcili -M no-aliases --no-print-imm-hex -d - \
# RUN: | FileCheck -check-prefix=CHECK-INST %s

# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-xqcili -show-encoding \
# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST %s
# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST,CHECK-ALIAS %s

# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-xqcili < %s \
# RUN: | llvm-objdump --mattr=+experimental-xqcili --no-print-imm-hex -d - \
# RUN: | FileCheck -check-prefix=CHECK-INST %s

# CHECK-INST: qc.e.li a0, -1
# CHECK-ENC: encoding: [0x1f,0x05,0xff,0xff,0xff,0xff]
qc.e.li x10, 4294967295

# CHECK-INST: qc.e.li a0, -2147483648
# CHECK-ENC: encoding: [0x1f,0x05,0x00,0x00,0x00,0x80]
Expand Down Expand Up @@ -44,3 +41,15 @@ qc.li x10, 12345
# CHECK-INST: qc.li a0, -12346
# CHECK-ENC: encoding: [0x1b,0xf5,0xc6,0xcf]
qc.li x10, -12346

# Check that compress patterns work as expected

# CHECK-ALIAS: li a0, -1
# CHECK-NOALIAS: c.li a0, -1
# CHECK-ENC: encoding: [0x7d,0x55]
qc.e.li x10, 4294967295

# CHECK-ALIAS: li a0, 31
# CHECK-NOALIAS: c.li a0, 31
# CHECK-ENC: encoding: [0x7d,0x45]
qc.li x10, 31
16 changes: 14 additions & 2 deletions llvm/test/MC/RISCV/xqcilia-valid.s
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Xqcilia - Qualcomm uC Large Immediate Arithmetic extension
# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-xqcilia -M no-aliases -show-encoding \
# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST %s
# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST,CHECK-NOALIAS %s
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-xqcilia < %s \
# RUN: | llvm-objdump --mattr=+experimental-xqcilia -M no-aliases --no-print-imm-hex -d - \
# RUN: | FileCheck -check-prefix=CHECK-INST %s
# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-xqcilia -show-encoding \
# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST %s
# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST,CHECK-ALIAS %s
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-xqcilia < %s \
# RUN: | llvm-objdump --mattr=+experimental-xqcilia --no-print-imm-hex -d - \
# RUN: | FileCheck -check-prefix=CHECK-INST %s
Expand Down Expand Up @@ -80,3 +80,15 @@ qc.e.xori x10, x9, -33554432
# CHECK-INST: qc.e.xori a0, s1, 33554431
# CHECK-ENC: encoding: [0x1f,0xb5,0xf4,0x3f,0xff,0x7f]
qc.e.xori x10, x9, 33554431

# Check that compress patterns work as expected

# CHECK-ALIAS: addi t0, t0, 20
# CHECK-NOALIAS: c.addi t0, 20
# CHECK-ENC: encoding: [0xd1,0x02]
qc.e.addi x5, x5, 20

# CHECK-ALIAS: andi s1, s1, -10
# CHECK-NOALIAS: c.andi s1, -10
# CHECK-ENC: encoding: [0xd9,0x98]
qc.e.andi x9, x9, -10