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" |
Chris Lattner | af76e59 | 2009-08-22 20:48:53 +0000 | [diff] [blame] | 16 | #include "SPUMCAsmInfo.h" |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 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); |
Chris Lattner | af76e59 | 2009-08-22 20:48:53 +0000 | [diff] [blame] | 28 | RegisterAsmInfo<SPULinuxMCAsmInfo> Y(TheCellSPUTarget); |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | const std::pair<unsigned, int> * |
Anton Korobeynikov | 16c29b5 | 2011-01-10 12:39:04 +0000 | [diff] [blame] | 32 | SPUFrameLowering::getCalleeSaveSpillSlots(unsigned &NumEntries) const { |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 33 | NumEntries = 1; |
| 34 | return &LR[0]; |
| 35 | } |
| 36 | |
Daniel Dunbar | e28039c | 2009-08-02 23:37:13 +0000 | [diff] [blame] | 37 | SPUTargetMachine::SPUTargetMachine(const Target &T, const std::string &TT, |
Evan Cheng | 276365d | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 38 | const std::string &CPU,const std::string &FS) |
Chris Lattner | 0a31d2f | 2009-08-11 20:42:37 +0000 | [diff] [blame] | 39 | : LLVMTargetMachine(T, TT), |
Evan Cheng | 276365d | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 40 | Subtarget(TT, CPU, FS), |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 41 | DataLayout(Subtarget.getTargetDataString()), |
| 42 | InstrInfo(*this), |
Anton Korobeynikov | 16c29b5 | 2011-01-10 12:39:04 +0000 | [diff] [blame] | 43 | FrameLowering(Subtarget), |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 44 | TLInfo(*this), |
Dan Gohman | ff7a562 | 2010-05-11 17:31:57 +0000 | [diff] [blame] | 45 | TSInfo(*this), |
Chris Lattner | 09e820b | 2009-08-02 04:44:33 +0000 | [diff] [blame] | 46 | InstrItins(Subtarget.getInstrItineraryData()) { |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 47 | // For the time being, use static relocations, since there's really no |
| 48 | // support for PIC yet. |
| 49 | setRelocationModel(Reloc::Static); |
| 50 | } |
| 51 | |
| 52 | //===----------------------------------------------------------------------===// |
| 53 | // Pass Pipeline Configuration |
| 54 | //===----------------------------------------------------------------------===// |
| 55 | |
Chris Lattner | 09e820b | 2009-08-02 04:44:33 +0000 | [diff] [blame] | 56 | bool SPUTargetMachine::addInstSelector(PassManagerBase &PM, |
| 57 | CodeGenOpt::Level OptLevel) { |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 58 | // Install an instruction selector. |
| 59 | PM.add(createSPUISelDag(*this)); |
| 60 | return false; |
| 61 | } |
Kalle Raiskila | 76020ed | 2011-01-11 09:07:54 +0000 | [diff] [blame] | 62 | |
| 63 | // passes to run just before printing the assembly |
| 64 | bool SPUTargetMachine:: |
| 65 | addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel) |
| 66 | { |
| 67 | //align instructions with nops/lnops for dual issue |
| 68 | PM.add(createSPUNopFillerPass(*this)); |
| 69 | return true; |
| 70 | } |