diff options
author | Victor Do Nascimento <victor.donascimento@arm.com> | 2024-01-05 17:27:04 +0000 |
---|---|---|
committer | Victor Do Nascimento <victor.donascimento@arm.com> | 2024-01-15 13:11:48 +0000 |
commit | c35460087723932ba7300072099bd0d65d9ce6d2 (patch) | |
tree | 63de650feaf214b78cfe9f4be4425d7b79729ac6 /opcodes/aarch64-dis.c | |
parent | 2f8890efc521d0477728ade637cb1d03a4aa799d (diff) | |
download | gdb-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-dis.c')
-rw-r--r-- | opcodes/aarch64-dis.c | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/opcodes/aarch64-dis.c b/opcodes/aarch64-dis.c index 2896a11..f63b747 100644 --- a/opcodes/aarch64-dis.c +++ b/opcodes/aarch64-dis.c @@ -1032,6 +1032,70 @@ aarch64_ext_addr_simple (const aarch64_operand *self ATTRIBUTE_UNUSED, return true; } +/* Decode the address operand for rcpc3 instructions with optional load/store + datasize offset, e.g. STILPP <Xs>, <Xt>, [<Xn|SP>{,#-16}]! and + LIDAP <Xs>, <Xt>, [<Xn|SP>]{,#-16}. */ +bool +aarch64_ext_rcpc3_addr_opt_offset (const aarch64_operand *self ATTRIBUTE_UNUSED, + aarch64_opnd_info *info, + aarch64_insn code, + const aarch64_inst *inst ATTRIBUTE_UNUSED, + aarch64_operand_error *err ATTRIBUTE_UNUSED) +{ + info->addr.base_regno = extract_field (FLD_Rn, code, 0); + if (!extract_field (FLD_opc2, code, 0)) + { + info->addr.writeback = 1; + + enum aarch64_opnd type; + for (int i = 0; i < AARCH64_MAX_OPND_NUM; i++) + { + aarch64_opnd_info opnd = info[i]; + type = opnd.type; + if (aarch64_operands[type].op_class == AARCH64_OPND_CLASS_ADDRESS) + break; + } + + assert (aarch64_operands[type].op_class == AARCH64_OPND_CLASS_ADDRESS); + int offset = calc_ldst_datasize (inst->operands); + + switch (type) + { + case AARCH64_OPND_RCPC3_ADDR_OPT_PREIND_WB: + case AARCH64_OPND_RCPC3_ADDR_PREIND_WB: + info->addr.offset.imm = -offset; + info->addr.preind = 1; + break; + case AARCH64_OPND_RCPC3_ADDR_OPT_POSTIND: + case AARCH64_OPND_RCPC3_ADDR_POSTIND: + info->addr.offset.imm = offset; + info->addr.postind = 1; + break; + default: + return false; + } + } + return true; +} + +bool +aarch64_ext_rcpc3_addr_offset (const aarch64_operand *self ATTRIBUTE_UNUSED, + aarch64_opnd_info *info, + aarch64_insn code, + const aarch64_inst *inst ATTRIBUTE_UNUSED, + aarch64_operand_error *errors ATTRIBUTE_UNUSED) +{ + info->qualifier = get_expected_qualifier (inst, info->idx); + + /* Rn */ + info->addr.base_regno = extract_field (self->fields[0], code, 0); + + /* simm9 */ + aarch64_insn imm = extract_fields (code, 0, 1, self->fields[1]); + info->addr.offset.imm = sign_extend (imm, 8); + return true; +} + /* Decode the address operand for e.g. stlur <Xt>, [<Xn|SP>{, <amount>}]. */ bool @@ -2579,6 +2643,26 @@ do_special_decoding (aarch64_inst *inst) value = extract_field (FLD_lse_sz, inst->value, 0); inst->operands[idx].qualifier = get_greg_qualifier_from_value (value); } + /* rcpc3 'size' field. */ + if (inst->opcode->flags & F_RCPC3_SIZE) + { + value = extract_field (FLD_rcpc3_size, inst->value, 0); + for (int i = 0; + aarch64_operands[inst->operands[i].type].op_class != AARCH64_OPND_CLASS_ADDRESS; + i++) + { + if (aarch64_operands[inst->operands[i].type].op_class + == AARCH64_OPND_CLASS_INT_REG) + inst->operands[i].qualifier = get_greg_qualifier_from_value (value & 1); + else if (aarch64_operands[inst->operands[i].type].op_class + == AARCH64_OPND_CLASS_FP_REG) + { + value += (extract_field (FLD_opc1, inst->value, 0) << 2); + inst->operands[i].qualifier = get_sreg_qualifier_from_value (value); + } + } + } + /* size:Q fields. */ if (inst->opcode->flags & F_SIZEQ) return decode_sizeq (inst); |