Shih-wei Liao | e264f62 | 2010-02-10 11:10:31 -0800 | [diff] [blame^] | 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 "SPUMCAsmInfo.h" |
| 17 | #include "SPUTargetMachine.h" |
| 18 | #include "llvm/PassManager.h" |
| 19 | #include "llvm/CodeGen/RegAllocRegistry.h" |
| 20 | #include "llvm/CodeGen/SchedulerRegistry.h" |
| 21 | #include "llvm/Target/TargetRegistry.h" |
| 22 | |
| 23 | using namespace llvm; |
| 24 | |
| 25 | extern "C" void LLVMInitializeCellSPUTarget() { |
| 26 | // Register the target. |
| 27 | RegisterTargetMachine<SPUTargetMachine> X(TheCellSPUTarget); |
| 28 | RegisterAsmInfo<SPULinuxMCAsmInfo> Y(TheCellSPUTarget); |
| 29 | } |
| 30 | |
| 31 | const std::pair<unsigned, int> * |
| 32 | SPUFrameInfo::getCalleeSaveSpillSlots(unsigned &NumEntries) const { |
| 33 | NumEntries = 1; |
| 34 | return &LR[0]; |
| 35 | } |
| 36 | |
| 37 | SPUTargetMachine::SPUTargetMachine(const Target &T, const std::string &TT, |
| 38 | const std::string &FS) |
| 39 | : LLVMTargetMachine(T, TT), |
| 40 | Subtarget(TT, FS), |
| 41 | DataLayout(Subtarget.getTargetDataString()), |
| 42 | InstrInfo(*this), |
| 43 | FrameInfo(*this), |
| 44 | TLInfo(*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 | } |