blob: 3fe259ad08d745c117652db84fe2d472fcac6b1b [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"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000019#include "ARMInstrInfo.h"
20#include "ARMFrameInfo.h"
21#include "ARMJITInfo.h"
22#include "ARMSubtarget.h"
23#include "ARMISelLowering.h"
David Goodwinaca520d2009-07-02 22:18:33 +000024#include "Thumb1InstrInfo.h"
25#include "Thumb2InstrInfo.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000026
27namespace llvm {
28
29class Module;
30
Anton Korobeynikov65d16ea2009-06-26 21:28:53 +000031class ARMBaseTargetMachine : public LLVMTargetMachine {
32protected:
Evan Cheng88e78d22009-06-19 01:51:50 +000033 ARMSubtarget Subtarget;
Anton Korobeynikov65d16ea2009-06-26 21:28:53 +000034
35private:
Evan Cheng88e78d22009-06-19 01:51:50 +000036 ARMFrameInfo FrameInfo;
37 ARMJITInfo JITInfo;
Evan Cheng88e78d22009-06-19 01:51:50 +000038 InstrItineraryData InstrItins;
39 Reloc::Model DefRelocModel; // Reloc model before it's overridden.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000040
Anton Korobeynikov74b114b2008-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.
David Greene302008d2009-07-14 20:18:05 +000044 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
Daniel Dunbarfe5939f2009-07-15 20:24:03 +000045 TargetMachine &tm,
Bill Wendling5ed22ac2009-04-29 23:29:43 +000046 bool verbose);
Anton Korobeynikov74b114b2008-08-17 13:55:10 +000047 static AsmPrinterCtorFn AsmPrinterCtor;
48
Dan Gohmanf17a25c2007-07-18 16:29:46 +000049public:
Daniel Dunbarfe5939f2009-07-15 20:24:03 +000050 ARMBaseTargetMachine(const Target &T, const Module &M, const std::string &FS,
51 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 virtual const TargetAsmInfo *createTargetAsmInfo() const;
Anton Korobeynikov74b114b2008-08-17 13:55:10 +000065
Dan Gohmanf17a25c2007-07-18 16:29:46 +000066 // Pass Pipeline Configuration
Bill Wendling5ed22ac2009-04-29 23:29:43 +000067 virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
Evan Cheng54353c92009-06-13 09:12:55 +000068 virtual bool addPreRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
Bill Wendling5ed22ac2009-04-29 23:29:43 +000069 virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
70 virtual bool addAssemblyEmitter(PassManagerBase &PM,
71 CodeGenOpt::Level OptLevel,
David Greene302008d2009-07-14 20:18:05 +000072 bool Verbose, formatted_raw_ostream &Out);
Bill Wendling5ed22ac2009-04-29 23:29:43 +000073 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
Evan Cheng77547212007-07-20 21:56:13 +000074 bool DumpAsm, MachineCodeEmitter &MCE);
Bruno Cardoso Lopes1ea31ff2009-05-30 20:51:52 +000075 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
76 bool DumpAsm, JITCodeEmitter &MCE);
Bruno Cardoso Lopesaabb9a52009-07-06 05:09:34 +000077 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
78 bool DumpAsm, ObjectCodeEmitter &OCE);
Bill Wendling5ed22ac2009-04-29 23:29:43 +000079 virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
80 CodeGenOpt::Level OptLevel,
81 bool DumpAsm,
82 MachineCodeEmitter &MCE);
Bruno Cardoso Lopes1ea31ff2009-05-30 20:51:52 +000083 virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
84 CodeGenOpt::Level OptLevel,
85 bool DumpAsm,
86 JITCodeEmitter &MCE);
Bruno Cardoso Lopesaabb9a52009-07-06 05:09:34 +000087 virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
88 CodeGenOpt::Level OptLevel,
89 bool DumpAsm,
90 ObjectCodeEmitter &OCE);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000091};
92
Anton Korobeynikov65d16ea2009-06-26 21:28:53 +000093/// ARMTargetMachine - ARM target machine.
94///
95class ARMTargetMachine : public ARMBaseTargetMachine {
96 ARMInstrInfo InstrInfo;
97 const TargetData DataLayout; // Calculates type size & alignment
98 ARMTargetLowering TLInfo;
99public:
Daniel Dunbarfe5939f2009-07-15 20:24:03 +0000100 ARMTargetMachine(const Target &T, const Module &M, const std::string &FS);
Anton Korobeynikov65d16ea2009-06-26 21:28:53 +0000101
102 virtual const ARMRegisterInfo *getRegisterInfo() const {
103 return &InstrInfo.getRegisterInfo();
104 }
105
106 virtual ARMTargetLowering *getTargetLowering() const {
107 return const_cast<ARMTargetLowering*>(&TLInfo);
108 }
109
110 virtual const ARMInstrInfo *getInstrInfo() const { return &InstrInfo; }
111 virtual const TargetData *getTargetData() const { return &DataLayout; }
112
113 static unsigned getJITMatchQuality();
114 static unsigned getModuleMatchQuality(const Module &M);
115};
116
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000117/// ThumbTargetMachine - Thumb target machine.
David Goodwinaca520d2009-07-02 22:18:33 +0000118/// Due to the way architectures are handled, this represents both
119/// Thumb-1 and Thumb-2.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000120///
Anton Korobeynikov65d16ea2009-06-26 21:28:53 +0000121class ThumbTargetMachine : public ARMBaseTargetMachine {
David Goodwinaca520d2009-07-02 22:18:33 +0000122 ARMBaseInstrInfo *InstrInfo; // either Thumb1InstrInfo or Thumb2InstrInfo
123 const TargetData DataLayout; // Calculates type size & alignment
Anton Korobeynikov65d16ea2009-06-26 21:28:53 +0000124 ARMTargetLowering TLInfo;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000125public:
Daniel Dunbarfe5939f2009-07-15 20:24:03 +0000126 ThumbTargetMachine(const Target &T, const Module &M, const std::string &FS);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000127
David Goodwinaca520d2009-07-02 22:18:33 +0000128 /// returns either Thumb1RegisterInfo of Thumb2RegisterInfo
129 virtual const ARMBaseRegisterInfo *getRegisterInfo() const {
130 return &InstrInfo->getRegisterInfo();
Anton Korobeynikov65d16ea2009-06-26 21:28:53 +0000131 }
132
David Goodwinaca520d2009-07-02 22:18:33 +0000133 virtual ARMTargetLowering *getTargetLowering() const {
Anton Korobeynikov65d16ea2009-06-26 21:28:53 +0000134 return const_cast<ARMTargetLowering*>(&TLInfo);
135 }
136
David Goodwinaca520d2009-07-02 22:18:33 +0000137 /// returns either Thumb1InstrInfo or Thumb2InstrInfo
138 virtual const ARMBaseInstrInfo *getInstrInfo() const { return InstrInfo; }
Anton Korobeynikov65d16ea2009-06-26 21:28:53 +0000139 virtual const TargetData *getTargetData() const { return &DataLayout; }
140
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000141 static unsigned getJITMatchQuality();
142 static unsigned getModuleMatchQuality(const Module &M);
143};
144
145} // end namespace llvm
146
147#endif