Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion llvm/include/llvm/CodeGen/MachineInstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ class MachineInstr
/// defined by this instruction.
unsigned DebugInstrNum;

/// Cached opcode from MCID.
uint16_t Opcode;

// Intrusive list support
friend struct ilist_traits<MachineInstr>;
friend struct ilist_callback_traits<MachineBasicBlock>;
Expand Down Expand Up @@ -563,7 +566,7 @@ class MachineInstr
const MCInstrDesc &getDesc() const { return *MCID; }

/// Returns the opcode of this MachineInstr.
unsigned getOpcode() const { return MCID->Opcode; }
unsigned getOpcode() const { return Opcode; }

/// Retuns the total number of operands.
unsigned getNumOperands() const { return NumOperands; }
Expand Down
6 changes: 4 additions & 2 deletions llvm/lib/CodeGen/MachineInstr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void MachineInstr::addImplicitDefUseOperands(MachineFunction &MF) {
MachineInstr::MachineInstr(MachineFunction &MF, const MCInstrDesc &TID,
DebugLoc DL, bool NoImp)
: MCID(&TID), NumOperands(0), Flags(0), AsmPrinterFlags(0),
DbgLoc(std::move(DL)), DebugInstrNum(0) {
DbgLoc(std::move(DL)), DebugInstrNum(0), Opcode(TID.Opcode) {
assert(DbgLoc.hasTrivialDestructor() && "Expected trivial destructor");

// Reserve space for the expected number of operands.
Expand All @@ -117,7 +117,8 @@ MachineInstr::MachineInstr(MachineFunction &MF, const MCInstrDesc &TID,
/// uniqueness.
MachineInstr::MachineInstr(MachineFunction &MF, const MachineInstr &MI)
: MCID(&MI.getDesc()), NumOperands(0), Flags(0), AsmPrinterFlags(0),
Info(MI.Info), DbgLoc(MI.getDebugLoc()), DebugInstrNum(0) {
Info(MI.Info), DbgLoc(MI.getDebugLoc()), DebugInstrNum(0),
Opcode(MI.getOpcode()) {
assert(DbgLoc.hasTrivialDestructor() && "Expected trivial destructor");

CapOperands = OperandCapacity::get(MI.getNumOperands());
Expand All @@ -143,6 +144,7 @@ void MachineInstr::setDesc(const MCInstrDesc &TID) {
if (getParent())
getMF()->handleChangeDesc(*this, TID);
MCID = &TID;
Opcode = TID.Opcode;
}

void MachineInstr::moveBefore(MachineInstr *MovePos) {
Expand Down