Put Target definitions inside Target specific header, and llvm namespace.
[oota-llvm.git] / lib / Target / Sparc / SparcTargetMachine.cpp
1 //===-- SparcTargetMachine.cpp - Define TargetMachine for Sparc -----------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //
11 //===----------------------------------------------------------------------===//
12
13 #include "SparcTargetAsmInfo.h"
14 #include "SparcTargetMachine.h"
15 #include "Sparc.h"
16 #include "llvm/Module.h"
17 #include "llvm/PassManager.h"
18 #include "llvm/Target/TargetMachineRegistry.h"
19 using namespace llvm;
20
21 // Register the target.
22 static RegisterTarget<SparcTargetMachine> X(TheSparcTarget, "sparc", "SPARC");
23
24 // Force static initialization.
25 extern "C" void LLVMInitializeSparcTarget() { }
26
27 const TargetAsmInfo *SparcTargetMachine::createTargetAsmInfo() const {
28   // FIXME: Handle Solaris subtarget someday :)
29   return new SparcELFTargetAsmInfo(*this);
30 }
31
32 /// SparcTargetMachine ctor - Create an ILP32 architecture model
33 ///
34 SparcTargetMachine::SparcTargetMachine(const Target &T, const Module &M, 
35                                        const std::string &FS)
36   : LLVMTargetMachine(T),
37     DataLayout("E-p:32:32-f128:128:128"),
38     Subtarget(M, FS), TLInfo(*this), InstrInfo(Subtarget),
39     FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) {
40 }
41
42 bool SparcTargetMachine::addInstSelector(PassManagerBase &PM,
43                                          CodeGenOpt::Level OptLevel) {
44   PM.add(createSparcISelDag(*this));
45   return false;
46 }
47
48 /// addPreEmitPass - This pass may be implemented by targets that want to run
49 /// passes immediately before machine code is emitted.  This should return
50 /// true if -print-machineinstrs should print out the code after the passes.
51 bool SparcTargetMachine::addPreEmitPass(PassManagerBase &PM,
52                                         CodeGenOpt::Level OptLevel){
53   PM.add(createSparcFPMoverPass(*this));
54   PM.add(createSparcDelaySlotFillerPass(*this));
55   return true;
56 }