aboutsummaryrefslogtreecommitdiff
path: root/opcodes/aarch64-asm.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2016-09-21 16:51:16 +0100
committerRichard Sandiford <richard.sandiford@arm.com>2016-09-21 16:51:16 +0100
commitb5464a6825e40e6d8ab2dd86c7ff5d65bedd64d4 (patch)
treed20a8aec105117180a6d86412a769c762ac6ee7c /opcodes/aarch64-asm.c
parent42408347b86745fdbd4bec9ee3a6a3fee31c4dee (diff)
downloadgdb-b5464a6825e40e6d8ab2dd86c7ff5d65bedd64d4.zip
gdb-b5464a6825e40e6d8ab2dd86c7ff5d65bedd64d4.tar.gz
gdb-b5464a6825e40e6d8ab2dd86c7ff5d65bedd64d4.tar.bz2
[AArch64][SVE 15/32] Add {insert,extract}_all_fields helpers
Several of the SVE operands use the aarch64_operand fields array to store the fields that make up the operand, rather than hard-coding the names in the C code. This patch adds helpers for inserting and extracting those fields. opcodes/ * aarch64-asm.c: Include libiberty.h. (insert_fields): New function. (aarch64_ins_imm): Use it. * aarch64-dis.c (extract_fields): New function. (aarch64_ext_imm): Use it.
Diffstat (limited to 'opcodes/aarch64-asm.c')
-rw-r--r--opcodes/aarch64-asm.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/opcodes/aarch64-asm.c b/opcodes/aarch64-asm.c
index 8fbd66f..3b0a383 100644
--- a/opcodes/aarch64-asm.c
+++ b/opcodes/aarch64-asm.c
@@ -20,6 +20,7 @@
#include "sysdep.h"
#include <stdarg.h>
+#include "libiberty.h"
#include "aarch64-asm.h"
/* Utilities. */
@@ -55,6 +56,25 @@ insert_fields (aarch64_insn *code, aarch64_insn value, aarch64_insn mask, ...)
va_end (va);
}
+/* Insert a raw field value VALUE into all fields in SELF->fields.
+ The least significant bit goes in the final field. */
+
+static void
+insert_all_fields (const aarch64_operand *self, aarch64_insn *code,
+ aarch64_insn value)
+{
+ unsigned int i;
+ enum aarch64_field_kind kind;
+
+ for (i = ARRAY_SIZE (self->fields); i-- > 0; )
+ if (self->fields[i] != FLD_NIL)
+ {
+ kind = self->fields[i];
+ insert_field (kind, code, value, 0);
+ value >>= fields[kind].width;
+ }
+}
+
/* Operand inserters. */
/* Insert register number. */
@@ -318,17 +338,11 @@ aarch64_ins_imm (const aarch64_operand *self, const aarch64_opnd_info *info,
const aarch64_inst *inst ATTRIBUTE_UNUSED)
{
int64_t imm;
- /* Maximum of two fields to insert. */
- assert (self->fields[2] == FLD_NIL);
imm = info->imm.value;
if (operand_need_shift_by_two (self))
imm >>= 2;
- if (self->fields[1] == FLD_NIL)
- insert_field (self->fields[0], code, imm, 0);
- else
- /* e.g. TBZ b5:b40. */
- insert_fields (code, imm, 0, 2, self->fields[1], self->fields[0]);
+ insert_all_fields (self, code, imm);
return NULL;
}