blob: 686cf9102838af58211fd49f76d2c172ec58794a [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"
16#include "llvm/Module.h"
17#include "llvm/PassManager.h"
18#include "llvm/Target/TargetMachineRegistry.h"
19using namespace llvm;
20
Dan Gohman089efff2008-05-13 00:00:25 +000021// Register the target.
Daniel Dunbarfe5939f2009-07-15 20:24:03 +000022static RegisterTarget<SparcTargetMachine> X(TheSparcTarget, "sparc", "SPARC");
Dan Gohmanf17a25c2007-07-18 16:29:46 +000023
Bob Wilsonebbc1c42009-06-23 23:59:40 +000024// Force static initialization.
25extern "C" void LLVMInitializeSparcTarget() { }
Douglas Gregor1dc5ff42009-06-16 20:12:29 +000026
Dan Gohmanf17a25c2007-07-18 16:29:46 +000027const TargetAsmInfo *SparcTargetMachine::createTargetAsmInfo() const {
Anton Korobeynikovdb9a8952008-08-07 09:51:25 +000028 // FIXME: Handle Solaris subtarget someday :)
29 return new SparcELFTargetAsmInfo(*this);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000030}
31
32/// SparcTargetMachine ctor - Create an ILP32 architecture model
33///
Daniel Dunbarfe5939f2009-07-15 20:24:03 +000034SparcTargetMachine::SparcTargetMachine(const Target &T, const Module &M,
35 const std::string &FS)
36 : LLVMTargetMachine(T),
37 DataLayout("E-p:32:32-f128:128:128"),
Dan Gohmanf2b29572008-10-03 16:55:19 +000038 Subtarget(M, FS), TLInfo(*this), InstrInfo(Subtarget),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000039 FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) {
40}
41
Bill Wendling58ed5d22009-04-29 00:15:41 +000042bool SparcTargetMachine::addInstSelector(PassManagerBase &PM,
Bill Wendling5ed22ac2009-04-29 23:29:43 +000043 CodeGenOpt::Level OptLevel) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000044 PM.add(createSparcISelDag(*this));
45 return false;
46}
47
48/// addPreEmitPass - This pass may be implemented by targets that want to run
49/// passes immediately before machine code is emitted. This should return
50/// true if -print-machineinstrs should print out the code after the passes.
Bill Wendling5ed22ac2009-04-29 23:29:43 +000051bool SparcTargetMachine::addPreEmitPass(PassManagerBase &PM,
52 CodeGenOpt::Level OptLevel){
Dan Gohmanf17a25c2007-07-18 16:29:46 +000053 PM.add(createSparcFPMoverPass(*this));
54 PM.add(createSparcDelaySlotFillerPass(*this));
55 return true;
56}