blob: a67471c04dedc18aef7c664cef71d10dfbf9e80a [file] [log] [blame]
Rafael Espindola7bc59bc2006-05-14 22:18:28 +00001//===-- ARMTargetMachine.h - Define TargetMachine for ARM -------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
Rafael Espindola7bc59bc2006-05-14 22:18:28 +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"
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000020#include "ARMInstrInfo.h"
Rafael Espindolaec46ea32006-08-16 14:43:33 +000021#include "ARMFrameInfo.h"
Evan Cheng148b6a42007-07-05 21:15:40 +000022#include "ARMJITInfo.h"
Evan Chenga8e29892007-01-19 07:51:42 +000023#include "ARMSubtarget.h"
Evan Chenge8308df2007-03-13 01:20:42 +000024#include "ARMISelLowering.h"
David Goodwinb50ea5c2009-07-02 22:18:33 +000025#include "Thumb1InstrInfo.h"
26#include "Thumb2InstrInfo.h"
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000027
28namespace llvm {
29
30class Module;
31
Anton Korobeynikovd49ea772009-06-26 21:28:53 +000032class ARMBaseTargetMachine : public LLVMTargetMachine {
33protected:
Evan Cheng8557c2b2009-06-19 01:51:50 +000034 ARMSubtarget Subtarget;
Anton Korobeynikovd49ea772009-06-26 21:28:53 +000035
36private:
Evan Cheng8557c2b2009-06-19 01:51:50 +000037 ARMFrameInfo FrameInfo;
38 ARMJITInfo JITInfo;
Evan Cheng8557c2b2009-06-19 01:51:50 +000039 InstrItineraryData InstrItins;
40 Reloc::Model DefRelocModel; // Reloc model before it's overridden.
Evan Chenge8308df2007-03-13 01:20:42 +000041
Anton Korobeynikov0bd89712008-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 Andersoncb371882008-08-21 00:14:44 +000045 typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
Anton Korobeynikovd49ea772009-06-26 21:28:53 +000046 ARMBaseTargetMachine &tm,
Bill Wendling98a366d2009-04-29 23:29:43 +000047 bool verbose);
Anton Korobeynikov0bd89712008-08-17 13:55:10 +000048 static AsmPrinterCtorFn AsmPrinterCtor;
49
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000050public:
Anton Korobeynikovd49ea772009-06-26 21:28:53 +000051 ARMBaseTargetMachine(const Module &M, const std::string &FS, bool isThumb);
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000052
Dan Gohmanc9f5f3f2008-05-14 01:58:56 +000053 virtual const ARMFrameInfo *getFrameInfo() const { return &FrameInfo; }
54 virtual ARMJITInfo *getJITInfo() { return &JITInfo; }
Evan Chenga8e29892007-01-19 07:51:42 +000055 virtual const ARMSubtarget *getSubtargetImpl() const { return &Subtarget; }
Anton Korobeynikovd49ea772009-06-26 21:28:53 +000056 virtual const InstrItineraryData getInstrItineraryData() const {
Evan Cheng8557c2b2009-06-19 01:51:50 +000057 return InstrItins;
58 }
Anton Korobeynikov0bd89712008-08-17 13:55:10 +000059
60 static void registerAsmPrinter(AsmPrinterCtorFn F) {
61 AsmPrinterCtor = F;
62 }
63
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000064 static unsigned getModuleMatchQuality(const Module &M);
Evan Cheng148b6a42007-07-05 21:15:40 +000065 static unsigned getJITMatchQuality();
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000066
Evan Chenga8e29892007-01-19 07:51:42 +000067 virtual const TargetAsmInfo *createTargetAsmInfo() const;
Anton Korobeynikov0bd89712008-08-17 13:55:10 +000068
Chris Lattner1911fd42006-09-04 04:14:57 +000069 // Pass Pipeline Configuration
Bill Wendling98a366d2009-04-29 23:29:43 +000070 virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
Evan Chenge7d6df72009-06-13 09:12:55 +000071 virtual bool addPreRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
Bill Wendling98a366d2009-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 Cheng42bf74b2009-03-25 01:47:28 +000075 bool Verbose, raw_ostream &Out);
Bill Wendling98a366d2009-04-29 23:29:43 +000076 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
Evan Cheng8bd60352007-07-20 21:56:13 +000077 bool DumpAsm, MachineCodeEmitter &MCE);
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +000078 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
79 bool DumpAsm, JITCodeEmitter &MCE);
Bruno Cardoso Lopesac57e6e2009-07-06 05:09:34 +000080 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
81 bool DumpAsm, ObjectCodeEmitter &OCE);
Bill Wendling98a366d2009-04-29 23:29:43 +000082 virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
83 CodeGenOpt::Level OptLevel,
84 bool DumpAsm,
85 MachineCodeEmitter &MCE);
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +000086 virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
87 CodeGenOpt::Level OptLevel,
88 bool DumpAsm,
89 JITCodeEmitter &MCE);
Bruno Cardoso Lopesac57e6e2009-07-06 05:09:34 +000090 virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
91 CodeGenOpt::Level OptLevel,
92 bool DumpAsm,
93 ObjectCodeEmitter &OCE);
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000094};
95
Anton Korobeynikovd49ea772009-06-26 21:28:53 +000096/// ARMTargetMachine - ARM target machine.
97///
98class ARMTargetMachine : public ARMBaseTargetMachine {
99 ARMInstrInfo InstrInfo;
100 const TargetData DataLayout; // Calculates type size & alignment
101 ARMTargetLowering TLInfo;
102public:
103 ARMTargetMachine(const Module &M, const std::string &FS);
104
105 virtual const ARMRegisterInfo *getRegisterInfo() const {
106 return &InstrInfo.getRegisterInfo();
107 }
108
109 virtual ARMTargetLowering *getTargetLowering() const {
110 return const_cast<ARMTargetLowering*>(&TLInfo);
111 }
112
113 virtual const ARMInstrInfo *getInstrInfo() const { return &InstrInfo; }
114 virtual const TargetData *getTargetData() const { return &DataLayout; }
115
116 static unsigned getJITMatchQuality();
117 static unsigned getModuleMatchQuality(const Module &M);
118};
119
Evan Cheng04321f72007-02-23 03:14:31 +0000120/// ThumbTargetMachine - Thumb target machine.
David Goodwinb50ea5c2009-07-02 22:18:33 +0000121/// Due to the way architectures are handled, this represents both
122/// Thumb-1 and Thumb-2.
Evan Cheng04321f72007-02-23 03:14:31 +0000123///
Anton Korobeynikovd49ea772009-06-26 21:28:53 +0000124class ThumbTargetMachine : public ARMBaseTargetMachine {
David Goodwinb50ea5c2009-07-02 22:18:33 +0000125 ARMBaseInstrInfo *InstrInfo; // either Thumb1InstrInfo or Thumb2InstrInfo
126 const TargetData DataLayout; // Calculates type size & alignment
Anton Korobeynikovd49ea772009-06-26 21:28:53 +0000127 ARMTargetLowering TLInfo;
Evan Cheng04321f72007-02-23 03:14:31 +0000128public:
129 ThumbTargetMachine(const Module &M, const std::string &FS);
130
David Goodwinb50ea5c2009-07-02 22:18:33 +0000131 /// returns either Thumb1RegisterInfo of Thumb2RegisterInfo
132 virtual const ARMBaseRegisterInfo *getRegisterInfo() const {
133 return &InstrInfo->getRegisterInfo();
Anton Korobeynikovd49ea772009-06-26 21:28:53 +0000134 }
135
David Goodwinb50ea5c2009-07-02 22:18:33 +0000136 virtual ARMTargetLowering *getTargetLowering() const {
Anton Korobeynikovd49ea772009-06-26 21:28:53 +0000137 return const_cast<ARMTargetLowering*>(&TLInfo);
138 }
139
David Goodwinb50ea5c2009-07-02 22:18:33 +0000140 /// returns either Thumb1InstrInfo or Thumb2InstrInfo
141 virtual const ARMBaseInstrInfo *getInstrInfo() const { return InstrInfo; }
Anton Korobeynikovd49ea772009-06-26 21:28:53 +0000142 virtual const TargetData *getTargetData() const { return &DataLayout; }
143
Evan Cheng148b6a42007-07-05 21:15:40 +0000144 static unsigned getJITMatchQuality();
Evan Cheng04321f72007-02-23 03:14:31 +0000145 static unsigned getModuleMatchQuality(const Module &M);
146};
147
Rafael Espindola7bc59bc2006-05-14 22:18:28 +0000148} // end namespace llvm
149
150#endif