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 MachineFunctionInfo * 51 createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, 52 const TargetSubtargetInfo *STI) const override; 53 54 TargetTransformInfo getTargetTransformInfo(const Function &F) const override; 55 56 bool usesPhysRegsForValues() const override { return false; } 57 58 yaml::MachineFunctionInfo *createDefaultFuncInfoYAML() const override; 59 yaml::MachineFunctionInfo * 60 convertFuncInfoToYAML(const MachineFunction &MF) const override; 61 bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &, 62 PerFunctionMIParsingState &PFS, 63 SMDiagnostic &Error, 64 SMRange &SourceRange) const override; 65 }; 66 67 } // end namespace llvm 68 69 #endif 70