bde03502df46f3004515b7c49b4ac1206c568bd3
[opencl/llvm.git] / test / MC / Mips / micromips-16-bit-instructions.s
1 # RUN: llvm-mc %s -triple=mipsel -show-encoding -mattr=micromips | \
2 # RUN: FileCheck -check-prefix=CHECK-EL %s
3 # RUN: llvm-mc %s -triple=mips -show-encoding -mattr=micromips | \
4 # RUN: FileCheck -check-prefix=CHECK-EB %s
5 # Check that the assembler can handle the documented syntax
6 # for arithmetic and logical instructions.
7 #------------------------------------------------------------------------------
8 # MicroMIPS 16-bit Instructions
9 #------------------------------------------------------------------------------
10 # Little endian
11 #------------------------------------------------------------------------------
12 # CHECK-EL: addu16  $6, $17, $4     # encoding: [0x42,0x07]
13 # CHECK-EL: subu16  $5, $16, $3     # encoding: [0xb1,0x06]
14 # CHECK-EL: andi16  $16, $2, 31     # encoding: [0x29,0x2c]
15 # CHECK-EL: and16   $16, $2         # encoding: [0x82,0x44]
16 # CHECK-EL: not16   $17, $3         # encoding: [0x0b,0x44]
17 # CHECK-EL: or16    $16, $4         # encoding: [0xc4,0x44]
18 # CHECK-EL: xor16   $17, $5         # encoding: [0x4d,0x44]
19 # CHECK-EL: sll16   $3, $16, 5      # encoding: [0x8a,0x25]
20 # CHECK-EL: srl16   $4, $17, 6      # encoding: [0x1d,0x26]
21 # CHECK-EL: lbu16   $3, 4($17)      # encoding: [0x94,0x09]
22 # CHECK-EL: lbu16   $3, -1($16)     # encoding: [0x8f,0x09]
23 # CHECK-EL: lhu16   $3, 4($16)      # encoding: [0x82,0x29]
24 # CHECK-EL: lw16    $4, 8($17)      # encoding: [0x12,0x6a]
25 # CHECK-EL: sb16    $3, 4($16)      # encoding: [0x84,0x89]
26 # CHECK-EL: sh16    $4, 8($17)      # encoding: [0x14,0xaa]
27 # CHECK-EL: sw16    $4, 4($17)      # encoding: [0x11,0xea]
28 # CHECK-EL: sw16    $zero, 4($17)   # encoding: [0x11,0xe8]
29 # CHECK-EL: lw      $3, 32($sp)     # encoding: [0x68,0x48]
30 # CHECK-EL: sw      $4, 124($sp)    # encoding: [0x9f,0xc8]
31 # CHECK-EL: li16    $3, -1          # encoding: [0xff,0xed]
32 # CHECK-EL: li16    $3, 126         # encoding: [0xfe,0xed]
33 # CHECK-EL: addiur1sp $7, 4         # encoding: [0x83,0x6f]
34 # CHECK-EL: addiur2 $6, $7, -1      # encoding: [0x7e,0x6f]
35 # CHECK-EL: addiur2 $6, $7, 12      # encoding: [0x76,0x6f]
36 # CHECK-EL: addius5 $7, -2          # encoding: [0xfc,0x4c]
37 # CHECK-EL: addiusp -1028           # encoding: [0xff,0x4f]
38 # CHECK-EL: addiusp -1032           # encoding: [0xfd,0x4f]
39 # CHECK-EL: addiusp 1024            # encoding: [0x01,0x4c]
40 # CHECK-EL: addiusp 1028            # encoding: [0x03,0x4c]
41 # CHECK-EL: addiusp -16             # encoding: [0xf9,0x4f]
42 # CHECK-EL: mfhi    $9              # encoding: [0x09,0x46]
43 # CHECK-EL: mflo    $9              # encoding: [0x49,0x46]
44 # CHECK-EL: move    $25, $1         # encoding: [0x21,0x0f]
45 # CHECK-EL: jrc     $9              # encoding: [0xa9,0x45]
46 # CHECK-NEXT: jalr    $9            # encoding: [0xc9,0x45]
47 # CHECK-EL: jraddiusp 20            # encoding: [0x05,0x47]
48 # CHECK-NEXT: jalrs16 $9            # encoding: [0xe9,0x45]
49 # CHECK-EL: nop                     # encoding: [0x00,0x0c]
50 # CHECK-EL: jr16    $9              # encoding: [0x89,0x45]
51 # CHECK-EL: nop                     # encoding: [0x00,0x00,0x00,0x00]
52 # CHECK-EL: beqz16 $6, 20           # encoding: [0x0a,0x8f]
53 # CHECK-EL: nop                     # encoding: [0x00,0x00,0x00,0x00]
54 # CHECK-EL: bnez16 $6, 20           # encoding: [0x0a,0xaf]
55 # CHECK-EL: nop                     # encoding: [0x00,0x00,0x00,0x00]
56 # CHECK-EL: b16 132                 # encoding: [0x42,0xcc]
57 # CHECK-EL: nop
58 # CHECK-EL: b16 132                 # encoding: [0x42,0xcc]
59 # CHECK-EL: nop
60 # CHECK-EL: break16 8               # encoding: [0x88,0x46]
61 # CHECK-EL: sdbbp16 14              # encoding: [0xce,0x46]
62 #------------------------------------------------------------------------------
63 # Big endian
64 #------------------------------------------------------------------------------
65 # CHECK-EB: addu16  $6, $17, $4     # encoding: [0x07,0x42]
66 # CHECK-EB: subu16  $5, $16, $3     # encoding: [0x06,0xb1]
67 # CHECK-EB: andi16  $16, $2, 31     # encoding: [0x2c,0x29]
68 # CHECK-EB: and16   $16, $2         # encoding: [0x44,0x82]
69 # CHECK-EB: not16   $17, $3         # encoding: [0x44,0x0b]
70 # CHECK-EB: or16    $16, $4         # encoding: [0x44,0xc4]
71 # CHECK-EB: xor16   $17, $5         # encoding: [0x44,0x4d]
72 # CHECK-EB: sll16   $3, $16, 5      # encoding: [0x25,0x8a]
73 # CHECK-EB: srl16   $4, $17, 6      # encoding: [0x26,0x1d]
74 # CHECK-EB: lbu16   $3, 4($17)      # encoding: [0x09,0x94]
75 # CHECK-EB: lbu16   $3, -1($16)     # encoding: [0x09,0x8f]
76 # CHECK-EB: lhu16   $3, 4($16)      # encoding: [0x29,0x82]
77 # CHECK-EB: lw16    $4, 8($17)      # encoding: [0x6a,0x12]
78 # CHECK-EB: sb16    $3, 4($16)      # encoding: [0x89,0x84]
79 # CHECK-EB: sh16    $4, 8($17)      # encoding: [0xaa,0x14]
80 # CHECK-EB: sw16    $4, 4($17)      # encoding: [0xea,0x11]
81 # CHECK-EB: sw16    $zero, 4($17)   # encoding: [0xe8,0x11]
82 # CHECK-EB: lw      $3, 32($sp)     # encoding: [0x48,0x68]
83 # CHECK-EB: sw      $4, 124($sp)    # encoding: [0xc8,0x9f]
84 # CHECK-EB: li16    $3, -1          # encoding: [0xed,0xff]
85 # CHECK-EB: li16    $3, 126         # encoding: [0xed,0xfe]
86 # CHECK-EB: addiur1sp $7, 4         # encoding: [0x6f,0x83]
87 # CHECK-EB: addiur2 $6, $7, -1      # encoding: [0x6f,0x7e]
88 # CHECK-EB: addiur2 $6, $7, 12      # encoding: [0x6f,0x76]
89 # CHECK-EB: addius5 $7, -2          # encoding: [0x4c,0xfc]
90 # CHECK-EB: addiusp -1028           # encoding: [0x4f,0xff]
91 # CHECK-EB: addiusp -1032           # encoding: [0x4f,0xfd]
92 # CHECK-EB: addiusp 1024            # encoding: [0x4c,0x01]
93 # CHECK-EB: addiusp 1028            # encoding: [0x4c,0x03]
94 # CHECK-EB: addiusp -16             # encoding: [0x4f,0xf9]
95 # CHECK-EB: mfhi    $9              # encoding: [0x46,0x09]
96 # CHECK-EB: mflo    $9              # encoding: [0x46,0x49]
97 # CHECK-EB: move    $25, $1         # encoding: [0x0f,0x21]
98 # CHECK-EB: jrc     $9              # encoding: [0x45,0xa9]
99 # CHECK-NEXT: jalr    $9            # encoding: [0x45,0xc9]
100 # CHECK-EB: jraddiusp 20            # encoding: [0x47,0x05]
101 # CHECK-NEXT: jalrs16 $9            # encoding: [0x45,0xe9]
102 # CHECK-EB: nop                     # encoding: [0x0c,0x00]
103 # CHECK-EB: jr16    $9              # encoding: [0x45,0x89]
104 # CHECK-EB: nop                     # encoding: [0x00,0x00,0x00,0x00]
105 # CHECK-EB: beqz16 $6, 20           # encoding: [0x8f,0x0a]
106 # CHECK-EB: nop                     # encoding: [0x00,0x00,0x00,0x00]
107 # CHECK-EB: bnez16 $6, 20           # encoding: [0xaf,0x0a]
108 # CHECK-EB: nop                     # encoding: [0x00,0x00,0x00,0x00]
109 # CHECK-EB: b16 132                 # encoding: [0xcc,0x42]
110 # CHECK-EB: nop
111 # CHECK-EB: b16 132                 # encoding: [0xcc,0x42]
112 # CHECK-EB: nop
113 # CHECK-EB: break16 8               # encoding: [0x46,0x88]
114 # CHECK-EB: sdbbp16 14              # encoding: [0x46,0xce]
116     addu16  $6, $17, $4
117     subu16  $5, $16, $3
118     andi16  $16, $2, 31
119     and16   $16, $2
120     not16   $17, $3
121     or16    $16, $4
122     xor16   $17, $5
123     sll16   $3, $16, 5
124     srl16   $4, $17, 6
125     lbu16   $3, 4($17)
126     lbu16   $3, -1($16)
127     lhu16   $3, 4($16)
128     lw16    $4, 8($17)
129     sb16    $3, 4($16)
130     sh16    $4, 8($17)
131     sw16    $4, 4($17)
132     sw16    $0, 4($17)
133     lw      $3, 32($sp)
134     sw      $4, 124($sp)
135     li16    $3, -1
136     li16    $3, 126
137     addiur1sp $7, 4
138     addiur2 $6, $7, -1
139     addiur2 $6, $7, 12
140     addius5 $7, -2
141     addiusp -1028
142     addiusp -1032
143     addiusp 1024
144     addiusp 1028
145     addiusp -16
146     mfhi    $9
147     mflo    $9
148     move    $25, $1
149     jrc     $9
150     jalr    $9
151     jraddiusp 20
152     jalrs16 $9
153     jr16    $9
154     beqz16 $6, 20
155     bnez16 $6, 20
156     b   132
157     b16 132
158     break16 8
159     sdbbp16 14