1 //===-- SparcTargetMachine.cpp - Define TargetMachine for Sparc -----------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
13 #include "SparcTargetAsmInfo.h"
14 #include "SparcTargetMachine.h"
16 #include "llvm/Module.h"
17 #include "llvm/PassManager.h"
18 #include "llvm/Target/TargetMachineRegistry.h"
21 // Register the target.
22 extern Target TheSparcTarget;
23 static RegisterTarget<SparcTargetMachine> X(TheSparcTarget, "sparc", "SPARC");
25 // No assembler printer by default
26 SparcTargetMachine::AsmPrinterCtorFn SparcTargetMachine::AsmPrinterCtor = 0;
29 // Force static initialization.
30 extern "C" void LLVMInitializeSparcTarget() { }
32 const TargetAsmInfo *SparcTargetMachine::createTargetAsmInfo() const {
33 // FIXME: Handle Solaris subtarget someday :)
34 return new SparcELFTargetAsmInfo(*this);
37 /// SparcTargetMachine ctor - Create an ILP32 architecture model
39 SparcTargetMachine::SparcTargetMachine(const Target &T, const Module &M,
40 const std::string &FS)
41 : LLVMTargetMachine(T),
42 DataLayout("E-p:32:32-f128:128:128"),
43 Subtarget(M, FS), TLInfo(*this), InstrInfo(Subtarget),
44 FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) {
47 bool SparcTargetMachine::addInstSelector(PassManagerBase &PM,
48 CodeGenOpt::Level OptLevel) {
49 PM.add(createSparcISelDag(*this));
53 /// addPreEmitPass - This pass may be implemented by targets that want to run
54 /// passes immediately before machine code is emitted. This should return
55 /// true if -print-machineinstrs should print out the code after the passes.
56 bool SparcTargetMachine::addPreEmitPass(PassManagerBase &PM,
57 CodeGenOpt::Level OptLevel){
58 PM.add(createSparcFPMoverPass(*this));
59 PM.add(createSparcDelaySlotFillerPass(*this));
63 bool SparcTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
64 CodeGenOpt::Level OptLevel,
66 formatted_raw_ostream &Out) {
67 // Output assembly language.
68 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
70 PM.add(AsmPrinterCtor(Out, *this, Verbose));