[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Tinycc-devel] [PATCH 12/16] arm-asm: Add stmda, ldmda, stm, ldm, stmia,
From: |
Danny Milosavljevic |
Subject: |
[Tinycc-devel] [PATCH 12/16] arm-asm: Add stmda, ldmda, stm, ldm, stmia, ldmia, stmdb, ldmdb, stmib, ldmib |
Date: |
Sat, 26 Dec 2020 22:58:13 +0100 |
---
arm-asm.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
arm-tok.h | 13 ++++++++++
2 files changed, 84 insertions(+)
diff --git a/arm-asm.c b/arm-asm.c
index 792b914..d62b9c3 100644
--- a/arm-asm.c
+++ b/arm-asm.c
@@ -231,6 +231,15 @@ static void asm_binary_opcode(TCCState *s1, int token)
}
}
+/* data processing and single data transfer instructions only */
+#define ENCODE_RN(register_index) ((register_index) << 16)
+#define ENCODE_RD(register_index) ((register_index) << 12)
+#define ENCODE_SET_CONDITION_CODES (1 << 20)
+
+/* Note: For data processing instructions, "1" means immediate.
+ Note: For single data transfer instructions, "0" means immediate. */
+#define ENCODE_IMMEDIATE_FLAG (1 << 25)
+
static void asm_block_data_transfer_opcode(TCCState *s1, int token)
{
uint32_t opcode;
@@ -281,6 +290,58 @@ static void asm_block_data_transfer_opcode(TCCState *s1,
int token)
else
asm_emit_opcode(token, (0x8bd << 16) | ops[0].regset); // TODO:
base register ?
break;
+ case TOK_ASM_stmdaeq:
+ case TOK_ASM_ldmdaeq:
+ case TOK_ASM_stmeq:
+ case TOK_ASM_ldmeq:
+ case TOK_ASM_stmiaeq:
+ case TOK_ASM_ldmiaeq:
+ case TOK_ASM_stmdbeq:
+ case TOK_ASM_ldmdbeq:
+ case TOK_ASM_stmibeq:
+ case TOK_ASM_ldmibeq:
+ switch (ARM_INSTRUCTION_GROUP(token)) {
+ case TOK_ASM_stmdaeq: // post-decrement store
+ opcode = 0x82 << 20;
+ break;
+ case TOK_ASM_ldmdaeq: // post-decrement load
+ opcode = 0x83 << 20;
+ break;
+ case TOK_ASM_stmeq: // post-increment store
+ case TOK_ASM_stmiaeq: // post-increment store
+ opcode = 0x8a << 20;
+ break;
+ case TOK_ASM_ldmeq: // post-increment load
+ case TOK_ASM_ldmiaeq: // post-increment load
+ opcode = 0x8b << 20;
+ break;
+ case TOK_ASM_stmdbeq: // pre-decrement store
+ opcode = 0x92 << 20;
+ break;
+ case TOK_ASM_ldmdbeq: // pre-decrement load
+ opcode = 0x93 << 20;
+ break;
+ case TOK_ASM_stmibeq: // pre-increment store
+ opcode = 0x9a << 20;
+ break;
+ case TOK_ASM_ldmibeq: // pre-increment load
+ opcode = 0x9b << 20;
+ break;
+ default:
+ tcc_error("internal error: This place should not be reached
(fallback in asm_block_data_transfer_opcode)");
+ }
+ // operands:
+ // Rn: first operand
+ // Register List: lower bits
+ if (nb_ops != 2)
+ expect("exactly two operands");
+ else if (ops[0].type != OP_REG32)
+ expect("(first operand) register");
+ else if (!op0_exclam)
+ tcc_error("first operand of '%s' should have an exclamation mark",
get_tok_str(token, NULL));
+ else
+ asm_emit_opcode(token, opcode | ENCODE_RN(ops[0].reg) |
ops[1].regset);
+ break;
default:
expect("block data transfer instruction");
}
@@ -461,6 +522,16 @@ ST_FUNC void asm_opcode(TCCState *s1, int token)
switch (ARM_INSTRUCTION_GROUP(token)) {
case TOK_ASM_pusheq:
case TOK_ASM_popeq:
+ case TOK_ASM_stmdaeq:
+ case TOK_ASM_ldmdaeq:
+ case TOK_ASM_stmeq:
+ case TOK_ASM_ldmeq:
+ case TOK_ASM_stmiaeq:
+ case TOK_ASM_ldmiaeq:
+ case TOK_ASM_stmdbeq:
+ case TOK_ASM_ldmdbeq:
+ case TOK_ASM_stmibeq:
+ case TOK_ASM_ldmibeq:
return asm_block_data_transfer_opcode(s1, token);
case TOK_ASM_nopeq:
case TOK_ASM_wfeeq:
diff --git a/arm-tok.h b/arm-tok.h
index 5106250..3860177 100644
--- a/arm-tok.h
+++ b/arm-tok.h
@@ -81,6 +81,19 @@
DEF_ASM_CONDED(umlal)
DEF_ASM_CONDED(umlals)
+ /* load/store */
+
+ DEF_ASM_CONDED(stmda)
+ DEF_ASM_CONDED(ldmda)
+ DEF_ASM_CONDED(stm)
+ DEF_ASM_CONDED(ldm)
+ DEF_ASM_CONDED(stmia)
+ DEF_ASM_CONDED(ldmia)
+ DEF_ASM_CONDED(stmdb)
+ DEF_ASM_CONDED(ldmdb)
+ DEF_ASM_CONDED(stmib)
+ DEF_ASM_CONDED(ldmib)
+
/* instruction macros */
DEF_ASM_CONDED(push)
- [Tinycc-devel] [PATCH 00/16] Add ARM inline assembler, Danny Milosavljevic, 2020/12/26
- [Tinycc-devel] [PATCH 03/16] arm-asm: Update copyright header, Danny Milosavljevic, 2020/12/26
- [Tinycc-devel] [PATCH 06/16] arm-asm: Add wfe, wfi, Danny Milosavljevic, 2020/12/26
- [Tinycc-devel] [PATCH 05/16] arm-asm: Add nop, Danny Milosavljevic, 2020/12/26
- [Tinycc-devel] [PATCH 08/16] arm-asm: Add push, pop, Danny Milosavljevic, 2020/12/26
- [Tinycc-devel] [PATCH 01/16] arm-asm: Publish g, gen_le16, gen_le32 in tcc.h, Danny Milosavljevic, 2020/12/26
- [Tinycc-devel] [PATCH 09/16] arm-asm: Add swi, Danny Milosavljevic, 2020/12/26
- [Tinycc-devel] [PATCH 07/16] arm-asm: Add parse_operand, Operand, Danny Milosavljevic, 2020/12/26
- [Tinycc-devel] [PATCH 10/16] arm-asm: Add clz, sxtb, sxth, uxtb, uxth, Danny Milosavljevic, 2020/12/26
- [Tinycc-devel] [PATCH 12/16] arm-asm: Add stmda, ldmda, stm, ldm, stmia, ldmia, stmdb, ldmdb, stmib, ldmib,
Danny Milosavljevic <=
- [Tinycc-devel] [PATCH 11/16] arm-asm: Add mul, mla, smull, umull, smlal, umlal, Danny Milosavljevic, 2020/12/26
- [Tinycc-devel] [PATCH 13/16] arm-asm: Add ldr, ldrb, str, strb, Danny Milosavljevic, 2020/12/26
- [Tinycc-devel] [PATCH 16/16] arm-asm: Optimize gen_le32, Danny Milosavljevic, 2020/12/26
- [Tinycc-devel] [PATCH 15/16] arm-asm: Add b, bl, bx, blx, Danny Milosavljevic, 2020/12/26
- [Tinycc-devel] [PATCH 14/16] arm-asm: Add and, eor, sub, rsb, add, adc, sbc, rsc, tst, teq, cmp, cmn, orr, mov, bic, mvn, Danny Milosavljevic, 2020/12/26
- Re: [Tinycc-devel] [PATCH 00/16] Add ARM inline assembler, Danny Milosavljevic, 2020/12/26
- [Tinycc-devel] [PATCH 02/16] arm-asm: Implement asm_parse_regvar and asm_clobber, Danny Milosavljevic, 2020/12/26
- [Tinycc-devel] [PATCH 04/16] arm-asm: Remove asm_error, Danny Milosavljevic, 2020/12/26
- Re: [Tinycc-devel] [PATCH 00/16] Add ARM inline assembler, Jan Nieuwenhuizen, 2020/12/27
- Re: [Tinycc-devel] [PATCH 00/16] Add ARM inline assembler, Michael Matz, 2020/12/27
- Prev by Date:
[Tinycc-devel] [PATCH 10/16] arm-asm: Add clz, sxtb, sxth, uxtb, uxth
- Next by Date:
[Tinycc-devel] [PATCH 11/16] arm-asm: Add mul, mla, smull, umull, smlal, umlal
- Previous by thread:
[Tinycc-devel] [PATCH 10/16] arm-asm: Add clz, sxtb, sxth, uxtb, uxth
- Next by thread:
[Tinycc-devel] [PATCH 11/16] arm-asm: Add mul, mla, smull, umull, smlal, umlal
- Index(es):