blob: a485897bfce4ef59a344448d0cdf66d3360ea4bc [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;
37
Anton Korobeynikov74b114b2008-08-17 13:55:10 +000038protected:
39 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
40 // set this functions to ctor pointer at startup time if they are linked in.
41 typedef FunctionPass *(*AsmPrinterCtorFn)(std::ostream &o,
42 ARMTargetMachine &tm);
43 static AsmPrinterCtorFn AsmPrinterCtor;
44
Dan Gohmanf17a25c2007-07-18 16:29:46 +000045public:
46 ARMTargetMachine(const Module &M, const std::string &FS, bool isThumb = false);
47
Dan Gohmanb41dfba2008-05-14 01:58:56 +000048 virtual const ARMInstrInfo *getInstrInfo() const { return &InstrInfo; }
49 virtual const ARMFrameInfo *getFrameInfo() const { return &FrameInfo; }
50 virtual ARMJITInfo *getJITInfo() { return &JITInfo; }
51 virtual const ARMRegisterInfo *getRegisterInfo() const {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000052 return &InstrInfo.getRegisterInfo();
53 }
54 virtual const TargetData *getTargetData() const { return &DataLayout; }
55 virtual const ARMSubtarget *getSubtargetImpl() const { return &Subtarget; }
Anton Korobeynikov74b114b2008-08-17 13:55:10 +000056 virtual ARMTargetLowering *getTargetLowering() const {
57 return const_cast<ARMTargetLowering*>(&TLInfo);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000058 }
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
Dan Gohmane34aa772008-03-11 22:29:46 +000070 virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
71 virtual bool addPreEmitPass(PassManagerBase &PM, bool Fast);
Anton Korobeynikov74b114b2008-08-17 13:55:10 +000072 virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
Dan Gohmanf17a25c2007-07-18 16:29:46 +000073 std::ostream &Out);
Dan Gohmane34aa772008-03-11 22:29:46 +000074 virtual bool addCodeEmitter(PassManagerBase &PM, bool Fast,
Evan Cheng77547212007-07-20 21:56:13 +000075 bool DumpAsm, MachineCodeEmitter &MCE);
Dan Gohmane34aa772008-03-11 22:29:46 +000076 virtual bool addSimpleCodeEmitter(PassManagerBase &PM, bool Fast,
Evan Cheng77547212007-07-20 21:56:13 +000077 bool DumpAsm, MachineCodeEmitter &MCE);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000078};
79
80/// ThumbTargetMachine - Thumb target machine.
81///
82class ThumbTargetMachine : public ARMTargetMachine {
83public:
84 ThumbTargetMachine(const Module &M, const std::string &FS);
85
86 static unsigned getJITMatchQuality();
87 static unsigned getModuleMatchQuality(const Module &M);
88};
89
90} // end namespace llvm
91
92#endif