1# RUN: llvm-mc %s -triple=riscv64 -riscv-no-aliases \ 2# RUN: | FileCheck -check-prefixes=CHECK-EXPAND,CHECK-INST %s 3# RUN: llvm-mc %s -triple=riscv64 \ 4# RUN: | FileCheck -check-prefixes=CHECK-EXPAND,CHECK-ALIAS %s 5# RUN: llvm-mc -filetype=obj -triple riscv64 < %s \ 6# RUN: | llvm-objdump -M no-aliases -d - \ 7# RUN: | FileCheck -check-prefixes=CHECK-OBJ-NOALIAS,CHECK-EXPAND,CHECK-INST %s 8# RUN: llvm-mc -filetype=obj -triple riscv64 < %s \ 9# RUN: | llvm-objdump -d - \ 10# RUN: | FileCheck -check-prefixes=CHECK-EXPAND,CHECK-ALIAS %s 11 12# The following check prefixes are used in this test: 13# CHECK-INST.....Match the canonical instr (tests alias to instr. mapping) 14# CHECK-ALIAS....Match the alias (tests instr. to alias mapping) 15# CHECK-EXPAND...Match canonical instr. unconditionally (tests alias expansion) 16 17# TODO ld 18# TODO sd 19 20# Needed for testing valid %pcrel_lo expressions 21.Lpcrel_hi0: auipc a0, %pcrel_hi(foo) 22 23# CHECK-INST: addi a0, zero, 0 24# CHECK-ALIAS: mv a0, zero 25li x10, 0 26# CHECK-EXPAND: addi a0, zero, 1 27li x10, 1 28# CHECK-EXPAND: addi a0, zero, -1 29li x10, -1 30# CHECK-EXPAND: addi a0, zero, 2047 31li x10, 2047 32# CHECK-EXPAND: addi a0, zero, -2047 33li x10, -2047 34# CHECK-EXPAND: lui a1, 1 35# CHECK-EXPAND: addiw a1, a1, -2048 36li x11, 2048 37# CHECK-EXPAND: addi a1, zero, -2048 38li x11, -2048 39# CHECK-EXPAND: lui a1, 1 40# CHECK-EXPAND: addiw a1, a1, -2047 41li x11, 2049 42# CHECK-EXPAND: lui a1, 1048575 43# CHECK-EXPAND: addiw a1, a1, 2047 44li x11, -2049 45# CHECK-EXPAND: lui a1, 1 46# CHECK-EXPAND: addiw a1, a1, -1 47li x11, 4095 48# CHECK-EXPAND: lui a1, 1048575 49# CHECK-EXPAND: addiw a1, a1, 1 50li x11, -4095 51# CHECK-EXPAND: lui a2, 1 52li x12, 4096 53# CHECK-EXPAND: lui a2, 1048575 54li x12, -4096 55# CHECK-EXPAND: lui a2, 1 56# CHECK-EXPAND: addiw a2, a2, 1 57li x12, 4097 58# CHECK-EXPAND: lui a2, 1048575 59# CHECK-EXPAND: addiw a2, a2, -1 60li x12, -4097 61# CHECK-EXPAND: lui a2, 524288 62# CHECK-EXPAND: addiw a2, a2, -1 63li x12, 2147483647 64# CHECK-EXPAND: lui a2, 524288 65# CHECK-EXPAND: addiw a2, a2, 1 66li x12, -2147483647 67# CHECK-EXPAND: lui a2, 524288 68li x12, -2147483648 69# CHECK-EXPAND: lui a2, 524288 70li x12, -0x80000000 71 72# CHECK-EXPAND: addi a2, zero, 1 73# CHECK-EXPAND: slli a2, a2, 31 74li x12, 0x80000000 75# CHECK-EXPAND: addi a2, zero, 1 76# CHECK-EXPAND: slli a2, a2, 32 77# CHECK-EXPAND: addi a2, a2, -1 78li x12, 0xFFFFFFFF 79 80# CHECK-EXPAND: addi t0, zero, 1 81# CHECK-EXPAND: slli t0, t0, 32 82li t0, 0x100000000 83# CHECK-EXPAND: addi t1, zero, -1 84# CHECK-EXPAND: slli t1, t1, 63 85li t1, 0x8000000000000000 86# CHECK-EXPAND: addi t1, zero, -1 87# CHECK-EXPAND: slli t1, t1, 63 88li t1, -0x8000000000000000 89# CHECK-EXPAND: lui t2, 9321 90# CHECK-EXPAND: addiw t2, t2, -1329 91# CHECK-EXPAND: slli t2, t2, 35 92li t2, 0x1234567800000000 93# CHECK-EXPAND: addi t3, zero, 7 94# CHECK-EXPAND: slli t3, t3, 36 95# CHECK-EXPAND: addi t3, t3, 11 96# CHECK-EXPAND: slli t3, t3, 24 97# CHECK-EXPAND: addi t3, t3, 15 98li t3, 0x700000000B00000F 99# CHECK-EXPAND: lui t4, 583 100# CHECK-EXPAND: addiw t4, t4, -1875 101# CHECK-EXPAND: slli t4, t4, 14 102# CHECK-EXPAND: addi t4, t4, -947 103# CHECK-EXPAND: slli t4, t4, 12 104# CHECK-EXPAND: addi t4, t4, 1511 105# CHECK-EXPAND: slli t4, t4, 13 106# CHECK-EXPAND: addi t4, t4, -272 107li t4, 0x123456789abcdef0 108# CHECK-EXPAND: addi t5, zero, -1 109li t5, 0xFFFFFFFFFFFFFFFF 110# CHECK-EXPAND: lui t6, 64 111# CHECK-EXPAND: addiw t6, t6, 1 112# CHECK-EXPAND: slli t6, t6, 13 113li t6, 0x80002000 114# CHECK-EXPAND: lui t0, 64 115# CHECK-EXPAND: addiw t0, t0, 1 116# CHECK-EXPAND: slli t0, t0, 14 117li x5, 0x100004000 118# CHECK-EXPAND: lui t1, 1 119# CHECK-EXPAND: addiw t1, t1, 1 120# CHECK-EXPAND: slli t1, t1, 32 121li x6, 0x100100000000 122# CHECK-EXPAND: addi t2, zero, 1 123# CHECK-EXPAND: slli t2, t2, 36 124# CHECK-EXPAND: addi t2, t2, -1 125# CHECK-EXPAND: slli t2, t2, 12 126# CHECK-EXPAND: addi t2, t2, 1 127li x7, 0xFFFFFFFFF001 128# CHECK-EXPAND: lui s0, 65536 129# CHECK-EXPAND: addiw s0, s0, -1 130# CHECK-EXPAND: slli s0, s0, 12 131# CHECK-EXPAND: addi s0, s0, 1 132li x8, 0xFFFFFFF001 133# CHECK-EXPAND: lui s1, 1 134# CHECK-EXPAND: addiw s1, s1, 1 135# CHECK-EXPAND: slli s1, s1, 32 136# CHECK-EXPAND: addi s1, s1, -3 137li x9, 0x1000FFFFFFFD 138# CHECK-EXPAND: addi a0, zero, -1 139# CHECK-EXPAND: slli a0, a0, 36 140# CHECK-EXPAND: addi a0, a0, 1 141# CHECK-EXPAND: slli a0, a0, 25 142# CHECK-EXPAND: addi a0, a0, -1 143li x10, 0xE000000001FFFFFF 144# CHECK-EXPAND: addi a1, zero, -2047 145# CHECK-EXPAND: slli a1, a1, 27 146# CHECK-EXPAND: addi a1, a1, -1 147# CHECK-EXPAND: slli a1, a1, 12 148# CHECK-EXPAND: addi a1, a1, 2047 149li x11, 0xFFFC007FFFFFF7FF 150 151# CHECK-EXPAND: addi a0, zero, 1110 152li a0, %lo(0x123456) 153 154# CHECK-OBJ-NOALIAS: addi a0, zero, 0 155# CHECK-OBJ: R_RISCV_LO12 156li a0, %lo(foo) 157# CHECK-OBJ-NOALIAS: addi a0, zero, 0 158# CHECK-OBJ: R_RISCV_PCREL_LO12 159li a0, %pcrel_lo(.Lpcrel_hi0) 160 161.equ CONST, 0x123456 162# CHECK-EXPAND: lui a0, 291 163# CHECK-EXPAND: addiw a0, a0, 1110 164li a0, CONST 165 166.equ CONST, 0x654321 167# CHECK-EXPAND: lui a0, 1620 168# CHECK-EXPAND: addiw a0, a0, 801 169li a0, CONST 170 171# CHECK-INST: subw t6, zero, ra 172# CHECK-ALIAS: negw t6, ra 173negw x31, x1 174# CHECK-INST: addiw t6, ra, 0 175# CHECK-ALIAS: sext.w t6, ra 176sext.w x31, x1 177 178# The following aliases are accepted as input but the canonical form 179# of the instruction will always be printed. 180# CHECK-INST: addiw a2, a3, 4 181# CHECK-ALIAS: addiw a2, a3, 4 182addw a2,a3,4 183 184# CHECK-INST: slliw a2, a3, 4 185# CHECK-ALIAS: slliw a2, a3, 4 186sllw a2,a3,4 187 188# CHECK-INST: srliw a2, a3, 4 189# CHECK-ALIAS: srliw a2, a3, 4 190srlw a2,a3,4 191 192# CHECK-INST: sraiw a2, a3, 4 193# CHECK-ALIAS: sraiw a2, a3, 4 194sraw a2,a3,4 195 196# CHECK-EXPAND: lwu a0, 0(a1) 197lwu x10, (x11) 198# CHECK-EXPAND: ld a0, 0(a1) 199ld x10, (x11) 200# CHECK-EXPAND: sd a0, 0(a1) 201sd x10, (x11) 202