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"
27 // Register the targets
28 RegisterTarget<SPUTargetMachine>
29 CELLSPU("cellspu", "STI CBEA Cell SPU [experimental]");
32 // No assembler printer by default
33 SPUTargetMachine::AsmPrinterCtorFn SPUTargetMachine::AsmPrinterCtor = 0;
35 // Force static initialization.
36 extern "C" void LLVMInitializeCellSPUTarget() { }
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,
83 CodeGenOpt::Level OptLevel)
85 // Install an instruction selector.
86 PM.add(createSPUISelDag(*this));
90 bool SPUTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
91 CodeGenOpt::Level OptLevel,
93 formatted_raw_ostream &Out) {
94 // Output assembly language.
95 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
97 PM.add(AsmPrinterCtor(Out, *this, Verbose));