blob: a6766236f097ad5701d4f9770d8e5667478f5b1d [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===-- SparcTargetMachine.cpp - Define TargetMachine for Sparc -----------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10//
11//===----------------------------------------------------------------------===//
12
Chris Lattner621c44d2009-08-22 20:48:53 +000013#include "SparcMCAsmInfo.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000014#include "SparcTargetMachine.h"
15#include "Sparc.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000016#include "llvm/PassManager.h"
Daniel Dunbarc680b012009-07-25 06:49:55 +000017#include "llvm/Target/TargetRegistry.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000018using namespace llvm;
19
Daniel Dunbarc680b012009-07-25 06:49:55 +000020extern "C" void LLVMInitializeSparcTarget() {
21 // Register the target.
Chris Lattner58957cd2010-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 Gregor1dc5ff42009-06-16 20:12:29 +000027
Dan Gohmanf17a25c2007-07-18 16:29:46 +000028}
29
30/// SparcTargetMachine ctor - Create an ILP32 architecture model
31///
Daniel Dunbarf5c2b852009-08-02 23:37:13 +000032SparcTargetMachine::SparcTargetMachine(const Target &T, const std::string &TT,
Chris Lattner58957cd2010-02-04 06:34:01 +000033 const std::string &FS, bool is64bit)
Chris Lattnerd9236ec2009-08-11 20:42:37 +000034 : LLVMTargetMachine(T, TT),
Chris Lattner58957cd2010-02-04 06:34:01 +000035 Subtarget(TT, FS, is64bit),
36 DataLayout(Subtarget.getDataLayout()),
37 TLInfo(*this), InstrInfo(Subtarget),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000038 FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) {
39}
40
Bill Wendling58ed5d22009-04-29 00:15:41 +000041bool SparcTargetMachine::addInstSelector(PassManagerBase &PM,
Bill Wendling5ed22ac2009-04-29 23:29:43 +000042 CodeGenOpt::Level OptLevel) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000043 PM.add(createSparcISelDag(*this));
44 return false;
45}
46
47/// 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 Wendling5ed22ac2009-04-29 23:29:43 +000050bool SparcTargetMachine::addPreEmitPass(PassManagerBase &PM,
51 CodeGenOpt::Level OptLevel){
Dan Gohmanf17a25c2007-07-18 16:29:46 +000052 PM.add(createSparcFPMoverPass(*this));
53 PM.add(createSparcDelaySlotFillerPass(*this));
54 return true;
55}
Chris Lattner58957cd2010-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}