#include "llvm/CodeGen/MachineCodeForInstruction.h"
#include "llvm/CodeGen/SSARegMap.h"
#include "llvm/CodeGen/MachineFunctionInfo.h"
-#include "llvm/CodeGen/FunctionFrameInfo.h"
+#include "llvm/CodeGen/MachineFrameInfo.h"
+#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetFrameInfo.h"
-#include "llvm/Target/MachineCacheInfo.h"
+#include "llvm/Target/TargetCacheInfo.h"
#include "llvm/Function.h"
#include "llvm/iOther.h"
#include "llvm/Pass.h"
: Annotation(MF_AID), Fn(F), Target(TM) {
SSARegMapping = new SSARegMap();
MFInfo = new MachineFunctionInfo(*this);
- FrameInfo = new FunctionFrameInfo();
+ FrameInfo = new MachineFrameInfo();
+ ConstantPool = new MachineConstantPool();
}
MachineFunction::~MachineFunction() {
delete SSARegMapping;
delete MFInfo;
delete FrameInfo;
+ delete ConstantPool;
}
void MachineFunction::dump() const { print(std::cerr); }
<< "\"\n";
// Print Frame Information
- getFrameInfo()->print(OS);
+ getFrameInfo()->print(*this, OS);
+
+ // Print Constant Pool
+ getConstantPool()->print(OS);
for (const_iterator BB = begin(); BB != end(); ++BB) {
BasicBlock *LBB = BB->getBasicBlock();
}
//===----------------------------------------------------------------------===//
-// FunctionFrameInfo implementation
+// MachineFrameInfo implementation
//===----------------------------------------------------------------------===//
-void FunctionFrameInfo::print(std::ostream &OS) const {
+/// CreateStackObject - Create a stack object for a value of the specified type.
+///
+int MachineFrameInfo::CreateStackObject(const Type *Ty, const TargetData &TD) {
+ return CreateStackObject(TD.getTypeSize(Ty), TD.getTypeAlignment(Ty));
+}
+
+int MachineFrameInfo::CreateStackObject(const TargetRegisterClass *RC) {
+ return CreateStackObject(RC->getSize(), RC->getAlignment());
+}
+
+
+void MachineFrameInfo::print(const MachineFunction &MF, std::ostream &OS) const{
+ int ValOffset = MF.getTarget().getFrameInfo().getOffsetOfLocalArea();
+
for (unsigned i = 0, e = Objects.size(); i != e; ++i) {
const StackObject &SO = Objects[i];
- OS << " <fi# " << (int)(i-NumFixedObjects) << "> is ";
+ OS << " <fi #" << (int)(i-NumFixedObjects) << "> is ";
if (SO.Size == 0)
OS << "variable sized";
else
if (i < NumFixedObjects)
OS << " fixed";
if (i < NumFixedObjects || SO.SPOffset != -1) {
+ int Off = SO.SPOffset + ValOffset;
OS << " at location [SP";
- if (SO.SPOffset > 0)
- OS << "+" << SO.SPOffset;
- else if (SO.SPOffset < 0)
- OS << SO.SPOffset;
+ if (Off > 0)
+ OS << "+" << Off;
+ else if (Off < 0)
+ OS << Off;
OS << "]";
}
OS << "\n";
OS << " Stack frame contains variable sized objects\n";
}
-void FunctionFrameInfo::dump() const { print(std::cerr); }
+void MachineFrameInfo::dump(const MachineFunction &MF) const {
+ print(MF, std::cerr);
+}
+
+
+//===----------------------------------------------------------------------===//
+// MachineConstantPool implementation
+//===----------------------------------------------------------------------===//
+
+void MachineConstantPool::print(std::ostream &OS) const {
+ for (unsigned i = 0, e = Constants.size(); i != e; ++i)
+ OS << " <cp #" << i << "> is" << *(Value*)Constants[i] << "\n";
+}
+void MachineConstantPool::dump() const { print(std::cerr); }
//===----------------------------------------------------------------------===//
// MachineFunctionInfo implementation
for (Function::const_iterator BB = F->begin(), BBE = F->end(); BB !=BBE; ++BB)
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I)
- if (const CallInst *callInst = dyn_cast<CallInst>(&*I))
+ if (const CallInst *callInst = dyn_cast<CallInst>(I))
{
unsigned numOperands = callInst->getNumOperands() - 1;
int numExtra = (int)numOperands-frameInfo.getNumFixedOutgoingArgs();