blob: b2745008aff154e5bc9db860e41c922e18b916d3 [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"
Anton Korobeynikovd49ea772009-06-26 21:28:53 +000025#include "ThumbInstrInfo.h"
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000026
27namespace llvm {
28
29class Module;
30
Anton Korobeynikovd49ea772009-06-26 21:28:53 +000031class ARMBaseTargetMachine : public LLVMTargetMachine {
32protected:
Evan Cheng8557c2b2009-06-19 01:51:50 +000033 ARMSubtarget Subtarget;
Anton Korobeynikovd49ea772009-06-26 21:28:53 +000034
35private:
Evan Cheng8557c2b2009-06-19 01:51:50 +000036 ARMFrameInfo FrameInfo;
37 ARMJITInfo JITInfo;
Evan Cheng8557c2b2009-06-19 01:51:50 +000038 InstrItineraryData InstrItins;
39 Reloc::Model DefRelocModel; // Reloc model before it's overridden.
Evan Chenge8308df2007-03-13 01:20:42 +000040
Anton Korobeynikov0bd89712008-08-17 13:55:10 +000041protected:
42 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
43 // set this functions to ctor pointer at startup time if they are linked in.
Owen Andersoncb371882008-08-21 00:14:44 +000044 typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
Anton Korobeynikovd49ea772009-06-26 21:28:53 +000045 ARMBaseTargetMachine &tm,
Bill Wendling98a366d2009-04-29 23:29:43 +000046 bool verbose);
Anton Korobeynikov0bd89712008-08-17 13:55:10 +000047 static AsmPrinterCtorFn AsmPrinterCtor;
48
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000049public:
Anton Korobeynikovd49ea772009-06-26 21:28:53 +000050 ARMBaseTargetMachine(const Module &M, const std::string &FS, bool isThumb);
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000051
Dan Gohmanc9f5f3f2008-05-14 01:58:56 +000052 virtual const ARMFrameInfo *getFrameInfo() const { return &FrameInfo; }
53 virtual ARMJITInfo *getJITInfo() { return &JITInfo; }
Evan Chenga8e29892007-01-19 07:51:42 +000054 virtual const ARMSubtarget *getSubtargetImpl() const { return &Subtarget; }
Anton Korobeynikovd49ea772009-06-26 21:28:53 +000055 virtual const InstrItineraryData getInstrItineraryData() const {
Evan Cheng8557c2b2009-06-19 01:51:50 +000056 return InstrItins;
57 }
Anton Korobeynikov0bd89712008-08-17 13:55:10 +000058
59 static void registerAsmPrinter(AsmPrinterCtorFn F) {
60 AsmPrinterCtor = F;
61 }
62
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000063 static unsigned getModuleMatchQuality(const Module &M);
Evan Cheng148b6a42007-07-05 21:15:40 +000064 static unsigned getJITMatchQuality();
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000065
Evan Chenga8e29892007-01-19 07:51:42 +000066 virtual const TargetAsmInfo *createTargetAsmInfo() const;
Anton Korobeynikov0bd89712008-08-17 13:55:10 +000067
Chris Lattner1911fd42006-09-04 04:14:57 +000068 // Pass Pipeline Configuration
Bill Wendling98a366d2009-04-29 23:29:43 +000069 virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
Evan Chenge7d6df72009-06-13 09:12:55 +000070 virtual bool addPreRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
Bill Wendling98a366d2009-04-29 23:29:43 +000071 virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
72 virtual bool addAssemblyEmitter(PassManagerBase &PM,
73 CodeGenOpt::Level OptLevel,
Evan Cheng42bf74b2009-03-25 01:47:28 +000074 bool Verbose, raw_ostream &Out);
Bill Wendling98a366d2009-04-29 23:29:43 +000075 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
Evan Cheng8bd60352007-07-20 21:56:13 +000076 bool DumpAsm, MachineCodeEmitter &MCE);
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +000077 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
78 bool DumpAsm, JITCodeEmitter &MCE);
Bill Wendling98a366d2009-04-29 23:29:43 +000079 virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
80 CodeGenOpt::Level OptLevel,
81 bool DumpAsm,
82 MachineCodeEmitter &MCE);
Bruno Cardoso Lopesa3f99f92009-05-30 20:51:52 +000083 virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
84 CodeGenOpt::Level OptLevel,
85 bool DumpAsm,
86 JITCodeEmitter &MCE);
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000087};
88
Anton Korobeynikovd49ea772009-06-26 21:28:53 +000089/// ARMTargetMachine - ARM target machine.
90///
91class ARMTargetMachine : public ARMBaseTargetMachine {
92 ARMInstrInfo InstrInfo;
93 const TargetData DataLayout; // Calculates type size & alignment
94 ARMTargetLowering TLInfo;
95public:
96 ARMTargetMachine(const Module &M, const std::string &FS);
97
98 virtual const ARMRegisterInfo *getRegisterInfo() const {
99 return &InstrInfo.getRegisterInfo();
100 }
101
102 virtual ARMTargetLowering *getTargetLowering() const {
103 return const_cast<ARMTargetLowering*>(&TLInfo);
104 }
105
106 virtual const ARMInstrInfo *getInstrInfo() const { return &InstrInfo; }
107 virtual const TargetData *getTargetData() const { return &DataLayout; }
108
109 static unsigned getJITMatchQuality();
110 static unsigned getModuleMatchQuality(const Module &M);
111};
112
Evan Cheng04321f72007-02-23 03:14:31 +0000113/// ThumbTargetMachine - Thumb target machine.
114///
Anton Korobeynikovd49ea772009-06-26 21:28:53 +0000115class ThumbTargetMachine : public ARMBaseTargetMachine {
116 ThumbInstrInfo InstrInfo;
117 const TargetData DataLayout; // Calculates type size & alignment
118 ARMTargetLowering TLInfo;
Evan Cheng04321f72007-02-23 03:14:31 +0000119public:
120 ThumbTargetMachine(const Module &M, const std::string &FS);
121
Anton Korobeynikova98cbc52009-06-27 12:16:40 +0000122 virtual const ThumbRegisterInfo *getRegisterInfo() const {
Anton Korobeynikovd49ea772009-06-26 21:28:53 +0000123 return &InstrInfo.getRegisterInfo();
124 }
125
126 virtual ARMTargetLowering *getTargetLowering() const {
127 return const_cast<ARMTargetLowering*>(&TLInfo);
128 }
129
130 virtual const ThumbInstrInfo *getInstrInfo() const { return &InstrInfo; }
131 virtual const TargetData *getTargetData() const { return &DataLayout; }
132
Evan Cheng148b6a42007-07-05 21:15:40 +0000133 static unsigned getJITMatchQuality();
Evan Cheng04321f72007-02-23 03:14:31 +0000134 static unsigned getModuleMatchQuality(const Module &M);
135};
136
Rafael Espindola7bc59bc2006-05-14 22:18:28 +0000137} // end namespace llvm
138
139#endif