1 //=- WebAssemblySubtarget.h - Define Subtarget for the 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_WEBASSEMBLYSUBTARGET_H
16 #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYSUBTARGET_H
18 #include "WebAssemblyFrameLowering.h"
19 #include "WebAssemblyISelLowering.h"
20 #include "WebAssemblyInstrInfo.h"
21 #include "WebAssemblySelectionDAGInfo.h"
22 #include "llvm/CodeGen/TargetSubtargetInfo.h"
25 #define GET_SUBTARGETINFO_HEADER
26 #include "WebAssemblyGenSubtargetInfo.inc"
30 class WebAssemblySubtarget final
: public WebAssemblyGenSubtargetInfo
{
37 bool HasAtomics
= false;
38 bool HasNontrappingFPToInt
= false;
39 bool HasSignExt
= false;
40 bool HasExceptionHandling
= false;
41 bool HasBulkMemory
= false;
43 /// String name of used CPU.
44 std::string CPUString
;
46 /// What processor and OS we're targeting.
49 WebAssemblyFrameLowering FrameLowering
;
50 WebAssemblyInstrInfo InstrInfo
;
51 WebAssemblySelectionDAGInfo TSInfo
;
52 WebAssemblyTargetLowering TLInfo
;
54 /// Initializes using CPUString and the passed in feature string so that we
55 /// can use initializer lists for subtarget initialization.
56 WebAssemblySubtarget
&initializeSubtargetDependencies(StringRef FS
);
59 /// This constructor initializes the data members to match that
60 /// of the specified triple.
61 WebAssemblySubtarget(const Triple
&TT
, const std::string
&CPU
,
62 const std::string
&FS
, const TargetMachine
&TM
);
64 const WebAssemblySelectionDAGInfo
*getSelectionDAGInfo() const override
{
67 const WebAssemblyFrameLowering
*getFrameLowering() const override
{
68 return &FrameLowering
;
70 const WebAssemblyTargetLowering
*getTargetLowering() const override
{
73 const WebAssemblyInstrInfo
*getInstrInfo() const override
{
76 const WebAssemblyRegisterInfo
*getRegisterInfo() const override
{
77 return &getInstrInfo()->getRegisterInfo();
79 const Triple
&getTargetTriple() const { return TargetTriple
; }
80 bool enableMachineScheduler() const override
;
81 bool useAA() const override
;
83 // Predicates used by WebAssemblyInstrInfo.td.
84 bool hasAddr64() const { return TargetTriple
.isArch64Bit(); }
85 bool hasSIMD128() const { return SIMDLevel
>= SIMD128
; }
86 bool hasUnimplementedSIMD128() const {
87 return SIMDLevel
>= UnimplementedSIMD128
;
89 bool hasAtomics() const { return HasAtomics
; }
90 bool hasNontrappingFPToInt() const { return HasNontrappingFPToInt
; }
91 bool hasSignExt() const { return HasSignExt
; }
92 bool hasExceptionHandling() const { return HasExceptionHandling
; }
93 bool hasBulkMemory() const { return HasBulkMemory
; }
95 /// Parses features string setting specified subtarget options. Definition of
96 /// function is auto generated by tblgen.
97 void ParseSubtargetFeatures(StringRef CPU
, StringRef FS
);
100 } // end namespace llvm