blob: c9a3cdd6c7bcd9b8e3af8cc1e2e2b0ccee9ebb66 [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
13#include "SparcTargetAsmInfo.h"
14#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.
22 RegisterTargetMachine<SparcTargetMachine> X(TheSparcTarget);
23}
Douglas Gregor1dc5ff42009-06-16 20:12:29 +000024
Dan Gohmanf17a25c2007-07-18 16:29:46 +000025const TargetAsmInfo *SparcTargetMachine::createTargetAsmInfo() const {
Anton Korobeynikovdb9a8952008-08-07 09:51:25 +000026 // FIXME: Handle Solaris subtarget someday :)
Chris Lattner361da8a2009-08-02 04:30:59 +000027 return new SparcELFTargetAsmInfo();
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,
Daniel Dunbarfe5939f2009-07-15 20:24:03 +000033 const std::string &FS)
Chris Lattnerd9236ec2009-08-11 20:42:37 +000034 : LLVMTargetMachine(T, TT),
Daniel Dunbarfe5939f2009-07-15 20:24:03 +000035 DataLayout("E-p:32:32-f128:128:128"),
Daniel Dunbarf5c2b852009-08-02 23:37:13 +000036 Subtarget(TT, FS), TLInfo(*this), InstrInfo(Subtarget),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000037 FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) {
38}
39
Bill Wendling58ed5d22009-04-29 00:15:41 +000040bool SparcTargetMachine::addInstSelector(PassManagerBase &PM,
Bill Wendling5ed22ac2009-04-29 23:29:43 +000041 CodeGenOpt::Level OptLevel) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000042 PM.add(createSparcISelDag(*this));
43 return false;
44}
45
46/// addPreEmitPass - This pass may be implemented by targets that want to run
47/// passes immediately before machine code is emitted. This should return
48/// true if -print-machineinstrs should print out the code after the passes.
Bill Wendling5ed22ac2009-04-29 23:29:43 +000049bool SparcTargetMachine::addPreEmitPass(PassManagerBase &PM,
50 CodeGenOpt::Level OptLevel){
Dan Gohmanf17a25c2007-07-18 16:29:46 +000051 PM.add(createSparcFPMoverPass(*this));
52 PM.add(createSparcDelaySlotFillerPass(*this));
53 return true;
54}