1# RUN: llvm-mc -triple riscv32 -mattr=-relax -riscv-no-aliases < %s \ 2# RUN: | FileCheck -check-prefix=CHECK-INST %s 3# RUN: llvm-mc -filetype=obj -triple riscv32 < %s \ 4# RUN: | llvm-readobj -r - | FileCheck -check-prefix=CHECK-RELOC %s 5# RUN: llvm-mc -triple riscv32 -filetype=obj < %s \ 6# RUN: | llvm-objdump --triple=riscv32 --mattr=+c -d - \ 7# RUN: | FileCheck -check-prefixes=CHECK-BYTES,CHECK-ALIAS %s 8 9# RUN: llvm-mc -triple riscv64 -mattr=-relax -riscv-no-aliases < %s \ 10# RUN: | FileCheck -check-prefix=CHECK-INST %s 11# RUN: llvm-mc -filetype=obj -triple riscv64 < %s \ 12# RUN: | llvm-readobj -r - | FileCheck -check-prefix=CHECK-RELOC %s 13# RUN: llvm-mc -triple riscv64 -filetype=obj < %s \ 14# RUN: | llvm-objdump --triple=riscv64 --mattr=+c -d - \ 15# RUN: | FileCheck -check-prefixes=CHECK-BYTES,CHECK-ALIAS %s 16 17# Test the operation of the push and pop assembler directives when 18# using .option relax and .option rvc. Checks that using .option pop 19# correctly restores all target features to their state at the point 20# where .option pop was last used. 21 22# CHECK-INST: call foo 23# CHECK-RELOC: R_RISCV_CALL foo 0x0 24# CHECK-RELOC-NOT: R_RISCV_RELAX - 0x0 25call foo 26 27# CHECK-INST: addi s0, sp, 1020 28# CHECK-BYTES: 13 04 c1 3f 29# CHECK-ALIAS: addi s0, sp, 1020 30addi s0, sp, 1020 31 32.option push # Push relax=false, rvc=false 33# CHECK-INST: .option push 34 35.option relax 36# CHECK-INST: .option relax 37# CHECK-INST: call bar 38# CHECK-RELOC-NEXT: R_RISCV_CALL bar 0x0 39# CHECK-RELOC-NEXT: R_RISCV_RELAX - 0x0 40call bar 41 42.option push # Push relax=true, rvc=false 43# CHECK-INST: .option push 44 45.option rvc 46# CHECK-INST: .option rvc 47# CHECK-INST: c.addi4spn s0, sp, 1020 48# CHECK-BYTES: e0 1f 49# CHECK-ALIAS: addi s0, sp, 1020 50addi s0, sp, 1020 51 52.option pop # Pop relax=true, rvc=false 53# CHECK-INST: .option pop 54# CHECK-INST: addi s0, sp, 1020 55# CHECK-BYTES: 13 04 c1 3f 56# CHECK-ALIAS: addi s0, sp, 1020 57addi s0, sp, 1020 58 59# CHECK-INST: call bar 60# CHECK-RELOC-NEXT: R_RISCV_CALL bar 0x0 61# CHECK-RELOC-NEXT: R_RISCV_RELAX - 0x0 62call bar 63 64.option pop # Pop relax=false, rvc=false 65# CHECK-INST: .option pop 66# CHECK-INST: call baz 67# CHECK-RELOC: R_RISCV_CALL baz 0x0 68# CHECK-RELOC-NOT: R_RISCV_RELAX - 0x0 69call baz 70 71# CHECK-INST: addi s0, sp, 1020 72# CHECK-BYTES: 13 04 c1 3f 73# CHECK-ALIAS: addi s0, sp, 1020 74addi s0, sp, 1020 75 76.option push # Push pic=false 77# CHECK-INST: .option push 78 79.option pic 80# CHECK-INST: .option pic 81 82la s0, symbol 83# CHECK-INST: auipc s0, %got_pcrel_hi(symbol) 84# CHECK-INST: l{{[wd]}} s0, %pcrel_lo(.Lpcrel_hi0)(s0) 85# CHECK-RELOC: R_RISCV_GOT_HI20 symbol 0x0 86# CHECK-RELOC: R_RISCV_PCREL_LO12_I .Lpcrel_hi0 0x0 87 88.option push # Push pic=true 89# CHECK-INST: .option push 90 91.option nopic 92# CHECK-INST: .option nopic 93 94la s0, symbol 95# CHECK-INST: auipc s0, %pcrel_hi(symbol) 96# CHECK-INST: addi s0, s0, %pcrel_lo(.Lpcrel_hi1) 97# CHECK-RELOC: R_RISCV_PCREL_HI20 symbol 0x0 98# CHECK-RELOC: R_RISCV_PCREL_LO12_I .Lpcrel_hi1 0x0 99 100.option pop # Push pic=true 101# CHECK-INST: .option pop 102 103la s0, symbol 104# CHECK-INST: auipc s0, %got_pcrel_hi(symbol) 105# CHECK-INST: l{{[wd]}} s0, %pcrel_lo(.Lpcrel_hi2)(s0) 106# CHECK-RELOC: R_RISCV_GOT_HI20 symbol 0x0 107# CHECK-RELOC: R_RISCV_PCREL_LO12_I .Lpcrel_hi2 0x0 108 109.option pop # Push pic=false 110# CHECK-INST: .option pop 111 112la s0, symbol 113# CHECK-INST: auipc s0, %pcrel_hi(symbol) 114# CHECK-INST: addi s0, s0, %pcrel_lo(.Lpcrel_hi3) 115# CHECK-RELOC: R_RISCV_PCREL_HI20 symbol 0x0 116# CHECK-RELOC: R_RISCV_PCREL_LO12_I .Lpcrel_hi3 0x0 117