aboutsummaryrefslogtreecommitdiff
path: root/opcodes/aarch64-asm.c
diff options
context:
space:
mode:
authorVictor Do Nascimento <victor.donascimento@arm.com>2024-01-05 17:27:04 +0000
committerVictor Do Nascimento <victor.donascimento@arm.com>2024-01-15 13:11:48 +0000
commitc35460087723932ba7300072099bd0d65d9ce6d2 (patch)
tree63de650feaf214b78cfe9f4be4425d7b79729ac6 /opcodes/aarch64-asm.c
parent2f8890efc521d0477728ade637cb1d03a4aa799d (diff)
downloadgdb-c35460087723932ba7300072099bd0d65d9ce6d2.zip
gdb-c35460087723932ba7300072099bd0d65d9ce6d2.tar.gz
gdb-c35460087723932ba7300072099bd0d65d9ce6d2.tar.bz2
aarch64: rcpc3: Define address operand fields and inserter/extractors
Beyond the need to encode any registers involved in data transfer and the address base register for load/stores, it is necessary to specify the data register addressing mode and whether the address register is to be pre/post-indexed, whereby loads may be post-indexed and stores pre-indexed with write-back. The use of a single bit to specify both the indexing mode and indexing value requires a novel function be written to accommodate this for address operand insertion in assembly and another for extraction in disassembly, along with the definition of two insn fields for use with these instructions. This therefore defines the following functions: - aarch64_ins_rcpc3_addr_opt_offset - aarch64_ins_rcpc3_addr_offset - aarch64_ext_rcpc3_addr_opt_offset - aarch64_ext_rcpc3_addr_offset It extends the `do_special_{encoding|decoding}' functions and defines two rcpc3 instruction fields: - FLD_opc2 - FLD_rcpc3_size
Diffstat (limited to 'opcodes/aarch64-asm.c')
-rw-r--r--opcodes/aarch64-asm.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/opcodes/aarch64-asm.c b/opcodes/aarch64-asm.c
index 4d0b13e..565c4b1 100644
--- a/opcodes/aarch64-asm.c
+++ b/opcodes/aarch64-asm.c
@@ -702,6 +702,24 @@ aarch64_ins_addr_offset (const aarch64_operand *self ATTRIBUTE_UNUSED,
return true;
}
+/* Encode the address operand for e.g.
+ stlur <Xt>, [<Xn|SP>{, <amount>}]. */
+bool
+aarch64_ins_rcpc3_addr_offset (const aarch64_operand *self ATTRIBUTE_UNUSED,
+ const aarch64_opnd_info *info, aarch64_insn *code,
+ const aarch64_inst *inst ATTRIBUTE_UNUSED,
+ aarch64_operand_error *errors ATTRIBUTE_UNUSED)
+{
+ /* Rn */
+ insert_field (self->fields[0], code, info->addr.base_regno, 0);
+
+ /* simm9 */
+ int imm = info->addr.offset.imm;
+ insert_field (self->fields[1], code, imm, 0);
+
+ return true;
+}
+
/* Encode the address operand for e.g. LDRSW <Xt>, [<Xn|SP>, #<simm>]!. */
bool
aarch64_ins_addr_simm (const aarch64_operand *self,
@@ -736,6 +754,28 @@ aarch64_ins_addr_simm (const aarch64_operand *self,
return true;
}
+/* Encode the address operand, potentially offset by the load/store ammount,
+ e.g. LDIAPP <Xt>, <Xt2> [<Xn|SP>, #<simm>]
+ and STILP <Xt>, <Xt2> [<Xn|SP>], #<simm>.*/
+bool
+aarch64_ins_rcpc3_addr_opt_offset (const aarch64_operand *self ATTRIBUTE_UNUSED,
+ const aarch64_opnd_info *info,
+ aarch64_insn *code,
+ const aarch64_inst *inst ATTRIBUTE_UNUSED,
+ aarch64_operand_error *errors ATTRIBUTE_UNUSED)
+{
+ int imm;
+
+ /* Rn */
+ insert_field (FLD_Rn, code, info->addr.base_regno, 0);
+ /* simm */
+ imm = info->addr.offset.imm;
+ if (!imm)
+ insert_field (FLD_opc2, code, 1, 0);
+
+ return true;
+}
+
/* Encode the address operand for e.g. LDRAA <Xt>, [<Xn|SP>{, #<simm>}]. */
bool
aarch64_ins_addr_simm10 (const aarch64_operand *self,
@@ -1943,6 +1983,22 @@ do_special_encoding (struct aarch64_inst *inst)
? 1 : 0;
insert_field (FLD_lse_sz, &inst->value, value, 0);
}
+ if (inst->opcode->flags & F_RCPC3_SIZE)
+ {
+ switch (inst->operands[0].qualifier)
+ {
+ case AARCH64_OPND_QLF_W: value = 2; break;
+ case AARCH64_OPND_QLF_X: value = 3; break;
+ case AARCH64_OPND_QLF_S_B: value = 0; break;
+ case AARCH64_OPND_QLF_S_H: value = 1; break;
+ case AARCH64_OPND_QLF_S_S: value = 2; break;
+ case AARCH64_OPND_QLF_S_D: value = 3; break;
+ case AARCH64_OPND_QLF_S_Q: value = 0; break;
+ default: return;
+ }
+ insert_field (FLD_rcpc3_size, &inst->value, value, 0);
+ }
+
if (inst->opcode->flags & F_SIZEQ)
encode_sizeq (inst);
if (inst->opcode->flags & F_FPTYPE)