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 and is distributed under the
7 // University of Illinois Open Source License. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 // Top-level implementation for the Cell SPU target.
13 //===----------------------------------------------------------------------===//
16 #include "SPURegisterNames.h"
17 #include "SPUTargetAsmInfo.h"
18 #include "SPUTargetMachine.h"
19 #include "llvm/Module.h"
20 #include "llvm/PassManager.h"
21 #include "llvm/Target/TargetMachineRegistry.h"
26 // Register the targets
27 RegisterTarget<SPUTargetMachine>
28 CELLSPU("cellspu", " STI CBEA Cell SPU");
31 const std::pair<unsigned, int> *
32 SPUFrameInfo::getCalleeSaveSpillSlots(unsigned &NumEntries) const {
38 SPUTargetMachine::createTargetAsmInfo() const
40 return new SPUTargetAsmInfo(*this);
44 SPUTargetMachine::getModuleMatchQuality(const Module &M)
46 // We strongly match "spu-*" or "cellspu-*".
47 std::string TT = M.getTargetTriple();
48 if ((TT.size() == 3 && std::string(TT.begin(), TT.begin()+3) == "spu")
49 || (TT.size() == 7 && std::string(TT.begin(), TT.begin()+7) == "cellspu")
50 || (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "spu-")
51 || (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "cellspu-"))
54 return 0; // No match at all...
57 SPUTargetMachine::SPUTargetMachine(const Module &M, const std::string &FS)
58 : Subtarget(*this, M, FS),
59 DataLayout(Subtarget.getTargetDataString()),
63 InstrItins(Subtarget.getInstrItineraryData())
65 // For the time being, use static relocations, since there's really no
66 // support for PIC yet.
67 setRelocationModel(Reloc::Static);
70 //===----------------------------------------------------------------------===//
71 // Pass Pipeline Configuration
72 //===----------------------------------------------------------------------===//
75 SPUTargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast)
77 // Install an instruction selector.
78 PM.add(createSPUISelDag(*this));
82 bool SPUTargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast,
84 PM.add(createSPUAsmPrinterPass(Out, *this));