1# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+c < %s \ 2# RUN: | llvm-objdump -d -M no-aliases - | FileCheck --check-prefix=INSTR %s 3# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+c,+relax < %s \ 4# RUN: | llvm-objdump -d -M no-aliases - | FileCheck --check-prefix=RELAX-INSTR %s 5# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+c,+relax < %s \ 6# RUN: | llvm-readobj -r - | FileCheck -check-prefix=RELAX-RELOC %s 7 8FAR_JUMP_NEGATIVE: 9 c.nop 10.space 2000 11 12FAR_BRANCH_NEGATIVE: 13 c.nop 14.space 256 15 16NEAR_NEGATIVE: 17 c.nop 18 19start: 20 c.bnez a0, NEAR 21#INSTR: c.bnez a0, 0x90e 22#RELAX-INSTR: c.bnez a0, 0 23#RELAX-RELOC: R_RISCV_RVC_BRANCH 24 c.bnez a0, NEAR_NEGATIVE 25#INSTR: c.bnez a0, 0x8d4 26#RELAX-INSTR: c.bnez a0, 0 27#RELAX-RELOC: R_RISCV_RVC_BRANCH 28 c.bnez a0, FAR_BRANCH 29#INSTR-NEXT: bne a0, zero, 0xa10 30#RELAX-INSTR-NEXT: bne a0, zero, 0 31#RELAX-RELOC: R_RISCV_BRANCH 32 c.bnez a0, FAR_BRANCH_NEGATIVE 33#INSTR-NEXT: bne a0, zero, 0x7d2 34#RELAX-INSTR-NEXT: bne a0, zero, 0 35#RELAX-RELOC: R_RISCV_BRANCH 36 c.bnez a0, FAR_JUMP 37#INSTR-NEXT: bne a0, zero, 0x11e2 38#RELAX-INSTR-NEXT: bne a0, zero, 0 39#RELAX-RELOC: R_RISCV_BRANCH 40 c.bnez a0, FAR_JUMP_NEGATIVE 41#INSTR-NEXT: bne a0, zero, 0x0 42#RELAX-INSTR-NEXT: bne a0, zero, 0 43#RELAX-RELOC: R_RISCV_BRANCH 44 45 c.beqz a0, NEAR 46#INSTR-NEXT: c.beqz a0, 0x90e 47#RELAX-INSTR-NEXT: c.beqz a0, 0 48#RELAX-RELOC: R_RISCV_RVC_BRANCH 49 c.beqz a0, NEAR_NEGATIVE 50#INSTR-NEXT: c.beqz a0, 0x8d4 51#RELAX-INSTR-NEXT: c.beqz a0, 0 52#RELAX-RELOC: R_RISCV_RVC_BRANCH 53 c.beqz a0, FAR_BRANCH 54#INSTR-NEXT: beq a0, zero, 0xa10 55#RELAX-INSTR-NEXT: beq a0, zero, 0 56#RELAX-RELOC: R_RISCV_BRANCH 57 c.beqz a0, FAR_BRANCH_NEGATIVE 58#INSTR-NEXT: beq a0, zero, 0x7d2 59#RELAX-INSTR-NEXT: beq a0, zero, 0 60#RELAX-RELOC: R_RISCV_BRANCH 61 c.beqz a0, FAR_JUMP 62#INSTR-NEXT: beq a0, zero, 0x11e2 63#RELAX-INSTR-NEXT: beq a0, zero, 0 64#RELAX-RELOC: R_RISCV_BRANCH 65 c.beqz a0, FAR_JUMP_NEGATIVE 66#INSTR-NEXT: beq a0, zero, 0x0 67#RELAX-INSTR-NEXT: beq a0, zero, 0 68#RELAX-RELOC: R_RISCV_BRANCH 69 70 c.j NEAR 71#INSTR-NEXT: c.j 0x90e 72#RELAX-INSTR-NEXT: c.j 0 73#RELAX-RELOC: R_RISCV_RVC_JUMP 74 c.j NEAR_NEGATIVE 75#INSTR-NEXT: c.j 0x8d4 76#RELAX-INSTR-NEXT: c.j 0 77#RELAX-RELOC: R_RISCV_RVC_JUMP 78 c.j FAR_BRANCH 79#INSTR-NEXT: c.j 0xa10 80#RELAX-INSTR-NEXT: c.j 0 81#RELAX-RELOC: R_RISCV_RVC_JUMP 82 c.j FAR_BRANCH_NEGATIVE 83#INSTR-NEXT: c.j 0x7d2 84#RELAX-INSTR-NEXT: c.j 0 85#RELAX-RELOC: R_RISCV_RVC_JUMP 86 c.j FAR_JUMP 87#INSTR-NEXT: jal zero, 0x11e2 88#RELAX-INSTR-NEXT: jal zero, 0 89#RELAX-RELOC: R_RISCV_JAL 90 c.j FAR_JUMP_NEGATIVE 91#INSTR-NEXT: jal zero, 0x0 92#RELAX-INSTR-NEXT: jal zero, 0 93#RELAX-RELOC: R_RISCV_JAL 94 95NEAR: 96 c.nop 97 98.space 256 99FAR_BRANCH: 100 c.nop 101 102.space 2000 103FAR_JUMP: 104 c.nop 105