History

arm-asm: Add clz, sxtb, sxth, uxtb, uxth

Danny Milosavljevic committed 5 years ago

Commit c4e13c11 parent c9e0c2a2 files · +57 −0Browse files

Unified · Split

2 files
  1. arm-asm.c +47 −0
  2. arm-tok.h +10 −0
arm-asm.c+47−0
@@ -190,6 +190,47 @@ static void asm_unary_opcode(TCCState *s1, int token) · 189 unmodified lines
190190 }
191191 }
192192
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+
193234 static void asm_block_data_transfer_opcode(TCCState *s1, int token)
194235 {
195236 uint32_t opcode;
@@ -268,6 +309,12 @@ ST_FUNC void asm_opcode(TCCState *s1, int token) · 72 unmodified lines
268309 return asm_nullary_opcode(token);
269310 case TOK_ASM_swieq:
270311 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);
271318 default:
272319 expect("known instruction");
273320 }
arm-tok.h+10−0
@@ -56,6 +56,16 @@ · 55 unmodified lines
5656 DEF_ASM_CONDED(wfi)
5757 DEF_ASM_CONDED(swi)
5858
59+ /* misc */
60+ DEF_ASM_CONDED(clz)
61+
62+ /* size conversion */
63+
64+ DEF_ASM_CONDED(sxtb)
65+ DEF_ASM_CONDED(sxth)
66+ DEF_ASM_CONDED(uxtb)
67+ DEF_ASM_CONDED(uxth)
68+
5969 /* instruction macros */
6070
6171 DEF_ASM_CONDED(push)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t