#include "SparcInternals.h"
#include "llvm/Analysis/SlotCalculator.h"
-#include "llvm/Transforms/Linker.h"
#include "llvm/CodeGen/MachineInstr.h"
+#include "llvm/CodeGen/MachineCodeForMethod.h"
#include "llvm/GlobalVariable.h"
-#include "llvm/GlobalValue.h"
#include "llvm/ConstantVals.h"
#include "llvm/DerivedTypes.h"
#include "llvm/BasicBlock.h"
#include "llvm/Module.h"
#include "Support/StringExtras.h"
#include "Support/HashExtras.h"
-#include <locale.h>
using std::string;
namespace {
public:
inline SparcAsmPrinter(std::ostream &o, const Module *M, const UltraSparc &t)
: toAsm(o), Table(SlotCalculator(M, true)), Target(t), CurSection(Unknown) {
- emitModule(M);
}
-private :
- void emitModule(const Module *M);
void emitMethod(const Method *M);
- void emitGlobalsAndConstants(const Module* module);
- //void processMethodArgument(const MethodArgument *MA);
+ void emitGlobalsAndConstants(const Module *M);
+private :
void emitBasicBlock(const BasicBlock *BB);
void emitMachineInst(const MachineInstr *MI);
return target.findOptimalStorageSize(CV->getType());
}
-inline
-unsigned int TypeToSize(const Type* type, const TargetMachine& target)
-{
- return target.findOptimalStorageSize(type);
-}
// Align data larger than one L1 cache line on L1 cache line boundaries.
<< TypeToAlignment(GV->getType()->getElementType(), Target) << "\n";
toAsm << "\t.type\t" << getID(GV) << ",#object\n";
toAsm << "\t.reserve\t" << getID(GV) << ","
- << TypeToSize(GV->getType()->getElementType(), Target)
+ << Target.findOptimalStorageSize(GV->getType()->getElementType())
<< "\n";
}
}
toAsm << "\n";
}
+} // End anonymous namespace
+
+//
+// emitAssembly - Output assembly language code (a .s file) for global
+// components of the specified module. This assumes that methods have been
+// previously output.
+//
void
-SparcAsmPrinter::emitModule(const Module *M)
+UltraSparc::emitAssembly(const Method *M, std::ostream &OutStr) const
{
- // TODO: Look for a filename annotation on M to emit a .file directive
- for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I)
- emitMethod(*I);
-
- emitGlobalsAndConstants(M);
+ SparcAsmPrinter Print(OutStr, M->getParent(), *this);
+ Print.emitMethod(M);
}
-} // End anonymous namespace
-
-
//
// emitAssembly - Output assembly language code (a .s file) for the specified
// method. The specified method must have been compiled before this may be
// used.
//
void
-UltraSparc::emitAssembly(const Module *M, std::ostream &toAsm) const
+UltraSparc::emitAssembly(const Module *M, std::ostream &OutStr) const
{
- SparcAsmPrinter Print(toAsm, M, *this);
+ SparcAsmPrinter Print(OutStr, M, *this);
+ Print.emitGlobalsAndConstants(M);
}
+