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" |
| 20 | #include "llvm/Target/TargetMachineRegistry.h" |
Scott Michel | aedc637 | 2008-12-10 00:15:19 +0000 | [diff] [blame] | 21 | #include "llvm/CodeGen/RegAllocRegistry.h" |
| 22 | #include "llvm/CodeGen/SchedulerRegistry.h" |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 23 | |
| 24 | using namespace llvm; |
| 25 | |
| 26 | namespace { |
| 27 | // Register the targets |
| 28 | RegisterTarget<SPUTargetMachine> |
Daniel Dunbar | 51b198a | 2009-07-15 20:24:03 +0000 | [diff] [blame] | 29 | CELLSPU(TheCellSPUTarget, "cellspu", "STI CBEA Cell SPU [experimental]"); |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 30 | } |
| 31 | |
Bob Wilson | a96751f | 2009-06-23 23:59:40 +0000 | [diff] [blame] | 32 | // Force static initialization. |
| 33 | extern "C" void LLVMInitializeCellSPUTarget() { } |
Douglas Gregor | 1555a23 | 2009-06-16 20:12:29 +0000 | [diff] [blame] | 34 | |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 35 | const std::pair<unsigned, int> * |
| 36 | SPUFrameInfo::getCalleeSaveSpillSlots(unsigned &NumEntries) const { |
| 37 | NumEntries = 1; |
| 38 | return &LR[0]; |
| 39 | } |
| 40 | |
| 41 | const TargetAsmInfo * |
| 42 | SPUTargetMachine::createTargetAsmInfo() const |
| 43 | { |
Scott Michel | d03eeaf | 2008-11-07 04:36:25 +0000 | [diff] [blame] | 44 | return new SPULinuxTargetAsmInfo(*this); |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 45 | } |
| 46 | |
Daniel Dunbar | 51b198a | 2009-07-15 20:24:03 +0000 | [diff] [blame] | 47 | SPUTargetMachine::SPUTargetMachine(const Target &T, const Module &M, |
| 48 | const std::string &FS) |
| 49 | : LLVMTargetMachine(T), |
| 50 | Subtarget(*this, M, FS), |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 51 | DataLayout(Subtarget.getTargetDataString()), |
| 52 | InstrInfo(*this), |
| 53 | FrameInfo(*this), |
| 54 | TLInfo(*this), |
| 55 | InstrItins(Subtarget.getInstrItineraryData()) |
| 56 | { |
| 57 | // For the time being, use static relocations, since there's really no |
| 58 | // support for PIC yet. |
| 59 | setRelocationModel(Reloc::Static); |
| 60 | } |
| 61 | |
| 62 | //===----------------------------------------------------------------------===// |
| 63 | // Pass Pipeline Configuration |
| 64 | //===----------------------------------------------------------------------===// |
| 65 | |
| 66 | bool |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 67 | SPUTargetMachine::addInstSelector(PassManagerBase &PM, |
| 68 | CodeGenOpt::Level OptLevel) |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 69 | { |
| 70 | // Install an instruction selector. |
| 71 | PM.add(createSPUISelDag(*this)); |
| 72 | return false; |
| 73 | } |