Remove attribution from file headers, per discussion on llvmdev.
[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 namespace {
22   // Register the target.
23   RegisterTarget<SparcTargetMachine> X("sparc", "  SPARC");
24 }
25
26 const TargetAsmInfo *SparcTargetMachine::createTargetAsmInfo() const {
27   return new SparcTargetAsmInfo(*this);
28 }
29
30 /// SparcTargetMachine ctor - Create an ILP32 architecture model
31 ///
32 SparcTargetMachine::SparcTargetMachine(const Module &M, const std::string &FS)
33   : DataLayout("E-p:32:32-f128:128:128"),
34     Subtarget(M, FS), InstrInfo(Subtarget),
35     FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) {
36 }
37
38 unsigned SparcTargetMachine::getModuleMatchQuality(const Module &M) {
39   std::string TT = M.getTargetTriple();
40   if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "sparc-")
41     return 20;
42   
43   // If the target triple is something non-sparc, we don't match.
44   if (!TT.empty()) return 0;
45
46   if (M.getEndianness()  == Module::BigEndian &&
47       M.getPointerSize() == Module::Pointer32)
48 #ifdef __sparc__
49     return 20;   // BE/32 ==> Prefer sparc on sparc
50 #else
51     return 5;    // BE/32 ==> Prefer ppc elsewhere
52 #endif
53   else if (M.getEndianness() != Module::AnyEndianness ||
54            M.getPointerSize() != Module::AnyPointerSize)
55     return 0;                                    // Match for some other target
56
57 #if defined(__sparc__)
58   return 10;
59 #else
60   return 0;
61 #endif
62 }
63
64 bool SparcTargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast) {
65   PM.add(createSparcISelDag(*this));
66   return false;
67 }
68
69 /// addPreEmitPass - This pass may be implemented by targets that want to run
70 /// passes immediately before machine code is emitted.  This should return
71 /// true if -print-machineinstrs should print out the code after the passes.
72 bool SparcTargetMachine::addPreEmitPass(FunctionPassManager &PM, bool Fast) {
73   PM.add(createSparcFPMoverPass(*this));
74   PM.add(createSparcDelaySlotFillerPass(*this));
75   return true;
76 }
77
78 bool SparcTargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast, 
79                                             std::ostream &Out) {
80   // Output assembly language.
81   PM.add(createSparcCodePrinterPass(Out, *this));
82   return false;
83 }