summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineFunction.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-02-09 04:46:04 +0000
committerChris Lattner <sabre@nondot.org>2006-02-09 04:46:04 +0000
commitf6190821da476057d0fa75a2c7e83fa0bc018579 (patch)
treeaf838ac482e63a5d9f05c799c1664f5791b22585 /llvm/lib/CodeGen/MachineFunction.cpp
parent8bb44151e1d7d0e3309c4fa8a3befc20b78a7c42 (diff)
downloadbcm5719-llvm-f6190821da476057d0fa75a2c7e83fa0bc018579.tar.gz
bcm5719-llvm-f6190821da476057d0fa75a2c7e83fa0bc018579.zip
Adjust to MachineConstantPool interface change: instead of keeping a
value/alignment pair for each constant, keep a value/offset pair. llvm-svn: 26078
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunction.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineFunction.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp
index 94d87159886..6fdd03847ef 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -112,7 +112,7 @@ MachineFunction::MachineFunction(const Function *F,
SSARegMapping = new SSARegMap();
MFInfo = 0;
FrameInfo = new MachineFrameInfo();
- ConstantPool = new MachineConstantPool();
+ ConstantPool = new MachineConstantPool(TM.getTargetData());
BasicBlocks.Parent = this;
}
@@ -345,10 +345,38 @@ void MachineFrameInfo::dump(const MachineFunction &MF) const {
// MachineConstantPool implementation
//===----------------------------------------------------------------------===//
+/// getConstantPoolIndex - Create a new entry in the constant pool or return
+/// an existing one. User must specify an alignment in bytes for the object.
+///
+unsigned MachineConstantPool::getConstantPoolIndex(Constant *C,
+ unsigned Alignment) {
+ assert(Alignment && "Alignment must be specified!");
+ if (Alignment > PoolAlignment) PoolAlignment = Alignment;
+
+ // Check to see if we already have this constant.
+ //
+ // FIXME, this could be made much more efficient for large constant pools.
+ unsigned AlignMask = (1 << Alignment)-1;
+ for (unsigned i = 0, e = Constants.size(); i != e; ++i)
+ if (Constants[i].Val == C && (Constants[i].Offset & AlignMask) == 0)
+ return i;
+
+ unsigned Offset = 0;
+ if (!Constants.empty()) {
+ Offset = Constants.back().Offset;
+ Offset += TD.getTypeSize(Constants.back().Val->getType());
+ Offset = (Offset+AlignMask)&~AlignMask;
+ }
+
+ Constants.push_back(MachineConstantPoolEntry(C, Offset));
+ return Constants.size()-1;
+}
+
+
void MachineConstantPool::print(std::ostream &OS) const {
for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
OS << " <cp #" << i << "> is" << *(Value*)Constants[i].Val;
- OS << " , align=" << Constants[i].Alignment;
+ OS << " , offset=" << Constants[i].Offset;
OS << "\n";
}
}
OpenPOWER on IntegriCloud