1# RUN: llvm-mc %s -triple=riscv64 -mattr=+c -riscv-no-aliases -show-encoding \ 2# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s 3# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+c < %s \ 4# RUN: | llvm-objdump --mattr=+c -M no-aliases -d -r - \ 5# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s 6# 7# 8# RUN: not llvm-mc -triple riscv64 \ 9# RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \ 10# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s 11# RUN: not llvm-mc -triple riscv32 -mattr=+c \ 12# RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \ 13# RUN: | FileCheck -check-prefixes=CHECK-NO-RV64 %s 14 15# TODO: more exhaustive testing of immediate encoding. 16 17# CHECK-ASM-AND-OBJ: c.ldsp ra, 0(sp) 18# CHECK-ASM: encoding: [0x82,0x60] 19# CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions) 20# CHECK-NO-RV64: error: instruction requires the following: RV64I Base Instruction Set 21c.ldsp ra, 0(sp) 22# CHECK-ASM-AND-OBJ: c.sdsp ra, 504(sp) 23# CHECK-ASM: encoding: [0x86,0xff] 24# CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions) 25# CHECK-NO-RV64: error: instruction requires the following: RV64I Base Instruction Set 26c.sdsp ra, 504(sp) 27# CHECK-ASM-AND-OBJ: c.ld a4, 0(a3) 28# CHECK-ASM: encoding: [0x98,0x62] 29# CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions) 30# CHECK-NO-RV64: error: instruction requires the following: RV64I Base Instruction Set 31c.ld a4, 0(a3) 32# CHECK-ASM-AND-OBJ: c.sd a5, 248(a3) 33# CHECK-ASM: encoding: [0xfc,0xfe] 34# CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions) 35# CHECK-NO-RV64: error: instruction requires the following: RV64I Base Instruction Set 36c.sd a5, 248(a3) 37 38# CHECK-ASM-AND-OBJ: c.subw a3, a4 39# CHECK-ASM: encoding: [0x99,0x9e] 40c.subw a3, a4 41# CHECK-ASM-AND-OBJ: c.addw a0, a2 42# CHECK-ASM: encoding: [0x31,0x9d] 43# CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions) 44# CHECK-NO-RV64: error: instruction requires the following: RV64I Base Instruction Set 45c.addw a0, a2 46 47# CHECK-ASM-AND-OBJ: c.addiw a3, -32 48# CHECK-ASM: encoding: [0x81,0x36] 49# CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions) 50# CHECK-NO-RV64: error: instruction requires the following: RV64I Base Instruction Set 51c.addiw a3, -32 52# CHECK-ASM-AND-OBJ: c.addiw a3, 31 53# CHECK-ASM: encoding: [0xfd,0x26] 54# CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions) 55# CHECK-NO-RV64: error: instruction requires the following: RV64I Base Instruction Set 56c.addiw a3, 31 57 58# CHECK-ASM-AND-OBJ: c.slli s0, 1 59# CHECK-ASM: encoding: [0x06,0x04] 60# CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions) 61# CHECK-NO-RV64: error: instruction requires the following: RV64I Base Instruction Set 62c.slli s0, 1 63# CHECK-ASM-AND-OBJ: c.srli a3, 63 64# CHECK-ASM: encoding: [0xfd,0x92] 65c.srli a3, 63 66# CHECK-ASM-AND-OBJ: c.srai a2, 63 67# CHECK-ASM: encoding: [0x7d,0x96] 68c.srai a2, 63 69