blob: 3f65f71bbeb35982f327cbdb9582c67edd62b4e4 [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"
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000025
26namespace llvm {
27
28class Module;
29
Chris Lattner1911fd42006-09-04 04:14:57 +000030class ARMTargetMachine : public LLVMTargetMachine {
Evan Chenga8e29892007-01-19 07:51:42 +000031 ARMSubtarget Subtarget;
32 const TargetData DataLayout; // Calculates type size & alignment
33 ARMInstrInfo InstrInfo;
34 ARMFrameInfo FrameInfo;
Evan Cheng148b6a42007-07-05 21:15:40 +000035 ARMJITInfo JITInfo;
Evan Chenge8308df2007-03-13 01:20:42 +000036 ARMTargetLowering TLInfo;
Evan Cheng65f24422008-10-30 16:10:54 +000037 Reloc::Model DefRelocModel; // Reloc model before it's overridden.
Evan Chenge8308df2007-03-13 01:20:42 +000038
Anton Korobeynikov0bd89712008-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 Andersoncb371882008-08-21 00:14:44 +000042 typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
Bill Wendling57f0db82009-02-24 08:30:20 +000043 ARMTargetMachine &tm,
Bill Wendling98a366d2009-04-29 23:29:43 +000044 CodeGenOpt::Level OptLevel,
45 bool verbose);
Anton Korobeynikov0bd89712008-08-17 13:55:10 +000046 static AsmPrinterCtorFn AsmPrinterCtor;
47
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000048public:
Evan Cheng04321f72007-02-23 03:14:31 +000049 ARMTargetMachine(const Module &M, const std::string &FS, bool isThumb = false);
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000050
Dan Gohmanc9f5f3f2008-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 {
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000055 return &InstrInfo.getRegisterInfo();
56 }
57 virtual const TargetData *getTargetData() const { return &DataLayout; }
Evan Chenga8e29892007-01-19 07:51:42 +000058 virtual const ARMSubtarget *getSubtargetImpl() const { return &Subtarget; }
Anton Korobeynikov0bd89712008-08-17 13:55:10 +000059 virtual ARMTargetLowering *getTargetLowering() const {
60 return const_cast<ARMTargetLowering*>(&TLInfo);
Evan Chenge8308df2007-03-13 01:20:42 +000061 }
Anton Korobeynikov0bd89712008-08-17 13:55:10 +000062
63 static void registerAsmPrinter(AsmPrinterCtorFn F) {
64 AsmPrinterCtor = F;
65 }
66
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000067 static unsigned getModuleMatchQuality(const Module &M);
Evan Cheng148b6a42007-07-05 21:15:40 +000068 static unsigned getJITMatchQuality();
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000069
Evan Chenga8e29892007-01-19 07:51:42 +000070 virtual const TargetAsmInfo *createTargetAsmInfo() const;
Anton Korobeynikov0bd89712008-08-17 13:55:10 +000071
Chris Lattner1911fd42006-09-04 04:14:57 +000072 // Pass Pipeline Configuration
Bill Wendling98a366d2009-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 Cheng42bf74b2009-03-25 01:47:28 +000077 bool Verbose, raw_ostream &Out);
Bill Wendling98a366d2009-04-29 23:29:43 +000078 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
Evan Cheng8bd60352007-07-20 21:56:13 +000079 bool DumpAsm, MachineCodeEmitter &MCE);
Bill Wendling98a366d2009-04-29 23:29:43 +000080 virtual bool addSimpleCodeEmitter(PassManagerBase &PM,
81 CodeGenOpt::Level OptLevel,
82 bool DumpAsm,
83 MachineCodeEmitter &MCE);
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000084};
85
Evan Cheng04321f72007-02-23 03:14:31 +000086/// ThumbTargetMachine - Thumb target machine.
87///
88class ThumbTargetMachine : public ARMTargetMachine {
89public:
90 ThumbTargetMachine(const Module &M, const std::string &FS);
91
Evan Cheng148b6a42007-07-05 21:15:40 +000092 static unsigned getJITMatchQuality();
Evan Cheng04321f72007-02-23 03:14:31 +000093 static unsigned getModuleMatchQuality(const Module &M);
94};
95
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000096} // end namespace llvm
97
98#endif