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"
21 #include "llvm/CodeGen/RegAllocRegistry.h"
22 #include "llvm/CodeGen/SchedulerRegistry.h"
26 /// CellSPUTargetMachineModule - Note that this is used on hosts that
27 /// cannot link in a library unless there are references into the
28 /// library. In particular, it seems that it is not possible to get
29 /// things to work on Win32 without this. Though it is unused, do not
31 extern "C" int CellSPUTargetMachineModule;
32 int CellSPUTargetMachineModule = 0;
35 // Register the targets
36 RegisterTarget<SPUTargetMachine>
37 CELLSPU("cellspu", "STI CBEA Cell SPU [experimental]");
40 // Force static initialization when called from llvm/InitializeAllTargets.h
42 void InitializeCellSPUTarget() { }
45 const std::pair<unsigned, int> *
46 SPUFrameInfo::getCalleeSaveSpillSlots(unsigned &NumEntries) const {
52 SPUTargetMachine::createTargetAsmInfo() const
54 return new SPULinuxTargetAsmInfo(*this);
58 SPUTargetMachine::getModuleMatchQuality(const Module &M)
60 // We strongly match "spu-*" or "cellspu-*".
61 std::string TT = M.getTargetTriple();
62 if ((TT.size() == 3 && std::string(TT.begin(), TT.begin()+3) == "spu")
63 || (TT.size() == 7 && std::string(TT.begin(), TT.begin()+7) == "cellspu")
64 || (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "spu-")
65 || (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "cellspu-"))
68 return 0; // No match at all...
71 SPUTargetMachine::SPUTargetMachine(const Module &M, const std::string &FS)
72 : Subtarget(*this, M, FS),
73 DataLayout(Subtarget.getTargetDataString()),
77 InstrItins(Subtarget.getInstrItineraryData())
79 // For the time being, use static relocations, since there's really no
80 // support for PIC yet.
81 setRelocationModel(Reloc::Static);
84 //===----------------------------------------------------------------------===//
85 // Pass Pipeline Configuration
86 //===----------------------------------------------------------------------===//
89 SPUTargetMachine::addInstSelector(PassManagerBase &PM,
90 CodeGenOpt::Level OptLevel)
92 // Install an instruction selector.
93 PM.add(createSPUISelDag(*this));
97 bool SPUTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
98 CodeGenOpt::Level OptLevel,
101 PM.add(createSPUAsmPrinterPass(Out, *this, OptLevel, Verbose));