196 lines · plain
1## Test invalid instructions on both loongarch32 and loongarch64 target.2 3# RUN: not llvm-mc --triple=loongarch32 %s 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK644# RUN: not llvm-mc --triple=loongarch64 %s 2>&1 --defsym=LA64=1 | FileCheck %s5 6## Out of range immediates7## uimm28bytepick.w $a0, $a0, $a0, -19# CHECK: :[[#@LINE-1]]:27: error: immediate must be an integer in the range [0, 3]10bytepick.w $a0, $a0, $a0, 411# CHECK: :[[#@LINE-1]]:27: error: immediate must be an integer in the range [0, 3]12 13## uimm2_plus114alsl.w $a0, $a0, $a0, 015# CHECK: :[[#@LINE-1]]:23: error: immediate must be an integer in the range [1, 4]16alsl.w $a0, $a0, $a0, 517# CHECK: :[[#@LINE-1]]:23: error: immediate must be an integer in the range [1, 4]18 19## uimm520slli.w $a0, $a0, -121# CHECK: :[[#@LINE-1]]:18: error: immediate must be an integer in the range [0, 31]22srli.w $a0, $a0, -123# CHECK: :[[#@LINE-1]]:18: error: immediate must be an integer in the range [0, 31]24srai.w $a0, $a0, 3225# CHECK: :[[#@LINE-1]]:18: error: immediate must be an integer in the range [0, 31]26rotri.w $a0, $a0, 3227# CHECK: :[[#@LINE-1]]:19: error: immediate must be an integer in the range [0, 31]28bstrins.w $a0, $a0, 31, -129# CHECK: :[[#@LINE-1]]:25: error: immediate must be an integer in the range [0, 31]30bstrpick.w $a0, $a0, 32, 031# CHECK: :[[#@LINE-1]]:22: error: immediate must be an integer in the range [0, 31]32preld -1, $a0, 033# CHECK: :[[#@LINE-1]]:7: error: immediate must be an integer in the range [0, 31]34preld 32, $a0, 035# CHECK: :[[#@LINE-1]]:7: error: immediate must be an integer in the range [0, 31]36 37## uimm1238andi $a0, $a0, -139# CHECK: :[[#@LINE-1]]:16: error: immediate must be an integer in the range [0, 4095]40xori $a0, $a0, 409641# CHECK: :[[#@LINE-1]]:16: error: immediate must be an integer in the range [0, 4095]42 43## uimm12_ori44ori $a0, $a0, 409645# CHECK: :[[#@LINE-1]]:15: error: operand must be a symbol with modifier (e.g. %abs_lo12) or an integer in the range [0, 4095]46 47## simm1248slti $a0, $a0, -204949# CHECK: :[[#@LINE-1]]:16: error: immediate must be an integer in the range [-2048, 2047]50sltui $a0, $a0, 204851# CHECK: :[[#@LINE-1]]:17: error: immediate must be an integer in the range [-2048, 2047]52preld 0, $a0, 204853# CHECK: :[[#@LINE-1]]:15: error: immediate must be an integer in the range [-2048, 2047]54 55## simm12_addlike56addi.w $a0, $a0, -204957# CHECK: :[[#@LINE-1]]:18: error: operand must be a symbol with modifier (e.g. %pc_lo12) or an integer in the range [-2048, 2047]58ld.b $a0, $a0, 204859# CHECK: :[[#@LINE-1]]:16: error: operand must be a symbol with modifier (e.g. %pc_lo12) or an integer in the range [-2048, 2047]60ld.h $a0, $a0, 204861# CHECK: :[[#@LINE-1]]:16: error: operand must be a symbol with modifier (e.g. %pc_lo12) or an integer in the range [-2048, 2047]62ld.w $a0, $a0, 204863# CHECK: :[[#@LINE-1]]:16: error: operand must be a symbol with modifier (e.g. %pc_lo12) or an integer in the range [-2048, 2047]64ld.bu $a0, $a0, -204965# CHECK: :[[#@LINE-1]]:17: error: operand must be a symbol with modifier (e.g. %pc_lo12) or an integer in the range [-2048, 2047]66ld.hu $a0, $a0, -204967# CHECK: :[[#@LINE-1]]:17: error: operand must be a symbol with modifier (e.g. %pc_lo12) or an integer in the range [-2048, 2047]68st.b $a0, $a0, 204869# CHECK: :[[#@LINE-1]]:16: error: operand must be a symbol with modifier (e.g. %pc_lo12) or an integer in the range [-2048, 2047]70st.h $a0, $a0, 204871# CHECK: :[[#@LINE-1]]:16: error: operand must be a symbol with modifier (e.g. %pc_lo12) or an integer in the range [-2048, 2047]72st.w $a0, $a0, -204973# CHECK: :[[#@LINE-1]]:16: error: operand must be a symbol with modifier (e.g. %pc_lo12) or an integer in the range [-2048, 2047]74 75## simm14_lsl276ll.w $a0, $a0, -3277277# CHECK: :[[#@LINE-1]]:16: error: immediate must be a multiple of 4 in the range [-32768, 32764]78ll.w $a0, $a0, -3276979# CHECK: :[[#@LINE-1]]:16: error: immediate must be a multiple of 4 in the range [-32768, 32764]80sc.w $a0, $a0, 3276781# CHECK: :[[#@LINE-1]]:16: error: immediate must be a multiple of 4 in the range [-32768, 32764]82sc.w $a0, $a0, 3276883# CHECK: :[[#@LINE-1]]:16: error: immediate must be a multiple of 4 in the range [-32768, 32764]84 85## simm16_lsl286beq $a0, $a0, -0x2000487# CHECK: :[[#@LINE-1]]:15: error: operand must be a symbol with modifier (e.g. %b16) or an integer in the range [-131072, 131068]88bne $a0, $a0, -0x2000489# CHECK: :[[#@LINE-1]]:15: error: operand must be a symbol with modifier (e.g. %b16) or an integer in the range [-131072, 131068]90blt $a0, $a0, -0x1FFFF91# CHECK: :[[#@LINE-1]]:15: error: operand must be a symbol with modifier (e.g. %b16) or an integer in the range [-131072, 131068]92bge $a0, $a0, -0x1FFFF93# CHECK: :[[#@LINE-1]]:15: error: operand must be a symbol with modifier (e.g. %b16) or an integer in the range [-131072, 131068]94bltu $a0, $a0, 0x1FFFF95# CHECK: :[[#@LINE-1]]:16: error: operand must be a symbol with modifier (e.g. %b16) or an integer in the range [-131072, 131068]96bgeu $a0, $a0, 0x1FFFF97# CHECK: :[[#@LINE-1]]:16: error: operand must be a symbol with modifier (e.g. %b16) or an integer in the range [-131072, 131068]98jirl $a0, $a0, 0x2000099# CHECK: :[[#@LINE-1]]:16: error: operand must be a symbol with modifier (e.g. %b16) or an integer in the range [-131072, 131068]100 101## simm20102pcaddu12i $a0, 0x80000103# CHECK: :[[#@LINE-1]]:16: error: immediate must be an integer in the range [-524288, 524287]104 105## simm20_pcaddi106pcaddi $a0, -0x80001107# CHECK: :[[#@LINE-1]]:13: error: operand must be a symbol with modifier (e.g. %pcrel_20) or an integer in the range [-524288, 524287]108 109## simm20_lu12iw110lu12i.w $a0, -0x80001111# CHECK: :[[#@LINE-1]]:14: error: operand must be a symbol with modifier (e.g. %abs_hi20) or an integer in the range [-524288, 524287]112 113## simm20_pcalau12i114pcalau12i $a0, 0x80000115# CHECK: :[[#@LINE-1]]:16: error: operand must be a symbol with modifier (e.g. %pc_hi20) or an integer in the range [-524288, 524287]116 117## simm21_lsl2118beqz $a0, -0x400001119# CHECK: :[[#@LINE-1]]:11: error: operand must be a symbol with modifier (e.g. %b21) or an integer in the range [-4194304, 4194300]120bnez $a0, -0x3FFFFF121# CHECK: :[[#@LINE-1]]:11: error: operand must be a symbol with modifier (e.g. %b21) or an integer in the range [-4194304, 4194300]122beqz $a0, 0x3FFFFF123# CHECK: :[[#@LINE-1]]:11: error: operand must be a symbol with modifier (e.g. %b21) or an integer in the range [-4194304, 4194300]124bnez $a0, 0x400000125# CHECK: :[[#@LINE-1]]:11: error: operand must be a symbol with modifier (e.g. %b21) or an integer in the range [-4194304, 4194300]126 127## simm26_lsl2128b -0x8000001129# CHECK: :[[#@LINE-1]]:3: error: operand must be a bare symbol name or an immediate must be a multiple of 4 in the range [-134217728, 134217724]130b 0x1131# CHECK: :[[#@LINE-1]]:3: error: operand must be a bare symbol name or an immediate must be a multiple of 4 in the range [-134217728, 134217724]132bl 0x7FFFFFF133# CHECK: :[[#@LINE-1]]:4: error: operand must be a bare symbol name or an immediate must be a multiple of 4 in the range [-134217728, 134217724]134bl 0x8000000135# CHECK: :[[#@LINE-1]]:4: error: operand must be a bare symbol name or an immediate must be a multiple of 4 in the range [-134217728, 134217724]136 137## Invalid mnemonics138nori $a0, $a0, 0139# CHECK: :[[#@LINE-1]]:1: error: unrecognized instruction mnemonic140andni $a0, $a0, 0141# CHECK: :[[#@LINE-1]]:1: error: unrecognized instruction mnemonic142orni $a0, $a0, 0143# CHECK: :[[#@LINE-1]]:1: error: unrecognized instruction mnemonic144 145## Invalid register names146add.w $foo, $a0, $a0147# CHECK: :[[#@LINE-1]]:8: error: invalid operand for instruction148sub.w $a8, $a0, $a0149# CHECK: :[[#@LINE-1]]:8: error: invalid operand for instruction150addi.w $x0, $a0, 0151# CHECK: :[[#@LINE-1]]:9: error: invalid operand for instruction152alsl.w $t9, $a0, $a0, 1153# CHECK: :[[#@LINE-1]]:9: error: invalid operand for instruction154lu12i.w $s10, 0155# CHECK: :[[#@LINE-1]]:10: error: invalid operand for instruction156 157.ifndef LA64158## LoongArch64 mnemonics159add.d $a0, $a0, $a0160# CHECK64: :[[#@LINE-1]]:1: error: instruction requires the following: LA64 Basic Integer and Privilege Instruction Set161addi.d $a0, $a0, 0162# CHECK64: :[[#@LINE-1]]:1: error: instruction requires the following: LA64 Basic Integer and Privilege Instruction Set163.endif164 165## Invalid operand types166slt $a0, $a0, 0167# CHECK: :[[#@LINE-1]]:15: error: invalid operand for instruction168slti $a0, 0, 0169# CHECK: :[[#@LINE-1]]:11: error: invalid operand for instruction170 171## Too many operands172andi $a0, $a0, 0, 0173# CHECK: :[[#@LINE-1]]:19: error: invalid operand for instruction174 175## Too few operands176and $a0, $a0177# CHECK: :[[#@LINE-1]]:1: error: too few operands for instruction178andi $a0, $a0179# CHECK: :[[#@LINE-1]]:1: error: too few operands for instruction180 181## Instructions outside the base integer ISA182## TODO: Test instructions in LSX/LASX/LBT/LVZ after their introduction.183 184## Using floating point registers when integer registers are expected185sll.w $a0, $a0, $fa0186# CHECK: :[[#@LINE-1]]:18: error: invalid operand for instruction187 188## msbw < lsbw189# CHECK: :[[#@LINE+1]]:21: error: msb is less than lsb190bstrins.w $a0, $a0, 1, 2191# CHECK: ^~~~192 193# CHECK: :[[#@LINE+1]]:22: error: msb is less than lsb194bstrpick.w $a0, $a0, 30, 31195# CHECK: ^~~~~~196