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_ENUM
26 #define GET_SUBTARGETINFO_HEADER
27 #include "WebAssemblyGenSubtargetInfo.inc"
31 // Defined in WebAssemblyGenSubtargetInfo.inc.
32 extern const SubtargetFeatureKV
33 WebAssemblyFeatureKV
[WebAssembly::NumSubtargetFeatures
];
35 class WebAssemblySubtarget final
: public WebAssemblyGenSubtargetInfo
{
41 bool HasAtomics
= false;
42 bool HasNontrappingFPToInt
= false;
43 bool HasSignExt
= false;
44 bool HasExceptionHandling
= false;
45 bool HasBulkMemory
= false;
46 bool HasMultivalue
= false;
47 bool HasMutableGlobals
= false;
48 bool HasTailCall
= false;
49 bool HasReferenceTypes
= false;
51 /// What processor and OS we're targeting.
54 WebAssemblyFrameLowering FrameLowering
;
55 WebAssemblyInstrInfo InstrInfo
;
56 WebAssemblySelectionDAGInfo TSInfo
;
57 WebAssemblyTargetLowering TLInfo
;
59 WebAssemblySubtarget
&initializeSubtargetDependencies(StringRef CPU
,
63 /// This constructor initializes the data members to match that
64 /// of the specified triple.
65 WebAssemblySubtarget(const Triple
&TT
, const std::string
&CPU
,
66 const std::string
&FS
, const TargetMachine
&TM
);
68 const WebAssemblySelectionDAGInfo
*getSelectionDAGInfo() const override
{
71 const WebAssemblyFrameLowering
*getFrameLowering() const override
{
72 return &FrameLowering
;
74 const WebAssemblyTargetLowering
*getTargetLowering() const override
{
77 const WebAssemblyInstrInfo
*getInstrInfo() const override
{
80 const WebAssemblyRegisterInfo
*getRegisterInfo() const override
{
81 return &getInstrInfo()->getRegisterInfo();
83 const Triple
&getTargetTriple() const { return TargetTriple
; }
84 bool enableAtomicExpand() const override
;
85 bool enableIndirectBrExpand() const override
{ return true; }
86 bool enableMachineScheduler() const override
;
87 bool useAA() const override
;
89 // Predicates used by WebAssemblyInstrInfo.td.
90 bool hasAddr64() const { return TargetTriple
.isArch64Bit(); }
91 bool hasSIMD128() const { return SIMDLevel
>= SIMD128
; }
92 bool hasAtomics() const { return HasAtomics
; }
93 bool hasNontrappingFPToInt() const { return HasNontrappingFPToInt
; }
94 bool hasSignExt() const { return HasSignExt
; }
95 bool hasExceptionHandling() const { return HasExceptionHandling
; }
96 bool hasBulkMemory() const { return HasBulkMemory
; }
97 bool hasMultivalue() const { return HasMultivalue
; }
98 bool hasMutableGlobals() const { return HasMutableGlobals
; }
99 bool hasTailCall() const { return HasTailCall
; }
100 bool hasReferenceTypes() const { return HasReferenceTypes
; }
102 /// Parses features string setting specified subtarget options. Definition of
103 /// function is auto generated by tblgen.
104 void ParseSubtargetFeatures(StringRef CPU
, StringRef TuneCPU
, StringRef FS
);
107 } // end namespace llvm