blob: b904b9559d00b5594fb8c82733dc52362e1129a3 [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"
Scott Michel564427e2007-12-05 01:24:05 +000018#include "llvm/PassManager.h"
Scott Michelaedc6372008-12-10 00:15:19 +000019#include "llvm/CodeGen/RegAllocRegistry.h"
20#include "llvm/CodeGen/SchedulerRegistry.h"
Daniel Dunbar0c795d62009-07-25 06:49:55 +000021#include "llvm/Target/TargetRegistry.h"
Scott Michel564427e2007-12-05 01:24:05 +000022
23using namespace llvm;
24
Daniel Dunbar0c795d62009-07-25 06:49:55 +000025extern "C" void LLVMInitializeCellSPUTarget() {
26 // Register the target.
27 RegisterTargetMachine<SPUTargetMachine> X(TheCellSPUTarget);
Chris Lattnera7ac47c2009-08-12 07:22:17 +000028 RegisterAsmInfo<SPULinuxTargetAsmInfo> Y(TheCellSPUTarget);
Scott Michel564427e2007-12-05 01:24:05 +000029}
30
31const std::pair<unsigned, int> *
32SPUFrameInfo::getCalleeSaveSpillSlots(unsigned &NumEntries) const {
33 NumEntries = 1;
34 return &LR[0];
35}
36
Daniel Dunbare28039c2009-08-02 23:37:13 +000037SPUTargetMachine::SPUTargetMachine(const Target &T, const std::string &TT,
Daniel Dunbar51b198a2009-07-15 20:24:03 +000038 const std::string &FS)
Chris Lattner0a31d2f2009-08-11 20:42:37 +000039 : LLVMTargetMachine(T, TT),
Daniel Dunbare28039c2009-08-02 23:37:13 +000040 Subtarget(TT, FS),
Scott Michel564427e2007-12-05 01:24:05 +000041 DataLayout(Subtarget.getTargetDataString()),
42 InstrInfo(*this),
43 FrameInfo(*this),
44 TLInfo(*this),
Chris Lattner09e820b2009-08-02 04:44:33 +000045 InstrItins(Subtarget.getInstrItineraryData()) {
Scott Michel564427e2007-12-05 01:24:05 +000046 // For the time being, use static relocations, since there's really no
47 // support for PIC yet.
48 setRelocationModel(Reloc::Static);
49}
50
51//===----------------------------------------------------------------------===//
52// Pass Pipeline Configuration
53//===----------------------------------------------------------------------===//
54
Chris Lattner09e820b2009-08-02 04:44:33 +000055bool SPUTargetMachine::addInstSelector(PassManagerBase &PM,
56 CodeGenOpt::Level OptLevel) {
Scott Michel564427e2007-12-05 01:24:05 +000057 // Install an instruction selector.
58 PM.add(createSPUISelDag(*this));
59 return false;
60}