Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 1 | //===-- SPUTargetMachine.cpp - Define TargetMachine for Cell SPU ----------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 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 "SPUTargetAsmInfo.h" |
| 17 | #include "SPUTargetMachine.h" |
| 18 | #include "llvm/Module.h" |
| 19 | #include "llvm/PassManager.h" |
Scott Michel | aedc637 | 2008-12-10 00:15:19 +0000 | [diff] [blame] | 20 | #include "llvm/CodeGen/RegAllocRegistry.h" |
| 21 | #include "llvm/CodeGen/SchedulerRegistry.h" |
Daniel Dunbar | 0c795d6 | 2009-07-25 06:49:55 +0000 | [diff] [blame] | 22 | #include "llvm/Target/TargetRegistry.h" |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 23 | |
| 24 | using namespace llvm; |
| 25 | |
Daniel Dunbar | 0c795d6 | 2009-07-25 06:49:55 +0000 | [diff] [blame] | 26 | extern "C" void LLVMInitializeCellSPUTarget() { |
| 27 | // Register the target. |
| 28 | RegisterTargetMachine<SPUTargetMachine> X(TheCellSPUTarget); |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | const std::pair<unsigned, int> * |
| 32 | SPUFrameInfo::getCalleeSaveSpillSlots(unsigned &NumEntries) const { |
| 33 | NumEntries = 1; |
| 34 | return &LR[0]; |
| 35 | } |
| 36 | |
Chris Lattner | 09e820b | 2009-08-02 04:44:33 +0000 | [diff] [blame] | 37 | const TargetAsmInfo *SPUTargetMachine::createTargetAsmInfo() const { |
| 38 | return new SPULinuxTargetAsmInfo(); |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 39 | } |
| 40 | |
Daniel Dunbar | 51b198a | 2009-07-15 20:24:03 +0000 | [diff] [blame] | 41 | SPUTargetMachine::SPUTargetMachine(const Target &T, const Module &M, |
| 42 | const std::string &FS) |
| 43 | : LLVMTargetMachine(T), |
Daniel Dunbar | 3be0340 | 2009-08-02 22:11:08 +0000 | [diff] [blame] | 44 | Subtarget(M.getTargetTriple(), FS), |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 45 | DataLayout(Subtarget.getTargetDataString()), |
| 46 | InstrInfo(*this), |
| 47 | FrameInfo(*this), |
| 48 | TLInfo(*this), |
Chris Lattner | 09e820b | 2009-08-02 04:44:33 +0000 | [diff] [blame] | 49 | InstrItins(Subtarget.getInstrItineraryData()) { |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 50 | // For the time being, use static relocations, since there's really no |
| 51 | // support for PIC yet. |
| 52 | setRelocationModel(Reloc::Static); |
| 53 | } |
| 54 | |
| 55 | //===----------------------------------------------------------------------===// |
| 56 | // Pass Pipeline Configuration |
| 57 | //===----------------------------------------------------------------------===// |
| 58 | |
Chris Lattner | 09e820b | 2009-08-02 04:44:33 +0000 | [diff] [blame] | 59 | bool SPUTargetMachine::addInstSelector(PassManagerBase &PM, |
| 60 | CodeGenOpt::Level OptLevel) { |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 61 | // Install an instruction selector. |
| 62 | PM.add(createSPUISelDag(*this)); |
| 63 | return false; |
| 64 | } |