blob: 255036311341979b13d7a0c78881762e02c188bb [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 +000022extern Target TheSparcTarget;
23static RegisterTarget<SparcTargetMachine> X(TheSparcTarget, "sparc", "SPARC");
Dan Gohmanf17a25c2007-07-18 16:29:46 +000024
Chris Lattnere880ec92009-06-19 15:48:10 +000025// No assembler printer by default
26SparcTargetMachine::AsmPrinterCtorFn SparcTargetMachine::AsmPrinterCtor = 0;
27
28
Bob Wilsonebbc1c42009-06-23 23:59:40 +000029// Force static initialization.
30extern "C" void LLVMInitializeSparcTarget() { }
Douglas Gregor1dc5ff42009-06-16 20:12:29 +000031
Dan Gohmanf17a25c2007-07-18 16:29:46 +000032const TargetAsmInfo *SparcTargetMachine::createTargetAsmInfo() const {
Anton Korobeynikovdb9a8952008-08-07 09:51:25 +000033 // FIXME: Handle Solaris subtarget someday :)
34 return new SparcELFTargetAsmInfo(*this);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000035}
36
37/// SparcTargetMachine ctor - Create an ILP32 architecture model
38///
Daniel Dunbarfe5939f2009-07-15 20:24:03 +000039SparcTargetMachine::SparcTargetMachine(const Target &T, const Module &M,
40 const std::string &FS)
41 : LLVMTargetMachine(T),
42 DataLayout("E-p:32:32-f128:128:128"),
Dan Gohmanf2b29572008-10-03 16:55:19 +000043 Subtarget(M, FS), TLInfo(*this), InstrInfo(Subtarget),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000044 FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) {
45}
46
Bill Wendling58ed5d22009-04-29 00:15:41 +000047bool SparcTargetMachine::addInstSelector(PassManagerBase &PM,
Bill Wendling5ed22ac2009-04-29 23:29:43 +000048 CodeGenOpt::Level OptLevel) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000049 PM.add(createSparcISelDag(*this));
50 return false;
51}
52
53/// addPreEmitPass - This pass may be implemented by targets that want to run
54/// passes immediately before machine code is emitted. This should return
55/// true if -print-machineinstrs should print out the code after the passes.
Bill Wendling5ed22ac2009-04-29 23:29:43 +000056bool SparcTargetMachine::addPreEmitPass(PassManagerBase &PM,
57 CodeGenOpt::Level OptLevel){
Dan Gohmanf17a25c2007-07-18 16:29:46 +000058 PM.add(createSparcFPMoverPass(*this));
59 PM.add(createSparcDelaySlotFillerPass(*this));
60 return true;
61}
62
Bill Wendling58ed5d22009-04-29 00:15:41 +000063bool SparcTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
Bill Wendling5ed22ac2009-04-29 23:29:43 +000064 CodeGenOpt::Level OptLevel,
Bill Wendling58ed5d22009-04-29 00:15:41 +000065 bool Verbose,
David Greene302008d2009-07-14 20:18:05 +000066 formatted_raw_ostream &Out) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000067 // Output assembly language.
Chris Lattnere880ec92009-06-19 15:48:10 +000068 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
69 if (AsmPrinterCtor)
Daniel Dunbarb10d2222009-07-01 01:48:54 +000070 PM.add(AsmPrinterCtor(Out, *this, Verbose));
Dan Gohmanf17a25c2007-07-18 16:29:46 +000071 return false;
72}