blob: ea59a80e870a01f7851b9b5dde1aa011ea5ba054 [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,
Evan Cheng34ad6db2011-07-20 07:51:56 +000035 StringRef CPU, StringRef FS,
36 Reloc::Model RM, CodeModel::Model CM)
37 : LLVMTargetMachine(T, TT, CPU, FS, RM, CM),
Evan Cheng276365d2011-06-30 01:53:36 +000038 Subtarget(TT, CPU, FS),
Scott Michel564427e2007-12-05 01:24:05 +000039 DataLayout(Subtarget.getTargetDataString()),
40 InstrInfo(*this),
Anton Korobeynikov16c29b52011-01-10 12:39:04 +000041 FrameLowering(Subtarget),
Scott Michel564427e2007-12-05 01:24:05 +000042 TLInfo(*this),
Dan Gohmanff7a5622010-05-11 17:31:57 +000043 TSInfo(*this),
Chris Lattner09e820b2009-08-02 04:44:33 +000044 InstrItins(Subtarget.getInstrItineraryData()) {
Scott Michel564427e2007-12-05 01:24:05 +000045}
46
47//===----------------------------------------------------------------------===//
48// Pass Pipeline Configuration
49//===----------------------------------------------------------------------===//
50
Chris Lattner09e820b2009-08-02 04:44:33 +000051bool SPUTargetMachine::addInstSelector(PassManagerBase &PM,
52 CodeGenOpt::Level OptLevel) {
Scott Michel564427e2007-12-05 01:24:05 +000053 // Install an instruction selector.
54 PM.add(createSPUISelDag(*this));
55 return false;
56}
Kalle Raiskila76020ed2011-01-11 09:07:54 +000057
58// passes to run just before printing the assembly
59bool SPUTargetMachine::
60addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel)
61{
62 //align instructions with nops/lnops for dual issue
63 PM.add(createSPUNopFillerPass(*this));
64 return true;
65}