diff --git a/gematria/basic_block/basic_block.cc b/gematria/basic_block/basic_block.cc index 768e4462..db1a24e6 100644 --- a/gematria/basic_block/basic_block.cc +++ b/gematria/basic_block/basic_block.cc @@ -62,7 +62,8 @@ std::string AddressTuple::ToString() const { buffer << "base_register='" << base_register << "', "; buffer << "base_register_size=" << base_register_size << ", "; buffer << "base_register_intefered_register={"; - for (const std::string& interfered_register : base_register_intefered_register) { + for (const std::string& interfered_register : + base_register_intefered_register) { buffer << "'" << interfered_register << "', "; } buffer << "}, "; @@ -74,7 +75,8 @@ std::string AddressTuple::ToString() const { buffer << "index_Register='" << index_register << "', "; buffer << "index_register_size=" << index_register_size << ", "; buffer << "index_register_intefered_register={"; - for (const std::string& interfered_register : index_register_intefered_register) { + for (const std::string& interfered_register : + index_register_intefered_register) { buffer << "'" << interfered_register << "', "; } buffer << "}, "; @@ -86,7 +88,8 @@ std::string AddressTuple::ToString() const { buffer << "segment_register='" << segment_register << "', "; buffer << "segment_register_size=" << segment_register_size << ", "; buffer << "segment_register_intefered_register={"; - for (const std::string& interfered_register : segment_register_intefered_register) { + for (const std::string& interfered_register : + segment_register_intefered_register) { buffer << "'" << interfered_register << "', "; } buffer << "}, "; @@ -126,12 +129,15 @@ bool InstructionOperand::operator==(const InstructionOperand& other) const { } InstructionOperand InstructionOperand::VirtualRegister( - const std::string register_name, size_t size, const std::vector& interfered_registers) { + const std::string register_name, size_t size, + const std::vector& interfered_registers, + std::vector interfered_registers_size) { InstructionOperand result; result.type_ = OperandType::kVirtualRegister; result.register_name_ = std::move(register_name); result.size_ = size; result.interfered_registers_ = std::move(interfered_registers); + result.interfered_registers_size_ = std::move(interfered_registers_size); return result; } @@ -166,14 +172,16 @@ InstructionOperand InstructionOperand::Address(AddressTuple address_tuple) { return result; } -InstructionOperand InstructionOperand::Address(std::string base_register, - int64_t displacement, - std::string index_register, - int scaling, - std::string segment_register, - int base_register_size, - int index_register_size, - int segment_register_size) { +InstructionOperand InstructionOperand::Address( + std::string base_register, int64_t displacement, std::string index_register, + int scaling, std::string segment_register, int base_register_size, + int index_register_size, int segment_register_size, + const std::vector& base_register_intefered_register, + const std::vector& index_register_intefered_register, + const std::vector& segment_register_intefered_register, + const std::vector& base_register_intefered_register_size, + const std::vector& index_register_intefered_register_size, + const std::vector& segment_register_intefered_register_size) { InstructionOperand result; result.type_ = OperandType::kAddress; result.address_.base_register = std::move(base_register); @@ -184,9 +192,18 @@ InstructionOperand InstructionOperand::Address(std::string base_register, result.address_.base_register_size = base_register_size; result.address_.index_register_size = index_register_size; result.address_.segment_register_size = segment_register_size; - result.address_.base_register_intefered_register = {}; - result.address_.index_register_intefered_register = {}; - result.address_.segment_register_intefered_register = {}; + result.address_.base_register_intefered_register = + std::move(base_register_intefered_register); + result.address_.index_register_intefered_register = + std::move(index_register_intefered_register); + result.address_.segment_register_intefered_register = + std::move(segment_register_intefered_register); + result.address_.base_register_intefered_register_sizes = + std::move(base_register_intefered_register_size); + result.address_.index_register_intefered_register_sizes = + std::move(index_register_intefered_register_size); + result.address_.segment_register_intefered_register_sizes = + std::move(segment_register_intefered_register_size); return result; } diff --git a/gematria/basic_block/basic_block.h b/gematria/basic_block/basic_block.h index b2833aad..604102e8 100644 --- a/gematria/basic_block/basic_block.h +++ b/gematria/basic_block/basic_block.h @@ -44,7 +44,7 @@ inline constexpr std::string_view kDisplacementToken = "_DISPLACEMENT_"; inline constexpr std::string_view kVirtualRegisterToken = "_VREG"; inline std::string getVREG_TOKEN(size_t size) { return std::string(kVirtualRegisterToken) + std::to_string(size) + "_"; -} +} // The type of an operand of an instruction. enum class OperandType { @@ -83,13 +83,17 @@ struct AddressTuple { AddressTuple() {} AddressTuple(const AddressTuple&) = default; AddressTuple(AddressTuple&&) = default; - AddressTuple(std::string base_register, int64_t displacement, - std::string index_register, int scaling, - std::string segment_register, int base_register_size = 64, - int index_register_size = 64, int segment_register_size = 64, - const std::vector base_register_intefered_register = {}, - const std::vector index_register_intefered_register = {}, - const std::vector segment_register_intefered_register = {}) + AddressTuple( + std::string base_register, int64_t displacement, + std::string index_register, int scaling, std::string segment_register, + int base_register_size = 64, int index_register_size = 64, + int segment_register_size = 64, + const std::vector base_register_intefered_register = {}, + const std::vector index_register_intefered_register = {}, + const std::vector segment_register_intefered_register = {}, + const std::vector base_register_intefered_register_sizes = {}, + const std::vector index_register_intefered_register_sizes = {}, + const std::vector segment_register_intefered_register_sizes = {}) : base_register(std::move(base_register)), displacement(displacement), index_register(std::move(index_register)), @@ -98,10 +102,18 @@ struct AddressTuple { base_register_size(std::move(base_register_size)), index_register_size(std::move(index_register_size)), segment_register_size(std::move(segment_register_size)), - base_register_intefered_register(std::move(base_register_intefered_register)), - index_register_intefered_register(std::move(index_register_intefered_register)), - segment_register_intefered_register(std::move(segment_register_intefered_register)) - {} + base_register_intefered_register( + std::move(base_register_intefered_register)), + base_register_intefered_register_sizes( + std::move(base_register_intefered_register_sizes)), + index_register_intefered_register( + std::move(index_register_intefered_register)), + index_register_intefered_register_sizes( + std::move(index_register_intefered_register_sizes)), + segment_register_intefered_register( + std::move(segment_register_intefered_register)), + segment_register_intefered_register_sizes( + std::move(segment_register_intefered_register_sizes)) {} AddressTuple& operator=(const AddressTuple&) = default; AddressTuple& operator=(AddressTuple&&) = default; @@ -144,12 +156,18 @@ struct AddressTuple { // The size of the segment register. Used only when segment_register is size_t segment_register_size; - // The name of the index register of the address. When empty, index register + // The name and size of the base register of the address. When empty, base + // register std::vector base_register_intefered_register; - // The name of the index register of the address. When empty, index register + std::vector base_register_intefered_register_sizes; + // The name and size of the index register of the address. When empty, index + // register std::vector index_register_intefered_register; - // The name of the index register of the address. When empty, index register + std::vector index_register_intefered_register_sizes; + // The name of the segment register of the address. When empty, segment + // register std::vector segment_register_intefered_register; + std::vector segment_register_intefered_register_sizes; }; std::ostream& operator<<(std::ostream& os, const AddressTuple& address_tuple); @@ -170,19 +188,25 @@ class InstructionOperand { InstructionOperand& operator=(InstructionOperand&&) = default; // The operands must be created through one of the factory functions. - static InstructionOperand VirtualRegister(std::string register_name, - size_t size, const std::vector& interfered_registers); + static InstructionOperand VirtualRegister( + std::string register_name, size_t size, + const std::vector& interfered_registers, + std::vector interfered_registers_size); static InstructionOperand Register(std::string register_name); static InstructionOperand ImmediateValue(uint64_t immediate_value); static InstructionOperand FpImmediateValue(double fp_immediate_value); static InstructionOperand Address(AddressTuple address_tuple); - static InstructionOperand Address(std::string base_register, - int64_t displacement, - std::string index_register, int scaling, - std::string segment_register, - int base_register_size = 64, - int index_register_size = 64, - int segment_register_size = 64); + static InstructionOperand Address( + std::string base_register, int64_t displacement, + std::string index_register, int scaling, std::string segment_register, + int base_register_size = 64, int index_register_size = 64, + int segment_register_size = 64, + const std::vector& base_register_intefered_register = {}, + const std::vector& index_register_intefered_register = {}, + const std::vector& segment_register_intefered_register = {}, + const std::vector& base_register_intefered_register_sizes = {}, + const std::vector& index_register_intefered_register_sizes = {}, + const std::vector& segment_register_intefered_register_sizes = {}); static InstructionOperand MemoryLocation(int alias_group_id); bool operator==(const InstructionOperand&) const; @@ -198,9 +222,16 @@ class InstructionOperand { std::vector getInterferedRegisters() const { assert(type_ == OperandType::kVirtualRegister); + assert(interfered_registers_.size() == interfered_registers_size_.size()); return interfered_registers_; } + std::vector getInterferedRegistersSize() const { + assert(type_ == OperandType::kVirtualRegister); + assert(interfered_registers_.size() == interfered_registers_size_.size()); + return interfered_registers_size_; + } + // Returns a human-readable representation of the operand. // // This method implements the __str__() and __repr__() methods in the Python @@ -258,6 +289,7 @@ class InstructionOperand { AddressTuple address_; int alias_group_id_ = 0; std::vector interfered_registers_; + std::vector interfered_registers_size_; }; std::ostream& operator<<(std::ostream& os, const InstructionOperand& operand); diff --git a/gematria/basic_block/basic_block_protos.cc b/gematria/basic_block/basic_block_protos.cc index 969e7d5e..e1c36b7d 100644 --- a/gematria/basic_block/basic_block_protos.cc +++ b/gematria/basic_block/basic_block_protos.cc @@ -26,12 +26,16 @@ namespace gematria { namespace { - std::vector ToVector( +std::vector ToVector( const google::protobuf::RepeatedPtrField& protos) { return std::vector(protos.begin(), protos.end()); - } } +std::vector ToVector(const google::protobuf::RepeatedField& protos) { + return std::vector(protos.begin(), protos.end()); +} +} // namespace + AddressTuple AddressTupleFromProto( const CanonicalizedOperandProto::AddressTuple& proto) { auto result = AddressTuple( @@ -40,17 +44,26 @@ AddressTuple AddressTupleFromProto( /* index_register = */ proto.index_register(), /* scaling = */ proto.scaling(), /* segment_register = */ proto.segment()); - if (proto.base_register()[0] == '%'){ + if (proto.base_register()[0] == '%') { result.base_register_size = proto.base_register_size(); - result.base_register_intefered_register = ToVector(proto.base_register_intefered_register()); + result.base_register_intefered_register = + ToVector(proto.base_register_intefered_register()); + result.base_register_intefered_register_sizes = + ToVector(proto.base_register_intefered_register_sizes()); } - if (proto.index_register()[0] == '%'){ + if (proto.index_register()[0] == '%') { result.index_register_size = proto.index_register_size(); - result.index_register_intefered_register = ToVector(proto.index_register_intefered_register()); + result.index_register_intefered_register = + ToVector(proto.index_register_intefered_register()); + result.index_register_intefered_register_sizes = + ToVector(proto.index_register_intefered_register_sizes()); } - if (proto.segment()[0] == '%'){ + if (proto.segment()[0] == '%') { result.segment_register_size = proto.segment_size(); - result.segment_register_intefered_register = ToVector(proto.segment_intefered_register()); + result.segment_register_intefered_register = + ToVector(proto.segment_intefered_register()); + result.segment_register_intefered_register_sizes = + ToVector(proto.segment_intefered_register_sizes()); } return result; } @@ -63,21 +76,29 @@ CanonicalizedOperandProto::AddressTuple ProtoFromAddressTuple( proto.set_index_register(address_tuple.index_register); proto.set_scaling(address_tuple.scaling); proto.set_segment(address_tuple.segment_register); - if (!address_tuple.base_register.empty() && address_tuple.base_register[0] == '%') { + if (!address_tuple.base_register.empty() && + address_tuple.base_register[0] == '%') { proto.set_base_register_size(address_tuple.base_register_size); - for (auto interfered_register : address_tuple.base_register_intefered_register){ - proto.add_base_register_intefered_register(std::move(interfered_register)); + for (auto interfered_register : + address_tuple.base_register_intefered_register) { + proto.add_base_register_intefered_register( + std::move(interfered_register)); } } - if (!address_tuple.index_register.empty() && address_tuple.index_register[0] == '%') { + if (!address_tuple.index_register.empty() && + address_tuple.index_register[0] == '%') { proto.set_index_register_size(address_tuple.index_register_size); - for (auto interfered_register : address_tuple.index_register_intefered_register){ - proto.add_index_register_intefered_register(std::move(interfered_register)); + for (auto interfered_register : + address_tuple.index_register_intefered_register) { + proto.add_index_register_intefered_register( + std::move(interfered_register)); } } - if (!address_tuple.segment_register.empty() && address_tuple.segment_register[0] == '%') { + if (!address_tuple.segment_register.empty() && + address_tuple.segment_register[0] == '%') { proto.set_segment_size(address_tuple.segment_register_size); - for (auto interfered_register : address_tuple.segment_register_intefered_register){ + for (auto interfered_register : + address_tuple.segment_register_intefered_register) { proto.add_segment_intefered_register(std::move(interfered_register)); } } @@ -101,13 +122,15 @@ InstructionOperand InstructionOperandFromProto( case CanonicalizedOperandProto::kMemory: return InstructionOperand::MemoryLocation( proto.memory().alias_group_id()); - case CanonicalizedOperandProto::kVirtualRegister: - { - std::vector interfered_registers = ToVector(proto.intefered_register()); - return InstructionOperand::VirtualRegister( - proto.virtual_register().name(), proto.virtual_register().size(), interfered_registers); - } - + case CanonicalizedOperandProto::kVirtualRegister: { + std::vector interfered_registers = + ToVector(proto.intefered_register()); + std::vector interfered_register_sizes = + ToVector(proto.intefered_register_sizes()); + return InstructionOperand::VirtualRegister( + proto.virtual_register().name(), proto.virtual_register().size(), + interfered_registers, interfered_register_sizes); + } } } diff --git a/gematria/basic_block/basic_block_protos_test.cc b/gematria/basic_block/basic_block_protos_test.cc index 006dec19..faf09a66 100644 --- a/gematria/basic_block/basic_block_protos_test.cc +++ b/gematria/basic_block/basic_block_protos_test.cc @@ -83,19 +83,33 @@ TEST(InstructionOperandFromProtoTest, FpImmediateValue) { TEST(InstructionOperandFromProtoTest, Address) { const CanonicalizedOperandProto proto = ParseTextProto(R"pb( address { - base_register: 'RSI' + base_register: "%8" + base_register_size: 32 + base_register_intefered_register: "%0" + base_register_intefered_register_sizes: 32 index_register: 'RCX' displacement: 32 scaling: 1 segment: 'ES' })pb"); InstructionOperand operand = InstructionOperandFromProto(proto); - EXPECT_EQ(operand, - InstructionOperand::Address(/* base_register = */ "RSI", - /* displacement = */ 32, - /* index_register = */ "RCX", - /* scaling = */ 1, - /* segment_register = */ "ES")); + InstructionOperand expected_operand = InstructionOperand::Address( + /* base_register = */ "%8", + /* displacement = */ 32, + /* index_register = */ "RCX", + /* scaling = */ 1, + /* segment_register = */ "ES", + /* base_register_size = */ 32, // Assuming these are optional and have + // default values + /* index_register_size = */ 64, + /* segment_register_size = */ 64, + /* base_register_intefered_register = */ {"%0"}, + /* index_register_intefered_register = */ {}, + /* segment_register_intefered_register = */ {}, + /* base_register_intefered_register_sizes = */ {32}, + /* index_register_intefered_register_sizes = */ {}, + /* segment_register_intefered_register_sizes = */ {}); + EXPECT_EQ(operand, expected_operand); } TEST(InstructionOperandFromProtoTest, Memory) { @@ -239,10 +253,12 @@ TEST(BasicBlockFromProtoTest, VRegInstructions) { canonicalized_instructions { mnemonic: "CMP64RI32" llvm_mnemonic: "CMP64ri32" - input_operands { - virtual_register { name: "%60" size: 64 } + input_operands { + virtual_register { name: "%60" size: 64 } intefered_register: "%61" intefered_register: "%62" + intefered_register_sizes: 64 + intefered_register_sizes: 64 } input_operands { immediate_value: 0 } implicit_output_operands { register_name: "EFLAGS" } @@ -254,7 +270,8 @@ TEST(BasicBlockFromProtoTest, VRegInstructions) { /* mnemonic = */ "CMP64RI32", /* llvm_mnemonic = */ "CMP64ri32", /* prefixes = */ {}, /* input_operands = */ - {InstructionOperand::VirtualRegister("%60", 64, {"%61, %62"}), + {InstructionOperand::VirtualRegister("%60", 64, {"%61, %62"}, + {64, 64}), InstructionOperand::ImmediateValue(0)}, /* implicit_input_operands = */ {}, /* output_operands = */ {}, diff --git a/gematria/basic_block/python/basic_block.cc b/gematria/basic_block/python/basic_block.cc index 9e010f47..2c713698 100644 --- a/gematria/basic_block/python/basic_block.cc +++ b/gematria/basic_block/python/basic_block.cc @@ -156,17 +156,25 @@ PYBIND11_MODULE(basic_block, m) { py::arg("fp_immediate_value")) .def_static("from_virtual_register", &InstructionOperand::VirtualRegister, - py::arg("register_name"), py::arg("size"), py::arg("interfered_registers")) + py::arg("register_name"), py::arg("size"), py::arg("interfered_registers"), py::arg("interfered_register_sizes")) .def_static( + int /* index_register_size */, int /* segment_register_size */, + const std::vector&, const std::vector&, const std::vector&, + const std::vector&, const std::vector&, const std::vector&)>( "from_address", &InstructionOperand::Address, py::arg("base_register") = std::string(), py::arg("displacement") = 0, py::arg("index_register") = std::string(), py::arg("scaling") = 0, py::arg("segment_register") = std::string(), py::arg("base_register_size") = 64, - py::arg("index_register_size") = 64, py::arg("segment_register_size") = 64) + py::arg("index_register_size") = 64, py::arg("segment_register_size") = 64, + py::arg("base_register_intefered_register") = std::vector(), + py::arg("index_register_intefered_register") = std::vector(), + py::arg("segment_register_intefered_register") = std::vector(), + py::arg("base_register_intefered_register_sizes") = std::vector(), + py::arg("index_register_intefered_register_sizes") = std::vector(), + py::arg("segment_register_intefered_register_sizes") = std::vector()) .def_static( "from_address", &InstructionOperand::Address, py::arg("address_tuple")) diff --git a/gematria/datasets/bhive_importer.cc b/gematria/datasets/bhive_importer.cc index ae323c4e..90ca3f3c 100644 --- a/gematria/datasets/bhive_importer.cc +++ b/gematria/datasets/bhive_importer.cc @@ -567,37 +567,37 @@ absl::StatusOr BHiveImporter::addInterferenceGraph( BasicBlockProto& bb_proto, BHiveImporter::FunctionLiveIntervalInfo& func_live_infos, BHiveImporter::BhiveLiveRange& bb_range) { - std::set live_virtual_registers; - std::set live_physical_registers; + std::unordered_map live_virtual_registers; + std::unordered_map live_physical_registers; // helper function to update live_virtual_registers and // live_physical_registers auto update_live_regs = [&](const CanonicalizedOperandProto& operand) { if (operand.operand_case() == CanonicalizedOperandProto::kVirtualRegister) { - live_virtual_registers.insert(operand.virtual_register().name()); + live_virtual_registers[operand.virtual_register().name()] = operand.virtual_register().size(); } else if (operand.operand_case() == CanonicalizedOperandProto::kRegisterName) { - live_physical_registers.insert(operand.register_name()); + live_physical_registers[operand.register_name()] = 64; } else if (operand.operand_case() == CanonicalizedOperandProto::kAddress) { if (!operand.address().base_register().empty()) { if (operand.address().base_register()[0] == '%') { - live_virtual_registers.insert(operand.address().base_register()); + live_virtual_registers[operand.address().base_register()] = operand.address().base_register_size(); } else { - live_physical_registers.insert(operand.address().base_register()); + live_physical_registers[operand.address().base_register()] = 64; } } if (!operand.address().index_register().empty()) { if (operand.address().index_register()[0] == '%') { - live_virtual_registers.insert(operand.address().index_register()); + live_virtual_registers[operand.address().index_register()] = operand.address().index_register_size(); } else { - live_physical_registers.insert(operand.address().index_register()); + live_physical_registers[operand.address().index_register()] = 64; } } if (!operand.address().segment().empty()) { if (operand.address().segment()[0] == '%') { - live_virtual_registers.insert(operand.address().segment()); + live_virtual_registers[operand.address().segment()] = operand.address().segment_size(); } else { - live_physical_registers.insert(operand.address().segment()); + live_physical_registers[operand.address().segment()] = 64; } } } @@ -606,8 +606,9 @@ absl::StatusOr BHiveImporter::addInterferenceGraph( auto add_interference_on_name = [&](const std::string& name, google::protobuf::RepeatedPtrField* - mutable_intefered_register) { - for (auto vReg : live_virtual_registers) { + mutable_intefered_register, + google::protobuf::RepeatedField* mutable_intefered_register_size) { + for (auto [vReg, vRegSize] : live_virtual_registers) { if (vReg == name) continue; assert(func_live_infos.virtual_register_live_range_func.find(vReg) != func_live_infos.virtual_register_live_range_func.end() && @@ -620,11 +621,12 @@ absl::StatusOr BHiveImporter::addInterferenceGraph( if (!check_result.ok()) return check_result; if (*check_result) { - mutable_intefered_register->Add(std::move(vReg)); + mutable_intefered_register->Add(std::string(vReg)); + mutable_intefered_register_size->Add(std::move(vRegSize)); } } // add interference from physical registers to current operand - for (auto pReg : live_physical_registers) { + for (auto [pReg, pRegSize] : live_physical_registers) { auto subRegs = superreg2subreg_[pReg]; // if there's one subReg of Preg that has interference with current // operand then add interference to proto @@ -646,7 +648,8 @@ absl::StatusOr BHiveImporter::addInterferenceGraph( bb_range); if (!check_result.ok()) return check_result; if (*check_result) { - mutable_intefered_register->Add(std::move(pReg)); + mutable_intefered_register->Add(std::string(pReg)); + mutable_intefered_register_size->Add(std::move(pRegSize)); break; } } @@ -658,7 +661,8 @@ absl::StatusOr BHiveImporter::addInterferenceGraph( if (operand.operand_case() == CanonicalizedOperandProto::kVirtualRegister) { auto result = add_interference_on_name(operand.virtual_register().name(), - operand.mutable_intefered_register()); + operand.mutable_intefered_register(), + operand.mutable_intefered_register_sizes()); if (!result.ok()) return result; } else if (operand.operand_case() == CanonicalizedOperandProto::kAddress) { if (!operand.address().base_register().empty() && @@ -666,7 +670,9 @@ absl::StatusOr BHiveImporter::addInterferenceGraph( auto result = add_interference_on_name( operand.address().base_register(), operand.mutable_address() - ->mutable_base_register_intefered_register()); + ->mutable_base_register_intefered_register(), + operand.mutable_address() + ->mutable_base_register_intefered_register_sizes()); if (!result.ok()) return result; } if (!operand.address().index_register().empty() && @@ -674,14 +680,16 @@ absl::StatusOr BHiveImporter::addInterferenceGraph( auto result = add_interference_on_name( operand.address().index_register(), operand.mutable_address() - ->mutable_index_register_intefered_register()); + ->mutable_index_register_intefered_register(), + operand.mutable_address()->mutable_index_register_intefered_register_sizes()); if (!result.ok()) return result; } if (!operand.address().segment().empty() && operand.address().segment()[0] == '%') { auto result = add_interference_on_name( operand.address().segment(), - operand.mutable_address()->mutable_segment_intefered_register()); + operand.mutable_address()->mutable_segment_intefered_register(), + operand.mutable_address()->mutable_segment_intefered_register_sizes()); if (!result.ok()) return result; } } diff --git a/gematria/llvm/canonicalizer.cc b/gematria/llvm/canonicalizer.cc index 228d7326..32fc1a74 100644 --- a/gematria/llvm/canonicalizer.cc +++ b/gematria/llvm/canonicalizer.cc @@ -509,7 +509,7 @@ void X86Canonicalizer::AddOperand(const llvm::MachineInstr& mi, int operand_inde InstructionOperand::Register(name)); } else { operand_list.push_back( - InstructionOperand::VirtualRegister(name, size, {})); + InstructionOperand::VirtualRegister(name, size, {}, {})); } } else if (operand.isImm()) { operand_list.push_back( @@ -520,6 +520,9 @@ void X86Canonicalizer::AddOperand(const llvm::MachineInstr& mi, int operand_inde } else if (operand.isFPImm()) { operand_list.push_back(InstructionOperand::FpImmediateValue( llvm::bit_cast(operand.getFPImm()))); + } else if (operand.isFI()){ + operand_list.push_back( + InstructionOperand::Register("RBP")); } else { llvm::errs() << "Unsupported operand type: "; operand.print(llvm::errs()); diff --git a/gematria/proto/canonicalized_instruction.proto b/gematria/proto/canonicalized_instruction.proto index a72ece20..cdda6d4d 100644 --- a/gematria/proto/canonicalized_instruction.proto +++ b/gematria/proto/canonicalized_instruction.proto @@ -64,24 +64,30 @@ message CanonicalizedOperandProto { int32 base_register_size = 2; // Optional. The name of the registers where the current register interfered with repeated string base_register_intefered_register = 3; + // Optional. The size of the registers where the current register interfered with + repeated int32 base_register_intefered_register_sizes = 4; // The name of the index register; empty when an index register is not used. - string index_register = 4; + string index_register = 5; // The size of the index register in bytes; zero when an index register is not used - int32 index_register_size = 5; + int32 index_register_size = 6; // Optional. The name of the registers where the current register interfered with - repeated string index_register_intefered_register = 6; + repeated string index_register_intefered_register = 7; + // Optional. The size of the registers where the current register interfered with + repeated int32 index_register_intefered_register_sizes = 8; // The value of the displacement; zero if displacement is not used. - int64 displacement = 7; + int64 displacement = 9; // The value of the scaling factor; one if scaling is not used. - int32 scaling = 8; + int32 scaling = 10; // The name of the segment register; empty when an explicit segment register // is not given. - string segment = 9; + string segment = 11; // The size of the segment register in bytes; zero when an explicit segment // register is not given. - int32 segment_size = 10; + int32 segment_size = 12; // Optional. The name of the registers where the current register interfered with - repeated string segment_intefered_register = 11; + repeated string segment_intefered_register = 13; + // Optional. The size of the registers where the current register interfered with + repeated int32 segment_intefered_register_sizes = 14; } // Contains information about a memory operand of an instruction. We allow @@ -139,4 +145,5 @@ message CanonicalizedOperandProto { // Optional. The name of the registers where the current register interfered with repeated string intefered_register = 7; + repeated int32 intefered_register_sizes = 8; } \ No newline at end of file diff --git a/mir_input/test_mir_input/AdaptiveMaxPooling2d.liveinfo b/mir_input/test_mir_input/AdaptiveMaxPooling2d.liveinfo index cb875872..f01a80e3 100644 --- a/mir_input/test_mir_input/AdaptiveMaxPooling2d.liveinfo +++ b/mir_input/test_mir_input/AdaptiveMaxPooling2d.liveinfo @@ -325,7 +325,7 @@ DIL [0B,16r:0) 0@0B-phi DIH [0B,16r:0) 0@0B-phi HDI [0B,16r:0) 0@0B-phi %0 [16r,160r:0) 0@16r weight:0.000000e+00 -%1 [32r,64r:0)[96r,208r:1) 0@32r weight:0.000000e+00 +%1 [32r,64r:0) 0@32r weight:0.000000e+00 %3 [128r,144r:0) 0@128r weight:0.000000e+00 %5 [96r,112r:0) 0@96r weight:0.000000e+00 %6 [80r,96r:0) 0@80r weight:0.000000e+00