blob: ca34b96365d3115cf13bf53c2fee158dab4928dd [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===-- SparcTargetMachine.h - Define TargetMachine for Sparc ---*- C++ -*-===//
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// 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"
18#include "llvm/Target/TargetData.h"
19#include "llvm/Target/TargetFrameInfo.h"
20#include "SparcInstrInfo.h"
21#include "SparcSubtarget.h"
Dan Gohmanf2b29572008-10-03 16:55:19 +000022#include "SparcISelLowering.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000023
24namespace llvm {
25
26class Module;
27
28class SparcTargetMachine : public LLVMTargetMachine {
29 const TargetData DataLayout; // Calculates type size & alignment
30 SparcSubtarget Subtarget;
Dan Gohmanf2b29572008-10-03 16:55:19 +000031 SparcTargetLowering TLInfo;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000032 SparcInstrInfo InstrInfo;
33 TargetFrameInfo FrameInfo;
34
35protected:
36 virtual const TargetAsmInfo *createTargetAsmInfo() const;
37
Chris Lattnere880ec92009-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 Greene302008d2009-07-14 20:18:05 +000040 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
Chris Lattnere880ec92009-06-19 15:48:10 +000041 TargetMachine &tm,
Chris Lattnere880ec92009-06-19 15:48:10 +000042 bool verbose);
43 static AsmPrinterCtorFn AsmPrinterCtor;
44
Dan Gohmanf17a25c2007-07-18 16:29:46 +000045public:
Daniel Dunbarfe5939f2009-07-15 20:24:03 +000046 SparcTargetMachine(const Target &T, const Module &M, const std::string &FS);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000047
48 virtual const SparcInstrInfo *getInstrInfo() const { return &InstrInfo; }
49 virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; }
Dan Gohmanb41dfba2008-05-14 01:58:56 +000050 virtual const SparcSubtarget *getSubtargetImpl() const{ return &Subtarget; }
51 virtual const SparcRegisterInfo *getRegisterInfo() const {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000052 return &InstrInfo.getRegisterInfo();
53 }
Dan Gohmanf2b29572008-10-03 16:55:19 +000054 virtual SparcTargetLowering* getTargetLowering() const {
55 return const_cast<SparcTargetLowering*>(&TLInfo);
56 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +000057 virtual const TargetData *getTargetData() const { return &DataLayout; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +000058
59 // Pass Pipeline Configuration
Bill Wendling5ed22ac2009-04-29 23:29:43 +000060 virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
61 virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
62 virtual bool addAssemblyEmitter(PassManagerBase &PM,
63 CodeGenOpt::Level OptLevel,
David Greene302008d2009-07-14 20:18:05 +000064 bool Verbose, formatted_raw_ostream &Out);
Chris Lattnere880ec92009-06-19 15:48:10 +000065
66 static void registerAsmPrinter(AsmPrinterCtorFn F) {
67 AsmPrinterCtor = F;
68 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +000069};
70
71} // end namespace llvm
72
73#endif