blob: 47f785a2640f691733cb06e80c2e8fca939c285f [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//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Scott Michel564427e2007-12-05 01:24:05 +00007//
8//===----------------------------------------------------------------------===//
9//
10// Top-level implementation for the Cell SPU target.
11//
12//===----------------------------------------------------------------------===//
13
14#include "SPU.h"
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
22using namespace llvm;
23
24namespace {
25 // Register the targets
26 RegisterTarget<SPUTargetMachine>
27 CELLSPU("cellspu", " STI CBEA Cell SPU");
28}
29
30const std::pair<unsigned, int> *
31SPUFrameInfo::getCalleeSaveSpillSlots(unsigned &NumEntries) const {
32 NumEntries = 1;
33 return &LR[0];
34}
35
36const TargetAsmInfo *
37SPUTargetMachine::createTargetAsmInfo() const
38{
39 return new SPUTargetAsmInfo(*this);
40}
41
42unsigned
43SPUTargetMachine::getModuleMatchQuality(const Module &M)
44{
45 // We strongly match "spu-*" or "cellspu-*".
46 std::string TT = M.getTargetTriple();
47 if ((TT.size() == 3 && std::string(TT.begin(), TT.begin()+3) == "spu")
48 || (TT.size() == 7 && std::string(TT.begin(), TT.begin()+7) == "cellspu")
49 || (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "spu-")
50 || (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "cellspu-"))
51 return 20;
52
53 return 0; // No match at all...
54}
55
56SPUTargetMachine::SPUTargetMachine(const Module &M, const std::string &FS)
57 : Subtarget(*this, M, FS),
58 DataLayout(Subtarget.getTargetDataString()),
59 InstrInfo(*this),
60 FrameInfo(*this),
61 TLInfo(*this),
62 InstrItins(Subtarget.getInstrItineraryData())
63{
64 // For the time being, use static relocations, since there's really no
65 // support for PIC yet.
66 setRelocationModel(Reloc::Static);
67}
68
69//===----------------------------------------------------------------------===//
70// Pass Pipeline Configuration
71//===----------------------------------------------------------------------===//
72
73bool
74SPUTargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast)
75{
76 // Install an instruction selector.
77 PM.add(createSPUISelDag(*this));
78 return false;
79}
80
81bool SPUTargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast,
82 std::ostream &Out) {
83 PM.add(createSPUAsmPrinterPass(Out, *this));
84 return false;
85}