1 // WebAssemblyTargetMachine.h - Define TargetMachine for WebAssembly -*- C++ -*-
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
7 //===----------------------------------------------------------------------===//
10 /// This file declares the WebAssembly-specific subclass of
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETMACHINE_H
16 #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETMACHINE_H
18 #include "WebAssemblySubtarget.h"
19 #include "llvm/Target/TargetMachine.h"
24 class WebAssemblyTargetMachine final
: public LLVMTargetMachine
{
25 std::unique_ptr
<TargetLoweringObjectFile
> TLOF
;
26 mutable StringMap
<std::unique_ptr
<WebAssemblySubtarget
>> SubtargetMap
;
27 bool UsesMultivalueABI
= false;
30 WebAssemblyTargetMachine(const Target
&T
, const Triple
&TT
, StringRef CPU
,
31 StringRef FS
, const TargetOptions
&Options
,
32 std::optional
<Reloc::Model
> RM
,
33 std::optional
<CodeModel::Model
> CM
,
34 CodeGenOptLevel OL
, bool JIT
);
36 ~WebAssemblyTargetMachine() override
;
38 const WebAssemblySubtarget
*getSubtargetImpl() const;
39 const WebAssemblySubtarget
*getSubtargetImpl(std::string CPU
,
40 std::string FS
) const;
41 const WebAssemblySubtarget
*
42 getSubtargetImpl(const Function
&F
) const override
;
44 // Pass Pipeline Configuration
45 TargetPassConfig
*createPassConfig(PassManagerBase
&PM
) override
;
47 TargetLoweringObjectFile
*getObjFileLowering() const override
{
52 createMachineFunctionInfo(BumpPtrAllocator
&Allocator
, const Function
&F
,
53 const TargetSubtargetInfo
*STI
) const override
;
55 TargetTransformInfo
getTargetTransformInfo(const Function
&F
) const override
;
57 bool usesPhysRegsForValues() const override
{ return false; }
59 yaml::MachineFunctionInfo
*createDefaultFuncInfoYAML() const override
;
60 yaml::MachineFunctionInfo
*
61 convertFuncInfoToYAML(const MachineFunction
&MF
) const override
;
62 bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo
&,
63 PerFunctionMIParsingState
&PFS
,
65 SMRange
&SourceRange
) const override
;
67 bool usesMultivalueABI() const { return UsesMultivalueABI
; }
70 } // end namespace llvm