blob: 3ed73613a31dc125c4f3e385539c544fdcac240e [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"
Chris Lattneraf76e592009-08-22 20:48:53 +000016#include "SPUMCAsmInfo.h"
Scott Michel564427e2007-12-05 01:24:05 +000017#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 Lattneraf76e592009-08-22 20:48:53 +000028 RegisterAsmInfo<SPULinuxMCAsmInfo> Y(TheCellSPUTarget);
Scott Michel564427e2007-12-05 01:24:05 +000029}
30
31const std::pair<unsigned, int> *
Anton Korobeynikov16c29b52011-01-10 12:39:04 +000032SPUFrameLowering::getCalleeSaveSpillSlots(unsigned &NumEntries) const {
Scott Michel564427e2007-12-05 01:24:05 +000033 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),
Anton Korobeynikov16c29b52011-01-10 12:39:04 +000043 FrameLowering(Subtarget),
Scott Michel564427e2007-12-05 01:24:05 +000044 TLInfo(*this),
Dan Gohmanff7a5622010-05-11 17:31:57 +000045 TSInfo(*this),
Chris Lattner09e820b2009-08-02 04:44:33 +000046 InstrItins(Subtarget.getInstrItineraryData()) {
Scott Michel564427e2007-12-05 01:24:05 +000047 // For the time being, use static relocations, since there's really no
48 // support for PIC yet.
49 setRelocationModel(Reloc::Static);
50}
51
52//===----------------------------------------------------------------------===//
53// Pass Pipeline Configuration
54//===----------------------------------------------------------------------===//
55
Chris Lattner09e820b2009-08-02 04:44:33 +000056bool SPUTargetMachine::addInstSelector(PassManagerBase &PM,
57 CodeGenOpt::Level OptLevel) {
Scott Michel564427e2007-12-05 01:24:05 +000058 // Install an instruction selector.
59 PM.add(createSPUISelDag(*this));
60 return false;
61}
Kalle Raiskila76020ed2011-01-11 09:07:54 +000062
63// passes to run just before printing the assembly
64bool SPUTargetMachine::
65addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel)
66{
67 //align instructions with nops/lnops for dual issue
68 PM.add(createSPUNopFillerPass(*this));
69 return true;
70}