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"
24 /// CellSPUTargetMachineModule - Note that this is used on hosts that
25 /// cannot link in a library unless there are references into the
26 /// library. In particular, it seems that it is not possible to get
27 /// things to work on Win32 without this. Though it is unused, do not
29 extern "C" int CellSPUTargetMachineModule;
30 int CellSPUTargetMachineModule = 0;
33 // Register the targets
34 RegisterTarget<SPUTargetMachine>
35 CELLSPU("cellspu", "STI CBEA Cell SPU [experimental]");
38 const std::pair<unsigned, int> *
39 SPUFrameInfo::getCalleeSaveSpillSlots(unsigned &NumEntries) const {
45 SPUTargetMachine::createTargetAsmInfo() const
47 return new SPULinuxTargetAsmInfo(*this);
51 SPUTargetMachine::getModuleMatchQuality(const Module &M)
53 // We strongly match "spu-*" or "cellspu-*".
54 std::string TT = M.getTargetTriple();
55 if ((TT.size() == 3 && std::string(TT.begin(), TT.begin()+3) == "spu")
56 || (TT.size() == 7 && std::string(TT.begin(), TT.begin()+7) == "cellspu")
57 || (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "spu-")
58 || (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "cellspu-"))
61 return 0; // No match at all...
64 SPUTargetMachine::SPUTargetMachine(const Module &M, const std::string &FS)
65 : Subtarget(*this, M, FS),
66 DataLayout(Subtarget.getTargetDataString()),
70 InstrItins(Subtarget.getInstrItineraryData())
72 // For the time being, use static relocations, since there's really no
73 // support for PIC yet.
74 setRelocationModel(Reloc::Static);
77 //===----------------------------------------------------------------------===//
78 // Pass Pipeline Configuration
79 //===----------------------------------------------------------------------===//
82 SPUTargetMachine::addInstSelector(PassManagerBase &PM, bool Fast)
84 // Install an instruction selector.
85 PM.add(createSPUISelDag(*this));
89 bool SPUTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
91 PM.add(createSPUAsmPrinterPass(Out, *this));