Skip to content

Commit 5e1cf12

Browse files
committed
Add support for zclsd and zilsd extensions + tests
1 parent 49f276e commit 5e1cf12

File tree

5 files changed

+51
-20
lines changed

5 files changed

+51
-20
lines changed

llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,13 @@ class RISCVMCInstrAnalysis : public MCInstrAnalysis {
308308
case RISCV::C_FLWSP:
309309
case RISCV::C_FSWSP:
310310
case RISCV::C_FLDSP:
311-
case RISCV::C_FSDSP: {
311+
case RISCV::C_FSDSP:
312+
case RISCV::C_LD_RV32:
313+
case RISCV::C_SD_RV32:
314+
case RISCV::C_SDSP_RV32:
315+
case RISCV::LD_RV32:
316+
case RISCV::C_LDSP_RV32:
317+
case RISCV::SD_RV32: {
312318
MCRegister Reg = Inst.getOperand(1).getReg();
313319
auto TargetRegState = getGPRState(Reg);
314320
if (TargetRegState && Reg != RISCV::X0) {
8.93 KB
Binary file not shown.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# RUN: llvm-objdump -d %p/Inputs/riscv32-ar-coverage | FileCheck %s
2+
3+
# CHECK: 00001000 <_start>:
4+
# CHECK-NEXT: 1000: 00000517 auipc a0, 0x0
5+
# CHECK-NEXT: 1004: 0559 addi a0, a0, 0x16 <target>
6+
# CHECK-NEXT: 1006: 00000517 auipc a0, 0x0
7+
# CHECK-NEXT: 100a: 6910 ld a2, 0x10(a0) <target>
8+
# CHECK-NEXT: 100c: 00000517 auipc a0, 0x0
9+
# CHECK-NEXT: 1010: 00c53523 sd a2, 0xa(a0) <target>
10+
# CHECK-NEXT: 1014: 0000 unimp
11+
12+
# the structure of this test file is similar to that of riscv64-ar-coverage
13+
# with the major difference being that these tests are focused on instructions
14+
# for 32 bit architecture
15+
16+
.global _start
17+
.text
18+
_start:
19+
auipc a0, 0x0
20+
addi a0, a0, 0x16 # addi -- behavior changes with differentr architectures
21+
22+
auipc a0, 0x0
23+
c.ld a2, 0x10(a0) # zclsd instruction
24+
25+
auipc a0, 0x0
26+
sd a2, 0xa(a0) # zilsd instruction
27+
28+
.skip 0x2
29+
target:
30+
ret:

llvm/test/tools/llvm-objdump/RISCV/riscv-ar-coverage.s renamed to llvm/test/tools/llvm-objdump/RISCV/riscv64-ar-coverage.s

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# RUN: llvm-objdump -d %p/Inputs/riscv-ar-coverage | FileCheck %s
1+
# RUN: llvm-objdump -d %p/Inputs/riscv64-ar-coverage | FileCheck %s
22

33
# CHECK: 0000000000001000 <_start>:
44
# CHECK-NEXT: 1000: 00001517 auipc a0, 0x1
@@ -22,23 +22,22 @@
2222
# CHECK-NEXT: 1032: 00a02423 sw a0, 0x8(zero)
2323
# CHECK-NEXT: 1036: 00101097 auipc ra, 0x101
2424
# CHECK-NEXT: 103a: fd6080e7 jalr -0x2a(ra) <func>
25-
# CHECK-NEXT: 103e: 00102437 lui s0, 0x102
26-
# CHECK-NEXT: 1042: 8800 sb s0, 0x0(s0) <target+0xffffc>
27-
# CHECK-NEXT: 1044: 00102137 lui sp, 0x102
28-
# CHECK-NEXT: 1048: 4522 lw a0, 0x8(sp) <far_target>
25+
# CHECK-NEXT: 103e: 640d lui s0, 0x3
26+
# CHECK-NEXT: 1040: 8800 sb s0, 0x0(s0) <zcb>
27+
# CHECK-NEXT: 1042: 4522 lw a0, 0x8(sp)
28+
2929

3030
.global _start
3131
.text
3232

33-
# The core of the feature being added was address resolution for instruction
34-
# sequences where a register is populated by immediate values via two
33+
# The core of the feature being added was address resolution for instruction
34+
# sequences where an register is populated by immediate values via two
3535
# separate instructions. First by an instruction that provides the upper bits
3636
# (auipc, lui ...) followed by another instruction for the lower bits (addi,
3737
# jalr, ld ...).
3838

39-
4039
_start:
41-
# Test block 1-3 each focus on a certain starting instruction in a sequences,
40+
# Test block 1-3 each focus on a certain starting instruction in a sequences,
4241
# the ones that provide the upper bits. The other sequence is another
4342
# instruction the provides the lower bits. The second instruction is
4443
# arbitrarily chosen to increase code coverage
@@ -69,7 +68,7 @@ _start:
6968
lui a1, 0x1 # unrelated instruction
7069
slli t1, t1, 0x1 # unrelated instruction
7170
addi a0, a0, 0x4
72-
addi a0, a0, 0x1
71+
addi a0, a0, 0x1 # verify register tracking terminates
7372

7473
# Test 5 ensures that an instruction writing into the zero register does
7574
# not trigger resolution because that register's value cannot change and
@@ -86,25 +85,21 @@ _start:
8685
call func
8786

8887
# test #7 zcb extension
89-
lui x8, 0x102
90-
# the immediate value for Zcb extension is heavily bounded, so we will relax
91-
# the requirement of hitting one of the labels and focus on correctness of the
92-
# resolution. This can be verified by looking at the source: The upper bits of
93-
# lui make the far jump related to .skip 0x100000 and then 8 more bytes must be
94-
# traversed before we hit far_target--.skip 0x4 and .word 1 in target. Adding 8
95-
# to address resolved for the instruction below yields exactly the desired label.
88+
lui x8, 0x3
9689
c.sb x8, 0(x8)
9790

9891
# test #8 stack based load/stores
99-
lui sp, 0x102
10092
c.lwsp a0, 0x8(sp)
10193

10294
# these are the labels that the instructions above are expecteed to resolve to
10395
.section .data
10496
.skip 0x4
10597
target:
10698
.word 1
107-
.skip 0x100000
99+
.skip 0xff8
100+
zcb:
101+
.word 1
102+
.skip 0xff004
108103
far_target:
109104
.word 2
110105
func:

0 commit comments

Comments
 (0)