* Use C++ style comments instead of C-style
[oota-llvm.git] / lib / CodeGen / MachineFunction.cpp
index 46036d0b58d8618621208d3b097b26587a3d291b..c1eb30a1966aeb7641aa6cf23e8842299047f303 100644 (file)
@@ -1,5 +1,12 @@
 //===-- MachineFunction.cpp -----------------------------------------------===//
 // 
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// 
+//===----------------------------------------------------------------------===//
+// 
 // Collect native machine code information for a function.  This allows
 // target-specific information about the generated code to be stored with each
 // function.
@@ -19,7 +26,7 @@
 #include "llvm/Function.h"
 #include "llvm/iOther.h"
 #include "llvm/Pass.h"
-#include <limits.h>
+#include "Config/limits.h"
 
 const int INVALID_FRAME_OFFSET = INT_MAX; // std::numeric_limits<int>::max();
 
@@ -80,15 +87,15 @@ namespace {
   };
 }
 
-Pass *createMachineCodeConstructionPass(TargetMachine &Target) {
+FunctionPass *createMachineCodeConstructionPass(TargetMachine &Target) {
   return new ConstructMachineFunction(Target);
 }
 
-Pass *createMachineCodeDestructionPass() {
+FunctionPass *createMachineCodeDestructionPass() {
   return new DestroyMachineFunction();
 }
 
-Pass *createMachineFunctionPrinterPass() {
+FunctionPass *createMachineFunctionPrinterPass() {
   return new Printer();
 }
 
@@ -120,13 +127,13 @@ void MachineFunction::print(std::ostream &OS) const {
      << "\"\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();
+    const BasicBlock *LBB = BB->getBasicBlock();
     OS << "\n" << LBB->getName() << " (" << (const void*)LBB << "):\n";
     for (MachineBasicBlock::const_iterator I = BB->begin(); I != BB->end();++I){
       OS << "\t";
@@ -188,7 +195,9 @@ int MachineFrameInfo::CreateStackObject(const TargetRegisterClass *RC) {
 }
 
 
-void MachineFrameInfo::print(std::ostream &OS) const {
+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 ";
@@ -200,11 +209,12 @@ void MachineFrameInfo::print(std::ostream &OS) const {
     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";
@@ -214,7 +224,9 @@ void MachineFrameInfo::print(std::ostream &OS) const {
     OS << "  Stack frame contains variable sized objects\n";
 }
 
-void MachineFrameInfo::dump() const { print(std::cerr); }
+void MachineFrameInfo::dump(const MachineFunction &MF) const {
+  print(MF, std::cerr);
+}
 
 
 //===----------------------------------------------------------------------===//
@@ -242,7 +254,7 @@ ComputeMaxOptionalArgsSize(const TargetMachine& target, const Function *F,
   
   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();