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