blob: f1b1a742914f3442e11bb3fa4f4f83eec8bf9f85 [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
26namespace {
27 // Register the targets
28 RegisterTarget<SPUTargetMachine>
Daniel Dunbar51b198a2009-07-15 20:24:03 +000029 CELLSPU(TheCellSPUTarget, "cellspu", "STI CBEA Cell SPU [experimental]");
Scott Michel564427e2007-12-05 01:24:05 +000030}
31
Bob Wilsona96751f2009-06-23 23:59:40 +000032// Force static initialization.
33extern "C" void LLVMInitializeCellSPUTarget() { }
Douglas Gregor1555a232009-06-16 20:12:29 +000034
Scott Michel564427e2007-12-05 01:24:05 +000035const std::pair<unsigned, int> *
36SPUFrameInfo::getCalleeSaveSpillSlots(unsigned &NumEntries) const {
37 NumEntries = 1;
38 return &LR[0];
39}
40
41const TargetAsmInfo *
42SPUTargetMachine::createTargetAsmInfo() const
43{
Scott Micheld03eeaf2008-11-07 04:36:25 +000044 return new SPULinuxTargetAsmInfo(*this);
Scott Michel564427e2007-12-05 01:24:05 +000045}
46
Daniel Dunbar51b198a2009-07-15 20:24:03 +000047SPUTargetMachine::SPUTargetMachine(const Target &T, const Module &M,
48 const std::string &FS)
49 : LLVMTargetMachine(T),
50 Subtarget(*this, M, FS),
Scott Michel564427e2007-12-05 01:24:05 +000051 DataLayout(Subtarget.getTargetDataString()),
52 InstrInfo(*this),
53 FrameInfo(*this),
54 TLInfo(*this),
55 InstrItins(Subtarget.getInstrItineraryData())
56{
57 // For the time being, use static relocations, since there's really no
58 // support for PIC yet.
59 setRelocationModel(Reloc::Static);
60}
61
62//===----------------------------------------------------------------------===//
63// Pass Pipeline Configuration
64//===----------------------------------------------------------------------===//
65
66bool
Bill Wendling98a366d2009-04-29 23:29:43 +000067SPUTargetMachine::addInstSelector(PassManagerBase &PM,
68 CodeGenOpt::Level OptLevel)
Scott Michel564427e2007-12-05 01:24:05 +000069{
70 // Install an instruction selector.
71 PM.add(createSPUISelDag(*this));
72 return false;
73}