blob: 3f65f71bbeb35982f327cbdb9582c67edd62b4e4 [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 {
31 ARMSubtarget Subtarget;
32 const TargetData DataLayout; // Calculates type size & alignment
33 ARMInstrInfo InstrInfo;
34 ARMFrameInfo FrameInfo;
35 ARMJITInfo JITInfo;
36 ARMTargetLowering TLInfo;
Evan Chengb8b40d62008-10-30 16:10:54 +000037 Reloc::Model DefRelocModel; // Reloc model before it's overridden.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000038
Anton Korobeynikov74b114b2008-08-17 13:55:10 +000039protected:
40 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
41 // set this functions to ctor pointer at startup time if they are linked in.
Owen Anderson847b99b2008-08-21 00:14:44 +000042 typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
Bill Wendling4f405312009-02-24 08:30:20 +000043 ARMTargetMachine &tm,
Bill Wendling5ed22ac2009-04-29 23:29:43 +000044 CodeGenOpt::Level OptLevel,
45 bool verbose);
Anton Korobeynikov74b114b2008-08-17 13:55:10 +000046 static AsmPrinterCtorFn AsmPrinterCtor;
47
Dan Gohmanf17a25c2007-07-18 16:29:46 +000048public:
49 ARMTargetMachine(const Module &M, const std::string &FS, bool isThumb = false);
50
Dan Gohmanb41dfba2008-05-14 01:58:56 +000051 virtual const ARMInstrInfo *getInstrInfo() const { return &InstrInfo; }
52 virtual const ARMFrameInfo *getFrameInfo() const { return &FrameInfo; }
53 virtual ARMJITInfo *getJITInfo() { return &JITInfo; }
54 virtual const ARMRegisterInfo *getRegisterInfo() const {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000055 return &InstrInfo.getRegisterInfo();
56 }
57 virtual const TargetData *getTargetData() const { return &DataLayout; }
58 virtual const ARMSubtarget *getSubtargetImpl() const { return &Subtarget; }
Anton Korobeynikov74b114b2008-08-17 13:55:10 +000059 virtual ARMTargetLowering *getTargetLowering() const {
60 return const_cast<ARMTargetLowering*>(&TLInfo);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000061 }
Anton Korobeynikov74b114b2008-08-17 13:55:10 +000062
63 static void registerAsmPrinter(AsmPrinterCtorFn F) {
64 AsmPrinterCtor = F;
65 }
66
Dan Gohmanf17a25c2007-07-18 16:29:46 +000067 static unsigned getModuleMatchQuality(const Module &M);
68 static unsigned getJITMatchQuality();
69
70 virtual const TargetAsmInfo *createTargetAsmInfo() const;
Anton Korobeynikov74b114b2008-08-17 13:55:10 +000071
Dan Gohmanf17a25c2007-07-18 16:29:46 +000072 // Pass Pipeline Configuration
Bill Wendling5ed22ac2009-04-29 23:29:43 +000073 virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
74 virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
75 virtual bool addAssemblyEmitter(PassManagerBase &PM,
76 CodeGenOpt::Level OptLevel,
Evan Cheng42ceb472009-03-25 01:47:28 +000077 bool Verbose, raw_ostream &Out);
Bill Wendling5ed22ac2009-04-29 23:29:43 +000078 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
Evan Cheng77547212007-07-20 21:56:13 +000079 bool DumpAsm, MachineCodeEmitter &MCE);
Bill Wendling5ed22ac2009-04-29 23:29:43 +000080 virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
81 CodeGenOpt::Level OptLevel,
82 bool DumpAsm,
83 MachineCodeEmitter &MCE);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000084};
85
86/// ThumbTargetMachine - Thumb target machine.
87///
88class ThumbTargetMachine : public ARMTargetMachine {
89public:
90 ThumbTargetMachine(const Module &M, const std::string &FS);
91
92 static unsigned getJITMatchQuality();
93 static unsigned getModuleMatchQuality(const Module &M);
94};
95
96} // end namespace llvm
97
98#endif