Fix up the CMake build for the new files added in r146960, they're
[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 "SPUTargetMachine.h"
16 #include "llvm/PassManager.h"
17 #include "llvm/CodeGen/RegAllocRegistry.h"
18 #include "llvm/CodeGen/SchedulerRegistry.h"
19 #include "llvm/Support/DynamicLibrary.h"
20 #include "llvm/Support/TargetRegistry.h"
21
22 using namespace llvm;
23
24 extern "C" void LLVMInitializeCellSPUTarget() { 
25   // Register the target.
26   RegisterTargetMachine<SPUTargetMachine> X(TheCellSPUTarget);
27 }
28
29 const std::pair<unsigned, int> *
30 SPUFrameLowering::getCalleeSaveSpillSlots(unsigned &NumEntries) const {
31   NumEntries = 1;
32   return &LR[0];
33 }
34
35 SPUTargetMachine::SPUTargetMachine(const Target &T, StringRef TT,
36                                    StringRef CPU, StringRef FS,
37                                    const TargetOptions &Options,
38                                    Reloc::Model RM, CodeModel::Model CM,
39                                    CodeGenOpt::Level OL)
40   : LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
41     Subtarget(TT, CPU, FS),
42     DataLayout(Subtarget.getTargetDataString()),
43     InstrInfo(*this),
44     FrameLowering(Subtarget),
45     TLInfo(*this),
46     TSInfo(*this),
47     InstrItins(Subtarget.getInstrItineraryData()) {
48 }
49
50 //===----------------------------------------------------------------------===//
51 // Pass Pipeline Configuration
52 //===----------------------------------------------------------------------===//
53
54 bool SPUTargetMachine::addInstSelector(PassManagerBase &PM) {
55   // Install an instruction selector.
56   PM.add(createSPUISelDag(*this));
57   return false;
58 }
59
60 // passes to run just before printing the assembly
61 bool SPUTargetMachine::
62 addPreEmitPass(PassManagerBase &PM) {
63   // load the TCE instruction scheduler, if available via
64   // loaded plugins
65   typedef llvm::FunctionPass* (*BuilderFunc)(const char*);
66   BuilderFunc schedulerCreator =
67     (BuilderFunc)(intptr_t)sys::DynamicLibrary::SearchForAddressOfSymbol(
68           "createTCESchedulerPass");
69   if (schedulerCreator != NULL)
70       PM.add(schedulerCreator("cellspu"));
71
72   //align instructions with nops/lnops for dual issue
73   PM.add(createSPUNopFillerPass(*this));
74   return true;
75 }