blob: 0605db393ec5fe9d78b2f88fb0773e3a7ec4f662 [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"
Daniel Dunbarc680b012009-07-25 06:49:55 +000018#include "llvm/Target/TargetRegistry.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000019using namespace llvm;
20
Daniel Dunbarc680b012009-07-25 06:49:55 +000021extern "C" void LLVMInitializeSparcTarget() {
22 // Register the target.
23 RegisterTargetMachine<SparcTargetMachine> X(TheSparcTarget);
24}
Douglas Gregor1dc5ff42009-06-16 20:12:29 +000025
Dan Gohmanf17a25c2007-07-18 16:29:46 +000026const TargetAsmInfo *SparcTargetMachine::createTargetAsmInfo() const {
Anton Korobeynikovdb9a8952008-08-07 09:51:25 +000027 // FIXME: Handle Solaris subtarget someday :)
28 return new SparcELFTargetAsmInfo(*this);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000029}
30
31/// SparcTargetMachine ctor - Create an ILP32 architecture model
32///
Daniel Dunbarfe5939f2009-07-15 20:24:03 +000033SparcTargetMachine::SparcTargetMachine(const Target &T, const Module &M,
34 const std::string &FS)
35 : LLVMTargetMachine(T),
36 DataLayout("E-p:32:32-f128:128:128"),
Dan Gohmanf2b29572008-10-03 16:55:19 +000037 Subtarget(M, FS), 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}