1# RUN: llvm-mc -triple riscv32 -mattr=+c -show-encoding < %s \ 2# RUN: | FileCheck -check-prefixes=CHECK,CHECK-ALIAS %s 3# RUN: llvm-mc -triple riscv32 -mattr=+c -show-encoding \ 4# RUN: -riscv-no-aliases <%s | FileCheck -check-prefixes=CHECK,CHECK-INST %s 5# RUN: llvm-mc -triple riscv32 -mattr=+c -filetype=obj < %s \ 6# RUN: | llvm-objdump -triple riscv32 -mattr=+c -d - \ 7# RUN: | FileCheck -check-prefixes=CHECK-BYTES,CHECK-ALIAS %s 8# RUN: llvm-mc -triple riscv32 -mattr=+c -filetype=obj < %s \ 9# RUN: | llvm-objdump -triple riscv32 -mattr=+c -d -riscv-no-aliases - \ 10# RUN: | FileCheck -check-prefixes=CHECK-BYTES,CHECK-INST %s 11 12# RUN: llvm-mc -triple riscv64 -mattr=+c -show-encoding < %s \ 13# RUN: | FileCheck -check-prefixes=CHECK-ALIAS %s 14# RUN: llvm-mc -triple riscv64 -mattr=+c -show-encoding \ 15# RUN: -riscv-no-aliases <%s | FileCheck -check-prefixes=CHECK-INST %s 16# RUN: llvm-mc -triple riscv64 -mattr=+c -filetype=obj < %s \ 17# RUN: | llvm-objdump -triple riscv64 -mattr=+c -d - \ 18# RUN: | FileCheck -check-prefixes=CHECK-BYTES,CHECK-ALIAS %s 19# RUN: llvm-mc -triple riscv64 -mattr=+c -filetype=obj < %s \ 20# RUN: | llvm-objdump -triple riscv64 -mattr=+c -d -riscv-no-aliases - \ 21# RUN: | FileCheck -check-prefixes=CHECK-BYTES,CHECK-INST %s 22 23# CHECK-BYTES: 2e 85 24# CHECK-ALIAS: add a0, zero, a1 25# CHECK-INST: c.mv a0, a1 26# CHECK: # encoding: [0x2e,0x85] 27addi a0, a1, 0 28 29# CHECK-BYTES: e0 1f 30# CHECK-ALIAS: addi s0, sp, 1020 31# CHECK-INST: c.addi4spn s0, sp, 1020 32# CHECK: # encoding: [0xe0,0x1f] 33addi s0, sp, 1020 34 35# CHECK-BYTES: e0 5f 36# CHECK-ALIAS: lw s0, 124(a5) 37# CHECK-INST: c.lw s0, 124(a5) 38# CHECK: # encoding: [0xe0,0x5f] 39lw s0, 124(a5) 40 41# CHECK-BYTES: e0 df 42# CHECK-ALIAS: sw s0, 124(a5) 43# CHECK-INST: c.sw s0, 124(a5) 44# CHECK: # encoding: [0xe0,0xdf] 45sw s0, 124(a5) 46 47# CHECK-BYTES: 01 00 48# CHECK-ALIAS: nop 49# CHECK-INST: c.nop 50# CHECK: # encoding: [0x01,0x00] 51nop 52 53# CHECK-BYTES: 81 10 54# CHECK-ALIAS: addi ra, ra, -32 55# CHECK-INST: c.addi ra, -32 56# CHECK: # encoding: [0x81,0x10] 57addi ra, ra, -32 58 59# CHECK-BYTES: 85 50 60# CHECK-ALIAS: addi ra, zero, -31 61# CHECK-INST: c.li ra, -31 62# CHECK: # encoding: [0x85,0x50] 63addi ra, zero, -31 64 65# CHECK-BYTES: 39 71 66# CHECK-ALIAS: addi sp, sp, -64 67# CHECK-INST: c.addi16sp sp, -64 68# CHECK: # encoding: [0x39,0x71] 69addi sp, sp, -64 70 71# CHECK-BYTES: fd 61 72# CHECK-ALIAS: lui gp, 31 73# CHECK-INST: c.lui gp, 31 74# CHECK: # encoding: [0xfd,0x61] 75lui gp, 31 76 77# CHECK-BYTES: 7d 80 78# CHECK-ALIAS: srli s0, s0, 31 79# CHECK-INST: c.srli s0, 31 80# CHECK: # encoding: [0x7d,0x80] 81srli s0, s0, 31 82 83# CHECK-BYTES: 7d 84 84# CHECK-ALIAS: srai s0, s0, 31 85# CHECK-INST: c.srai s0, 31 86# CHECK: # encoding: [0x7d,0x84] 87srai s0, s0, 31 88 89# CHECK-BYTES: 7d 88 90# CHECK-ALIAS: andi s0, s0, 31 91# CHECK-INST: c.andi s0, 31 92# CHECK: # encoding: [0x7d,0x88] 93andi s0, s0, 31 94 95# CHECK-BYTES: 1d 8c 96# CHECK-ALIAS: sub s0, s0, a5 97# CHECK-INST: c.sub s0, a5 98# CHECK: # encoding: [0x1d,0x8c] 99sub s0, s0, a5 100 101# CHECK-BYTES: 3d 8c 102# CHECK-ALIAS: xor s0, s0, a5 103# CHECK-INST: c.xor s0, a5 104# CHECK: # encoding: [0x3d,0x8c] 105xor s0, s0, a5 106 107# CHECK-BYTES: 3d 8c 108# CHECK-ALIAS: xor s0, s0, a5 109# CHECK-INST: c.xor s0, a5 110# CHECK: # encoding: [0x3d,0x8c] 111xor s0, a5, s0 112 113# CHECK-BYTES: 5d 8c 114# CHECK-ALIAS: or s0, s0, a5 115# CHECK-INST: c.or s0, a5 116# CHECK: # encoding: [0x5d,0x8c] 117or s0, s0, a5 118 119# CHECK-BYTES: 45 8c 120# CHECK-ALIAS: or s0, s0, s1 121# CHECK-INST: c.or s0, s1 122# CHECK: # encoding: [0x45,0x8c] 123or s0, s1, s0 124 125# CHECK-BYTES: 7d 8c 126# CHECK-ALIAS: and s0, s0, a5 127# CHECK-INST: c.and s0, a5 128# CHECK: # encoding: [0x7d,0x8c] 129and s0, s0, a5 130 131# CHECK-BYTES: 7d 8c 132# CHECK-ALIAS: and s0, s0, a5 133# CHECK-INST: c.and s0, a5 134# CHECK: # encoding: [0x7d,0x8c] 135and s0, a5, s0 136 137# CHECK-BYTES: 01 b0 138# CHECK-ALIAS: j -2048 139# CHECK-INST: c.j -2048 140# CHECK: # encoding: [0x01,0xb0] 141jal zero, -2048 142 143# CHECK-BYTES: 01 d0 144# CHECK-ALIAS: beqz s0, -256 145# CHECK-INST: c.beqz s0, -256 146# CHECK: # encoding: [0x01,0xd0] 147beq s0, zero, -256 148 149# CHECK-BYTES: 7d ec 150# CHECk-ALIAS: bnez s0, 254 151# CHECK-INST: c.bnez s0, 254 152# CHECK: # encoding: [0x7d,0xec] 153bne s0, zero, 254 154 155# CHECK-BYTES: 7e 04 156# CHECK-ALIAS: slli s0, s0, 31 157# CHECK-INST: c.slli s0, 31 158# CHECK: # encoding: [0x7e,0x04] 159slli s0, s0, 31 160 161# CHECK-BYTES: fe 50 162# CHECK-ALIAS: lw ra, 252(sp) 163# CHECK-INST: c.lwsp ra, 252(sp) 164# CHECK: # encoding: [0xfe,0x50] 165lw ra, 252(sp) 166 167# CHECK-BYTES: 82 80 168# CHECK-ALIAS: ret 169# CHECK-INST: c.jr ra 170# CHECK: # encoding: [0x82,0x80] 171jalr zero, ra, 0 172 173# CHECK-BYTES: 92 80 174# CHECK-ALIAS: add ra, zero, tp 175# CHECK-INST: c.mv ra, tp 176# CHECK: # encoding: [0x92,0x80] 177add ra, zero, tp 178 179# CHECK-BYTES: 92 80 180# CHECK-ALIAS: add ra, zero, tp 181# CHECK-INST: c.mv ra, tp 182# CHECK: # encoding: [0x92,0x80] 183add ra, tp, zero 184 185# CHECK-BYTES: 02 90 186# CHECK-ALIAS: ebreak 187# CHECK-INST: c.ebreak 188# CHECK: # encoding: [0x02,0x90] 189ebreak 190 191# CHECK-BYTES: 02 94 192# CHECK-ALIAS: jalr s0 193# CHECK-INST: c.jalr s0 194# CHECK: # encoding: [0x02,0x94] 195jalr ra, s0, 0 196 197# CHECK-BYTES: 3e 94 198# CHECK-ALIAS: add s0, s0, a5 199# CHECK-INST: c.add s0, a5 200# CHECK: # encoding: [0x3e,0x94] 201add s0, a5, s0 202 203# CHECK-BYTES: 3e 94 204# CHECK-ALIAS: add s0, s0, a5 205# CHECK-INST: c.add s0, a5 206# CHECK: # encoding: [0x3e,0x94] 207add s0, s0, a5 208 209# CHECK-BYTES: 82 df 210# CHECK-ALIAS: sw zero, 252(sp) 211# CHECK-INST: c.swsp zero, 252(sp) 212# CHECK: # encoding: [0x82,0xdf] 213sw zero, 252(sp) 214