SparcTargetMachine.h revision 225503a5b5de954788ad1e4bc9c69211de334c05
1//===-- SparcTargetMachine.h - Define TargetMachine for Sparc ---*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
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"
22#include "SparcISelLowering.h"
23
24namespace llvm {
25
26class Module;
27
28class SparcTargetMachine : public LLVMTargetMachine {
29  const TargetData DataLayout;       // Calculates type size & alignment
30  SparcSubtarget Subtarget;
31  SparcTargetLowering TLInfo;
32  SparcInstrInfo InstrInfo;
33  TargetFrameInfo FrameInfo;
34
35protected:
36  virtual const TargetAsmInfo *createTargetAsmInfo() const;
37
38  // 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.
40  typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
41                                            TargetMachine &tm,
42                                            CodeGenOpt::Level OptLevel,
43                                            bool verbose);
44  static AsmPrinterCtorFn AsmPrinterCtor;
45
46public:
47  SparcTargetMachine(const Module &M, const std::string &FS);
48
49  virtual const SparcInstrInfo *getInstrInfo() const { return &InstrInfo; }
50  virtual const TargetFrameInfo  *getFrameInfo() const { return &FrameInfo; }
51  virtual const SparcSubtarget   *getSubtargetImpl() const{ return &Subtarget; }
52  virtual const SparcRegisterInfo *getRegisterInfo() const {
53    return &InstrInfo.getRegisterInfo();
54  }
55  virtual SparcTargetLowering* getTargetLowering() const {
56    return const_cast<SparcTargetLowering*>(&TLInfo);
57  }
58  virtual const TargetData       *getTargetData() const { return &DataLayout; }
59  static unsigned getModuleMatchQuality(const Module &M);
60
61  // Pass Pipeline Configuration
62  virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
63  virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
64  virtual bool addAssemblyEmitter(PassManagerBase &PM,
65                                  CodeGenOpt::Level OptLevel,
66                                  bool Verbose, raw_ostream &Out);
67
68  static void registerAsmPrinter(AsmPrinterCtorFn F) {
69    AsmPrinterCtor = F;
70  }
71};
72
73} // end namespace llvm
74
75#endif
76