Skip to content

Commit 3c9e766

Browse files
committed
Refactor HPPA
1 parent cfbc9b2 commit 3c9e766

File tree

11 files changed

+1070
-1421
lines changed

11 files changed

+1070
-1421
lines changed

MCInst.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ void MCInst_Init(MCInst *inst)
3636
inst->tied_op_idx[i] = -1;
3737
inst->isAliasInstr = false;
3838
inst->fillDetailOps = false;
39+
memset(&inst->hppa_ext, 0, sizeof(inst->hppa_ext));
3940
}
4041

4142
void MCInst_clear(MCInst *inst)

Mapping.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ DEFINE_get_detail_op(ppc, PPC);
334334
DEFINE_get_detail_op(tricore, TriCore);
335335
DEFINE_get_detail_op(aarch64, AArch64);
336336
DEFINE_get_detail_op(alpha, Alpha);
337+
DEFINE_get_detail_op(hppa, HPPA);
337338

338339
/// Returns true if for this architecture the
339340
/// alias operands should be filled.

Mapping.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ DECL_get_detail_op(ppc, PPC);
124124
DECL_get_detail_op(tricore, TriCore);
125125
DECL_get_detail_op(aarch64, AArch64);
126126
DECL_get_detail_op(alpha, Alpha);
127+
DECL_get_detail_op(hppa, HPPA);
127128

128129
/// Increments the detail->arch.op_count by one.
129130
#define DEFINE_inc_detail_op_count(arch, ARCH) \
@@ -149,6 +150,8 @@ DEFINE_inc_detail_op_count(aarch64, AArch64);
149150
DEFINE_dec_detail_op_count(aarch64, AArch64);
150151
DEFINE_inc_detail_op_count(alpha, Alpha);
151152
DEFINE_dec_detail_op_count(alpha, Alpha);
153+
DEFINE_inc_detail_op_count(hppa, HPPA);
154+
DEFINE_dec_detail_op_count(hppa, HPPA);
152155

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

179183
static inline bool detail_is_set(const MCInst *MI)
180184
{

MathExtras.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,13 @@ static inline int64_t SignExtend64(uint64_t X, unsigned B) {
430430
return (int64_t)(X << (64 - B)) >> (64 - B);
431431
}
432432

433+
/// \brief Removes the rightmost bit of x and extends the field to the left with that
434+
/// bit to form a 64-bit quantity. The field is of size len
435+
static inline int64_t LowSignExtend64(uint64_t x, unsigned len)
436+
{
437+
return (x >> 1) - ((x & 1) << (len - 1));
438+
}
439+
433440
/// \brief One extend number X starting at bit B and returns it as int32_t.
434441
/// Requires 0 < B <= 32.
435442
static inline int32_t OneExtend32(uint32_t X, unsigned B) {
@@ -467,4 +474,13 @@ static inline unsigned int countLeadingZeros(int x)
467474
return count;
468475
}
469476

477+
/// \brief Get specified field from 32-bit instruction. Returns bits from the segment [from, to]
478+
static inline uint32_t get_insn_field(uint32_t insn, uint8_t from, uint8_t to) {
479+
return insn >> (31 - to) & ((1 << (to - from + 1)) - 1);
480+
}
481+
/// \brief Get specified bit from 32-bit instruction
482+
static inline uint32_t get_insn_bit(uint32_t insn, uint8_t bit) {
483+
return get_insn_field(insn, bit, bit);
484+
}
485+
470486
#endif

0 commit comments

Comments
 (0)