WebAssemblyTargetMachine.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // WebAssemblyTargetMachine.h - Define TargetMachine for WebAssembly -*- 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. /// \file
  10. /// This file declares the WebAssembly-specific subclass of
  11. /// TargetMachine.
  12. ///
  13. //===----------------------------------------------------------------------===//
  14. #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETMACHINE_H
  15. #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETMACHINE_H
  16. #include "WebAssemblySubtarget.h"
  17. #include "llvm/Target/TargetMachine.h"
  18. #include <optional>
  19. namespace llvm {
  20. class WebAssemblyTargetMachine final : public LLVMTargetMachine {
  21. std::unique_ptr<TargetLoweringObjectFile> TLOF;
  22. mutable StringMap<std::unique_ptr<WebAssemblySubtarget>> SubtargetMap;
  23. public:
  24. WebAssemblyTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
  25. StringRef FS, const TargetOptions &Options,
  26. std::optional<Reloc::Model> RM,
  27. std::optional<CodeModel::Model> CM,
  28. CodeGenOpt::Level OL, bool JIT);
  29. ~WebAssemblyTargetMachine() override;
  30. const WebAssemblySubtarget *getSubtargetImpl() const;
  31. const WebAssemblySubtarget *getSubtargetImpl(std::string CPU,
  32. std::string FS) const;
  33. const WebAssemblySubtarget *
  34. getSubtargetImpl(const Function &F) const override;
  35. // Pass Pipeline Configuration
  36. TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
  37. TargetLoweringObjectFile *getObjFileLowering() const override {
  38. return TLOF.get();
  39. }
  40. MachineFunctionInfo *
  41. createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F,
  42. const TargetSubtargetInfo *STI) const override;
  43. TargetTransformInfo getTargetTransformInfo(const Function &F) const override;
  44. bool usesPhysRegsForValues() const override { return false; }
  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. };
  53. } // end namespace llvm
  54. #endif