blob: 8eabe9209d9b801394891f40e2456972604b3094 [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
Evan Cheng43966132011-07-19 06:37:02 +000034SPUTargetMachine::SPUTargetMachine(const Target &T, StringRef TT,
35 StringRef CPU,StringRef FS, Reloc::Model RM)
36 : LLVMTargetMachine(T, TT, CPU, FS, RM),
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}
45
46//===----------------------------------------------------------------------===//
47// Pass Pipeline Configuration
48//===----------------------------------------------------------------------===//
49
Chris Lattner09e820b2009-08-02 04:44:33 +000050bool SPUTargetMachine::addInstSelector(PassManagerBase &PM,
51 CodeGenOpt::Level OptLevel) {
Scott Michel564427e2007-12-05 01:24:05 +000052 // Install an instruction selector.
53 PM.add(createSPUISelDag(*this));
54 return false;
55}
Kalle Raiskila76020ed2011-01-11 09:07:54 +000056
57// passes to run just before printing the assembly
58bool SPUTargetMachine::
59addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel)
60{
61 //align instructions with nops/lnops for dual issue
62 PM.add(createSPUNopFillerPass(*this));
63 return true;
64}