1 //===-- SPUTargetMachine.cpp - Define TargetMachine for Cell SPU ----------===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by a team from the Computer Systems Research
6 // Department at The Aerospace Corporation.
8 // See README.txt for details.
10 //===----------------------------------------------------------------------===//
12 // Top-level implementation for the Cell SPU target.
14 //===----------------------------------------------------------------------===//
17 #include "SPURegisterNames.h"
18 #include "SPUTargetAsmInfo.h"
19 #include "SPUTargetMachine.h"
20 #include "llvm/Module.h"
21 #include "llvm/PassManager.h"
22 #include "llvm/Target/TargetMachineRegistry.h"
27 // Register the targets
28 RegisterTarget<SPUTargetMachine>
29 CELLSPU("cellspu", " STI CBEA Cell SPU");
32 const std::pair<unsigned, int> *
33 SPUFrameInfo::getCalleeSaveSpillSlots(unsigned &NumEntries) const {
39 SPUTargetMachine::createTargetAsmInfo() const
41 return new SPUTargetAsmInfo(*this);
45 SPUTargetMachine::getModuleMatchQuality(const Module &M)
47 // We strongly match "spu-*" or "cellspu-*".
48 std::string TT = M.getTargetTriple();
49 if ((TT.size() == 3 && std::string(TT.begin(), TT.begin()+3) == "spu")
50 || (TT.size() == 7 && std::string(TT.begin(), TT.begin()+7) == "cellspu")
51 || (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "spu-")
52 || (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "cellspu-"))
55 return 0; // No match at all...
58 SPUTargetMachine::SPUTargetMachine(const Module &M, const std::string &FS)
59 : Subtarget(*this, M, FS),
60 DataLayout(Subtarget.getTargetDataString()),
64 InstrItins(Subtarget.getInstrItineraryData())
66 // For the time being, use static relocations, since there's really no
67 // support for PIC yet.
68 setRelocationModel(Reloc::Static);
71 //===----------------------------------------------------------------------===//
72 // Pass Pipeline Configuration
73 //===----------------------------------------------------------------------===//
76 SPUTargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast)
78 // Install an instruction selector.
79 PM.add(createSPUISelDag(*this));
83 bool SPUTargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast,
85 PM.add(createSPUAsmPrinterPass(Out, *this));