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 extern Target TheCellSPUTarget;
28 // Register the targets
29 RegisterTarget<SPUTargetMachine>
30 CELLSPU(TheCellSPUTarget, "cellspu", "STI CBEA Cell SPU [experimental]");
33 // No assembler printer by default
34 SPUTargetMachine::AsmPrinterCtorFn SPUTargetMachine::AsmPrinterCtor = 0;
36 // Force static initialization.
37 extern "C" void LLVMInitializeCellSPUTarget() { }
39 const std::pair<unsigned, int> *
40 SPUFrameInfo::getCalleeSaveSpillSlots(unsigned &NumEntries) const {
46 SPUTargetMachine::createTargetAsmInfo() const
48 return new SPULinuxTargetAsmInfo(*this);
52 SPUTargetMachine::getModuleMatchQuality(const Module &M)
54 // We strongly match "spu-*" or "cellspu-*".
55 std::string TT = M.getTargetTriple();
56 if ((TT.size() == 3 && std::string(TT.begin(), TT.begin()+3) == "spu")
57 || (TT.size() == 7 && std::string(TT.begin(), TT.begin()+7) == "cellspu")
58 || (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "spu-")
59 || (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "cellspu-"))
62 return 0; // No match at all...
65 SPUTargetMachine::SPUTargetMachine(const Module &M, const std::string &FS)
66 : Subtarget(*this, M, FS),
67 DataLayout(Subtarget.getTargetDataString()),
71 InstrItins(Subtarget.getInstrItineraryData())
73 // For the time being, use static relocations, since there's really no
74 // support for PIC yet.
75 setRelocationModel(Reloc::Static);
78 //===----------------------------------------------------------------------===//
79 // Pass Pipeline Configuration
80 //===----------------------------------------------------------------------===//
83 SPUTargetMachine::addInstSelector(PassManagerBase &PM,
84 CodeGenOpt::Level OptLevel)
86 // Install an instruction selector.
87 PM.add(createSPUISelDag(*this));
91 bool SPUTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
92 CodeGenOpt::Level OptLevel,
94 formatted_raw_ostream &Out) {
95 // Output assembly language.
96 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
98 PM.add(AsmPrinterCtor(Out, *this, Verbose));