reg_alloc: Correct OpArg::setBit for Reg

This commit is contained in:
MerryMage 2016-08-26 15:23:38 +01:00
parent 065c53ebfc
commit 59a8e14d1c
3 changed files with 26 additions and 3 deletions

View file

@ -191,7 +191,8 @@ HostLoc RegAlloc::UseHostLocReg(IR::Inst* use_inst, HostLocList desired_location
OpArg RegAlloc::UseOpArg(IR::Value use_value, HostLocList desired_locations) { OpArg RegAlloc::UseOpArg(IR::Value use_value, HostLocList desired_locations) {
if (use_value.IsImmediate()) { if (use_value.IsImmediate()) {
return Xbyak::Operand(); // return a None ASSERT_MSG(false, "UseOpArg does not support immediates");
return {}; // return a None
} }
IR::Inst* use_inst = use_value.GetInst(); IR::Inst* use_inst = use_value.GetInst();

View file

@ -26,7 +26,7 @@ namespace BackendX64 {
struct OpArg { struct OpArg {
OpArg() : type(OPERAND), inner_operand() {} OpArg() : type(OPERAND), inner_operand() {}
OpArg(const Xbyak::Address& address) : type(ADDRESS), inner_address(address) {} OpArg(const Xbyak::Address& address) : type(ADDRESS), inner_address(address) {}
OpArg(const Xbyak::Operand& operand) : type(OPERAND), inner_operand(operand) {} OpArg(const Xbyak::Reg& reg) : type(REG), inner_reg(reg) {}
Xbyak::Operand& operator*() { Xbyak::Operand& operator*() {
switch (type) { switch (type) {
@ -34,6 +34,8 @@ struct OpArg {
return inner_address; return inner_address;
case OPERAND: case OPERAND:
return inner_operand; return inner_operand;
case REG:
return inner_reg;
} }
ASSERT_MSG(false, "Unreachable"); ASSERT_MSG(false, "Unreachable");
} }
@ -46,6 +48,24 @@ struct OpArg {
case OPERAND: case OPERAND:
inner_operand.setBit(bits); inner_operand.setBit(bits);
return; return;
case REG:
switch (bits) {
case 8:
inner_reg = inner_reg.cvt8();
return;
case 16:
inner_reg = inner_reg.cvt16();
return;
case 32:
inner_reg = inner_reg.cvt32();
return;
case 64:
inner_reg = inner_reg.cvt64();
return;
default:
ASSERT_MSG(false, "Invalid bits");
return;
}
} }
ASSERT_MSG(false, "Unreachable"); ASSERT_MSG(false, "Unreachable");
} }
@ -54,11 +74,13 @@ private:
enum { enum {
OPERAND, OPERAND,
ADDRESS, ADDRESS,
REG,
} type; } type;
union { union {
Xbyak::Operand inner_operand; Xbyak::Operand inner_operand;
Xbyak::Address inner_address; Xbyak::Address inner_address;
Xbyak::Reg inner_reg;
}; };
}; };

View file

@ -308,7 +308,7 @@ TEST_CASE("Fuzz Thumb instructions set 1", "[JitX64][Thumb]") {
} }
SECTION("long blocks") { SECTION("long blocks") {
FuzzJitThumb(1024, 1025, 10, instruction_select); FuzzJitThumb(1024, 1025, 1000, instruction_select);
} }
} }