blob: a485897bfce4ef59a344448d0cdf66d3360ea4bc [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;
37
Anton Korobeynikov0bd89712008-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
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000045public:
Evan Cheng04321f72007-02-23 03:14:31 +000046 ARMTargetMachine(const Module &M, const std::string &FS, bool isThumb = false);
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000047
Dan Gohmanc9f5f3f2008-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 {
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000052 return &InstrInfo.getRegisterInfo();
53 }
54 virtual const TargetData *getTargetData() const { return &DataLayout; }
Evan Chenga8e29892007-01-19 07:51:42 +000055 virtual const ARMSubtarget *getSubtargetImpl() const { return &Subtarget; }
Anton Korobeynikov0bd89712008-08-17 13:55:10 +000056 virtual ARMTargetLowering *getTargetLowering() const {
57 return const_cast<ARMTargetLowering*>(&TLInfo);
Evan Chenge8308df2007-03-13 01:20:42 +000058 }
Anton Korobeynikov0bd89712008-08-17 13:55:10 +000059
60 static void registerAsmPrinter(AsmPrinterCtorFn F) {
61 AsmPrinterCtor = F;
62 }
63
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000064 static unsigned getModuleMatchQuality(const Module &M);
Evan Cheng148b6a42007-07-05 21:15:40 +000065 static unsigned getJITMatchQuality();
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000066
Evan Chenga8e29892007-01-19 07:51:42 +000067 virtual const TargetAsmInfo *createTargetAsmInfo() const;
Anton Korobeynikov0bd89712008-08-17 13:55:10 +000068
Chris Lattner1911fd42006-09-04 04:14:57 +000069 // Pass Pipeline Configuration
Dan Gohmanbfae8312008-03-11 22:29:46 +000070 virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
71 virtual bool addPreEmitPass(PassManagerBase &PM, bool Fast);
Anton Korobeynikov0bd89712008-08-17 13:55:10 +000072 virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
Chris Lattner1911fd42006-09-04 04:14:57 +000073 std::ostream &Out);
Dan Gohmanbfae8312008-03-11 22:29:46 +000074 virtual bool addCodeEmitter(PassManagerBase &PM, bool Fast,
Evan Cheng8bd60352007-07-20 21:56:13 +000075 bool DumpAsm, MachineCodeEmitter &MCE);
Dan Gohmanbfae8312008-03-11 22:29:46 +000076 virtual bool addSimpleCodeEmitter(PassManagerBase &PM, bool Fast,
Evan Cheng8bd60352007-07-20 21:56:13 +000077 bool DumpAsm, MachineCodeEmitter &MCE);
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000078};
79
Evan Cheng04321f72007-02-23 03:14:31 +000080/// ThumbTargetMachine - Thumb target machine.
81///
82class ThumbTargetMachine : public ARMTargetMachine {
83public:
84 ThumbTargetMachine(const Module &M, const std::string &FS);
85
Evan Cheng148b6a42007-07-05 21:15:40 +000086 static unsigned getJITMatchQuality();
Evan Cheng04321f72007-02-23 03:14:31 +000087 static unsigned getModuleMatchQuality(const Module &M);
88};
89
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000090} // end namespace llvm
91
92#endif