Remove unused AsmPrinter OptLevel argument, and propogate.
[oota-llvm.git] / lib / Target / CellSPU / SPUTargetMachine.cpp
1 //===-- SPUTargetMachine.cpp - Define TargetMachine for Cell SPU ----------===//
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 // Top-level implementation for the Cell SPU target.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "SPU.h"
15 #include "SPURegisterNames.h"
16 #include "SPUTargetAsmInfo.h"
17 #include "SPUTargetMachine.h"
18 #include "llvm/Module.h"
19 #include "llvm/PassManager.h"
20 #include "llvm/Target/TargetMachineRegistry.h"
21 #include "llvm/CodeGen/RegAllocRegistry.h"
22 #include "llvm/CodeGen/SchedulerRegistry.h"
23
24 using namespace llvm;
25
26 namespace {
27   // Register the targets
28   RegisterTarget<SPUTargetMachine>
29   CELLSPU("cellspu", "STI CBEA Cell SPU [experimental]");
30 }
31
32 // No assembler printer by default
33 SPUTargetMachine::AsmPrinterCtorFn SPUTargetMachine::AsmPrinterCtor = 0;
34
35 // Force static initialization.
36 extern "C" void LLVMInitializeCellSPUTarget() { }
37
38 const std::pair<unsigned, int> *
39 SPUFrameInfo::getCalleeSaveSpillSlots(unsigned &NumEntries) const {
40   NumEntries = 1;
41   return &LR[0];
42 }
43
44 const TargetAsmInfo *
45 SPUTargetMachine::createTargetAsmInfo() const
46 {
47   return new SPULinuxTargetAsmInfo(*this);
48 }
49
50 unsigned
51 SPUTargetMachine::getModuleMatchQuality(const Module &M)
52 {
53   // We strongly match "spu-*" or "cellspu-*".
54   std::string TT = M.getTargetTriple();
55   if ((TT.size() == 3 && std::string(TT.begin(), TT.begin()+3) == "spu")
56       || (TT.size() == 7 && std::string(TT.begin(), TT.begin()+7) == "cellspu")
57       || (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "spu-")
58       || (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "cellspu-"))
59     return 20;
60   
61   return 0;                     // No match at all...
62 }
63
64 SPUTargetMachine::SPUTargetMachine(const Module &M, const std::string &FS)
65   : Subtarget(*this, M, FS),
66     DataLayout(Subtarget.getTargetDataString()),
67     InstrInfo(*this),
68     FrameInfo(*this),
69     TLInfo(*this),
70     InstrItins(Subtarget.getInstrItineraryData())
71 {
72   // For the time being, use static relocations, since there's really no
73   // support for PIC yet.
74   setRelocationModel(Reloc::Static);
75 }
76
77 //===----------------------------------------------------------------------===//
78 // Pass Pipeline Configuration
79 //===----------------------------------------------------------------------===//
80
81 bool
82 SPUTargetMachine::addInstSelector(PassManagerBase &PM,
83                                   CodeGenOpt::Level OptLevel)
84 {
85   // Install an instruction selector.
86   PM.add(createSPUISelDag(*this));
87   return false;
88 }
89
90 bool SPUTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
91                                           CodeGenOpt::Level OptLevel,
92                                           bool Verbose,
93                                           raw_ostream &Out) {
94   // Output assembly language.
95   assert(AsmPrinterCtor && "AsmPrinter was not linked in");
96   if (AsmPrinterCtor)
97     PM.add(AsmPrinterCtor(Out, *this, Verbose));
98   return false;
99 }