diff options
| author | Alex Bradbury <asb@lowrisc.org> | 2017-12-07 13:19:57 +0000 |
|---|---|---|
| committer | Alex Bradbury <asb@lowrisc.org> | 2017-12-07 13:19:57 +0000 |
| commit | f8f4b905448ae242ea08c84c0a36abc0431dc98b (patch) | |
| tree | 87bd86c19960e3e11d24595ddf18a06a049e201d /llvm/test/MC/RISCV | |
| parent | 9f6aec4b7aab9a0c0d33bff634af0e148ed580ef (diff) | |
| download | bcm5719-llvm-f8f4b905448ae242ea08c84c0a36abc0431dc98b.tar.gz bcm5719-llvm-f8f4b905448ae242ea08c84c0a36abc0431dc98b.zip | |
[RISCV] MC layer support for the jump/branch instructions of the RVC extension
Differential Revision: https://reviews.llvm.org/D40002
Patch by Shiva Chen.
llvm-svn: 320038
Diffstat (limited to 'llvm/test/MC/RISCV')
| -rw-r--r-- | llvm/test/MC/RISCV/fixups-compressed.s | 18 | ||||
| -rw-r--r-- | llvm/test/MC/RISCV/relocations.s | 14 | ||||
| -rw-r--r-- | llvm/test/MC/RISCV/rv32c-invalid.s | 13 | ||||
| -rw-r--r-- | llvm/test/MC/RISCV/rv32c-valid.s | 19 |
4 files changed, 62 insertions, 2 deletions
diff --git a/llvm/test/MC/RISCV/fixups-compressed.s b/llvm/test/MC/RISCV/fixups-compressed.s new file mode 100644 index 00000000000..bf6cbfc3556 --- /dev/null +++ b/llvm/test/MC/RISCV/fixups-compressed.s @@ -0,0 +1,18 @@ +# RUN: llvm-mc %s -triple riscv32 -mattr=+c -show-encoding \ +# RUN: | FileCheck -check-prefix=CHECK-FIXUP %s +# RUN: llvm-mc -triple riscv32 -filetype=obj -mattr=+c < %s \ +# RUN: | llvm-objdump -mattr=+c -d - | FileCheck -check-prefix=CHECK-INSTR %s + +.LBB0_2: +# CHECK-FIXUP: fixup A - offset: 0, value: .LBB0_2, kind: fixup_riscv_rvc_jump +# CHECK-INSTR: c.j 0 +c.j .LBB0_2 +# CHECK: fixup A - offset: 0, value: func1, kind: fixup_riscv_rvc_jump +# CHECK-INSTR: c.jal 0 +c.jal func1 +# CHECK-FIXUP: fixup A - offset: 0, value: .LBB0_2, kind: fixup_riscv_rvc_branch +# CHECK-INSTR: c.beqz a3, -4 +c.beqz a3, .LBB0_2 +# CHECK-FIXUP: fixup A - offset: 0, value: .LBB0_2, kind: fixup_riscv_rvc_branch +# CHECK-INSTR: c.bnez a5, -6 +c.bnez a5, .LBB0_2 diff --git a/llvm/test/MC/RISCV/relocations.s b/llvm/test/MC/RISCV/relocations.s index c11e2f38dfc..a6009b0ad67 100644 --- a/llvm/test/MC/RISCV/relocations.s +++ b/llvm/test/MC/RISCV/relocations.s @@ -1,6 +1,6 @@ -# RUN: llvm-mc -triple riscv32 < %s -show-encoding \ +# RUN: llvm-mc -triple riscv32 -mattr=+c < %s -show-encoding \ # RUN: | FileCheck -check-prefix=INSTR -check-prefix=FIXUP %s -# RUN: llvm-mc -filetype=obj -triple riscv32 < %s \ +# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+c < %s \ # RUN: | llvm-readobj -r | FileCheck -check-prefix=RELOC %s # Check prefixes: @@ -63,3 +63,13 @@ bgeu a0, a1, foo # RELOC: R_RISCV_BRANCH # INSTR: bgeu a0, a1, foo # FIXUP: fixup A - offset: 0, value: foo, kind: fixup_riscv_branch + +c.jal foo +# RELOC: R_RISCV_RVC_JUMP +# INSTR: c.jal foo +# FIXUP: fixup A - offset: 0, value: foo, kind: fixup_riscv_rvc_jump + +c.bnez a0, foo +# RELOC: R_RISCV_RVC_BRANCH +# INSTR: c.bnez a0, foo +# FIXUP: fixup A - offset: 0, value: foo, kind: fixup_riscv_rvc_branch diff --git a/llvm/test/MC/RISCV/rv32c-invalid.s b/llvm/test/MC/RISCV/rv32c-invalid.s index c3403aa632b..639148bb4ff 100644 --- a/llvm/test/MC/RISCV/rv32c-invalid.s +++ b/llvm/test/MC/RISCV/rv32c-invalid.s @@ -1,12 +1,17 @@ # RUN: not llvm-mc -triple=riscv32 -mattr=+c < %s 2>&1 | FileCheck %s ## GPRC +.LBB: c.lw ra, 4(sp) # CHECK: :[[@LINE]]:7: error: invalid operand for instruction c.sw sp, 4(sp) # CHECK: :[[@LINE]]:7: error: invalid operand for instruction +c.beqz t0, .LBB # CHECK: :[[@LINE]]:9: error: invalid operand for instruction +c.bnez s8, .LBB # CHECK: :[[@LINE]]:9: error: invalid operand for instruction ## GPRNoX0 c.lwsp x0, 4(sp) # CHECK: :[[@LINE]]:9: error: invalid operand for instruction c.lwsp zero, 4(sp) # CHECK: :[[@LINE]]:9: error: invalid operand for instruction +c.jr x0 # CHECK: :[[@LINE]]:7: error: invalid operand for instruction +c.jalr zero # CHECK: :[[@LINE]]:9: error: invalid operand for instruction # Out of range immediates @@ -16,3 +21,11 @@ c.swsp ra, -4(sp) # CHECK: :[[@LINE]]:13: error: immediate must be a multiple o ## uimm7_lsb00 c.lw s0, -4(sp) # CHECK: :[[@LINE]]:11: error: immediate must be a multiple of 4 bytes in the range [0, 124] c.sw s0, 128(sp) # CHECK: :[[@LINE]]:11: error: immediate must be a multiple of 4 bytes in the range [0, 124] + +## simm9_lsb0 +c.bnez s1, -258 # CHECK: :[[@LINE]]:13: error: immediate must be a multiple of 2 bytes in the range [-256, 254] +c.beqz a0, 256 # CHECK: :[[@LINE]]:13: error: immediate must be a multiple of 2 bytes in the range [-256, 254] + +## simm12_lsb0 +c.j 2048 # CHECK: :[[@LINE]]:5: error: immediate must be a multiple of 2 bytes in the range [-2048, 2046] +c.jal -2050 # CHECK: :[[@LINE]]:7: error: immediate must be a multiple of 2 bytes in the range [-2048, 2046] diff --git a/llvm/test/MC/RISCV/rv32c-valid.s b/llvm/test/MC/RISCV/rv32c-valid.s index 86c2dff5698..ce4273d3802 100644 --- a/llvm/test/MC/RISCV/rv32c-valid.s +++ b/llvm/test/MC/RISCV/rv32c-valid.s @@ -21,3 +21,22 @@ c.lw a2, 0(a0) # CHECK-INST: c.sw a5, 124(a3) # CHECK: encoding: [0xfc,0xde] c.sw a5, 124(a3) + +# CHECK-INST: c.j -2048 +# CHECK: encoding: [0x01,0xb0] +c.j -2048 +# CHECK-INST: c.jal 2046 +# CHECK: encoding: [0xfd,0x2f] +c.jal 2046 +# CHECK-INST: c.jr a7 +# CHECK: encoding: [0x82,0x88] +c.jr a7 +# CHECK-INST: c.jalr a1 +# CHECK: encoding: [0x82,0x95] +c.jalr a1 +# CHECK-INST: c.beqz a3, -256 +# CHECK: encoding: [0x81,0xd2] +c.beqz a3, -256 +# CHECK-INST: c.bnez a5, 254 +# CHECK: encoding: [0xfd,0xef] +c.bnez a5, 254 |

