From 9953d86e635131a1e76ff76194143ae8ebbb4f07 Mon Sep 17 00:00:00 2001 From: Tanya Lattner Date: Sun, 23 May 2004 20:58:02 +0000 Subject: [PATCH] Fixed up my changes to add support for cloning Machine Instructions. llvm-svn: 13665 --- llvm/include/llvm/CodeGen/MachineInstr.h | 9 ++------- llvm/lib/CodeGen/MachineInstr.cpp | 5 +++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/llvm/include/llvm/CodeGen/MachineInstr.h b/llvm/include/llvm/CodeGen/MachineInstr.h index b6c18610ad3a..a488b45f7811 100644 --- a/llvm/include/llvm/CodeGen/MachineInstr.h +++ b/llvm/include/llvm/CodeGen/MachineInstr.h @@ -398,9 +398,6 @@ public: const MachineBasicBlock* getParent() const { return parent; } MachineBasicBlock* getParent() { return parent; } - //void setParent(const MachineBasicBlock *MBB) { parent = MBB; } - void setParent(MachineBasicBlock *MBB) { parent = MBB; } - /// getOpcode - Returns the opcode of this MachineInstr. /// const int getOpcode() const { return Opcode; } @@ -461,10 +458,8 @@ public: MachineOperand::MO_VirtualRegister, V); } - //Clone Instruction - //Create a copy of 'this' instruction that is - //identical in all ways except the following: The instruction has no - //parent The instruction has no name + /// 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(); // diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index e1e44fd47e09..401cd8b41723 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -73,7 +73,8 @@ MachineInstr::MachineInstr(MachineBasicBlock *MBB, short opcode, MachineInstr::MachineInstr(const MachineInstr &MI) { Opcode = MI.getOpcode(); numImplicitRefs = MI.getNumImplicitRefs(); - + operands.reserve(MI.getNumOperands()); + //Add operands for(unsigned i=0; i < MI.getNumOperands(); ++i) operands.push_back(MachineOperand(MI.getOperand(i))); @@ -89,7 +90,7 @@ MachineInstr::~MachineInstr() ///all ways except the following: The instruction has no parent The ///instruction has no name MachineInstr* MachineInstr::clone() { - MachineInstr* newInst = new MachineInstr(*this); + return new MachineInstr(*this); } /// OperandComplete - Return true if it's illegal to add a new operand