82 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8///9/// \file10/// This file declares the WebAssembly-specific subclass of11/// TargetMachine.12///13//===----------------------------------------------------------------------===//14 15#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETMACHINE_H16#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETMACHINE_H17 18#include "WebAssemblySubtarget.h"19#include "llvm/CodeGen/CodeGenTargetMachineImpl.h"20#include <optional>21 22namespace llvm {23 24namespace WebAssembly {25// Exception handling / setjmp-longjmp handling command-line options26extern cl::opt<bool> WasmEnableEmEH; // asm.js-style EH27extern cl::opt<bool> WasmEnableEmSjLj; // asm.js-style SjLJ28extern cl::opt<bool> WasmEnableEH; // EH using Wasm EH instructions29extern cl::opt<bool> WasmEnableSjLj; // SjLj using Wasm EH instructions30extern cl::opt<bool> WasmUseLegacyEH; // Legacy Wasm EH31} // namespace WebAssembly32 33class WebAssemblyTargetMachine final : public CodeGenTargetMachineImpl {34 std::unique_ptr<TargetLoweringObjectFile> TLOF;35 mutable StringMap<std::unique_ptr<WebAssemblySubtarget>> SubtargetMap;36 bool UsesMultivalueABI = false;37 38public:39 WebAssemblyTargetMachine(const Target &T, const Triple &TT, StringRef CPU,40 StringRef FS, const TargetOptions &Options,41 std::optional<Reloc::Model> RM,42 std::optional<CodeModel::Model> CM,43 CodeGenOptLevel OL, bool JIT);44 45 ~WebAssemblyTargetMachine() override;46 47 const WebAssemblySubtarget *getSubtargetImpl() const;48 const WebAssemblySubtarget *getSubtargetImpl(std::string CPU,49 std::string FS) const;50 const WebAssemblySubtarget *51 getSubtargetImpl(const Function &F) const override;52 53 // Pass Pipeline Configuration54 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;55 56 TargetLoweringObjectFile *getObjFileLowering() const override {57 return TLOF.get();58 }59 60 MachineFunctionInfo *61 createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F,62 const TargetSubtargetInfo *STI) const override;63 64 TargetTransformInfo getTargetTransformInfo(const Function &F) const override;65 66 bool usesPhysRegsForValues() const override { return false; }67 68 yaml::MachineFunctionInfo *createDefaultFuncInfoYAML() const override;69 yaml::MachineFunctionInfo *70 convertFuncInfoToYAML(const MachineFunction &MF) const override;71 bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &,72 PerFunctionMIParsingState &PFS,73 SMDiagnostic &Error,74 SMRange &SourceRange) const override;75 76 bool usesMultivalueABI() const { return UsesMultivalueABI; }77};78 79} // end namespace llvm80 81#endif82