blob: 3542a2b87e43202f42e1a9759ff61dd0e309ba6a [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"
Scott Michel564427e2007-12-05 01:24:05 +000015#include "SPUTargetMachine.h"
Scott Michel564427e2007-12-05 01:24:05 +000016#include "llvm/PassManager.h"
Scott Michelaedc6372008-12-10 00:15:19 +000017#include "llvm/CodeGen/RegAllocRegistry.h"
18#include "llvm/CodeGen/SchedulerRegistry.h"
Daniel Dunbar0c795d62009-07-25 06:49:55 +000019#include "llvm/Target/TargetRegistry.h"
Scott Michel564427e2007-12-05 01:24:05 +000020
21using namespace llvm;
22
Daniel Dunbar0c795d62009-07-25 06:49:55 +000023extern "C" void LLVMInitializeCellSPUTarget() {
24 // Register the target.
25 RegisterTargetMachine<SPUTargetMachine> X(TheCellSPUTarget);
Scott Michel564427e2007-12-05 01:24:05 +000026}
27
28const std::pair<unsigned, int> *
Anton Korobeynikov16c29b52011-01-10 12:39:04 +000029SPUFrameLowering::getCalleeSaveSpillSlots(unsigned &NumEntries) const {
Scott Michel564427e2007-12-05 01:24:05 +000030 NumEntries = 1;
31 return &LR[0];
32}
33
Daniel Dunbare28039c2009-08-02 23:37:13 +000034SPUTargetMachine::SPUTargetMachine(const Target &T, const std::string &TT,
Evan Cheng276365d2011-06-30 01:53:36 +000035 const std::string &CPU,const std::string &FS)
Evan Chengebdeeab2011-07-08 01:53:10 +000036 : LLVMTargetMachine(T, TT, CPU, FS),
Evan Cheng276365d2011-06-30 01:53:36 +000037 Subtarget(TT, CPU, FS),
Scott Michel564427e2007-12-05 01:24:05 +000038 DataLayout(Subtarget.getTargetDataString()),
39 InstrInfo(*this),
Anton Korobeynikov16c29b52011-01-10 12:39:04 +000040 FrameLowering(Subtarget),
Scott Michel564427e2007-12-05 01:24:05 +000041 TLInfo(*this),
Dan Gohmanff7a5622010-05-11 17:31:57 +000042 TSInfo(*this),
Chris Lattner09e820b2009-08-02 04:44:33 +000043 InstrItins(Subtarget.getInstrItineraryData()) {
Scott Michel564427e2007-12-05 01:24:05 +000044 // For the time being, use static relocations, since there's really no
45 // support for PIC yet.
46 setRelocationModel(Reloc::Static);
47}
48
49//===----------------------------------------------------------------------===//
50// Pass Pipeline Configuration
51//===----------------------------------------------------------------------===//
52
Chris Lattner09e820b2009-08-02 04:44:33 +000053bool SPUTargetMachine::addInstSelector(PassManagerBase &PM,
54 CodeGenOpt::Level OptLevel) {
Scott Michel564427e2007-12-05 01:24:05 +000055 // Install an instruction selector.
56 PM.add(createSPUISelDag(*this));
57 return false;
58}
Kalle Raiskila76020ed2011-01-11 09:07:54 +000059
60// passes to run just before printing the assembly
61bool SPUTargetMachine::
62addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel)
63{
64 //align instructions with nops/lnops for dual issue
65 PM.add(createSPUNopFillerPass(*this));
66 return true;
67}