AArch64TargetMachine.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. //==-- AArch64TargetMachine.h - Define TargetMachine for AArch64 -*- 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 AArch64 specific subclass of TargetMachine.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_LIB_TARGET_AARCH64_AARCH64TARGETMACHINE_H
  13. #define LLVM_LIB_TARGET_AARCH64_AARCH64TARGETMACHINE_H
  14. #include "AArch64InstrInfo.h"
  15. #include "AArch64Subtarget.h"
  16. #include "llvm/IR/DataLayout.h"
  17. #include "llvm/Target/TargetMachine.h"
  18. #include <optional>
  19. namespace llvm {
  20. class AArch64TargetMachine : public LLVMTargetMachine {
  21. protected:
  22. std::unique_ptr<TargetLoweringObjectFile> TLOF;
  23. mutable StringMap<std::unique_ptr<AArch64Subtarget>> SubtargetMap;
  24. public:
  25. AArch64TargetMachine(const Target &T, const Triple &TT, StringRef CPU,
  26. StringRef FS, const TargetOptions &Options,
  27. std::optional<Reloc::Model> RM,
  28. std::optional<CodeModel::Model> CM, CodeGenOpt::Level OL,
  29. bool JIT, bool IsLittleEndian);
  30. ~AArch64TargetMachine() override;
  31. const AArch64Subtarget *getSubtargetImpl(const Function &F) const override;
  32. // DO NOT IMPLEMENT: There is no such thing as a valid default subtarget,
  33. // subtargets are per-function entities based on the target-specific
  34. // attributes of each function.
  35. const AArch64Subtarget *getSubtargetImpl() const = delete;
  36. // Pass Pipeline Configuration
  37. TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
  38. TargetTransformInfo getTargetTransformInfo(const Function &F) const override;
  39. TargetLoweringObjectFile* getObjFileLowering() const override {
  40. return TLOF.get();
  41. }
  42. MachineFunctionInfo *
  43. createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F,
  44. const TargetSubtargetInfo *STI) const override;
  45. yaml::MachineFunctionInfo *createDefaultFuncInfoYAML() const override;
  46. yaml::MachineFunctionInfo *
  47. convertFuncInfoToYAML(const MachineFunction &MF) const override;
  48. bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &,
  49. PerFunctionMIParsingState &PFS,
  50. SMDiagnostic &Error,
  51. SMRange &SourceRange) const override;
  52. /// Returns true if a cast between SrcAS and DestAS is a noop.
  53. bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override {
  54. // Addrspacecasts are always noops.
  55. return true;
  56. }
  57. private:
  58. bool isLittle;
  59. };
  60. // AArch64 little endian target machine.
  61. //
  62. class AArch64leTargetMachine : public AArch64TargetMachine {
  63. virtual void anchor();
  64. public:
  65. AArch64leTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
  66. StringRef FS, const TargetOptions &Options,
  67. std::optional<Reloc::Model> RM,
  68. std::optional<CodeModel::Model> CM,
  69. CodeGenOpt::Level OL, bool JIT);
  70. };
  71. // AArch64 big endian target machine.
  72. //
  73. class AArch64beTargetMachine : public AArch64TargetMachine {
  74. virtual void anchor();
  75. public:
  76. AArch64beTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
  77. StringRef FS, const TargetOptions &Options,
  78. std::optional<Reloc::Model> RM,
  79. std::optional<CodeModel::Model> CM,
  80. CodeGenOpt::Level OL, bool JIT);
  81. };
  82. } // end namespace llvm
  83. #endif