]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - contrib/llvm/lib/Target/CellSPU/SPUTargetMachine.cpp
Copy head to stable/9 as part of 9.0-RELEASE release cycle.
[FreeBSD/stable/9.git] / contrib / llvm / 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/Target/TargetRegistry.h"
20
21 using namespace llvm;
22
23 extern "C" void LLVMInitializeCellSPUTarget() { 
24   // Register the target.
25   RegisterTargetMachine<SPUTargetMachine> X(TheCellSPUTarget);
26 }
27
28 const std::pair<unsigned, int> *
29 SPUFrameLowering::getCalleeSaveSpillSlots(unsigned &NumEntries) const {
30   NumEntries = 1;
31   return &LR[0];
32 }
33
34 SPUTargetMachine::SPUTargetMachine(const Target &T, const std::string &TT,
35                                    const std::string &CPU,const std::string &FS)
36   : LLVMTargetMachine(T, TT, CPU, FS),
37     Subtarget(TT, CPU, FS),
38     DataLayout(Subtarget.getTargetDataString()),
39     InstrInfo(*this),
40     FrameLowering(Subtarget),
41     TLInfo(*this),
42     TSInfo(*this),
43     InstrItins(Subtarget.getInstrItineraryData()) {
44   // For the time being, use static relocations, since there's really no
45   // support for PIC yet.
46   setRelocationModel(Reloc::Static);
47 }
48
49 //===----------------------------------------------------------------------===//
50 // Pass Pipeline Configuration
51 //===----------------------------------------------------------------------===//
52
53 bool SPUTargetMachine::addInstSelector(PassManagerBase &PM,
54                                        CodeGenOpt::Level OptLevel) {
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, CodeGenOpt::Level OptLevel) 
63 {
64   //align instructions with nops/lnops for dual issue
65   PM.add(createSPUNopFillerPass(*this));
66   return true;
67 }