blob: a0df54d6d5282a63722714701ac84a1d9e475d4f [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"
David Goodwinaca520d2009-07-02 22:18:33 +000025#include "Thumb1InstrInfo.h"
26#include "Thumb2InstrInfo.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000027
28namespace llvm {
29
30class Module;
31
Anton Korobeynikov65d16ea2009-06-26 21:28:53 +000032class ARMBaseTargetMachine : public LLVMTargetMachine {
33protected:
Evan Cheng88e78d22009-06-19 01:51:50 +000034 ARMSubtarget Subtarget;
Anton Korobeynikov65d16ea2009-06-26 21:28:53 +000035
36private:
Evan Cheng88e78d22009-06-19 01:51:50 +000037 ARMFrameInfo FrameInfo;
38 ARMJITInfo JITInfo;
Evan Cheng88e78d22009-06-19 01:51:50 +000039 InstrItineraryData InstrItins;
40 Reloc::Model DefRelocModel; // Reloc model before it's overridden.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000041
Anton Korobeynikov74b114b2008-08-17 13:55:10 +000042protected:
43 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
44 // set this functions to ctor pointer at startup time if they are linked in.
Owen Anderson847b99b2008-08-21 00:14:44 +000045 typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
Anton Korobeynikov65d16ea2009-06-26 21:28:53 +000046 ARMBaseTargetMachine &tm,
Bill Wendling5ed22ac2009-04-29 23:29:43 +000047 bool verbose);
Anton Korobeynikov74b114b2008-08-17 13:55:10 +000048 static AsmPrinterCtorFn AsmPrinterCtor;
49
Dan Gohmanf17a25c2007-07-18 16:29:46 +000050public:
Anton Korobeynikov65d16ea2009-06-26 21:28:53 +000051 ARMBaseTargetMachine(const Module &M, const std::string &FS, bool isThumb);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000052
Dan Gohmanb41dfba2008-05-14 01:58:56 +000053 virtual const ARMFrameInfo *getFrameInfo() const { return &FrameInfo; }
54 virtual ARMJITInfo *getJITInfo() { return &JITInfo; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +000055 virtual const ARMSubtarget *getSubtargetImpl() const { return &Subtarget; }
Anton Korobeynikov65d16ea2009-06-26 21:28:53 +000056 virtual const InstrItineraryData getInstrItineraryData() const {
Evan Cheng88e78d22009-06-19 01:51:50 +000057 return InstrItins;
58 }
Anton Korobeynikov74b114b2008-08-17 13:55:10 +000059
60 static void registerAsmPrinter(AsmPrinterCtorFn F) {
61 AsmPrinterCtor = F;
62 }
63
Dan Gohmanf17a25c2007-07-18 16:29:46 +000064 static unsigned getModuleMatchQuality(const Module &M);
65 static unsigned getJITMatchQuality();
66
67 virtual const TargetAsmInfo *createTargetAsmInfo() const;
Anton Korobeynikov74b114b2008-08-17 13:55:10 +000068
Dan Gohmanf17a25c2007-07-18 16:29:46 +000069 // Pass Pipeline Configuration
Bill Wendling5ed22ac2009-04-29 23:29:43 +000070 virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
Evan Cheng54353c92009-06-13 09:12:55 +000071 virtual bool addPreRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
Bill Wendling5ed22ac2009-04-29 23:29:43 +000072 virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
73 virtual bool addAssemblyEmitter(PassManagerBase &PM,
74 CodeGenOpt::Level OptLevel,
Evan Cheng42ceb472009-03-25 01:47:28 +000075 bool Verbose, raw_ostream &Out);
Bill Wendling5ed22ac2009-04-29 23:29:43 +000076 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
Evan Cheng77547212007-07-20 21:56:13 +000077 bool DumpAsm, MachineCodeEmitter &MCE);
Bruno Cardoso Lopes1ea31ff2009-05-30 20:51:52 +000078 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
79 bool DumpAsm, JITCodeEmitter &MCE);
Bill Wendling5ed22ac2009-04-29 23:29:43 +000080 virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
81 CodeGenOpt::Level OptLevel,
82 bool DumpAsm,
83 MachineCodeEmitter &MCE);
Bruno Cardoso Lopes1ea31ff2009-05-30 20:51:52 +000084 virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
85 CodeGenOpt::Level OptLevel,
86 bool DumpAsm,
87 JITCodeEmitter &MCE);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000088};
89
Anton Korobeynikov65d16ea2009-06-26 21:28:53 +000090/// ARMTargetMachine - ARM target machine.
91///
92class ARMTargetMachine : public ARMBaseTargetMachine {
93 ARMInstrInfo InstrInfo;
94 const TargetData DataLayout; // Calculates type size & alignment
95 ARMTargetLowering TLInfo;
96public:
97 ARMTargetMachine(const Module &M, const std::string &FS);
98
99 virtual const ARMRegisterInfo *getRegisterInfo() const {
100 return &InstrInfo.getRegisterInfo();
101 }
102
103 virtual ARMTargetLowering *getTargetLowering() const {
104 return const_cast<ARMTargetLowering*>(&TLInfo);
105 }
106
107 virtual const ARMInstrInfo *getInstrInfo() const { return &InstrInfo; }
108 virtual const TargetData *getTargetData() const { return &DataLayout; }
109
110 static unsigned getJITMatchQuality();
111 static unsigned getModuleMatchQuality(const Module &M);
112};
113
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000114/// ThumbTargetMachine - Thumb target machine.
David Goodwinaca520d2009-07-02 22:18:33 +0000115/// Due to the way architectures are handled, this represents both
116/// Thumb-1 and Thumb-2.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000117///
Anton Korobeynikov65d16ea2009-06-26 21:28:53 +0000118class ThumbTargetMachine : public ARMBaseTargetMachine {
David Goodwinaca520d2009-07-02 22:18:33 +0000119 ARMBaseInstrInfo *InstrInfo; // either Thumb1InstrInfo or Thumb2InstrInfo
120 const TargetData DataLayout; // Calculates type size & alignment
Anton Korobeynikov65d16ea2009-06-26 21:28:53 +0000121 ARMTargetLowering TLInfo;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000122public:
123 ThumbTargetMachine(const Module &M, const std::string &FS);
124
David Goodwinaca520d2009-07-02 22:18:33 +0000125 /// returns either Thumb1RegisterInfo of Thumb2RegisterInfo
126 virtual const ARMBaseRegisterInfo *getRegisterInfo() const {
127 return &InstrInfo->getRegisterInfo();
Anton Korobeynikov65d16ea2009-06-26 21:28:53 +0000128 }
129
David Goodwinaca520d2009-07-02 22:18:33 +0000130 virtual ARMTargetLowering *getTargetLowering() const {
Anton Korobeynikov65d16ea2009-06-26 21:28:53 +0000131 return const_cast<ARMTargetLowering*>(&TLInfo);
132 }
133
David Goodwinaca520d2009-07-02 22:18:33 +0000134 /// returns either Thumb1InstrInfo or Thumb2InstrInfo
135 virtual const ARMBaseInstrInfo *getInstrInfo() const { return InstrInfo; }
Anton Korobeynikov65d16ea2009-06-26 21:28:53 +0000136 virtual const TargetData *getTargetData() const { return &DataLayout; }
137
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000138 static unsigned getJITMatchQuality();
139 static unsigned getModuleMatchQuality(const Module &M);
140};
141
142} // end namespace llvm
143
144#endif