1# Instructions that are valid
2#
3# RUN: llvm-mc %s -triple=mips-unknown-linux -show-encoding -mcpu=mips32r2 | FileCheck %s
4a:
5        .set noat
6        abs.d     $f7,$f25             # CHECK: encoding:
7        abs.s     $f9,$f16
8        add       $s7,$s2,$a1
9        add       $9,$14,15176         # CHECK: addi $9, $14, 15176   # encoding: [0x21,0xc9,0x3b,0x48]
10        add       $24,-7193            # CHECK: addi $24, $24, -7193  # encoding: [0x23,0x18,0xe3,0xe7]
11        add.d     $f1,$f7,$f29
12        add.s     $f8,$f21,$f24
13        addi      $13,$9,26322
14        addi      $8,$8,~1             # CHECK: addi $8, $8, -2 # encoding: [0x21,0x08,0xff,0xfe]
15        addu      $9,$a0,$a2
16        addu      $9,10                # CHECK: addiu $9, $9, 10    # encoding: [0x25,0x29,0x00,0x0a]
17        and       $s7,$v0,$12
18        and       $2,4                 # CHECK: andi $2, $2, 4 # encoding: [0x30,0x42,0x00,0x04]
19        bc1f      $fcc0, 4             # CHECK: bc1f 4        # encoding: [0x45,0x00,0x00,0x01]
20        bc1f      $fcc1, 4             # CHECK: bc1f $fcc1, 4 # encoding: [0x45,0x04,0x00,0x01]
21        bc1f      4                    # CHECK: bc1f 4        # encoding: [0x45,0x00,0x00,0x01]
22        bc1fl     $fcc0,4688           # CHECK: bc1fl 4688      # encoding: [0x45,0x02,0x04,0x94]
23        bc1fl     4688                 # CHECK: bc1fl 4688      # encoding: [0x45,0x02,0x04,0x94]
24        bc1fl     $fcc7,27             # CHECK: bc1fl $fcc7, 27 # encoding: [0x45,0x1e,0x00,0x06]
25        bc1t      $fcc0, 4             # CHECK: bc1t 4        # encoding: [0x45,0x01,0x00,0x01]
26        bc1t      $fcc1, 4             # CHECK: bc1t $fcc1, 4 # encoding: [0x45,0x05,0x00,0x01]
27        bc1t      4                    # CHECK: bc1t 4        # encoding: [0x45,0x01,0x00,0x01]
28        bc1tl     $fcc0,4688           # CHECK: bc1tl 4688      # encoding: [0x45,0x03,0x04,0x94]
29        bc1tl     4688                 # CHECK: bc1tl 4688      # encoding: [0x45,0x03,0x04,0x94]
30        bc1tl     $fcc7,27             # CHECK: bc1tl $fcc7, 27 # encoding: [0x45,0x1f,0x00,0x06]
31        bal       21100                # CHECK: bal 21100     # encoding: [0x04,0x11,0x14,0x9b]
32        bgezal    $0, 21100            # CHECK: bal 21100     # encoding: [0x04,0x11,0x14,0x9b]
33        bgezal    $6, 21100            # CHECK: bgezal $6, 21100 # encoding: [0x04,0xd1,0x14,0x9b]
34        bltzal    $6, 21100            # CHECK: bltzal $6, 21100 # encoding: [0x04,0xd0,0x14,0x9b]
35        beql      $14,$s3,12544        # CHECK: beql $14, $19, 12544 # encoding: [0x51,0xd3,0x0c,0x40]
36        bgezall   $12,7293             # CHECK: bgezall $12, 7293    # encoding: [0x05,0x93,0x07,0x1f]
37        bgezl     $4,-6858             # CHECK: bgezl $4, -6858      # encoding: [0x04,0x83,0xf9,0x4d]
38        bgtzl     $10,-3738            # CHECK: bgtzl $10, -3738     # encoding: [0x5d,0x40,0xfc,0x59]
39        blezl     $6,2974              # CHECK: blezl $6, 2974       # encoding: [0x58,0xc0,0x02,0xe7]
40        bltzall   $6,488               # CHECK: bltzall $6, 488      # encoding: [0x04,0xd2,0x00,0x7a]
41        bltzl     $s1,-9964            # CHECK: bltzl $17, -9964     # encoding: [0x06,0x22,0xf6,0x45]
42        bnel      $gp,$s4,5107         # CHECK: bnel $gp, $20, 5107  # encoding: [0x57,0x94,0x04,0xfc]
43        cache     1, 8($5)             # CHECK: cache 1, 8($5)       # encoding: [0xbc,0xa1,0x00,0x08]
44        c.ngl.d   $f29,$f29
45        c.ngle.d  $f0,$f16
46        c.sf.d    $f30,$f0
47        c.sf.s    $f14,$f22
48        ceil.w.d  $f11,$f25
49        ceil.w.s  $f6,$f20
50        cfc1      $s1,$21
51        clo       $11,$a1              # CHECK: clo $11, $5   # encoding: [0x70,0xab,0x58,0x21]
52        clz       $sp,$gp              # CHECK: clz $sp, $gp  # encoding: [0x73,0x9d,0xe8,0x20]
53        ctc1      $a2,$26
54        cvt.d.s   $f22,$f28
55        cvt.d.w   $f26,$f11
56        cvt.l.d   $f24,$f15
57        cvt.l.s   $f11,$f29
58        cvt.s.d   $f26,$f8
59        cvt.s.w   $f22,$f15
60        cvt.w.d   $f20,$f14
61        cvt.w.s   $f20,$f24
62        deret
63        di        $s8                  # CHECK: di  $fp       # encoding: [0x41,0x7e,0x60,0x00]
64        di                             # CHECK: di            # encoding: [0x41,0x60,0x60,0x00]
65        div       $zero,$25,$11
66        div.d     $f29,$f20,$f27
67        div.s     $f4,$f5,$f15
68        divu      $zero,$25,$15
69        ehb                            # CHECK: ehb # encoding:  [0x00,0x00,0x00,0xc0]
70        ei        $14                  # CHECK: ei  $14       # encoding: [0x41,0x6e,0x60,0x20]
71        ei                             # CHECK: ei            # encoding: [0x41,0x60,0x60,0x20]
72        eret
73        floor.w.d $f14,$f11
74        floor.w.s $f8,$f9
75        j         1f                   # CHECK: j $tmp0 # encoding: [0b000010AA,A,A,A]
76                                       # CHECK:         #   fixup A - offset: 0, value: ($tmp0), kind: fixup_Mips_26
77        j         a                    # CHECK: j a     # encoding: [0b000010AA,A,A,A]
78                                       # CHECK:         #   fixup A - offset: 0, value: a, kind: fixup_Mips_26
79        j         1328                 # CHECK: j 1328  # encoding: [0x08,0x00,0x01,0x4c]
80        jal       21100                # CHECK: jal 21100     # encoding: [0x0c,0x00,0x14,0x9b]
81        jr.hb     $4                   # CHECK: jr.hb  $4 # encoding: [0x00,0x80,0x04,0x08]
82        jalr.hb   $4                   # CHECK: jalr.hb  $4 # encoding: [0x00,0x80,0xfc,0x09]
83        jalr.hb   $4, $5               # CHECK: jalr.hb  $4, $5 # encoding: [0x00,0xa0,0x24,0x09]
84        lb        $24,-14515($10)
85        lbu       $8,30195($v1)
86        ldc1      $f11,16391($s0)
87        ldc2      $8,-21181($at)        # CHECK: ldc2 $8, -21181($1)   # encoding: [0xd8,0x28,0xad,0x43]
88        ldxc1     $f8,$s7($15)
89        lh        $11,-8556($s5)
90        lhu       $s3,-22851($v0)
91        li        $at,-29773
92        li        $zero,-29889
93        ll        $v0,-7321($s2)       # CHECK: ll $2, -7321($18)     # encoding: [0xc2,0x42,0xe3,0x67]
94        luxc1     $f19,$s6($s5)
95        lw        $8,5674($a1)
96        lwc1      $f16,10225($k0)
97        lwc2      $18,-841($a2)        # CHECK: lwc2 $18, -841($6)     # encoding: [0xc8,0xd2,0xfc,0xb7]
98        lwl       $s4,-4231($15)
99        lwr       $zero,-19147($gp)
100        lwxc1     $f12,$s1($s8)
101        madd      $s6,$13
102        madd      $zero,$9
103        madd.d    $f18,$f19,$f26,$f20
104        madd.s    $f1,$f31,$f19,$f25
105        maddu     $s3,$gp
106        maddu     $24,$s2
107        mfc0      $8,$15,1             # CHECK: mfc0 $8, $15, 1      # encoding: [0x40,0x08,0x78,0x01]
108        mfc1      $a3,$f27
109        mfhc1     $s8,$f24
110        mfhi      $s3
111        mfhi      $sp
112        mflo      $s1
113        mov.d     $f20,$f14
114        mov.s     $f2,$f27
115        move      $s8,$a0              # CHECK: move $fp, $4             # encoding: [0x00,0x80,0xf0,0x25]
116        move      $25,$a2              # CHECK: move $25, $6             # encoding: [0x00,0xc0,0xc8,0x25]
117        movf      $gp,$8,$fcc7
118        movf.d    $f6,$f11,$fcc5
119        movf.s    $f23,$f5,$fcc6
120        movn      $v1,$s1,$s0
121        movn.d    $f27,$f21,$k0
122        movn.s    $f12,$f0,$s7
123        movt      $zero,$s4,$fcc5
124        movt.d    $f0,$f2,$fcc0
125        movt.s    $f30,$f2,$fcc1
126        movz      $a1,$s6,$9
127        movz.d    $f12,$f29,$9
128        movz.s    $f25,$f7,$v1
129        msub      $s7,$k1
130        msub.d    $f10,$f1,$f31,$f18
131        msub.s    $f12,$f19,$f10,$f16
132        msubu     $15,$a1
133        mtc0      $9,$15,1             # CHECK: mtc0 $9, $15, 1     # encoding: [0x40,0x89,0x78,0x01]
134        mtc1      $s8,$f9
135        mthc1     $zero,$f16
136        mthi      $s1
137        mtlo      $sp
138        mtlo      $25
139        mul       $s0,$s4,$at
140        mul.d     $f20,$f20,$f16
141        mul.s     $f30,$f10,$f2
142        mult      $sp,$s4
143        mult      $sp,$v0
144        multu     $gp,$k0
145        multu     $9,$s2
146        negu      $2                   # CHECK: negu $2, $2            # encoding: [0x00,0x02,0x10,0x23]
147        negu      $2,$3                # CHECK: negu $2, $3            # encoding: [0x00,0x03,0x10,0x23]
148        neg.d     $f27,$f18
149        neg.s     $f1,$f15
150        nmadd.d   $f18,$f9,$f14,$f19
151        nmadd.s   $f0,$f5,$f25,$f12
152        nmsub.d   $f30,$f8,$f16,$f30
153        nmsub.s   $f1,$f24,$f19,$f4
154        nop
155        nor       $a3,$zero,$a3
156        or        $12,$s0,$sp
157        or        $2, 4                # CHECK: ori $2, $2, 4           # encoding: [0x34,0x42,0x00,0x04]
158        pause                          # CHECK: pause # encoding:  [0x00,0x00,0x01,0x40]
159        pref      1, 8($5)             # CHECK: pref 1, 8($5)           # encoding: [0xcc,0xa1,0x00,0x08]
160        # FIXME: Use the code generator in order to print the .set directives
161        #        instead of the instruction printer.
162        rdhwr     $sp,$11              # CHECK:      .set  push
163                                       # CHECK-NEXT: .set  mips32r2
164                                       # CHECK-NEXT: rdhwr $sp, $11
165                                       # CHECK-NEXT: .set  pop          # encoding: [0x7c,0x1d,0x58,0x3b]
166        rotr      $1,15                # CHECK: rotr $1, $1, 15         # encoding: [0x00,0x21,0x0b,0xc2]
167        rotr      $1,$14,15            # CHECK: rotr $1, $14, 15        # encoding: [0x00,0x2e,0x0b,0xc2]
168        rotrv     $1,$14,$15           # CHECK: rotrv $1, $14, $15      # encoding: [0x01,0xee,0x08,0x46]
169        round.w.d $f6,$f4
170        round.w.s $f27,$f28
171        sb        $s6,-19857($14)
172        sc        $15,18904($s3)       # CHECK: sc $15, 18904($19)     # encoding: [0xe2,0x6f,0x49,0xd8]
173        sdbbp                          # CHECK: sdbbp                  # encoding: [0x70,0x00,0x00,0x3f]
174        sdbbp     34                   # CHECK: sdbbp 34               # encoding: [0x70,0x00,0x08,0xbf]
175        sdc1      $f31,30574($13)
176        sdc2      $20,23157($s2)       # CHECK: sdc2 $20, 23157($18)   # encoding: [0xfa,0x54,0x5a,0x75]
177        sdxc1     $f11,$10($14)
178        seb       $25,$15
179        seh       $v1,$12
180        sh        $14,-6704($15)
181        sll       $a3,18               # CHECK: sll $7, $7, 18         # encoding: [0x00,0x07,0x3c,0x80]
182        sll       $a3,$zero,18         # CHECK: sll $7, $zero, 18      # encoding: [0x00,0x00,0x3c,0x80]
183        sll       $a3,$zero,$9         # CHECK: sllv $7, $zero, $9     # encoding: [0x01,0x20,0x38,0x04]
184        sllv      $a3,$zero,$9         # CHECK: sllv $7, $zero, $9     # encoding: [0x01,0x20,0x38,0x04]
185        slt       $s7,$11,$k1          # CHECK: slt $23, $11, $27      # encoding: [0x01,0x7b,0xb8,0x2a]
186        slti      $s1,$10,9489         # CHECK: slti $17, $10, 9489    # encoding: [0x29,0x51,0x25,0x11]
187        sltiu     $25,$25,-15531       # CHECK: sltiu $25, $25, -15531 # encoding: [0x2f,0x39,0xc3,0x55]
188        sltu      $s4,$s5,$11          # CHECK: sltu  $20, $21, $11    # encoding: [0x02,0xab,0xa0,0x2b]
189        sltu      $24,$25,-15531       # CHECK: sltiu $24, $25, -15531 # encoding: [0x2f,0x38,0xc3,0x55]
190        sqrt.d    $f17,$f22
191        sqrt.s    $f0,$f1
192        sra       $s1,15               # CHECK: sra $17, $17, 15       # encoding: [0x00,0x11,0x8b,0xc3]
193        sra       $s1,$s7,15           # CHECK: sra $17, $23, 15       # encoding: [0x00,0x17,0x8b,0xc3]
194        sra       $s1,$s7,$sp          # CHECK: srav $17, $23, $sp     # encoding: [0x03,0xb7,0x88,0x07]
195        srav      $s1,$s7,$sp          # CHECK: srav $17, $23, $sp     # encoding: [0x03,0xb7,0x88,0x07]
196        srl       $2,7                 # CHECK: srl $2, $2, 7          # encoding: [0x00,0x02,0x11,0xc2]
197        srl       $2,$2,7              # CHECK: srl $2, $2, 7          # encoding: [0x00,0x02,0x11,0xc2]
198        srl       $25,$s4,$a0          # CHECK: srlv $25, $20, $4      # encoding: [0x00,0x94,0xc8,0x06]
199        srlv      $25,$s4,$a0          # CHECK: srlv $25, $20, $4      # encoding: [0x00,0x94,0xc8,0x06]
200        ssnop                          # CHECK: ssnop                  # encoding: [0x00,0x00,0x00,0x40]
201        sub       $s6,$s3,$12
202        sub       $22,$17,-3126        # CHECK: addi $22, $17, 3126    # encoding: [0x22,0x36,0x0c,0x36]
203        sub       $13,6512             # CHECK: addi $13, $13, -6512   # encoding: [0x21,0xad,0xe6,0x90]
204        sub.d     $f18,$f3,$f17
205        sub.s     $f23,$f22,$f22
206        subu      $sp,$s6,$s6
207        suxc1     $f12,$k1($13)
208        sw        $ra,-10160($sp)
209        swc1      $f6,-8465($24)
210        swc2      $25,24880($s0)       # CHECK: swc2 $25, 24880($16)   # encoding: [0xea,0x19,0x61,0x30]
211        swl       $15,13694($s3)
212        swr       $s1,-26590($14)
213        swxc1     $f19,$12($k0)
214        sync                           # CHECK: sync                   # encoding: [0x00,0x00,0x00,0x0f]
215        sync      1                    # CHECK: sync 1                 # encoding: [0x00,0x00,0x00,0x4f]
216        syscall                        # CHECK: syscall                # encoding: [0x00,0x00,0x00,0x0c]
217        syscall   256                  # CHECK: syscall 256            # encoding: [0x00,0x00,0x40,0x0c]
218        teq       $0,$3                # CHECK: teq $zero, $3          # encoding: [0x00,0x03,0x00,0x34]
219        teq       $5,$7,620            # CHECK: teq $5, $7, 620        # encoding: [0x00,0xa7,0x9b,0x34]
220        teqi      $s5,-17504
221        tge       $7,$10               # CHECK: tge $7, $10            # encoding: [0x00,0xea,0x00,0x30]
222        tge       $5,$19,340           # CHECK: tge $5, $19, 340       # encoding: [0x00,0xb3,0x55,0x30]
223        tgei      $s1,5025
224        tgeiu     $sp,-28621
225        tgeu      $22,$28              # CHECK: tgeu $22, $gp          # encoding: [0x02,0xdc,0x00,0x31]
226        tgeu      $20,$14,379          # CHECK: tgeu $20, $14, 379     # encoding: [0x02,0x8e,0x5e,0xf1]
227        tlbp                           # CHECK: tlbp                   # encoding: [0x42,0x00,0x00,0x08]
228        tlbr                           # CHECK: tlbr                   # encoding: [0x42,0x00,0x00,0x01]
229        tlbwi                          # CHECK: tlbwi                  # encoding: [0x42,0x00,0x00,0x02]
230        tlbwr                          # CHECK: tlbwr                  # encoding: [0x42,0x00,0x00,0x06]
231        tlt       $15,$13              # CHECK: tlt $15, $13           # encoding: [0x01,0xed,0x00,0x32]
232        tlt       $2,$19,133           # CHECK: tlt $2, $19, 133       # encoding: [0x00,0x53,0x21,0x72]
233        tlti      $14,-21059
234        tltiu     $ra,-5076
235        tltu      $11,$16              # CHECK: tltu $11, $16          # encoding: [0x01,0x70,0x00,0x33]
236        tltu      $16,$29,1016         # CHECK: tltu $16, $sp, 1016    # encoding: [0x02,0x1d,0xfe,0x33]
237        tne       $6,$17               # CHECK: tne $6, $17            # encoding: [0x00,0xd1,0x00,0x36]
238        tne       $7,$8,885            # CHECK: tne $7, $8, 885        # encoding: [0x00,0xe8,0xdd,0x76]
239        tnei      $12,-29647
240        trunc.w.d $f22,$f15            # CHECK: trunc.w.d $f22, $f14   # encoding: [0x46,0x20,0x75,0x8d]
241        trunc.w.s $f28,$f30            # CHECK: trunc.w.s $f28, $f30   # encoding: [0x46,0x00,0xf7,0x0d]
242        trunc.w.d $f4,$f6,$4           # CHECK: trunc.w.d $f4, $f6     # encoding: [0x46,0x20,0x31,0x0d]
243        trunc.w.s $f4,$f6,$4           # CHECK: trunc.w.s $f4, $f6     # encoding: [0x46,0x00,0x31,0x0d]
244        wsbh      $k1,$9
245        xor       $s2,$a0,$s8
246        xor       $2, 4                # CHECK: xori $2, $2, 4         # encoding: [0x38,0x42,0x00,0x04]
247        synci     -15842($a2)          # CHECK: synci -15842($6)        # encoding: [0x04,0xdf,0xc2,0x1e]
248
2491:
250
251        # Check that we accept traditional %relocation(symbol) offsets for stores
252        # and loads, not just a sign 16 bit offset.
253
254        lui       $2, %hi(g_8)            # CHECK:  encoding: [0x3c,0x02,A,A]
255        lb        $3, %lo(g_8)($2)        # CHECK:  encoding: [0x80,0x43,A,A]
256        lh        $3, %lo(g_8)($2)        # CHECK:  encoding: [0x84,0x43,A,A]
257        lhu       $3, %lo(g_8)($2)        # CHECK:  encoding: [0x94,0x43,A,A]
258        lw        $3, %lo(g_8)($2)        # CHECK:  encoding: [0x8c,0x43,A,A]
259        sb        $3, %lo(g_8)($2)        # CHECK:  encoding: [0xa0,0x43,A,A]
260        sh        $3, %lo(g_8)($2)        # CHECK:  encoding: [0xa4,0x43,A,A]
261        sw        $3, %lo(g_8)($2)        # CHECK:  encoding: [0xac,0x43,A,A]
262
263        lwl       $3, %lo(g_8)($2)        # CHECK:  encoding: [0x88,0x43,A,A]
264        lwr       $3, %lo(g_8)($2)        # CHECK:  encoding: [0x98,0x43,A,A]
265        swl       $3, %lo(g_8)($2)        # CHECK:  encoding: [0xa8,0x43,A,A]
266        swr       $3, %lo(g_8)($2)        # CHECK:  encoding: [0xb8,0x43,A,A]
267
268        lwc1      $f0, %lo(g_8)($2)       # CHECK:  encoding: [0xc4,0x40,A,A]
269        ldc1      $f0, %lo(g_8)($2)       # CHECK:  encoding: [0xd4,0x40,A,A]
270        swc1      $f0, %lo(g_8)($2)       # CHECK:  encoding: [0xe4,0x40,A,A]
271        sdc1      $f0, %lo(g_8)($2)       # CHECK:  encoding: [0xf4,0x40,A,A]
272        .type     g_8,@object
273        .comm     g_8,16,16
274