blob: 068fd00348c65add1d341c9c91c54cdb4399e516 [file] [log] [blame]
Scott Michel564427e2007-12-05 01:24:05 +00001//===-- SPUTargetMachine.cpp - Define TargetMachine for Cell SPU ----------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by a team from the Computer Systems Research
6// Department at The Aerospace Corporation.
7//
8// See README.txt for details.
9//
10//===----------------------------------------------------------------------===//
11//
12// Top-level implementation for the Cell SPU target.
13//
14//===----------------------------------------------------------------------===//
15
16#include "SPU.h"
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"
23
24using namespace llvm;
25
26namespace {
27 // Register the targets
28 RegisterTarget<SPUTargetMachine>
29 CELLSPU("cellspu", " STI CBEA Cell SPU");
30}
31
32const std::pair<unsigned, int> *
33SPUFrameInfo::getCalleeSaveSpillSlots(unsigned &NumEntries) const {
34 NumEntries = 1;
35 return &LR[0];
36}
37
38const TargetAsmInfo *
39SPUTargetMachine::createTargetAsmInfo() const
40{
41 return new SPUTargetAsmInfo(*this);
42}
43
44unsigned
45SPUTargetMachine::getModuleMatchQuality(const Module &M)
46{
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-"))
53 return 20;
54
55 return 0; // No match at all...
56}
57
58SPUTargetMachine::SPUTargetMachine(const Module &M, const std::string &FS)
59 : Subtarget(*this, M, FS),
60 DataLayout(Subtarget.getTargetDataString()),
61 InstrInfo(*this),
62 FrameInfo(*this),
63 TLInfo(*this),
64 InstrItins(Subtarget.getInstrItineraryData())
65{
66 // For the time being, use static relocations, since there's really no
67 // support for PIC yet.
68 setRelocationModel(Reloc::Static);
69}
70
71//===----------------------------------------------------------------------===//
72// Pass Pipeline Configuration
73//===----------------------------------------------------------------------===//
74
75bool
76SPUTargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast)
77{
78 // Install an instruction selector.
79 PM.add(createSPUISelDag(*this));
80 return false;
81}
82
83bool SPUTargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast,
84 std::ostream &Out) {
85 PM.add(createSPUAsmPrinterPass(Out, *this));
86 return false;
87}