LLVM 23.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
28#include <string>
29
30#define GET_SUBTARGETINFO_HEADER
31#include "WebAssemblyGenSubtargetInfo.inc"
32
33namespace llvm {
34
35// Defined in WebAssemblyGenSubtargetInfo.inc.
36extern const SubtargetFeatureKV
37 WebAssemblyFeatureKV[WebAssembly::NumSubtargetFeatures];
38
40 enum SIMDEnum {
41 NoSIMD,
42 SIMD128,
43 RelaxedSIMD,
44 } SIMDLevel = NoSIMD;
45
46 bool HasAtomics = false;
47 bool HasBulkMemory = false;
48 bool HasBulkMemoryOpt = false;
49 bool HasCallIndirectOverlong = false;
50 bool HasCompactImports = false;
51 bool HasExceptionHandling = false;
52 bool HasExtendedConst = false;
53 bool HasFP16 = false;
54 bool HasGC = false;
55 bool HasLibcallThreadContext = false;
56 bool HasMultiMemory = false;
57 bool HasMultivalue = false;
58 bool HasMutableGlobals = false;
59 bool HasNontrappingFPToInt = false;
60 bool HasReferenceTypes = false;
61 bool HasRelaxedAtomics = false;
62 bool HasSignExt = false;
63 bool HasTailCall = false;
64 bool HasWideArithmetic = false;
65
66 /// What processor and OS we're targeting.
67 Triple TargetTriple;
68
69 WebAssemblyFrameLowering FrameLowering;
70 WebAssemblyInstrInfo InstrInfo;
73
74 std::unique_ptr<CallLowering> CallLoweringInfo;
75 std::unique_ptr<InstructionSelector> InstSelector;
76 std::unique_ptr<LegalizerInfo> Legalizer;
77 std::unique_ptr<RegisterBankInfo> RegBankInfo;
78
79 WebAssemblySubtarget &initializeSubtargetDependencies(StringRef CPU,
80 StringRef FS);
81
82public:
83 /// This constructor initializes the data members to match that
84 /// of the specified triple.
85 WebAssemblySubtarget(const Triple &TT, const std::string &CPU,
86 const std::string &FS, const TargetMachine &TM);
87
89 return &TSInfo;
90 }
92 return &FrameLowering;
93 }
95 return &TLInfo;
96 }
97 const WebAssemblyInstrInfo *getInstrInfo() const override {
98 return &InstrInfo;
99 }
100 const WebAssemblyRegisterInfo *getRegisterInfo() const override {
101 return &getInstrInfo()->getRegisterInfo();
102 }
103 const Triple &getTargetTriple() const { return TargetTriple; }
104 bool enableAtomicExpand() const override;
105 bool enableIndirectBrExpand() const override { return true; }
106 bool enableMachineScheduler() const override;
107 bool useAA() const override;
108
109 // Predicates used by WebAssemblyInstrInfo.td.
110 bool hasAddr64() const { return TargetTriple.isArch64Bit(); }
111 bool hasAtomics() const { return HasAtomics; }
112 bool hasBulkMemory() const { return HasBulkMemory; }
113 bool hasBulkMemoryOpt() const { return HasBulkMemoryOpt; }
114 bool hasCallIndirectOverlong() const { return HasCallIndirectOverlong; }
115 bool hasCompactImports() const { return HasCompactImports; }
116 bool hasExceptionHandling() const { return HasExceptionHandling; }
117 bool hasExtendedConst() const { return HasExtendedConst; }
118 bool hasFP16() const { return HasFP16; }
119 bool hasGC() const { return HasGC; }
120 bool hasLibcallThreadContext() const { return HasLibcallThreadContext; }
121 bool hasMultiMemory() const { return HasMultiMemory; }
122 bool hasMultivalue() const { return HasMultivalue; }
123 bool hasMutableGlobals() const { return HasMutableGlobals; }
124 bool hasNontrappingFPToInt() const { return HasNontrappingFPToInt; }
125 bool hasReferenceTypes() const { return HasReferenceTypes; }
126 bool hasRelaxedAtomics() const { return HasRelaxedAtomics; }
127 bool hasRelaxedSIMD() const { return SIMDLevel >= RelaxedSIMD; }
128 bool hasSignExt() const { return HasSignExt; }
129 bool hasSIMD128() const { return SIMDLevel >= SIMD128; }
130 bool hasTailCall() const { return HasTailCall; }
131 bool hasWideArithmetic() const { return HasWideArithmetic; }
132
133 /// Parses features string setting specified subtarget options. Definition of
134 /// function is auto generated by tblgen.
136
137 const CallLowering *getCallLowering() const override;
139 const LegalizerInfo *getLegalizerInfo() const override;
140 const RegisterBankInfo *getRegBankInfo() const override;
141};
142
143} // end namespace llvm
144
145#endif
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...
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.
Holds all the information related to register banks.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Primary interface to the complete machine description for the target machine.
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
const WebAssemblyRegisterInfo & getRegisterInfo() const
bool enableAtomicExpand() const override
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
WebAssemblySubtarget(const Triple &TT, const std::string &CPU, const std::string &FS, const TargetMachine &TM)
This constructor initializes the data members to match that of the specified triple.
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 SubtargetFeatureKV WebAssemblyFeatureKV[WebAssembly::NumSubtargetFeatures]