| @@ -190,6 +190,47 @@ static void asm_unary_opcode(TCCState *s1, int token) · 189 unmodified lines |
| 190 | } | 190 | } |
| 191 | } | 191 | } |
| 192 | | 192 | |
| | 193 | static void asm_binary_opcode(TCCState *s1, int token) |
| | 194 | { |
| | 195 | Operand ops[2]; |
| | 196 | parse_operand(s1, &ops[0]); |
| | 197 | if (tok == ',') |
| | 198 | next(); |
| | 199 | else |
| | 200 | expect("','"); |
| | 201 | parse_operand(s1, &ops[1]); |
| | 202 | if (ops[0].type != OP_REG32) { |
| | 203 | expect("(destination operand) register"); |
| | 204 | return; |
| | 205 | } |
| | 206 | |
| | 207 | if (ops[1].type != OP_REG32) |
| | 208 | expect("(source operand) register"); |
| | 209 | else switch (ARM_INSTRUCTION_GROUP(token)) { |
| | 210 | case TOK_ASM_clzeq: |
| | 211 | asm_emit_opcode(token, 0x16f0f10 | (ops[0].reg << 12) | ops[1].reg); |
| | 212 | break; |
| | 213 | case TOK_ASM_sxtbeq: |
| | 214 | /* TODO: optional ROR (8|16|24) */ |
| | 215 | asm_emit_opcode(token, 0x6af0070 | (ops[0].reg << 12) | ops[1].reg); |
| | 216 | break; |
| | 217 | case TOK_ASM_sxtheq: |
| | 218 | /* TODO: optional ROR (8|16|24) */ |
| | 219 | asm_emit_opcode(token, 0x6bf0070 | (ops[0].reg << 12) | ops[1].reg); |
| | 220 | break; |
| | 221 | case TOK_ASM_uxtbeq: |
| | 222 | /* TODO: optional ROR (8|16|24) */ |
| | 223 | asm_emit_opcode(token, 0x6ef0070 | (ops[0].reg << 12) | ops[1].reg); |
| | 224 | break; |
| | 225 | case TOK_ASM_uxtheq: |
| | 226 | /* TODO: optional ROR (8|16|24) */ |
| | 227 | asm_emit_opcode(token, 0x6ff0070 | (ops[0].reg << 12) | ops[1].reg); |
| | 228 | break; |
| | 229 | default: |
| | 230 | expect("binary instruction"); |
| | 231 | } |
| | 232 | } |
| | 233 | |
| 193 | static void asm_block_data_transfer_opcode(TCCState *s1, int token) | 234 | static void asm_block_data_transfer_opcode(TCCState *s1, int token) |
| 194 | { | 235 | { |
| 195 | uint32_t opcode; | 236 | uint32_t opcode; |
| @@ -268,6 +309,12 @@ ST_FUNC void asm_opcode(TCCState *s1, int token) · 72 unmodified lines |
| 268 | return asm_nullary_opcode(token); | 309 | return asm_nullary_opcode(token); |
| 269 | case TOK_ASM_swieq: | 310 | case TOK_ASM_swieq: |
| 270 | return asm_unary_opcode(s1, token); | 311 | return asm_unary_opcode(s1, token); |
| | 312 | case TOK_ASM_clzeq: |
| | 313 | case TOK_ASM_sxtbeq: |
| | 314 | case TOK_ASM_sxtheq: |
| | 315 | case TOK_ASM_uxtbeq: |
| | 316 | case TOK_ASM_uxtheq: |
| | 317 | return asm_binary_opcode(s1, token); |
| 271 | default: | 318 | default: |
| 272 | expect("known instruction"); | 319 | expect("known instruction"); |
| 273 | } | 320 | } |