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 15 #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETMACHINE_H 16 #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETMACHINE_H 17 18 #include "WebAssemblySubtarget.h" 19 #include "llvm/Target/TargetMachine.h" 20 #include <optional> 21 22 namespace llvm { 23 24 class WebAssemblyTargetMachine final : public LLVMTargetMachine { 25 std::unique_ptr<TargetLoweringObjectFile> TLOF; 26 mutable StringMap<std::unique_ptr<WebAssemblySubtarget>> SubtargetMap; 27 28 public: 29 WebAssemblyTargetMachine(const Target &T, const Triple &TT, StringRef CPU, 30 StringRef FS, const TargetOptions &Options, 31 std::optional<Reloc::Model> RM, 32 std::optional<CodeModel::Model> CM, 33 CodeGenOpt::Level OL, bool JIT); 34 35 ~WebAssemblyTargetMachine() override; 36 37 const WebAssemblySubtarget *getSubtargetImpl() const; 38 const WebAssemblySubtarget *getSubtargetImpl(std::string CPU, 39 std::string FS) const; 40 const WebAssemblySubtarget * 41 getSubtargetImpl(const Function &F) const override; 42 43 // Pass Pipeline Configuration 44 TargetPassConfig *createPassConfig(PassManagerBase &PM) override; 45 46 TargetLoweringObjectFile *getObjFileLowering() const override { 47 return TLOF.get(); 48 } 49 50 TargetTransformInfo getTargetTransformInfo(const Function &F) const override; 51 52 bool usesPhysRegsForValues() const override { return false; } 53 54 yaml::MachineFunctionInfo *createDefaultFuncInfoYAML() const override; 55 yaml::MachineFunctionInfo * 56 convertFuncInfoToYAML(const MachineFunction &MF) const override; 57 bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &, 58 PerFunctionMIParsingState &PFS, 59 SMDiagnostic &Error, 60 SMRange &SourceRange) const override; 61 }; 62 63 } // end namespace llvm 64 65 #endif 66