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