xref: /aosp_15_r20/external/llvm/test/MC/Mips/mips-alu-instructions.s (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker# RUN: llvm-mc %s -triple=mipsel-unknown-linux -show-encoding -mcpu=mips32r2 | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker# Check that the assembler can handle the documented syntax
3*9880d681SAndroid Build Coastguard Worker# for arithmetic and logical instructions.
4*9880d681SAndroid Build Coastguard Worker#------------------------------------------------------------------------------
5*9880d681SAndroid Build Coastguard Worker# Logical instructions
6*9880d681SAndroid Build Coastguard Worker#------------------------------------------------------------------------------
7*9880d681SAndroid Build Coastguard Worker# CHECK:  and    $9, $6, $7      # encoding: [0x24,0x48,0xc7,0x00]
8*9880d681SAndroid Build Coastguard Worker# CHECK:  andi   $9, $6, 17767   # encoding: [0x67,0x45,0xc9,0x30]
9*9880d681SAndroid Build Coastguard Worker# CHECK:  andi   $9, $6, 17767   # encoding: [0x67,0x45,0xc9,0x30]
10*9880d681SAndroid Build Coastguard Worker# CHECK:  andi   $9, $9, 17767   # encoding: [0x67,0x45,0x29,0x31]
11*9880d681SAndroid Build Coastguard Worker# CHECK:  clo    $6, $7          # encoding: [0x21,0x30,0xe6,0x70]
12*9880d681SAndroid Build Coastguard Worker# CHECK:  clz    $6, $7          # encoding: [0x20,0x30,0xe6,0x70]
13*9880d681SAndroid Build Coastguard Worker# CHECK:  ins    $19, $9, 6, 7   # encoding: [0x84,0x61,0x33,0x7d]
14*9880d681SAndroid Build Coastguard Worker# CHECK:  nor    $9, $6, $7      # encoding: [0x27,0x48,0xc7,0x00]
15*9880d681SAndroid Build Coastguard Worker# CHECK:  or     $3, $3, $5      # encoding: [0x25,0x18,0x65,0x00]
16*9880d681SAndroid Build Coastguard Worker# CHECK:  ori    $4, $5, 17767   # encoding: [0x67,0x45,0xa4,0x34]
17*9880d681SAndroid Build Coastguard Worker# CHECK:  ori    $9, $6, 17767   # encoding: [0x67,0x45,0xc9,0x34]
18*9880d681SAndroid Build Coastguard Worker# CHECK:  ori    $11, $11, 128   # encoding: [0x80,0x00,0x6b,0x35]
19*9880d681SAndroid Build Coastguard Worker# CHECK:  rotr   $9, $6, 7       # encoding: [0xc2,0x49,0x26,0x00]
20*9880d681SAndroid Build Coastguard Worker# CHECK:  rotrv  $9, $6, $7      # encoding: [0x46,0x48,0xe6,0x00]
21*9880d681SAndroid Build Coastguard Worker# CHECK:  sll    $4, $3, 7       # encoding: [0xc0,0x21,0x03,0x00]
22*9880d681SAndroid Build Coastguard Worker# CHECK:  sllv   $2, $3, $5      # encoding: [0x04,0x10,0xa3,0x00]
23*9880d681SAndroid Build Coastguard Worker# CHECK:  slt    $3, $3, $5      # encoding: [0x2a,0x18,0x65,0x00]
24*9880d681SAndroid Build Coastguard Worker# CHECK:  slti   $3, $3, 103     # encoding: [0x67,0x00,0x63,0x28]
25*9880d681SAndroid Build Coastguard Worker# CHECK:  slti   $3, $3, 103     # encoding: [0x67,0x00,0x63,0x28]
26*9880d681SAndroid Build Coastguard Worker# CHECK:  sltiu  $3, $3, 103     # encoding: [0x67,0x00,0x63,0x2c]
27*9880d681SAndroid Build Coastguard Worker# CHECK:  sltu   $3, $3, $5      # encoding: [0x2b,0x18,0x65,0x00]
28*9880d681SAndroid Build Coastguard Worker# CHECK:  sra    $4, $3, 7       # encoding: [0xc3,0x21,0x03,0x00]
29*9880d681SAndroid Build Coastguard Worker# CHECK:  srav   $2, $3, $5      # encoding: [0x07,0x10,0xa3,0x00]
30*9880d681SAndroid Build Coastguard Worker# CHECK:  srl    $4, $3, 7       # encoding: [0xc2,0x21,0x03,0x00]
31*9880d681SAndroid Build Coastguard Worker# CHECK:  srlv   $2, $3, $5      # encoding: [0x06,0x10,0xa3,0x00]
32*9880d681SAndroid Build Coastguard Worker# CHECK:  xor    $3, $3, $5      # encoding: [0x26,0x18,0x65,0x00]
33*9880d681SAndroid Build Coastguard Worker# CHECK:  xori   $9, $6, 17767   # encoding: [0x67,0x45,0xc9,0x38]
34*9880d681SAndroid Build Coastguard Worker# CHECK:  xori   $9, $6, 17767   # encoding: [0x67,0x45,0xc9,0x38]
35*9880d681SAndroid Build Coastguard Worker# CHECK:  xori   $11, $11, 12    # encoding: [0x0c,0x00,0x6b,0x39]
36*9880d681SAndroid Build Coastguard Worker# CHECK:  wsbh   $6, $7          # encoding: [0xa0,0x30,0x07,0x7c]
37*9880d681SAndroid Build Coastguard Worker# CHECK:  not    $7, $8          # encoding: [0x27,0x38,0x00,0x01]
38*9880d681SAndroid Build Coastguard Worker     and    $9,  $6, $7
39*9880d681SAndroid Build Coastguard Worker     and    $9,  $6, 17767
40*9880d681SAndroid Build Coastguard Worker     andi   $9,  $6, 17767
41*9880d681SAndroid Build Coastguard Worker     andi   $9,  17767
42*9880d681SAndroid Build Coastguard Worker     clo    $6,  $7
43*9880d681SAndroid Build Coastguard Worker     clz    $6,  $7
44*9880d681SAndroid Build Coastguard Worker     ins    $19, $9, 6,7
45*9880d681SAndroid Build Coastguard Worker     nor    $9,  $6, $7
46*9880d681SAndroid Build Coastguard Worker     or     $3,  $3, $5
47*9880d681SAndroid Build Coastguard Worker     or     $4,  $5, 17767
48*9880d681SAndroid Build Coastguard Worker     ori    $9,  $6, 17767
49*9880d681SAndroid Build Coastguard Worker     ori    $11, 128
50*9880d681SAndroid Build Coastguard Worker     rotr   $9,  $6, 7
51*9880d681SAndroid Build Coastguard Worker     rotrv  $9,  $6, $7
52*9880d681SAndroid Build Coastguard Worker     sll    $4,  $3, 7
53*9880d681SAndroid Build Coastguard Worker     sllv   $2,  $3, $5
54*9880d681SAndroid Build Coastguard Worker     slt    $3,  $3, $5
55*9880d681SAndroid Build Coastguard Worker     slt    $3,  $3, 103
56*9880d681SAndroid Build Coastguard Worker     slti   $3,  $3, 103
57*9880d681SAndroid Build Coastguard Worker     sltiu  $3,  $3, 103
58*9880d681SAndroid Build Coastguard Worker     sltu   $3,  $3, $5
59*9880d681SAndroid Build Coastguard Worker     sra    $4,  $3, 7
60*9880d681SAndroid Build Coastguard Worker     srav   $2,  $3, $5
61*9880d681SAndroid Build Coastguard Worker     srl    $4,  $3, 7
62*9880d681SAndroid Build Coastguard Worker     srlv   $2,  $3, $5
63*9880d681SAndroid Build Coastguard Worker     xor    $3,  $3, $5
64*9880d681SAndroid Build Coastguard Worker     xor    $9,  $6, 17767
65*9880d681SAndroid Build Coastguard Worker     xori   $9,  $6, 17767
66*9880d681SAndroid Build Coastguard Worker     xori   $11, 12
67*9880d681SAndroid Build Coastguard Worker     wsbh   $6,  $7
68*9880d681SAndroid Build Coastguard Worker     not    $7  ,$8
69*9880d681SAndroid Build Coastguard Worker
70*9880d681SAndroid Build Coastguard Worker#------------------------------------------------------------------------------
71*9880d681SAndroid Build Coastguard Worker# Arithmetic instructions
72*9880d681SAndroid Build Coastguard Worker#------------------------------------------------------------------------------
73*9880d681SAndroid Build Coastguard Worker
74*9880d681SAndroid Build Coastguard Worker# CHECK:  add    $9, $6, $7      # encoding: [0x20,0x48,0xc7,0x00]
75*9880d681SAndroid Build Coastguard Worker# CHECK:  addi   $9, $6, 17767   # encoding: [0x67,0x45,0xc9,0x20]
76*9880d681SAndroid Build Coastguard Worker# CHECK:  addiu  $9, $6, -15001  # encoding: [0x67,0xc5,0xc9,0x24]
77*9880d681SAndroid Build Coastguard Worker# CHECK:  addi   $9, $6, 17767   # encoding: [0x67,0x45,0xc9,0x20]
78*9880d681SAndroid Build Coastguard Worker# CHECK:  addi   $9, $9, 17767   # encoding: [0x67,0x45,0x29,0x21]
79*9880d681SAndroid Build Coastguard Worker# CHECK:  addiu  $9, $6, -15001  # encoding: [0x67,0xc5,0xc9,0x24]
80*9880d681SAndroid Build Coastguard Worker# CHECK:  addiu  $11, $11, 40    # encoding: [0x28,0x00,0x6b,0x25]
81*9880d681SAndroid Build Coastguard Worker# CHECK:  addu   $9, $6, $7      # encoding: [0x21,0x48,0xc7,0x00]
82*9880d681SAndroid Build Coastguard Worker# CHECK:  madd   $6, $7          # encoding: [0x00,0x00,0xc7,0x70]
83*9880d681SAndroid Build Coastguard Worker# CHECK:  maddu  $6, $7          # encoding: [0x01,0x00,0xc7,0x70]
84*9880d681SAndroid Build Coastguard Worker# CHECK:  msub   $6, $7          # encoding: [0x04,0x00,0xc7,0x70]
85*9880d681SAndroid Build Coastguard Worker# CHECK:  msubu  $6, $7          # encoding: [0x05,0x00,0xc7,0x70]
86*9880d681SAndroid Build Coastguard Worker# CHECK:  mult   $3, $5          # encoding: [0x18,0x00,0x65,0x00]
87*9880d681SAndroid Build Coastguard Worker# CHECK:  multu  $3, $5          # encoding: [0x19,0x00,0x65,0x00]
88*9880d681SAndroid Build Coastguard Worker# CHECK:  sub    $9, $6, $7      # encoding: [0x22,0x48,0xc7,0x00]
89*9880d681SAndroid Build Coastguard Worker# CHECK:  addi   $sp, $sp, -56   # encoding: [0xc8,0xff,0xbd,0x23]
90*9880d681SAndroid Build Coastguard Worker# CHECK:  subu   $4, $3, $5      # encoding: [0x23,0x20,0x65,0x00]
91*9880d681SAndroid Build Coastguard Worker# CHECK:  addiu   $sp, $sp, -40  # encoding: [0xd8,0xff,0xbd,0x27]
92*9880d681SAndroid Build Coastguard Worker# CHECK:  neg     $6, $7         # encoding: [0x22,0x30,0x07,0x00]
93*9880d681SAndroid Build Coastguard Worker# CHECK:  negu    $6, $7         # encoding: [0x23,0x30,0x07,0x00]
94*9880d681SAndroid Build Coastguard Worker# CHECK:  move    $7, $8         # encoding: [0x25,0x38,0x00,0x01]
95*9880d681SAndroid Build Coastguard Worker# CHECK:  .set    push
96*9880d681SAndroid Build Coastguard Worker# CHECK:  .set    mips32r2
97*9880d681SAndroid Build Coastguard Worker# CHECK:  rdhwr   $5, $29
98*9880d681SAndroid Build Coastguard Worker# CHECK:  .set    pop            # encoding: [0x3b,0xe8,0x05,0x7c]
99*9880d681SAndroid Build Coastguard Worker    add    $9,$6,$7
100*9880d681SAndroid Build Coastguard Worker    add    $9,$6,17767
101*9880d681SAndroid Build Coastguard Worker    addu   $9,$6,-15001
102*9880d681SAndroid Build Coastguard Worker    addi   $9,$6,17767
103*9880d681SAndroid Build Coastguard Worker    addi   $9,17767
104*9880d681SAndroid Build Coastguard Worker    addiu  $9,$6,-15001
105*9880d681SAndroid Build Coastguard Worker    addiu  $11,40
106*9880d681SAndroid Build Coastguard Worker    addu   $9,$6,$7
107*9880d681SAndroid Build Coastguard Worker    madd   $6,$7
108*9880d681SAndroid Build Coastguard Worker    maddu  $6,$7
109*9880d681SAndroid Build Coastguard Worker    msub   $6,$7
110*9880d681SAndroid Build Coastguard Worker    msubu  $6,$7
111*9880d681SAndroid Build Coastguard Worker    mult   $3,$5
112*9880d681SAndroid Build Coastguard Worker    multu  $3,$5
113*9880d681SAndroid Build Coastguard Worker    sub    $9,$6,$7
114*9880d681SAndroid Build Coastguard Worker    sub    $sp,$sp,56
115*9880d681SAndroid Build Coastguard Worker    subu   $4,$3,$5
116*9880d681SAndroid Build Coastguard Worker    subu    $sp,$sp,40
117*9880d681SAndroid Build Coastguard Worker    neg    $6,$7
118*9880d681SAndroid Build Coastguard Worker    negu   $6,$7
119*9880d681SAndroid Build Coastguard Worker    move   $7,$8
120*9880d681SAndroid Build Coastguard Worker    rdhwr   $5, $29
121*9880d681SAndroid Build Coastguard Worker
122*9880d681SAndroid Build Coastguard Worker#------------------------------------------------------------------------------
123*9880d681SAndroid Build Coastguard Worker# Shortcuts for arithmetic instructions
124*9880d681SAndroid Build Coastguard Worker#------------------------------------------------------------------------------
125*9880d681SAndroid Build Coastguard Worker
126*9880d681SAndroid Build Coastguard Worker# CHECK:	add	$9, $9, $3	# encoding: [0x20,0x48,0x23,0x01]
127*9880d681SAndroid Build Coastguard Worker# CHECK:	addu	$9, $9, $3	# encoding: [0x21,0x48,0x23,0x01]
128*9880d681SAndroid Build Coastguard Worker# CHECK:	addi	$9, $9, 10	# encoding: [0x0a,0x00,0x29,0x21]
129*9880d681SAndroid Build Coastguard Worker# CHECK:	addiu	$9, $9, 10	# encoding: [0x0a,0x00,0x29,0x25]
130*9880d681SAndroid Build Coastguard Worker# CHECK:	and	$5, $5, $6	# encoding: [0x24,0x28,0xa6,0x00]
131*9880d681SAndroid Build Coastguard Worker# CHECK:	mul	$9, $9, $3	# encoding: [0x02,0x48,0x23,0x71]
132*9880d681SAndroid Build Coastguard Worker# CHECK:	or	$2, $2, $4	# encoding: [0x25,0x10,0x44,0x00]
133*9880d681SAndroid Build Coastguard Worker# CHECK:	sub	$9, $9, $3	# encoding: [0x22,0x48,0x23,0x01]
134*9880d681SAndroid Build Coastguard Worker# CHECK:	subu	$9, $9, $3	# encoding: [0x23,0x48,0x23,0x01]
135*9880d681SAndroid Build Coastguard Worker# CHECK:	addi	$9, $9, -10	# encoding: [0xf6,0xff,0x29,0x21]
136*9880d681SAndroid Build Coastguard Worker# CHECK:	addiu	$9, $9, -10	# encoding: [0xf6,0xff,0x29,0x25]
137*9880d681SAndroid Build Coastguard Worker# CHECK:	xor	$9, $9, $10	# encoding: [0x26,0x48,0x2a,0x01]
138*9880d681SAndroid Build Coastguard Worker	add	$9, $3
139*9880d681SAndroid Build Coastguard Worker	addu	$9, $3
140*9880d681SAndroid Build Coastguard Worker	add	$9, 10
141*9880d681SAndroid Build Coastguard Worker	addu	$9, 10
142*9880d681SAndroid Build Coastguard Worker	and	$5, $6
143*9880d681SAndroid Build Coastguard Worker	mul	$9, $3
144*9880d681SAndroid Build Coastguard Worker	or	$2, $4
145*9880d681SAndroid Build Coastguard Worker	sub	$9, $3
146*9880d681SAndroid Build Coastguard Worker	subu	$9, $3
147*9880d681SAndroid Build Coastguard Worker	sub	$9, 10
148*9880d681SAndroid Build Coastguard Worker	subu	$9, 10
149*9880d681SAndroid Build Coastguard Worker	xor	$9, $10
150