1 //===-- SPUTargetMachine.cpp - Define TargetMachine for Cell SPU ----------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Top-level implementation for the Cell SPU target.
12 //===----------------------------------------------------------------------===//
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"
25 // Register the targets
26 RegisterTarget<SPUTargetMachine>
27 CELLSPU("cellspu", " STI CBEA Cell SPU");
30 const std::pair<unsigned, int> *
31 SPUFrameInfo::getCalleeSaveSpillSlots(unsigned &NumEntries) const {
37 SPUTargetMachine::createTargetAsmInfo() const
39 return new SPUTargetAsmInfo(*this);
43 SPUTargetMachine::getModuleMatchQuality(const Module &M)
45 // We strongly match "spu-*" or "cellspu-*".
46 std::string TT = M.getTargetTriple();
47 if ((TT.size() == 3 && std::string(TT.begin(), TT.begin()+3) == "spu")
48 || (TT.size() == 7 && std::string(TT.begin(), TT.begin()+7) == "cellspu")
49 || (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "spu-")
50 || (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "cellspu-"))
53 return 0; // No match at all...
56 SPUTargetMachine::SPUTargetMachine(const Module &M, const std::string &FS)
57 : Subtarget(*this, M, FS),
58 DataLayout(Subtarget.getTargetDataString()),
62 InstrItins(Subtarget.getInstrItineraryData())
64 // For the time being, use static relocations, since there's really no
65 // support for PIC yet.
66 setRelocationModel(Reloc::Static);
69 //===----------------------------------------------------------------------===//
70 // Pass Pipeline Configuration
71 //===----------------------------------------------------------------------===//
74 SPUTargetMachine::addInstSelector(PassManagerBase &PM, bool Fast)
76 // Install an instruction selector.
77 PM.add(createSPUISelDag(*this));
81 bool SPUTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
83 PM.add(createSPUAsmPrinterPass(Out, *this));