ARMTargetMachine.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //===-- ARMTargetMachine.h - Define TargetMachine for ARM -------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file declares the ARM specific subclass of TargetMachine.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_LIB_TARGET_ARM_ARMTARGETMACHINE_H
  13. #define LLVM_LIB_TARGET_ARM_ARMTARGETMACHINE_H
  14. #include "ARMSubtarget.h"
  15. #include "llvm/ADT/Optional.h"
  16. #include "llvm/ADT/StringMap.h"
  17. #include "llvm/ADT/StringRef.h"
  18. #include "llvm/Analysis/TargetTransformInfo.h"
  19. #include "llvm/Support/CodeGen.h"
  20. #include "llvm/Target/TargetMachine.h"
  21. #include <memory>
  22. namespace llvm {
  23. class ARMBaseTargetMachine : public LLVMTargetMachine {
  24. public:
  25. enum ARMABI {
  26. ARM_ABI_UNKNOWN,
  27. ARM_ABI_APCS,
  28. ARM_ABI_AAPCS, // ARM EABI
  29. ARM_ABI_AAPCS16
  30. } TargetABI;
  31. protected:
  32. std::unique_ptr<TargetLoweringObjectFile> TLOF;
  33. bool isLittle;
  34. mutable StringMap<std::unique_ptr<ARMSubtarget>> SubtargetMap;
  35. public:
  36. ARMBaseTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
  37. StringRef FS, const TargetOptions &Options,
  38. Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
  39. CodeGenOpt::Level OL, bool isLittle);
  40. ~ARMBaseTargetMachine() override;
  41. const ARMSubtarget *getSubtargetImpl(const Function &F) const override;
  42. // DO NOT IMPLEMENT: There is no such thing as a valid default subtarget,
  43. // subtargets are per-function entities based on the target-specific
  44. // attributes of each function.
  45. const ARMSubtarget *getSubtargetImpl() const = delete;
  46. bool isLittleEndian() const { return isLittle; }
  47. TargetTransformInfo getTargetTransformInfo(const Function &F) override;
  48. // Pass Pipeline Configuration
  49. TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
  50. TargetLoweringObjectFile *getObjFileLowering() const override {
  51. return TLOF.get();
  52. }
  53. bool isTargetHardFloat() const {
  54. return TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
  55. TargetTriple.getEnvironment() == Triple::MuslEABIHF ||
  56. TargetTriple.getEnvironment() == Triple::EABIHF ||
  57. (TargetTriple.isOSBinFormatMachO() &&
  58. TargetTriple.getSubArch() == Triple::ARMSubArch_v7em) ||
  59. TargetTriple.isOSWindows() ||
  60. TargetABI == ARMBaseTargetMachine::ARM_ABI_AAPCS16;
  61. }
  62. bool targetSchedulesPostRAScheduling() const override { return true; };
  63. /// Returns true if a cast between SrcAS and DestAS is a noop.
  64. bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override {
  65. // Addrspacecasts are always noops.
  66. return true;
  67. }
  68. };
  69. /// ARM/Thumb little endian target machine.
  70. ///
  71. class ARMLETargetMachine : public ARMBaseTargetMachine {
  72. public:
  73. ARMLETargetMachine(const Target &T, const Triple &TT, StringRef CPU,
  74. StringRef FS, const TargetOptions &Options,
  75. Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
  76. CodeGenOpt::Level OL, bool JIT);
  77. };
  78. /// ARM/Thumb big endian target machine.
  79. ///
  80. class ARMBETargetMachine : public ARMBaseTargetMachine {
  81. public:
  82. ARMBETargetMachine(const Target &T, const Triple &TT, StringRef CPU,
  83. StringRef FS, const TargetOptions &Options,
  84. Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
  85. CodeGenOpt::Level OL, bool JIT);
  86. };
  87. } // end namespace llvm
  88. #endif // LLVM_LIB_TARGET_ARM_ARMTARGETMACHINE_H