blob: b84eab568d2909b9d8206b5078a65ea4b4d0ace1 [file] [log] [blame]
Chris Lattner7c90f732006-02-05 05:50:24 +00001//===-- SparcTargetMachine.cpp - Define TargetMachine for Sparc -----------===//
Misha Brukmanb5f662f2005-04-21 23:30:14 +00002//
Brian Gaekee785e532004-02-25 19:28:19 +00003// 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.
Misha Brukmanb5f662f2005-04-21 23:30:14 +00007//
Brian Gaekee785e532004-02-25 19:28:19 +00008//===----------------------------------------------------------------------===//
Misha Brukmanb5f662f2005-04-21 23:30:14 +00009//
Brian Gaekee785e532004-02-25 19:28:19 +000010//
11//===----------------------------------------------------------------------===//
12
Anton Korobeynikov33464912010-11-15 00:06:54 +000013#include "Sparc.h"
Chris Lattneraf76e592009-08-22 20:48:53 +000014#include "SparcMCAsmInfo.h"
Chris Lattner7c90f732006-02-05 05:50:24 +000015#include "SparcTargetMachine.h"
Brian Gaekee785e532004-02-25 19:28:19 +000016#include "llvm/PassManager.h"
Daniel Dunbar0c795d62009-07-25 06:49:55 +000017#include "llvm/Target/TargetRegistry.h"
Chris Lattner8d8a6bc2004-02-28 19:52:49 +000018using namespace llvm;
Brian Gaekee785e532004-02-25 19:28:19 +000019
Daniel Dunbar0c795d62009-07-25 06:49:55 +000020extern "C" void LLVMInitializeSparcTarget() {
21 // Register the target.
Chris Lattner87c06d62010-02-04 06:34:01 +000022 RegisterTargetMachine<SparcV8TargetMachine> X(TheSparcTarget);
23 RegisterTargetMachine<SparcV9TargetMachine> Y(TheSparcV9Target);
24
25 RegisterAsmInfo<SparcELFMCAsmInfo> A(TheSparcTarget);
26 RegisterAsmInfo<SparcELFMCAsmInfo> B(TheSparcV9Target);
Douglas Gregor1555a232009-06-16 20:12:29 +000027
Jim Laskeyfde1b3b2006-09-07 23:39:26 +000028}
29
Chris Lattner7c90f732006-02-05 05:50:24 +000030/// SparcTargetMachine ctor - Create an ILP32 architecture model
Brian Gaekee785e532004-02-25 19:28:19 +000031///
Daniel Dunbare28039c2009-08-02 23:37:13 +000032SparcTargetMachine::SparcTargetMachine(const Target &T, const std::string &TT,
Chris Lattner87c06d62010-02-04 06:34:01 +000033 const std::string &FS, bool is64bit)
Chris Lattner0a31d2f2009-08-11 20:42:37 +000034 : LLVMTargetMachine(T, TT),
Chris Lattner87c06d62010-02-04 06:34:01 +000035 Subtarget(TT, FS, is64bit),
36 DataLayout(Subtarget.getDataLayout()),
Anton Korobeynikov33464912010-11-15 00:06:54 +000037 TLInfo(*this), TSInfo(*this), InstrInfo(Subtarget),
Anton Korobeynikov16c29b52011-01-10 12:39:04 +000038 FrameLowering(Subtarget) {
Brian Gaeke0e2d4662004-10-09 05:57:01 +000039}
40
Bill Wendlingbe8cc2a2009-04-29 00:15:41 +000041bool SparcTargetMachine::addInstSelector(PassManagerBase &PM,
Bill Wendling98a366d2009-04-29 23:29:43 +000042 CodeGenOpt::Level OptLevel) {
Chris Lattner7c90f732006-02-05 05:50:24 +000043 PM.add(createSparcISelDag(*this));
Chris Lattner9ff6ba12004-02-28 20:21:45 +000044 return false;
Brian Gaekee785e532004-02-25 19:28:19 +000045}
46
Chris Lattner1911fd42006-09-04 04:14:57 +000047/// addPreEmitPass - This pass may be implemented by targets that want to run
48/// passes immediately before machine code is emitted. This should return
49/// true if -print-machineinstrs should print out the code after the passes.
Bill Wendling98a366d2009-04-29 23:29:43 +000050bool SparcTargetMachine::addPreEmitPass(PassManagerBase &PM,
51 CodeGenOpt::Level OptLevel){
Chris Lattner1911fd42006-09-04 04:14:57 +000052 PM.add(createSparcFPMoverPass(*this));
53 PM.add(createSparcDelaySlotFillerPass(*this));
54 return true;
55}
Chris Lattner87c06d62010-02-04 06:34:01 +000056
57SparcV8TargetMachine::SparcV8TargetMachine(const Target &T,
58 const std::string &TT,
59 const std::string &FS)
60 : SparcTargetMachine(T, TT, FS, false) {
61}
62
63SparcV9TargetMachine::SparcV9TargetMachine(const Target &T,
64 const std::string &TT,
65 const std::string &FS)
66 : SparcTargetMachine(T, TT, FS, true) {
67}