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