blob: c4c8e6c1d985824a7598cf2b2966eb14bf25dcdc [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===-- ARMTargetMachine.h - Define TargetMachine for ARM -------*- 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
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file declares the ARM specific subclass of TargetMachine.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef ARMTARGETMACHINE_H
15#define ARMTARGETMACHINE_H
16
17#include "llvm/Target/TargetMachine.h"
18#include "llvm/Target/TargetData.h"
19#include "llvm/Target/TargetFrameInfo.h"
20#include "ARMInstrInfo.h"
21#include "ARMFrameInfo.h"
22#include "ARMJITInfo.h"
23#include "ARMSubtarget.h"
24#include "ARMISelLowering.h"
25
26namespace llvm {
27
28class Module;
29
30class ARMTargetMachine : public LLVMTargetMachine {
Evan Cheng88e78d22009-06-19 01:51:50 +000031 ARMSubtarget Subtarget;
32 const TargetData DataLayout; // Calculates type size & alignment
33 ARMInstrInfo InstrInfo;
34 ARMFrameInfo FrameInfo;
35 ARMJITInfo JITInfo;
36 ARMTargetLowering TLInfo;
37 InstrItineraryData InstrItins;
38 Reloc::Model DefRelocModel; // Reloc model before it's overridden.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000039
Anton Korobeynikov74b114b2008-08-17 13:55:10 +000040protected:
41 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
42 // set this functions to ctor pointer at startup time if they are linked in.
Owen Anderson847b99b2008-08-21 00:14:44 +000043 typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
Bill Wendling4f405312009-02-24 08:30:20 +000044 ARMTargetMachine &tm,
Bill Wendling5ed22ac2009-04-29 23:29:43 +000045 CodeGenOpt::Level OptLevel,
46 bool verbose);
Anton Korobeynikov74b114b2008-08-17 13:55:10 +000047 static AsmPrinterCtorFn AsmPrinterCtor;
48
Dan Gohmanf17a25c2007-07-18 16:29:46 +000049public:
50 ARMTargetMachine(const Module &M, const std::string &FS, bool isThumb = false);
51
Dan Gohmanb41dfba2008-05-14 01:58:56 +000052 virtual const ARMInstrInfo *getInstrInfo() const { return &InstrInfo; }
53 virtual const ARMFrameInfo *getFrameInfo() const { return &FrameInfo; }
54 virtual ARMJITInfo *getJITInfo() { return &JITInfo; }
55 virtual const ARMRegisterInfo *getRegisterInfo() const {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000056 return &InstrInfo.getRegisterInfo();
57 }
58 virtual const TargetData *getTargetData() const { return &DataLayout; }
59 virtual const ARMSubtarget *getSubtargetImpl() const { return &Subtarget; }
Anton Korobeynikov74b114b2008-08-17 13:55:10 +000060 virtual ARMTargetLowering *getTargetLowering() const {
61 return const_cast<ARMTargetLowering*>(&TLInfo);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000062 }
Evan Cheng88e78d22009-06-19 01:51:50 +000063 virtual const InstrItineraryData getInstrItineraryData() const {
64 return InstrItins;
65 }
Anton Korobeynikov74b114b2008-08-17 13:55:10 +000066
67 static void registerAsmPrinter(AsmPrinterCtorFn F) {
68 AsmPrinterCtor = F;
69 }
70
Dan Gohmanf17a25c2007-07-18 16:29:46 +000071 static unsigned getModuleMatchQuality(const Module &M);
72 static unsigned getJITMatchQuality();
73
74 virtual const TargetAsmInfo *createTargetAsmInfo() const;
Anton Korobeynikov74b114b2008-08-17 13:55:10 +000075
Dan Gohmanf17a25c2007-07-18 16:29:46 +000076 // Pass Pipeline Configuration
Bill Wendling5ed22ac2009-04-29 23:29:43 +000077 virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
Evan Cheng54353c92009-06-13 09:12:55 +000078 virtual bool addPreRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
Bill Wendling5ed22ac2009-04-29 23:29:43 +000079 virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
80 virtual bool addAssemblyEmitter(PassManagerBase &PM,
81 CodeGenOpt::Level OptLevel,
Evan Cheng42ceb472009-03-25 01:47:28 +000082 bool Verbose, raw_ostream &Out);
Bill Wendling5ed22ac2009-04-29 23:29:43 +000083 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
Evan Cheng77547212007-07-20 21:56:13 +000084 bool DumpAsm, MachineCodeEmitter &MCE);
Bruno Cardoso Lopes1ea31ff2009-05-30 20:51:52 +000085 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
86 bool DumpAsm, JITCodeEmitter &MCE);
Bill Wendling5ed22ac2009-04-29 23:29:43 +000087 virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
88 CodeGenOpt::Level OptLevel,
89 bool DumpAsm,
90 MachineCodeEmitter &MCE);
Bruno Cardoso Lopes1ea31ff2009-05-30 20:51:52 +000091 virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
92 CodeGenOpt::Level OptLevel,
93 bool DumpAsm,
94 JITCodeEmitter &MCE);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000095};
96
97/// ThumbTargetMachine - Thumb target machine.
98///
99class ThumbTargetMachine : public ARMTargetMachine {
100public:
101 ThumbTargetMachine(const Module &M, const std::string &FS);
102
103 static unsigned getJITMatchQuality();
104 static unsigned getModuleMatchQuality(const Module &M);
105};
106
107} // end namespace llvm
108
109#endif