summaryrefslogtreecommitdiff
path: root/include/llvm/CodeGen/MachineInstrBuilder.h
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-07-07 23:14:23 +0000
committerDan Gohman <gohman@apple.com>2008-07-07 23:14:23 +0000
commit8e5f2c6f65841542e2a7092553fe42a00048e4c7 (patch)
tree24fe54b796f3f450ba6aff12b7357068ca66e341 /include/llvm/CodeGen/MachineInstrBuilder.h
parent0e5f1306b059b62d7725f324e087efbc8e7a782d (diff)
downloadllvm-8e5f2c6f65841542e2a7092553fe42a00048e4c7.tar.gz
llvm-8e5f2c6f65841542e2a7092553fe42a00048e4c7.tar.bz2
llvm-8e5f2c6f65841542e2a7092553fe42a00048e4c7.tar.xz
Pool-allocation for MachineInstrs, MachineBasicBlocks, and
MachineMemOperands. The pools are owned by MachineFunctions. This drastically reduces the number of calls to malloc/free made during the "Emit" phase of scheduling, as well as later phases in CodeGen. Combined with other changes, this speeds up the "instruction selection" phase of CodeGen by 10% in some cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53212 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/MachineInstrBuilder.h')
-rw-r--r--include/llvm/CodeGen/MachineInstrBuilder.h20
1 files changed, 8 insertions, 12 deletions
diff --git a/include/llvm/CodeGen/MachineInstrBuilder.h b/include/llvm/CodeGen/MachineInstrBuilder.h
index 748a9b4006..0b1f2f71b2 100644
--- a/include/llvm/CodeGen/MachineInstrBuilder.h
+++ b/include/llvm/CodeGen/MachineInstrBuilder.h
@@ -83,27 +83,23 @@ public:
MI->addOperand(MachineOperand::CreateES(FnName, 0));
return *this;
}
-
- /// addMemOperand - Add a memory operand to the machine instruction.
- const MachineInstrBuilder &addMemOperand(const MachineMemOperand &MO) const {
- MI->addMemOperand(MO);
- return *this;
- }
};
/// BuildMI - Builder interface. Specify how to create the initial instruction
/// itself.
///
-inline MachineInstrBuilder BuildMI(const TargetInstrDesc &TID) {
- return MachineInstrBuilder(new MachineInstr(TID));
+inline MachineInstrBuilder BuildMI(MachineFunction &MF,
+ const TargetInstrDesc &TID) {
+ return MachineInstrBuilder(MF.CreateMachineInstr(TID));
}
/// BuildMI - This version of the builder sets up the first operand as a
/// destination virtual register.
///
-inline MachineInstrBuilder BuildMI(const TargetInstrDesc &TID,
+inline MachineInstrBuilder BuildMI(MachineFunction &MF,
+ const TargetInstrDesc &TID,
unsigned DestReg) {
- return MachineInstrBuilder(new MachineInstr(TID)).addReg(DestReg, true);
+ return MachineInstrBuilder(MF.CreateMachineInstr(TID)).addReg(DestReg, true);
}
/// BuildMI - This version of the builder inserts the newly-built
@@ -114,7 +110,7 @@ inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
MachineBasicBlock::iterator I,
const TargetInstrDesc &TID,
unsigned DestReg) {
- MachineInstr *MI = new MachineInstr(TID);
+ MachineInstr *MI = BB.getParent()->CreateMachineInstr(TID);
BB.insert(I, MI);
return MachineInstrBuilder(MI).addReg(DestReg, true);
}
@@ -126,7 +122,7 @@ inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
MachineBasicBlock::iterator I,
const TargetInstrDesc &TID) {
- MachineInstr *MI = new MachineInstr(TID);
+ MachineInstr *MI = BB.getParent()->CreateMachineInstr(TID);
BB.insert(I, MI);
return MachineInstrBuilder(MI);
}