LLVM 24.0.0git
WebAssemblySubtarget.h
Go to the documentation of this file.
1//=- WebAssemblySubtarget.h - Define Subtarget for the 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/// TargetSubtarget.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYSUBTARGET_H
16#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYSUBTARGET_H
17
29#include <string>
30
31#define OPTIONS_STRUCT_DECL
32#include "WebAssemblyOptions.inc"
33
34#define GET_SUBTARGETINFO_HEADER
35#include "WebAssemblyGenSubtargetInfo.inc"
36
37namespace llvm {
38class LLVMContext;
39class Module;
40class WebAssemblyTargetMachine;
41
42const WebAssemblyOptions &getWebAssemblyOptions(const LLVMContext &C);
43const WebAssemblyOptions &getWebAssemblyOptions(const Module &M);
44
46 const WebAssemblyOptions &CLOpts;
47
48 enum SIMDEnum {
49 NoSIMD,
50 SIMD128,
51 RelaxedSIMD,
52 } SIMDLevel = NoSIMD;
53
54 bool HasAcquireReleaseAtomics = false;
55 bool HasAtomics = false;
56 bool HasBulkMemory = false;
57 bool HasBulkMemoryOpt = false;
58 bool HasCallIndirectOverlong = false;
59 bool HasCompactImports = false;
60 bool HasExceptionHandling = false;
61 bool HasExtendedConst = false;
62 bool HasFP16 = false;
63 bool HasGC = false;
64 bool HasCooperativeMultithreading = false;
65 bool HasLibcallThreadContext = false;
66 bool HasMultiMemory = false;
67 bool HasMultivalue = false;
68 bool HasMutableGlobals = false;
69 bool HasNontrappingFPToInt = false;
70 bool HasReferenceTypes = false;
71 bool HasSignExt = false;
72 bool HasTailCall = false;
73 bool HasWideArithmetic = false;
74
75 /// What processor and OS we're targeting.
76 Triple TargetTriple;
77
78 /// The ABI in use.
80
81 WebAssemblyFrameLowering FrameLowering;
82 WebAssemblyInstrInfo InstrInfo;
85
86 std::unique_ptr<CallLowering> CallLoweringInfo;
87 std::unique_ptr<InstructionSelector> InstSelector;
88 std::unique_ptr<LegalizerInfo> Legalizer;
89 std::unique_ptr<RegisterBankInfo> RegBankInfo;
90
91 WebAssemblySubtarget &initializeSubtargetDependencies(StringRef CPU,
92 StringRef FS);
93
94public:
95 /// This constructor initializes the data members to match that
96 /// of the specified triple.
98 const WebAssemblyTargetMachine &TM, StringRef ABIName);
99
101 return &TSInfo;
102 }
104 return &FrameLowering;
105 }
107 return &TLInfo;
108 }
109 const WebAssemblyInstrInfo *getInstrInfo() const override {
110 return &InstrInfo;
111 }
112 const WebAssemblyRegisterInfo *getRegisterInfo() const override {
113 return &getInstrInfo()->getRegisterInfo();
114 }
115 const WebAssemblyOptions &getCLOpts() const { return CLOpts; }
116 const Triple &getTargetTriple() const { return TargetTriple; }
117 bool enableAtomicExpand() const override;
118 bool enableIndirectBrExpand() const override { return true; }
119 bool enableMachineScheduler() const override;
120 bool useAA() const override;
121
122 // Predicates used by WebAssemblyInstrInfo.td.
123 bool hasAcquireReleaseAtomics() const { return HasAcquireReleaseAtomics; }
124 bool hasAddr64() const { return TargetTriple.isArch64Bit(); }
125 bool hasAtomics() const { return HasAtomics; }
126 bool hasBulkMemory() const { return HasBulkMemory; }
127 bool hasBulkMemoryOpt() const { return HasBulkMemoryOpt; }
128 bool hasCallIndirectOverlong() const { return HasCallIndirectOverlong; }
129 bool hasCompactImports() const { return HasCompactImports; }
130 bool hasExceptionHandling() const { return HasExceptionHandling; }
131 bool hasExtendedConst() const { return HasExtendedConst; }
132 bool hasFP16() const { return HasFP16; }
133 bool hasGC() const { return HasGC; }
135 return HasCooperativeMultithreading;
136 }
137 bool hasLibcallThreadContext() const { return HasLibcallThreadContext; }
138 bool hasMultiMemory() const { return HasMultiMemory; }
139 bool hasMultivalue() const { return HasMultivalue; }
140 bool hasMutableGlobals() const { return HasMutableGlobals; }
141 bool hasNontrappingFPToInt() const { return HasNontrappingFPToInt; }
142 bool hasReferenceTypes() const { return HasReferenceTypes; }
143 bool hasRelaxedSIMD() const { return SIMDLevel >= RelaxedSIMD; }
144 bool hasSignExt() const { return HasSignExt; }
145 bool hasSIMD128() const { return SIMDLevel >= SIMD128; }
146 bool hasTailCall() const { return HasTailCall; }
147 bool hasWideArithmetic() const { return HasWideArithmetic; }
148
149 bool usesMultivalueABI() const {
151 }
152
153 /// Parses features string setting specified subtarget options. Definition of
154 /// function is auto generated by tblgen.
156
157 const CallLowering *getCallLowering() const override;
159 const LegalizerInfo *getLegalizerInfo() const override;
160 const RegisterBankInfo *getRegBankInfo() const override;
161};
162
163} // end namespace llvm
164
165#endif
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file describes how to lower LLVM calls to machine code calls.
Interface for Targets to specify which operations they can successfully select and how the others sho...
Machine Check Debug Module
This class implements WebAssembly-specific bits of TargetFrameLowering class.
This file defines the interfaces that WebAssembly uses to lower LLVM code into a selection DAG.
This file contains the WebAssembly implementation of the TargetInstrInfo class.
This file provides WebAssembly-specific target descriptions.
This file defines the WebAssembly subclass for SelectionDAGTargetInfo.
This file contains the declaration of the WebAssembly-specific utility functions.
Holds all the information related to register banks.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
const WebAssemblyRegisterInfo & getRegisterInfo() const
WebAssemblySubtarget(const Triple &TT, StringRef CPU, StringRef FS, const WebAssemblyTargetMachine &TM, StringRef ABIName)
This constructor initializes the data members to match that of the specified triple.
bool enableAtomicExpand() const override
const WebAssemblyOptions & getCLOpts() const
const WebAssemblySelectionDAGInfo * getSelectionDAGInfo() const override
const Triple & getTargetTriple() const
bool enableIndirectBrExpand() const override
const CallLowering * getCallLowering() const override
const WebAssemblyTargetLowering * getTargetLowering() const override
const WebAssemblyInstrInfo * getInstrInfo() const override
const WebAssemblyRegisterInfo * getRegisterInfo() const override
const RegisterBankInfo * getRegBankInfo() const override
bool enableMachineScheduler() const override
InstructionSelector * getInstructionSelector() const override
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS)
Parses features string setting specified subtarget options.
const WebAssemblyFrameLowering * getFrameLowering() const override
const LegalizerInfo * getLegalizerInfo() const override
This is an optimization pass for GlobalISel generic memory operations.
const WebAssemblyOptions & getWebAssemblyOptions(const LLVMContext &C)