/3rd_party/llvm/lib/Target/ARM/ARMTargetMachine.h

https://code.google.com/p/softart/ · C++ Header · 146 lines · 100 code · 20 blank · 26 comment · 0 complexity · 21a7aa452d4e3a851dfde49cf3eda45b MD5 · raw file

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