Commit 8c61e806 authored by swift_gan's avatar swift_gan

tweak code

parent 44b68896
...@@ -137,7 +137,7 @@ void A64_B_BL::assembler() { ...@@ -137,7 +137,7 @@ void A64_B_BL::assembler() {
A64_CBZ_CBNZ::A64_CBZ_CBNZ() {} A64_CBZ_CBNZ::A64_CBZ_CBNZ() {}
A64_CBZ_CBNZ::A64_CBZ_CBNZ(aarch64_cbz_cbnz *inst) : A64_INST_PC_REL(inst) { A64_CBZ_CBNZ::A64_CBZ_CBNZ(STRUCT_A64(CBZ_CBNZ) *inst) : A64_INST_PC_REL(inst) {
decode(inst); decode(inst);
} }
...@@ -151,7 +151,7 @@ ADDR A64_CBZ_CBNZ::getImmPCOffset() { ...@@ -151,7 +151,7 @@ ADDR A64_CBZ_CBNZ::getImmPCOffset() {
return signExtend64(19 + 2, COMBINE(get()->imm19, 0b00, 2)); return signExtend64(19 + 2, COMBINE(get()->imm19, 0b00, 2));
} }
void A64_CBZ_CBNZ::decode(aarch64_cbz_cbnz *inst) { void A64_CBZ_CBNZ::decode(STRUCT_A64(CBZ_CBNZ) *inst) {
op = OP(get()->op); op = OP(get()->op);
if (inst->sf == 1) { if (inst->sf == 1) {
rt = XRegister::get(static_cast<U8>(inst->rt)); rt = XRegister::get(static_cast<U8>(inst->rt));
...@@ -174,7 +174,7 @@ void A64_CBZ_CBNZ::assembler() { ...@@ -174,7 +174,7 @@ void A64_CBZ_CBNZ::assembler() {
A64_B_COND::A64_B_COND() {} A64_B_COND::A64_B_COND() {}
A64_B_COND::A64_B_COND(aarch64_b_cond *inst) : A64_INST_PC_REL(inst) { A64_B_COND::A64_B_COND(STRUCT_A64(B_COND) *inst) : A64_INST_PC_REL(inst) {
decode(inst); decode(inst);
} }
...@@ -186,7 +186,7 @@ ADDR A64_B_COND::getImmPCOffset() { ...@@ -186,7 +186,7 @@ ADDR A64_B_COND::getImmPCOffset() {
return signExtend64(19 + 2, COMBINE(get()->imm19, 0b00, 2)); return signExtend64(19 + 2, COMBINE(get()->imm19, 0b00, 2));
} }
void A64_B_COND::decode(aarch64_b_cond *inst) { void A64_B_COND::decode(STRUCT_A64(B_COND) *inst) {
condition = Condition(inst->cond); condition = Condition(inst->cond);
offset = getImmPCOffset(); offset = getImmPCOffset();
} }
...@@ -202,7 +202,7 @@ void A64_B_COND::assembler() { ...@@ -202,7 +202,7 @@ void A64_B_COND::assembler() {
A64_TBZ_TBNZ::A64_TBZ_TBNZ() {} A64_TBZ_TBNZ::A64_TBZ_TBNZ() {}
A64_TBZ_TBNZ::A64_TBZ_TBNZ(aarch64_tbz_tbnz *inst) : A64_INST_PC_REL(inst) { A64_TBZ_TBNZ::A64_TBZ_TBNZ(STRUCT_A64(TBZ_TBNZ) *inst) : A64_INST_PC_REL(inst) {
decode(inst); decode(inst);
} }
...@@ -217,7 +217,7 @@ ADDR A64_TBZ_TBNZ::getImmPCOffset() { ...@@ -217,7 +217,7 @@ ADDR A64_TBZ_TBNZ::getImmPCOffset() {
return signExtend64(14, get()->imm14) << 2; return signExtend64(14, get()->imm14) << 2;
} }
void A64_TBZ_TBNZ::decode(aarch64_tbz_tbnz *inst) { void A64_TBZ_TBNZ::decode(STRUCT_A64(TBZ_TBNZ) *inst) {
bit = COMBINE(inst->b5, inst->b40, 5); bit = COMBINE(inst->b5, inst->b40, 5);
if (inst->b5 == 1) { if (inst->b5 == 1) {
rt = XRegister::get(static_cast<U8>(inst->rt)); rt = XRegister::get(static_cast<U8>(inst->rt));
......
...@@ -228,7 +228,7 @@ namespace SandHook { ...@@ -228,7 +228,7 @@ namespace SandHook {
}; };
class INST_A64(CBZ_CBNZ) : public A64_INST_PC_REL<aarch64_cbz_cbnz> { class INST_A64(CBZ_CBNZ) : public A64_INST_PC_REL<STRUCT_A64(CBZ_CBNZ)> {
public: public:
enum OP { enum OP {
...@@ -238,7 +238,7 @@ namespace SandHook { ...@@ -238,7 +238,7 @@ namespace SandHook {
A64_CBZ_CBNZ(); A64_CBZ_CBNZ();
A64_CBZ_CBNZ(aarch64_cbz_cbnz *inst); A64_CBZ_CBNZ(STRUCT_A64(CBZ_CBNZ) *inst);
A64_CBZ_CBNZ(OP op, ADDR offset, RegisterA64 *rt); A64_CBZ_CBNZ(OP op, ADDR offset, RegisterA64 *rt);
...@@ -248,7 +248,7 @@ namespace SandHook { ...@@ -248,7 +248,7 @@ namespace SandHook {
ADDR getImmPCOffset() override; ADDR getImmPCOffset() override;
void decode(aarch64_cbz_cbnz *inst) override; void decode(STRUCT_A64(CBZ_CBNZ) *inst) override;
void assembler() override; void assembler() override;
...@@ -259,11 +259,11 @@ namespace SandHook { ...@@ -259,11 +259,11 @@ namespace SandHook {
}; };
class INST_A64(B_COND) : public A64_INST_PC_REL<aarch64_b_cond> { class INST_A64(B_COND) : public A64_INST_PC_REL<STRUCT_A64(B_COND)> {
public: public:
A64_B_COND(); A64_B_COND();
A64_B_COND(aarch64_b_cond *inst); A64_B_COND(STRUCT_A64(B_COND) *inst);
A64_B_COND(Condition condition, ADDR offset); A64_B_COND(Condition condition, ADDR offset);
...@@ -273,7 +273,7 @@ namespace SandHook { ...@@ -273,7 +273,7 @@ namespace SandHook {
ADDR getImmPCOffset() override; ADDR getImmPCOffset() override;
void decode(aarch64_b_cond *inst) override; void decode(STRUCT_A64(B_COND) *inst) override;
void assembler() override; void assembler() override;
...@@ -283,7 +283,7 @@ namespace SandHook { ...@@ -283,7 +283,7 @@ namespace SandHook {
}; };
class INST_A64(TBZ_TBNZ) : public A64_INST_PC_REL<aarch64_tbz_tbnz> { class INST_A64(TBZ_TBNZ) : public A64_INST_PC_REL<STRUCT_A64(TBZ_TBNZ)> {
public: public:
enum OP { enum OP {
...@@ -293,7 +293,7 @@ namespace SandHook { ...@@ -293,7 +293,7 @@ namespace SandHook {
A64_TBZ_TBNZ(); A64_TBZ_TBNZ();
A64_TBZ_TBNZ(aarch64_tbz_tbnz *inst); A64_TBZ_TBNZ(STRUCT_A64(TBZ_TBNZ) *inst);
A64_TBZ_TBNZ(OP op, RegisterA64 *rt, U32 bit, ADDR offset); A64_TBZ_TBNZ(OP op, RegisterA64 *rt, U32 bit, ADDR offset);
...@@ -303,7 +303,7 @@ namespace SandHook { ...@@ -303,7 +303,7 @@ namespace SandHook {
ADDR getImmPCOffset() override; ADDR getImmPCOffset() override;
void decode(aarch64_tbz_tbnz *inst) override; void decode(STRUCT_A64(TBZ_TBNZ) *inst) override;
void assembler() override; void assembler() override;
......
...@@ -95,7 +95,7 @@ struct STRUCT_A64(B_BL) { ...@@ -95,7 +95,7 @@ struct STRUCT_A64(B_BL) {
}; };
DEFINE_OPCODE(CBZ_CBNZ, 0b011010) DEFINE_OPCODE(CBZ_CBNZ, 0b011010)
struct aarch64_cbz_cbnz { struct STRUCT_A64(CBZ_CBNZ) {
InstA64 sf:1; InstA64 sf:1;
InstA64 opcode:6; InstA64 opcode:6;
InstA64 op:1; InstA64 op:1;
...@@ -104,7 +104,7 @@ struct aarch64_cbz_cbnz { ...@@ -104,7 +104,7 @@ struct aarch64_cbz_cbnz {
}; };
DEFINE_OPCODE(B_COND, 0b01010100) DEFINE_OPCODE(B_COND, 0b01010100)
struct aarch64_b_cond { struct STRUCT_A64(B_COND) {
InstA64 opcode:8; InstA64 opcode:8;
InstA64 imm19:19; InstA64 imm19:19;
InstA64 unkown:1; InstA64 unkown:1;
...@@ -113,7 +113,7 @@ struct aarch64_b_cond { ...@@ -113,7 +113,7 @@ struct aarch64_b_cond {
DEFINE_OPCODE(TBZ_TBNZ, 0b011011) DEFINE_OPCODE(TBZ_TBNZ, 0b011011)
struct aarch64_tbz_tbnz { struct STRUCT_A64(TBZ_TBNZ) {
InstA64 b5:1; InstA64 b5:1;
InstA64 opcode:6; InstA64 opcode:6;
InstA64 op:1; InstA64 op:1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment