1# RUN: llvm-mc %s -triple=riscv32 | FileCheck -check-prefixes=ASM %s 2# RUN: llvm-mc %s -triple=riscv64 | FileCheck -check-prefixes=ASM %s 3# RUN: llvm-mc %s -triple=riscv32 -mattr=+relax | FileCheck -check-prefix=ASM %s 4# RUN: llvm-mc %s -triple=riscv64 -mattr=+relax | FileCheck -check-prefix=ASM %s 5# RUN: llvm-mc -filetype=obj -triple riscv32 < %s \ 6# RUN: | llvm-objdump -d -M no-aliases - | FileCheck --check-prefixes=DISASM,DISASM-NORELAX %s 7# RUN: llvm-mc -filetype=obj -triple riscv64 < %s \ 8# RUN: | llvm-objdump -d -M no-aliases - | FileCheck --check-prefixes=DISASM,DISASM-NORELAX %s 9# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+relax < %s \ 10# RUN: | llvm-objdump -d -M no-aliases - | FileCheck --check-prefixes=DISASM,DISASM-RELAX %s 11# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+relax < %s \ 12# RUN: | llvm-objdump -d -M no-aliases - | FileCheck --check-prefixes=DISASM,DISASM-RELAX %s 13 14# Checks change of options does not cause error: could not find corresponding %pcrel_hi 15# when assembling pseudoinstruction and its extended form. Also checks that we 16# evaluate the correct value for local symbols in such a situation. 17 18.option push 19.option norelax 20 la a0, a_symbol 21.option pop 22 la a1, another_symbol 23 24# ASM-LABEL: .Lpcrel_hi0{{>?}}: 25# ASM-NEXT: auipc a0, %pcrel_hi(a_symbol) 26# ASM-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi0) 27# ASM-LABEL: .Lpcrel_hi1{{>?}}: 28# ASM-NEXT: auipc a1, %pcrel_hi(another_symbol) 29# ASM-NEXT: addi a1, a1, %pcrel_lo(.Lpcrel_hi1) 30 31# DISASM-LABEL: <.Lpcrel_hi0>: 32# DISASM-NEXT: auipc a0, 0 33# DISASM-NEXT: addi a0, a0, 0 34# DISASM-LABEL: <.Lpcrel_hi1>: 35# DISASM-NEXT: auipc a1, 0 36# DISASM-NEXT: addi a1, a1, 0 37 38.option push 39.option norelax 401:auipc a0, %pcrel_hi(a_symbol) 41 addi a0, a0, %pcrel_lo(1b) 42.option pop 432:auipc a1, %pcrel_hi(another_symbol) 44 addi a1, a1, %pcrel_lo(2b) 45 46# ASM-LABEL: .Ltmp0{{>?}}: 47# ASM-NEXT: auipc a0, %pcrel_hi(a_symbol) 48# ASM-NEXT: addi a0, a0, %pcrel_lo(.Ltmp0) 49# ASM-LABEL: .Ltmp1{{>?}}: 50# ASM-NEXT: auipc a1, %pcrel_hi(another_symbol) 51# ASM-NEXT: addi a1, a1, %pcrel_lo(.Ltmp1) 52 53# DISASM-LABEL: .Ltmp0{{>?}}: 54# DISASM-NEXT: auipc a0, 0 55# DISASM-NEXT: addi a0, a0, 0 56# DISASM-LABEL: .Ltmp1{{>?}}: 57# DISASM-NEXT: auipc a1, 0 58# DISASM-NEXT: addi a1, a1, 0 59 60.option push 61.option norelax 62 la a0, a_symbol 63.option pop 64 la a1, local_symbol1 65 66local_symbol1: 67 nop 68 69# ASM-LABEL: .Lpcrel_hi2{{>?}}: 70# ASM-NEXT: auipc a0, %pcrel_hi(a_symbol) 71# ASM-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi2) 72# ASM-LABEL: .Lpcrel_hi3{{>?}}: 73# ASM-NEXT: auipc a1, %pcrel_hi(local_symbol1) 74# ASM-NEXT: addi a1, a1, %pcrel_lo(.Lpcrel_hi3) 75 76# DISASM-LABEL: .Lpcrel_hi2{{>?}}: 77# DISASM-NEXT: auipc a0, 0 78# DISASM-NEXT: addi a0, a0, 0 79# DISASM-NORELAX-NEXT: auipc a1, 0 80# DISASM-NORELAX-NEXT: addi a1, a1, 8 81# DISASM-RELAX-LABEL: .Lpcrel_hi3{{>?}}: 82# DISASM-RELAX-NEXT: auipc a1, 0 83# DISASM-RELAX-NEXT: addi a1, a1, 0 84 85.option push 86.option norelax 871:auipc a0, %pcrel_hi(a_symbol) 88 addi a0, a0, %pcrel_lo(1b) 89.option pop 902:auipc a1, %pcrel_hi(local_symbol2) 91 addi a1, a1, %pcrel_lo(2b) 92 93local_symbol2: 94 nop 95 96# ASM-LABEL: .Ltmp2{{>?}}: 97# ASM-NEXT: auipc a0, %pcrel_hi(a_symbol) 98# ASM-NEXT: addi a0, a0, %pcrel_lo(.Ltmp2) 99# ASM-LABEL: .Ltmp3{{>?}}: 100# ASM-NEXT: auipc a1, %pcrel_hi(local_symbol2) 101# ASM-NEXT: addi a1, a1, %pcrel_lo(.Ltmp3) 102 103# DISASM-LABEL: .Ltmp2{{>?}}: 104# DISASM-NEXT: auipc a0, 0 105# DISASM-NEXT: addi a0, a0, 0 106# DISASM-NORELAX-NEXT: auipc a1, 0 107# DISASM-NORELAX-NEXT: addi a1, a1, 8 108# DISASM-RELAX-LABEL: .Ltmp3{{>?}}: 109# DISASM-RELAX-NEXT: auipc a1, 0 110# DISASM-RELAX-NEXT: addi a1, a1, 0 111