blob: 16b923b8ce7d322702d2b805bd315d9a0da2a10d [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"
16#include "SPUTargetAsmInfo.h"
17#include "SPUTargetMachine.h"
18#include "llvm/Module.h"
19#include "llvm/PassManager.h"
Scott Michelaedc6372008-12-10 00:15:19 +000020#include "llvm/CodeGen/RegAllocRegistry.h"
21#include "llvm/CodeGen/SchedulerRegistry.h"
Daniel Dunbar0c795d62009-07-25 06:49:55 +000022#include "llvm/Target/TargetRegistry.h"
Scott Michel564427e2007-12-05 01:24:05 +000023
24using namespace llvm;
25
Daniel Dunbar0c795d62009-07-25 06:49:55 +000026extern "C" void LLVMInitializeCellSPUTarget() {
27 // Register the target.
28 RegisterTargetMachine<SPUTargetMachine> X(TheCellSPUTarget);
Scott Michel564427e2007-12-05 01:24:05 +000029}
30
31const std::pair<unsigned, int> *
32SPUFrameInfo::getCalleeSaveSpillSlots(unsigned &NumEntries) const {
33 NumEntries = 1;
34 return &LR[0];
35}
36
Chris Lattner09e820b2009-08-02 04:44:33 +000037const TargetAsmInfo *SPUTargetMachine::createTargetAsmInfo() const {
38 return new SPULinuxTargetAsmInfo();
Scott Michel564427e2007-12-05 01:24:05 +000039}
40
Daniel Dunbar51b198a2009-07-15 20:24:03 +000041SPUTargetMachine::SPUTargetMachine(const Target &T, const Module &M,
42 const std::string &FS)
43 : LLVMTargetMachine(T),
Daniel Dunbar3be03402009-08-02 22:11:08 +000044 Subtarget(M.getTargetTriple(), FS),
Scott Michel564427e2007-12-05 01:24:05 +000045 DataLayout(Subtarget.getTargetDataString()),
46 InstrInfo(*this),
47 FrameInfo(*this),
48 TLInfo(*this),
Chris Lattner09e820b2009-08-02 04:44:33 +000049 InstrItins(Subtarget.getInstrItineraryData()) {
Scott Michel564427e2007-12-05 01:24:05 +000050 // For the time being, use static relocations, since there's really no
51 // support for PIC yet.
52 setRelocationModel(Reloc::Static);
53}
54
55//===----------------------------------------------------------------------===//
56// Pass Pipeline Configuration
57//===----------------------------------------------------------------------===//
58
Chris Lattner09e820b2009-08-02 04:44:33 +000059bool SPUTargetMachine::addInstSelector(PassManagerBase &PM,
60 CodeGenOpt::Level OptLevel) {
Scott Michel564427e2007-12-05 01:24:05 +000061 // Install an instruction selector.
62 PM.add(createSPUISelDag(*this));
63 return false;
64}