blob: 255036311341979b13d7a0c78881762e02c188bb [file] [log] [blame]
Chris Lattner158e1f52006-02-05 05:50:24 +00001//===-- SparcTargetMachine.cpp - Define TargetMachine for Sparc -----------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Chris Lattner158e1f52006-02-05 05:50:24 +00007//
8//===----------------------------------------------------------------------===//
9//
10//
11//===----------------------------------------------------------------------===//
12
Jim Laskeyae92ce82006-09-07 23:39:26 +000013#include "SparcTargetAsmInfo.h"
Chris Lattner158e1f52006-02-05 05:50:24 +000014#include "SparcTargetMachine.h"
15#include "Sparc.h"
Chris Lattner158e1f52006-02-05 05:50:24 +000016#include "llvm/Module.h"
17#include "llvm/PassManager.h"
Chris Lattner158e1f52006-02-05 05:50:24 +000018#include "llvm/Target/TargetMachineRegistry.h"
Chris Lattner158e1f52006-02-05 05:50:24 +000019using namespace llvm;
20
Dan Gohmand78c4002008-05-13 00:00:25 +000021// Register the target.
Daniel Dunbare8338102009-07-15 20:24:03 +000022extern Target TheSparcTarget;
23static RegisterTarget<SparcTargetMachine> X(TheSparcTarget, "sparc", "SPARC");
Chris Lattner158e1f52006-02-05 05:50:24 +000024
Chris Lattner3773afe2009-06-19 15:48:10 +000025// No assembler printer by default
26SparcTargetMachine::AsmPrinterCtorFn SparcTargetMachine::AsmPrinterCtor = 0;
27
28
Bob Wilson5a495fe2009-06-23 23:59:40 +000029// Force static initialization.
30extern "C" void LLVMInitializeSparcTarget() { }
Douglas Gregor1b731d52009-06-16 20:12:29 +000031
Jim Laskeyae92ce82006-09-07 23:39:26 +000032const TargetAsmInfo *SparcTargetMachine::createTargetAsmInfo() const {
Anton Korobeynikov1a11e8a2008-08-07 09:51:25 +000033 // FIXME: Handle Solaris subtarget someday :)
34 return new SparcELFTargetAsmInfo(*this);
Jim Laskeyae92ce82006-09-07 23:39:26 +000035}
36
Chris Lattner158e1f52006-02-05 05:50:24 +000037/// SparcTargetMachine ctor - Create an ILP32 architecture model
38///
Daniel Dunbare8338102009-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 Gohman2c836cf2008-10-03 16:55:19 +000043 Subtarget(M, FS), TLInfo(*this), InstrInfo(Subtarget),
Chris Lattner158e1f52006-02-05 05:50:24 +000044 FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) {
45}
46
Bill Wendling084669a2009-04-29 00:15:41 +000047bool SparcTargetMachine::addInstSelector(PassManagerBase &PM,
Bill Wendling026e5d72009-04-29 23:29:43 +000048 CodeGenOpt::Level OptLevel) {
Chris Lattner158e1f52006-02-05 05:50:24 +000049 PM.add(createSparcISelDag(*this));
Chris Lattner158e1f52006-02-05 05:50:24 +000050 return false;
51}
52
Chris Lattner12e97302006-09-04 04:14:57 +000053/// 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 Wendling026e5d72009-04-29 23:29:43 +000056bool SparcTargetMachine::addPreEmitPass(PassManagerBase &PM,
57 CodeGenOpt::Level OptLevel){
Chris Lattner12e97302006-09-04 04:14:57 +000058 PM.add(createSparcFPMoverPass(*this));
59 PM.add(createSparcDelaySlotFillerPass(*this));
60 return true;
61}
62
Bill Wendling084669a2009-04-29 00:15:41 +000063bool SparcTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
Bill Wendling026e5d72009-04-29 23:29:43 +000064 CodeGenOpt::Level OptLevel,
Bill Wendling084669a2009-04-29 00:15:41 +000065 bool Verbose,
David Greenea31f96c2009-07-14 20:18:05 +000066 formatted_raw_ostream &Out) {
Chris Lattner12e97302006-09-04 04:14:57 +000067 // Output assembly language.
Chris Lattner3773afe2009-06-19 15:48:10 +000068 assert(AsmPrinterCtor && "AsmPrinter was not linked in");
69 if (AsmPrinterCtor)
Daniel Dunbar75c12e12009-07-01 01:48:54 +000070 PM.add(AsmPrinterCtor(Out, *this, Verbose));
Chris Lattner12e97302006-09-04 04:14:57 +000071 return false;
72}