Updated source file headers to llvm coding standard.
[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 was developed by a team from the Computer Systems Research
6 // Department at The Aerospace Corporation and is distributed under the
7 // University of Illinois Open Source License. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10 //
11 // Top-level implementation for the Cell SPU target.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "SPU.h"
16 #include "SPURegisterNames.h"
17 #include "SPUTargetAsmInfo.h"
18 #include "SPUTargetMachine.h"
19 #include "llvm/Module.h"
20 #include "llvm/PassManager.h"
21 #include "llvm/Target/TargetMachineRegistry.h"
22
23 using namespace llvm;
24
25 namespace {
26   // Register the targets
27   RegisterTarget<SPUTargetMachine>
28   CELLSPU("cellspu", "  STI CBEA Cell SPU");
29 }
30
31 const std::pair<unsigned, int> *
32 SPUFrameInfo::getCalleeSaveSpillSlots(unsigned &NumEntries) const {
33   NumEntries = 1;
34   return &LR[0];
35 }
36
37 const TargetAsmInfo *
38 SPUTargetMachine::createTargetAsmInfo() const
39 {
40   return new SPUTargetAsmInfo(*this);
41 }
42
43 unsigned
44 SPUTargetMachine::getModuleMatchQuality(const Module &M)
45 {
46   // We strongly match "spu-*" or "cellspu-*".
47   std::string TT = M.getTargetTriple();
48   if ((TT.size() == 3 && std::string(TT.begin(), TT.begin()+3) == "spu")
49       || (TT.size() == 7 && std::string(TT.begin(), TT.begin()+7) == "cellspu")
50       || (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "spu-")
51       || (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "cellspu-"))
52     return 20;
53   
54   return 0;                     // No match at all...
55 }
56
57 SPUTargetMachine::SPUTargetMachine(const Module &M, const std::string &FS)
58   : Subtarget(*this, M, FS),
59     DataLayout(Subtarget.getTargetDataString()),
60     InstrInfo(*this),
61     FrameInfo(*this),
62     TLInfo(*this),
63     InstrItins(Subtarget.getInstrItineraryData())
64 {
65   // For the time being, use static relocations, since there's really no
66   // support for PIC yet.
67   setRelocationModel(Reloc::Static);
68 }
69
70 //===----------------------------------------------------------------------===//
71 // Pass Pipeline Configuration
72 //===----------------------------------------------------------------------===//
73
74 bool
75 SPUTargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast)
76 {
77   // Install an instruction selector.
78   PM.add(createSPUISelDag(*this));
79   return false;
80 }
81
82 bool SPUTargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast, 
83                                           std::ostream &Out) {
84   PM.add(createSPUAsmPrinterPass(Out, *this));
85   return false;
86 }