blob: 6fe9a222b4df9d93a1f48ad1bb0940f916308cd8 [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,
Anton Korobeynikov74b114b2008-08-17 13:55:10 +000043 ARMTargetMachine &tm);
44 static AsmPrinterCtorFn AsmPrinterCtor;
45
Dan Gohmanf17a25c2007-07-18 16:29:46 +000046public:
47 ARMTargetMachine(const Module &M, const std::string &FS, bool isThumb = false);
48
Dan Gohmanb41dfba2008-05-14 01:58:56 +000049 virtual const ARMInstrInfo *getInstrInfo() const { return &InstrInfo; }
50 virtual const ARMFrameInfo *getFrameInfo() const { return &FrameInfo; }
51 virtual ARMJITInfo *getJITInfo() { return &JITInfo; }
52 virtual const ARMRegisterInfo *getRegisterInfo() const {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000053 return &InstrInfo.getRegisterInfo();
54 }
55 virtual const TargetData *getTargetData() const { return &DataLayout; }
56 virtual const ARMSubtarget *getSubtargetImpl() const { return &Subtarget; }
Anton Korobeynikov74b114b2008-08-17 13:55:10 +000057 virtual ARMTargetLowering *getTargetLowering() const {
58 return const_cast<ARMTargetLowering*>(&TLInfo);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000059 }
Anton Korobeynikov74b114b2008-08-17 13:55:10 +000060
61 static void registerAsmPrinter(AsmPrinterCtorFn F) {
62 AsmPrinterCtor = F;
63 }
64
Dan Gohmanf17a25c2007-07-18 16:29:46 +000065 static unsigned getModuleMatchQuality(const Module &M);
66 static unsigned getJITMatchQuality();
67
68 virtual const TargetAsmInfo *createTargetAsmInfo() const;
Anton Korobeynikov74b114b2008-08-17 13:55:10 +000069
Dan Gohmanf17a25c2007-07-18 16:29:46 +000070 // Pass Pipeline Configuration
Dan Gohmane34aa772008-03-11 22:29:46 +000071 virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
72 virtual bool addPreEmitPass(PassManagerBase &PM, bool Fast);
Anton Korobeynikov74b114b2008-08-17 13:55:10 +000073 virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
Owen Anderson847b99b2008-08-21 00:14:44 +000074 raw_ostream &Out);
Dan Gohmane34aa772008-03-11 22:29:46 +000075 virtual bool addCodeEmitter(PassManagerBase &PM, bool Fast,
Evan Cheng77547212007-07-20 21:56:13 +000076 bool DumpAsm, MachineCodeEmitter &MCE);
Dan Gohmane34aa772008-03-11 22:29:46 +000077 virtual bool addSimpleCodeEmitter(PassManagerBase &PM, bool Fast,
Evan Cheng77547212007-07-20 21:56:13 +000078 bool DumpAsm, MachineCodeEmitter &MCE);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000079};
80
81/// ThumbTargetMachine - Thumb target machine.
82///
83class ThumbTargetMachine : public ARMTargetMachine {
84public:
85 ThumbTargetMachine(const Module &M, const std::string &FS);
86
87 static unsigned getJITMatchQuality();
88 static unsigned getModuleMatchQuality(const Module &M);
89};
90
91} // end namespace llvm
92
93#endif