Author: lattner Date: Sun Dec 30 00:11:04 2007 New Revision: 45449 URL: http://llvm.org/viewvc/llvm-project?rev=45449&view=rev Log: make machine operands fatter: give each one an up-pointer to the machineinstr that owns it.
Modified: llvm/trunk/include/llvm/CodeGen/MachineInstr.h llvm/trunk/include/llvm/CodeGen/MachineOperand.h llvm/trunk/lib/CodeGen/MachineInstr.cpp Modified: llvm/trunk/include/llvm/CodeGen/MachineInstr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineInstr.h?rev=45449&r1=45448&r2=45449&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineInstr.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineInstr.h Sun Dec 30 00:11:04 2007 @@ -166,11 +166,15 @@ bool isImpReg = Op.isRegister() && Op.isImplicit(); assert((isImpReg || !OperandsComplete()) && "Trying to add an operand to a machine instr that is already done!"); - if (isImpReg || NumImplicitOps == 0) // This is true most of the time. + if (isImpReg || NumImplicitOps == 0) {// This is true most of the time. Operands.push_back(Op); - else + Operands.back().ParentMI = this; + } else { // Insert a real operand before any implicit ones. - Operands.insert(Operands.begin()+Operands.size()-NumImplicitOps, Op); + unsigned OpNo = Operands.size()-NumImplicitOps; + Operands.insert(Operands.begin()+OpNo, Op); + Operands[OpNo].ParentMI = this; + } } //===--------------------------------------------------------------------===// Modified: llvm/trunk/include/llvm/CodeGen/MachineOperand.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineOperand.h?rev=45449&r1=45448&r2=45449&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineOperand.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineOperand.h Sun Dec 30 00:11:04 2007 @@ -23,7 +23,8 @@ class MachineBasicBlock; class GlobalValue; - + class MachineInstr; + /// MachineOperand class - Representation of each machine instruction operand. /// class MachineOperand { @@ -48,6 +49,9 @@ int64_t immedVal; // For MO_Immediate and MO_*Index. } contents; + /// ParentMI - This is the instruction that this operand is embedded into. + MachineInstr *ParentMI; + MachineOperandType opType:8; // Discriminate the union. bool IsDef : 1; // True if this is a def, false if this is a use. bool IsImp : 1; // True if this is an implicit def or use. @@ -69,7 +73,7 @@ unsigned char subReg; } auxInfo; - MachineOperand() {} + MachineOperand() : ParentMI(0) {} void print(std::ostream &os) const; void print(std::ostream *os) const { if (os) print(*os); } @@ -335,6 +339,7 @@ IsDead = MO.IsDead; opType = MO.opType; auxInfo = MO.auxInfo; + ParentMI = MO.ParentMI; return *this; } Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=45449&r1=45448&r2=45449&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Sun Dec 30 00:11:04 2007 @@ -85,8 +85,10 @@ Operands.reserve(MI.getNumOperands()); // Add operands - for (unsigned i = 0; i != MI.getNumOperands(); ++i) + for (unsigned i = 0; i != MI.getNumOperands(); ++i) { Operands.push_back(MI.getOperand(i)); + Operands.back().ParentMI = this; + } // Set parent, next, and prev to null parent = 0; @@ -97,6 +99,10 @@ MachineInstr::~MachineInstr() { LeakDetector::removeGarbageObject(this); +#ifndef NDEBUG + for (unsigned i = 0, e = Operands.size(); i != e; ++i) + assert(Operands[i].ParentMI == this && "ParentMI mismatch!"); +#endif } /// getOpcode - Returns the opcode of this MachineInstr. _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits