blob: 5903f9b612dd778b40049605ff010efa08fa9665 [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"
Chris Lattneraf76e592009-08-22 20:48:53 +000015#include "SPUMCAsmInfo.h"
Scott Michel564427e2007-12-05 01:24:05 +000016#include "SPUTargetMachine.h"
Scott Michel564427e2007-12-05 01:24:05 +000017#include "llvm/PassManager.h"
Scott Michelaedc6372008-12-10 00:15:19 +000018#include "llvm/CodeGen/RegAllocRegistry.h"
19#include "llvm/CodeGen/SchedulerRegistry.h"
Daniel Dunbar0c795d62009-07-25 06:49:55 +000020#include "llvm/Target/TargetRegistry.h"
Scott Michel564427e2007-12-05 01:24:05 +000021
22using namespace llvm;
23
Daniel Dunbar0c795d62009-07-25 06:49:55 +000024extern "C" void LLVMInitializeCellSPUTarget() {
25 // Register the target.
26 RegisterTargetMachine<SPUTargetMachine> X(TheCellSPUTarget);
Chris Lattneraf76e592009-08-22 20:48:53 +000027 RegisterAsmInfo<SPULinuxMCAsmInfo> Y(TheCellSPUTarget);
Scott Michel564427e2007-12-05 01:24:05 +000028}
29
30const std::pair<unsigned, int> *
Anton Korobeynikov16c29b52011-01-10 12:39:04 +000031SPUFrameLowering::getCalleeSaveSpillSlots(unsigned &NumEntries) const {
Scott Michel564427e2007-12-05 01:24:05 +000032 NumEntries = 1;
33 return &LR[0];
34}
35
Daniel Dunbare28039c2009-08-02 23:37:13 +000036SPUTargetMachine::SPUTargetMachine(const Target &T, const std::string &TT,
Evan Cheng276365d2011-06-30 01:53:36 +000037 const std::string &CPU,const std::string &FS)
Evan Chengebdeeab2011-07-08 01:53:10 +000038 : LLVMTargetMachine(T, TT, CPU, FS),
Evan Cheng276365d2011-06-30 01:53:36 +000039 Subtarget(TT, CPU, FS),
Scott Michel564427e2007-12-05 01:24:05 +000040 DataLayout(Subtarget.getTargetDataString()),
41 InstrInfo(*this),
Anton Korobeynikov16c29b52011-01-10 12:39:04 +000042 FrameLowering(Subtarget),
Scott Michel564427e2007-12-05 01:24:05 +000043 TLInfo(*this),
Dan Gohmanff7a5622010-05-11 17:31:57 +000044 TSInfo(*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}
Kalle Raiskila76020ed2011-01-11 09:07:54 +000061
62// passes to run just before printing the assembly
63bool SPUTargetMachine::
64addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel)
65{
66 //align instructions with nops/lnops for dual issue
67 PM.add(createSPUNopFillerPass(*this));
68 return true;
69}