blob: 880da0dff4313e86490b010e56c4ddc49ead135b [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"
Scott Michelaedc6372008-12-10 00:15:19 +000021#include "llvm/CodeGen/RegAllocRegistry.h"
22#include "llvm/CodeGen/SchedulerRegistry.h"
Scott Michel564427e2007-12-05 01:24:05 +000023
24using namespace llvm;
25
Daniel Dunbar51b198a2009-07-15 20:24:03 +000026extern Target TheCellSPUTarget;
Scott Michel564427e2007-12-05 01:24:05 +000027namespace {
28 // Register the targets
29 RegisterTarget<SPUTargetMachine>
Daniel Dunbar51b198a2009-07-15 20:24:03 +000030 CELLSPU(TheCellSPUTarget, "cellspu", "STI CBEA Cell SPU [experimental]");
Scott Michel564427e2007-12-05 01:24:05 +000031}
32
Bob Wilsona96751f2009-06-23 23:59:40 +000033// Force static initialization.
34extern "C" void LLVMInitializeCellSPUTarget() { }
Douglas Gregor1555a232009-06-16 20:12:29 +000035
Scott Michel564427e2007-12-05 01:24:05 +000036const std::pair<unsigned, int> *
37SPUFrameInfo::getCalleeSaveSpillSlots(unsigned &NumEntries) const {
38 NumEntries = 1;
39 return &LR[0];
40}
41
42const TargetAsmInfo *
43SPUTargetMachine::createTargetAsmInfo() const
44{
Scott Micheld03eeaf2008-11-07 04:36:25 +000045 return new SPULinuxTargetAsmInfo(*this);
Scott Michel564427e2007-12-05 01:24:05 +000046}
47
Daniel Dunbar51b198a2009-07-15 20:24:03 +000048SPUTargetMachine::SPUTargetMachine(const Target &T, const Module &M,
49 const std::string &FS)
50 : LLVMTargetMachine(T),
51 Subtarget(*this, M, FS),
Scott Michel564427e2007-12-05 01:24:05 +000052 DataLayout(Subtarget.getTargetDataString()),
53 InstrInfo(*this),
54 FrameInfo(*this),
55 TLInfo(*this),
56 InstrItins(Subtarget.getInstrItineraryData())
57{
58 // For the time being, use static relocations, since there's really no
59 // support for PIC yet.
60 setRelocationModel(Reloc::Static);
61}
62
63//===----------------------------------------------------------------------===//
64// Pass Pipeline Configuration
65//===----------------------------------------------------------------------===//
66
67bool
Bill Wendling98a366d2009-04-29 23:29:43 +000068SPUTargetMachine::addInstSelector(PassManagerBase &PM,
69 CodeGenOpt::Level OptLevel)
Scott Michel564427e2007-12-05 01:24:05 +000070{
71 // Install an instruction selector.
72 PM.add(createSPUISelDag(*this));
73 return false;
74}
75
Bill Wendlingbe8cc2a2009-04-29 00:15:41 +000076bool SPUTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
Bill Wendling98a366d2009-04-29 23:29:43 +000077 CodeGenOpt::Level OptLevel,
Bill Wendlingbe8cc2a2009-04-29 00:15:41 +000078 bool Verbose,
David Greene71847812009-07-14 20:18:05 +000079 formatted_raw_ostream &Out) {
Daniel Dunbarf0552292009-07-15 22:01:32 +000080 FunctionPass *Printer = getTarget().createAsmPrinter(Out, *this, Verbose);
81 if (!Printer)
82 llvm_report_error("unable to create assembly printer");
83 PM.add(Printer);
Scott Michel564427e2007-12-05 01:24:05 +000084 return false;
85}