Remove attribution from file headers, per discussion on llvmdev.
[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
22 using namespace llvm;
23
24 namespace {
25   // Register the targets
26   RegisterTarget<SPUTargetMachine>
27   CELLSPU("cellspu", "  STI CBEA Cell SPU");
28 }
29
30 const std::pair<unsigned, int> *
31 SPUFrameInfo::getCalleeSaveSpillSlots(unsigned &NumEntries) const {
32   NumEntries = 1;
33   return &LR[0];
34 }
35
36 const TargetAsmInfo *
37 SPUTargetMachine::createTargetAsmInfo() const
38 {
39   return new SPUTargetAsmInfo(*this);
40 }
41
42 unsigned
43 SPUTargetMachine::getModuleMatchQuality(const Module &M)
44 {
45   // We strongly match "spu-*" or "cellspu-*".
46   std::string TT = M.getTargetTriple();
47   if ((TT.size() == 3 && std::string(TT.begin(), TT.begin()+3) == "spu")
48       || (TT.size() == 7 && std::string(TT.begin(), TT.begin()+7) == "cellspu")
49       || (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "spu-")
50       || (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "cellspu-"))
51     return 20;
52   
53   return 0;                     // No match at all...
54 }
55
56 SPUTargetMachine::SPUTargetMachine(const Module &M, const std::string &FS)
57   : Subtarget(*this, M, FS),
58     DataLayout(Subtarget.getTargetDataString()),
59     InstrInfo(*this),
60     FrameInfo(*this),
61     TLInfo(*this),
62     InstrItins(Subtarget.getInstrItineraryData())
63 {
64   // For the time being, use static relocations, since there's really no
65   // support for PIC yet.
66   setRelocationModel(Reloc::Static);
67 }
68
69 //===----------------------------------------------------------------------===//
70 // Pass Pipeline Configuration
71 //===----------------------------------------------------------------------===//
72
73 bool
74 SPUTargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast)
75 {
76   // Install an instruction selector.
77   PM.add(createSPUISelDag(*this));
78   return false;
79 }
80
81 bool SPUTargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast, 
82                                           std::ostream &Out) {
83   PM.add(createSPUAsmPrinterPass(Out, *this));
84   return false;
85 }