#ifndef LLVM_CODEGEN_MACHINEINSTR_H
#define LLVM_CODEGEN_MACHINEINSTR_H
-#include "Support/iterator"
+#include "llvm/ADT/iterator"
+#include <string>
#include <vector>
#include <cassert>
MachineOperand(int ImmVal = 0, MachineOperandType OpTy = MO_VirtualRegister)
: flags(0), opType(OpTy), regNum(-1) {
zeroContents ();
+ contents.immedVal = ImmVal;
}
MachineOperand(int Reg, MachineOperandType OpTy, UseType UseTy)
contents.SymbolName = new std::string(M.getSymbolName());
}
+
~MachineOperand() {
if (isExternalSymbol())
delete contents.SymbolName;
assert(isMachineBasicBlock() && "Wrong MachineOperand accessor");
return contents.MBB;
}
+ void setMachineBasicBlock(MachineBasicBlock *MBB) {
+ assert(isMachineBasicBlock() && "Wrong MachineOperand accessor");
+ contents.MBB = MBB;
+ }
int getFrameIndex() const {
assert(isFrameIndex() && "Wrong MachineOperand accessor");
return contents.immedVal;
// code.' It's not clear where the duplication is.
assert(hasAllocatedReg() && "This operand cannot have a register number!");
regNum = Reg;
- }
+ }
+
+ void setValueReg(Value *val) {
+ assert(getVRegValueOrNull() != 0 && "Original operand must of type Value*");
+ contents.value = val;
+ }
+
void setImmedValue(int immVal) {
assert(isImmediate() && "Wrong MachineOperand mutator");
contents.immedVal = immVal;
friend std::ostream& operator<<(std::ostream& os, const MachineOperand& mop);
-private:
- /// markHi32, markLo32, etc. - These methods must be accessed via
- /// corresponding methods in MachineInstr. These methods are deprecated
- /// and only used by the SPARC v9 back-end.
+ /// markHi32, markLo32, etc. - These methods are deprecated and only used by
+ /// the SPARC v9 back-end.
///
void markHi32() { flags |= HIFLAG32; }
void markLo32() { flags |= LOFLAG32; }
void markHi64() { flags |= HIFLAG64; }
void markLo64() { flags |= LOFLAG64; }
+private:
/// setRegForValue - Replaces the Value with its corresponding physical
/// register after register allocation is complete. This is deprecated
/// and only used by the SPARC v9 back-end.
// OperandComplete - Return true if it's illegal to add a new operand
bool OperandsComplete() const;
- MachineInstr(const MachineInstr &); // DO NOT IMPLEMENT
+ //Constructor used by clone() method
+ MachineInstr(const MachineInstr&);
+
void operator=(const MachineInstr&); // DO NOT IMPLEMENT
// Intrusive list support
MachineOperand::MO_VirtualRegister, V);
}
+ /// clone - Create a copy of 'this' instruction that is identical in
+ /// all ways except the the instruction has no parent, prev, or next.
+ MachineInstr* clone() const;
+
//
// Debugging support
//
- void print(std::ostream &OS, const TargetMachine &TM) const;
+ void print(std::ostream &OS, const TargetMachine *TM) const;
void dump() const;
friend std::ostream& operator<<(std::ostream& os, const MachineInstr& minstr);
unsigned substituteValue(const Value* oldVal, Value* newVal,
bool defsOnly, bool notDefsAndUses,
bool& someArgsWereIgnored);
-
- void setOperandHi32(unsigned i) { operands[i].markHi32(); }
- void setOperandLo32(unsigned i) { operands[i].markLo32(); }
- void setOperandHi64(unsigned i) { operands[i].markHi64(); }
- void setOperandLo64(unsigned i) { operands[i].markLo64(); }
-
// SetRegForOperand -
// SetRegForImplicitRef -