Home | History | Annotate | Download | only in RISCV
      1 # RUN: llvm-mc -triple=riscv32 -mattr=+c -riscv-no-aliases -show-encoding < %s \
      2 # RUN:     | FileCheck -check-prefixes=CHECK,CHECK-INST %s
      3 # RUN: llvm-mc -triple=riscv64 -mattr=+c -riscv-no-aliases -show-encoding < %s \
      4 # RUN:     | FileCheck -check-prefixes=CHECK,CHECK-INST %s
      5 # RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+c < %s \
      6 # RUN:     | llvm-objdump -riscv-no-aliases -d - \
      7 # RUN:     | FileCheck -check-prefix=CHECK-INST %s
      8 # RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+c < %s \
      9 # RUN:     | llvm-objdump -riscv-no-aliases -d - \
     10 # RUN:     | FileCheck -check-prefix=CHECK-INST %s
     11 
     12 # TODO: more exhaustive testing of immediate encoding.
     13 
     14 # CHECK-INST: c.lwsp  ra, 0(sp)
     15 # CHECK: encoding: [0x82,0x40]
     16 c.lwsp  ra, 0(sp)
     17 # CHECK-INST: c.swsp  ra, 252(sp)
     18 # CHECK: encoding: [0x86,0xdf]
     19 c.swsp  ra, 252(sp)
     20 # CHECK-INST: c.lw    a2, 0(a0)
     21 # CHECK: encoding: [0x10,0x41]
     22 c.lw    a2, 0(a0)
     23 # CHECK-INST: c.sw    a5, 124(a3)
     24 # CHECK: encoding: [0xfc,0xde]
     25 c.sw    a5, 124(a3)
     26 
     27 # CHECK-INST: c.j     -2048
     28 # CHECK: encoding: [0x01,0xb0]
     29 c.j     -2048
     30 # CHECK-INST: c.jr    a7
     31 # CHECK: encoding: [0x82,0x88]
     32 c.jr    a7
     33 # CHECK-INST: c.jalr  a1
     34 # CHECK: encoding: [0x82,0x95]
     35 c.jalr  a1
     36 # CHECK-INST: c.beqz  a3, -256
     37 # CHECK: encoding: [0x81,0xd2]
     38 c.beqz  a3, -256
     39 # CHECK-INST: c.bnez  a5,  254
     40 # CHECK: encoding: [0xfd,0xef]
     41 c.bnez  a5,  254
     42 
     43 # CHECK-INST: c.li  a7, 31
     44 # CHECK: encoding: [0xfd,0x48]
     45 c.li    a7, 31
     46 # CHECK-INST: c.addi  a3, -32
     47 # CHECK: encoding: [0x81,0x16]
     48 c.addi  a3, -32
     49 # CHECK-INST: c.addi16sp  sp, -512
     50 # CHECK: encoding: [0x01,0x71]
     51 c.addi16sp  sp, -512
     52 # CHECK-INST: c.addi16sp  sp, 496
     53 # CHECK: encoding: [0x7d,0x61]
     54 c.addi16sp  sp, 496
     55 # CHECK-INST: c.addi4spn  a3, sp, 1020
     56 # CHECK: encoding: [0xf4,0x1f]
     57 c.addi4spn      a3, sp, 1020
     58 # CHECK-INST: c.addi4spn  a3, sp, 4
     59 # CHECK: encoding: [0x54,0x00]
     60 c.addi4spn      a3, sp, 4
     61 # CHECK-INST: c.slli  a1, 1
     62 # CHECK: encoding: [0x86,0x05]
     63 c.slli  a1, 1
     64 # CHECK-INST: c.srli  a3, 31
     65 # CHECK: encoding: [0xfd,0x82]
     66 c.srli  a3, 31
     67 # CHECK-INST: c.srai  a4, 2
     68 # CHECK: encoding: [0x09,0x87]
     69 c.srai  a4, 2
     70 # CHECK-INST: c.andi  a5, 15
     71 # CHECK: encoding: [0xbd,0x8b]
     72 c.andi  a5, 15
     73 # CHECK-INST: c.mv    a7, s0
     74 # CHECK: encoding: [0xa2,0x88]
     75 c.mv    a7, s0
     76 # CHECK-INST: c.and   a1, a2
     77 # CHECK: encoding: [0xf1,0x8d]
     78 c.and   a1, a2
     79 # CHECK-INST: c.or    a2, a3
     80 # CHECK: encoding: [0x55,0x8e]
     81 c.or    a2, a3
     82 # CHECK-INST: c.xor   a3, a4
     83 # CHECK: encoding: [0xb9,0x8e]
     84 c.xor   a3, a4
     85 # CHECK-INST: c.sub   a4, a5
     86 # CHECK: encoding: [0x1d,0x8f]
     87 c.sub   a4, a5
     88 # CHECK-INST: c.nop
     89 # CHECK: encoding: [0x01,0x00]
     90 c.nop
     91 # CHECK-INST: c.ebreak
     92 # CHECK: encoding: [0x02,0x90]
     93 c.ebreak
     94 # CHECK-INST: c.lui   s0, 1
     95 # CHECK: encoding: [0x05,0x64]
     96 c.lui   s0, 1
     97 # CHECK-INST: c.lui   s0, 31
     98 # CHECK: encoding: [0x7d,0x64]
     99 c.lui   s0, 31
    100 # CHECK-INST: c.lui   s0, 1048544
    101 # CHECK: encoding: [0x01,0x74]
    102 c.lui   s0, 0xfffe0
    103 # CHECK-INST: c.lui   s0, 1048575
    104 # CHECK: encoding: [0x7d,0x74]
    105 c.lui   s0, 0xfffff
    106