1 //===-- ARMTargetMachine.h - Define TargetMachine for ARM -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the ARM specific subclass of TargetMachine.
12 //===----------------------------------------------------------------------===//
14 #ifndef ARMTARGETMACHINE_H
15 #define ARMTARGETMACHINE_H
17 #include "ARMFrameLowering.h"
18 #include "ARMISelLowering.h"
19 #include "ARMInstrInfo.h"
20 #include "ARMJITInfo.h"
21 #include "ARMSelectionDAGInfo.h"
22 #include "ARMSubtarget.h"
23 #include "Thumb1FrameLowering.h"
24 #include "Thumb1InstrInfo.h"
25 #include "Thumb2InstrInfo.h"
26 #include "llvm/ADT/OwningPtr.h"
27 #include "llvm/IR/DataLayout.h"
28 #include "llvm/MC/MCStreamer.h"
29 #include "llvm/Target/TargetMachine.h"
33 class ARMBaseTargetMachine : public LLVMTargetMachine {
35 ARMSubtarget Subtarget;
38 InstrItineraryData InstrItins;
41 ARMBaseTargetMachine(const Target &T, StringRef TT,
42 StringRef CPU, StringRef FS,
43 const TargetOptions &Options,
44 Reloc::Model RM, CodeModel::Model CM,
45 CodeGenOpt::Level OL);
47 virtual ARMJITInfo *getJITInfo() { return &JITInfo; }
48 virtual const ARMSubtarget *getSubtargetImpl() const { return &Subtarget; }
49 virtual const ARMTargetLowering *getTargetLowering() const {
50 // Implemented by derived classes
51 llvm_unreachable("getTargetLowering not implemented");
53 virtual const InstrItineraryData *getInstrItineraryData() const {
57 /// \brief Register ARM analysis passes with a pass manager.
58 virtual void addAnalysisPasses(PassManagerBase &PM);
60 // Pass Pipeline Configuration
61 virtual TargetPassConfig *createPassConfig(PassManagerBase &PM);
63 virtual bool addCodeEmitter(PassManagerBase &PM, JITCodeEmitter &MCE);
66 /// ARMTargetMachine - ARM target machine.
68 class ARMTargetMachine : public ARMBaseTargetMachine {
69 virtual void anchor();
70 ARMInstrInfo InstrInfo;
71 const DataLayout DL; // Calculates type size & alignment
72 ARMTargetLowering TLInfo;
73 ARMSelectionDAGInfo TSInfo;
74 ARMFrameLowering FrameLowering;
76 ARMTargetMachine(const Target &T, StringRef TT,
77 StringRef CPU, StringRef FS,
78 const TargetOptions &Options,
79 Reloc::Model RM, CodeModel::Model CM,
80 CodeGenOpt::Level OL);
82 virtual const ARMRegisterInfo *getRegisterInfo() const {
83 return &InstrInfo.getRegisterInfo();
86 virtual const ARMTargetLowering *getTargetLowering() const {
90 virtual const ARMSelectionDAGInfo* getSelectionDAGInfo() const {
93 virtual const ARMFrameLowering *getFrameLowering() const {
94 return &FrameLowering;
96 virtual const ARMInstrInfo *getInstrInfo() const { return &InstrInfo; }
97 virtual const DataLayout *getDataLayout() const { return &DL; }
100 /// ThumbTargetMachine - Thumb target machine.
101 /// Due to the way architectures are handled, this represents both
102 /// Thumb-1 and Thumb-2.
104 class ThumbTargetMachine : public ARMBaseTargetMachine {
105 virtual void anchor();
106 // Either Thumb1InstrInfo or Thumb2InstrInfo.
107 OwningPtr<ARMBaseInstrInfo> InstrInfo;
108 const DataLayout DL; // Calculates type size & alignment
109 ARMTargetLowering TLInfo;
110 ARMSelectionDAGInfo TSInfo;
111 // Either Thumb1FrameLowering or ARMFrameLowering.
112 OwningPtr<ARMFrameLowering> FrameLowering;
114 ThumbTargetMachine(const Target &T, StringRef TT,
115 StringRef CPU, StringRef FS,
116 const TargetOptions &Options,
117 Reloc::Model RM, CodeModel::Model CM,
118 CodeGenOpt::Level OL);
120 /// returns either Thumb1RegisterInfo or Thumb2RegisterInfo
121 virtual const ARMBaseRegisterInfo *getRegisterInfo() const {
122 return &InstrInfo->getRegisterInfo();
125 virtual const ARMTargetLowering *getTargetLowering() const {
129 virtual const ARMSelectionDAGInfo *getSelectionDAGInfo() const {
133 /// returns either Thumb1InstrInfo or Thumb2InstrInfo
134 virtual const ARMBaseInstrInfo *getInstrInfo() const {
135 return InstrInfo.get();
137 /// returns either Thumb1FrameLowering or ARMFrameLowering
138 virtual const ARMFrameLowering *getFrameLowering() const {
139 return FrameLowering.get();
141 virtual const DataLayout *getDataLayout() const { return &DL; }
144 } // end namespace llvm