Skip to content

Commit

Permalink
Refactor HPPA
Browse files Browse the repository at this point in the history
  • Loading branch information
R33v0LT committed Mar 17, 2024
1 parent cfbc9b2 commit 3c9e766
Show file tree
Hide file tree
Showing 11 changed files with 1,070 additions and 1,421 deletions.
1 change: 1 addition & 0 deletions MCInst.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void MCInst_Init(MCInst *inst)
inst->tied_op_idx[i] = -1;
inst->isAliasInstr = false;
inst->fillDetailOps = false;
memset(&inst->hppa_ext, 0, sizeof(inst->hppa_ext));
}

void MCInst_clear(MCInst *inst)
Expand Down
1 change: 1 addition & 0 deletions Mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ DEFINE_get_detail_op(ppc, PPC);
DEFINE_get_detail_op(tricore, TriCore);
DEFINE_get_detail_op(aarch64, AArch64);
DEFINE_get_detail_op(alpha, Alpha);
DEFINE_get_detail_op(hppa, HPPA);

/// Returns true if for this architecture the
/// alias operands should be filled.
Expand Down
4 changes: 4 additions & 0 deletions Mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ DECL_get_detail_op(ppc, PPC);
DECL_get_detail_op(tricore, TriCore);
DECL_get_detail_op(aarch64, AArch64);
DECL_get_detail_op(alpha, Alpha);
DECL_get_detail_op(hppa, HPPA);

/// Increments the detail->arch.op_count by one.
#define DEFINE_inc_detail_op_count(arch, ARCH) \
Expand All @@ -149,6 +150,8 @@ DEFINE_inc_detail_op_count(aarch64, AArch64);
DEFINE_dec_detail_op_count(aarch64, AArch64);
DEFINE_inc_detail_op_count(alpha, Alpha);
DEFINE_dec_detail_op_count(alpha, Alpha);
DEFINE_inc_detail_op_count(hppa, HPPA);
DEFINE_dec_detail_op_count(hppa, HPPA);

/// Returns true if a memory operand is currently edited.
static inline bool doing_mem(const MCInst *MI)
Expand All @@ -175,6 +178,7 @@ DEFINE_get_arch_detail(ppc, PPC);
DEFINE_get_arch_detail(tricore, TriCore);
DEFINE_get_arch_detail(aarch64, AArch64);
DEFINE_get_arch_detail(alpha, Alpha);
DEFINE_get_arch_detail(hppa, HPPA);

static inline bool detail_is_set(const MCInst *MI)
{
Expand Down
16 changes: 16 additions & 0 deletions MathExtras.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,13 @@ static inline int64_t SignExtend64(uint64_t X, unsigned B) {
return (int64_t)(X << (64 - B)) >> (64 - B);
}

/// \brief Removes the rightmost bit of x and extends the field to the left with that
/// bit to form a 64-bit quantity. The field is of size len
static inline int64_t LowSignExtend64(uint64_t x, unsigned len)
{
return (x >> 1) - ((x & 1) << (len - 1));
}

/// \brief One extend number X starting at bit B and returns it as int32_t.
/// Requires 0 < B <= 32.
static inline int32_t OneExtend32(uint32_t X, unsigned B) {
Expand Down Expand Up @@ -467,4 +474,13 @@ static inline unsigned int countLeadingZeros(int x)
return count;
}

/// \brief Get specified field from 32-bit instruction. Returns bits from the segment [from, to]
static inline uint32_t get_insn_field(uint32_t insn, uint8_t from, uint8_t to) {
return insn >> (31 - to) & ((1 << (to - from + 1)) - 1);
}
/// \brief Get specified bit from 32-bit instruction
static inline uint32_t get_insn_bit(uint32_t insn, uint8_t bit) {
return get_insn_field(insn, bit, bit);
}

#endif
Loading

0 comments on commit 3c9e766

Please sign in to comment.