Next round of MC refactoring. This patch factor MC table instantiations, MC
[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 "SPUMCAsmInfo.h"
16 #include "SPUTargetMachine.h"
17 #include "llvm/PassManager.h"
18 #include "llvm/CodeGen/RegAllocRegistry.h"
19 #include "llvm/CodeGen/SchedulerRegistry.h"
20 #include "llvm/Target/TargetRegistry.h"
21
22 using namespace llvm;
23
24 extern "C" void LLVMInitializeCellSPUTarget() { 
25   // Register the target.
26   RegisterTargetMachine<SPUTargetMachine> X(TheCellSPUTarget);
27   RegisterAsmInfo<SPULinuxMCAsmInfo> Y(TheCellSPUTarget);
28 }
29
30 const std::pair<unsigned, int> *
31 SPUFrameLowering::getCalleeSaveSpillSlots(unsigned &NumEntries) const {
32   NumEntries = 1;
33   return &LR[0];
34 }
35
36 SPUTargetMachine::SPUTargetMachine(const Target &T, const std::string &TT,
37                                    const std::string &CPU,const std::string &FS)
38   : LLVMTargetMachine(T, TT, CPU, FS),
39     Subtarget(TT, CPU, FS),
40     DataLayout(Subtarget.getTargetDataString()),
41     InstrInfo(*this),
42     FrameLowering(Subtarget),
43     TLInfo(*this),
44     TSInfo(*this),
45     InstrItins(Subtarget.getInstrItineraryData()) {
46   // For the time being, use static relocations, since there's really no
47   // support for PIC yet.
48   setRelocationModel(Reloc::Static);
49 }
50
51 //===----------------------------------------------------------------------===//
52 // Pass Pipeline Configuration
53 //===----------------------------------------------------------------------===//
54
55 bool SPUTargetMachine::addInstSelector(PassManagerBase &PM,
56                                        CodeGenOpt::Level OptLevel) {
57   // Install an instruction selector.
58   PM.add(createSPUISelDag(*this));
59   return false;
60 }
61
62 // passes to run just before printing the assembly
63 bool SPUTargetMachine::
64 addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel) 
65 {
66   //align instructions with nops/lnops for dual issue
67   PM.add(createSPUNopFillerPass(*this));
68   return true;
69 }