AArch64TargetMachine.h 3.4 KB

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