blob: 5da4a7839d456993eb72f389e86a8e62406df9a5 [file] [log] [blame]
Chris Lattner158e1f52006-02-05 05:50:24 +00001//===-- SparcTargetMachine.h - Define TargetMachine for Sparc ---*- C++ -*-===//
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// This file declares the Sparc specific subclass of TargetMachine.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef SPARCTARGETMACHINE_H
15#define SPARCTARGETMACHINE_H
16
17#include "llvm/Target/TargetMachine.h"
Owen Anderson8c2c1e92006-05-12 06:33:49 +000018#include "llvm/Target/TargetData.h"
Chris Lattner158e1f52006-02-05 05:50:24 +000019#include "llvm/Target/TargetFrameInfo.h"
Chris Lattner158e1f52006-02-05 05:50:24 +000020#include "SparcInstrInfo.h"
21#include "SparcSubtarget.h"
Dan Gohman2c836cf2008-10-03 16:55:19 +000022#include "SparcISelLowering.h"
Chris Lattner158e1f52006-02-05 05:50:24 +000023
24namespace llvm {
25
Chris Lattner158e1f52006-02-05 05:50:24 +000026class Module;
27
Chris Lattner12e97302006-09-04 04:14:57 +000028class SparcTargetMachine : public LLVMTargetMachine {
Owen Anderson20a631f2006-05-03 01:29:57 +000029 const TargetData DataLayout; // Calculates type size & alignment
Chris Lattner158e1f52006-02-05 05:50:24 +000030 SparcSubtarget Subtarget;
Dan Gohman2c836cf2008-10-03 16:55:19 +000031 SparcTargetLowering TLInfo;
Chris Lattner158e1f52006-02-05 05:50:24 +000032 SparcInstrInfo InstrInfo;
33 TargetFrameInfo FrameInfo;
Jim Laskeyae92ce82006-09-07 23:39:26 +000034
35protected:
36 virtual const TargetAsmInfo *createTargetAsmInfo() const;
37
Chris Lattner3773afe2009-06-19 15:48:10 +000038 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
39 // set this functions to ctor pointer at startup time if they are linked in.
David Greenea31f96c2009-07-14 20:18:05 +000040 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
Chris Lattner3773afe2009-06-19 15:48:10 +000041 TargetMachine &tm,
Chris Lattner3773afe2009-06-19 15:48:10 +000042 bool verbose);
43 static AsmPrinterCtorFn AsmPrinterCtor;
44
Chris Lattner158e1f52006-02-05 05:50:24 +000045public:
Chris Lattner6f95ab72006-03-23 05:43:16 +000046 SparcTargetMachine(const Module &M, const std::string &FS);
Chris Lattner158e1f52006-02-05 05:50:24 +000047
48 virtual const SparcInstrInfo *getInstrInfo() const { return &InstrInfo; }
49 virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; }
Dan Gohmaneabd6472008-05-14 01:58:56 +000050 virtual const SparcSubtarget *getSubtargetImpl() const{ return &Subtarget; }
51 virtual const SparcRegisterInfo *getRegisterInfo() const {
Chris Lattner158e1f52006-02-05 05:50:24 +000052 return &InstrInfo.getRegisterInfo();
53 }
Dan Gohman2c836cf2008-10-03 16:55:19 +000054 virtual SparcTargetLowering* getTargetLowering() const {
55 return const_cast<SparcTargetLowering*>(&TLInfo);
56 }
Owen Anderson20a631f2006-05-03 01:29:57 +000057 virtual const TargetData *getTargetData() const { return &DataLayout; }
Chris Lattner158e1f52006-02-05 05:50:24 +000058 static unsigned getModuleMatchQuality(const Module &M);
59
Chris Lattner12e97302006-09-04 04:14:57 +000060 // Pass Pipeline Configuration
Bill Wendling026e5d72009-04-29 23:29:43 +000061 virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
62 virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
63 virtual bool addAssemblyEmitter(PassManagerBase &PM,
64 CodeGenOpt::Level OptLevel,
David Greenea31f96c2009-07-14 20:18:05 +000065 bool Verbose, formatted_raw_ostream &Out);
Chris Lattner3773afe2009-06-19 15:48:10 +000066
67 static void registerAsmPrinter(AsmPrinterCtorFn F) {
68 AsmPrinterCtor = F;
69 }
Chris Lattner158e1f52006-02-05 05:50:24 +000070};
71
72} // end namespace llvm
73
74#endif