LLVM  14.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 
20 #include "WebAssemblyInstrInfo.h"
23 #include <string>
24 
25 #define GET_SUBTARGETINFO_ENUM
26 #define GET_SUBTARGETINFO_HEADER
27 #include "WebAssemblyGenSubtargetInfo.inc"
28 
29 namespace llvm {
30 
31 // Defined in WebAssemblyGenSubtargetInfo.inc.
32 extern const SubtargetFeatureKV
33  WebAssemblyFeatureKV[WebAssembly::NumSubtargetFeatures];
34 
36  enum SIMDEnum {
37  NoSIMD,
38  SIMD128,
39  RelaxedSIMD,
40  } SIMDLevel = NoSIMD;
41 
42  bool HasAtomics = false;
43  bool HasNontrappingFPToInt = false;
44  bool HasSignExt = false;
45  bool HasExceptionHandling = false;
46  bool HasBulkMemory = false;
47  bool HasMultivalue = false;
48  bool HasMutableGlobals = false;
49  bool HasTailCall = false;
50  bool HasReferenceTypes = false;
51 
52  /// What processor and OS we're targeting.
53  Triple TargetTriple;
54 
55  WebAssemblyFrameLowering FrameLowering;
56  WebAssemblyInstrInfo InstrInfo;
59 
60  WebAssemblySubtarget &initializeSubtargetDependencies(StringRef CPU,
61  StringRef FS);
62 
63 public:
64  /// This constructor initializes the data members to match that
65  /// of the specified triple.
66  WebAssemblySubtarget(const Triple &TT, const std::string &CPU,
67  const std::string &FS, const TargetMachine &TM);
68 
70  return &TSInfo;
71  }
72  const WebAssemblyFrameLowering *getFrameLowering() const override {
73  return &FrameLowering;
74  }
75  const WebAssemblyTargetLowering *getTargetLowering() const override {
76  return &TLInfo;
77  }
78  const WebAssemblyInstrInfo *getInstrInfo() const override {
79  return &InstrInfo;
80  }
81  const WebAssemblyRegisterInfo *getRegisterInfo() const override {
82  return &getInstrInfo()->getRegisterInfo();
83  }
84  const Triple &getTargetTriple() const { return TargetTriple; }
85  bool enableAtomicExpand() const override;
86  bool enableIndirectBrExpand() const override { return true; }
87  bool enableMachineScheduler() const override;
88  bool useAA() const override;
89 
90  // Predicates used by WebAssemblyInstrInfo.td.
91  bool hasAddr64() const { return TargetTriple.isArch64Bit(); }
92  bool hasSIMD128() const { return SIMDLevel >= SIMD128; }
93  bool hasRelaxedSIMD() const { return SIMDLevel >= RelaxedSIMD; }
94  bool hasAtomics() const { return HasAtomics; }
95  bool hasNontrappingFPToInt() const { return HasNontrappingFPToInt; }
96  bool hasSignExt() const { return HasSignExt; }
97  bool hasExceptionHandling() const { return HasExceptionHandling; }
98  bool hasBulkMemory() const { return HasBulkMemory; }
99  bool hasMultivalue() const { return HasMultivalue; }
100  bool hasMutableGlobals() const { return HasMutableGlobals; }
101  bool hasTailCall() const { return HasTailCall; }
102  bool hasReferenceTypes() const { return HasReferenceTypes; }
103 
104  /// Parses features string setting specified subtarget options. Definition of
105  /// function is auto generated by tblgen.
107 };
108 
109 } // end namespace llvm
110 
111 #endif
llvm::WebAssemblySubtarget::getRegisterInfo
const WebAssemblyRegisterInfo * getRegisterInfo() const override
Definition: WebAssemblySubtarget.h:81
llvm::WebAssemblyFeatureKV
const SubtargetFeatureKV WebAssemblyFeatureKV[WebAssembly::NumSubtargetFeatures]
llvm::WebAssemblySubtarget::getTargetTriple
const Triple & getTargetTriple() const
Definition: WebAssemblySubtarget.h:84
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
WebAssemblyISelLowering.h
llvm::WebAssemblySubtarget::hasTailCall
bool hasTailCall() const
Definition: WebAssemblySubtarget.h:101
llvm::WebAssemblyFrameLowering
Definition: WebAssemblyFrameLowering.h:22
llvm::WebAssemblySubtarget::hasExceptionHandling
bool hasExceptionHandling() const
Definition: WebAssemblySubtarget.h:97
llvm::WebAssemblySubtarget::WebAssemblySubtarget
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.
Definition: WebAssemblySubtarget.cpp:40
llvm::WebAssemblySubtarget::getTargetLowering
const WebAssemblyTargetLowering * getTargetLowering() const override
Definition: WebAssemblySubtarget.h:75
llvm::WebAssemblySubtarget::hasMultivalue
bool hasMultivalue() const
Definition: WebAssemblySubtarget.h:99
llvm::WebAssemblySubtarget::hasMutableGlobals
bool hasMutableGlobals() const
Definition: WebAssemblySubtarget.h:100
WebAssemblySelectionDAGInfo.h
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
llvm::WebAssemblySubtarget::hasAddr64
bool hasAddr64() const
Definition: WebAssemblySubtarget.h:91
llvm::WebAssemblyRegisterInfo
Definition: WebAssemblyRegisterInfo.h:28
llvm::Triple::isArch64Bit
bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition: Triple.cpp:1366
llvm::WebAssemblyTargetLowering
Definition: WebAssemblyISelLowering.h:43
llvm::WebAssemblySubtarget::hasRelaxedSIMD
bool hasRelaxedSIMD() const
Definition: WebAssemblySubtarget.h:93
WebAssemblyInstrInfo.h
llvm::X86AS::FS
@ FS
Definition: X86.h:188
llvm::WebAssemblySubtarget::enableMachineScheduler
bool enableMachineScheduler() const override
Definition: WebAssemblySubtarget.cpp:54
llvm::WebAssemblySubtarget::hasReferenceTypes
bool hasReferenceTypes() const
Definition: WebAssemblySubtarget.h:102
WebAssemblyFrameLowering.h
llvm::WebAssemblySubtarget::hasNontrappingFPToInt
bool hasNontrappingFPToInt() const
Definition: WebAssemblySubtarget.h:95
llvm::WebAssemblySubtarget::getInstrInfo
const WebAssemblyInstrInfo * getInstrInfo() const override
Definition: WebAssemblySubtarget.h:78
llvm::TargetMachine
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:79
llvm::WebAssemblySubtarget::ParseSubtargetFeatures
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS)
Parses features string setting specified subtarget options.
llvm::WebAssemblySubtarget::enableAtomicExpand
bool enableAtomicExpand() const override
Definition: WebAssemblySubtarget.cpp:49
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::WebAssemblySubtarget::hasBulkMemory
bool hasBulkMemory() const
Definition: WebAssemblySubtarget.h:98
TargetSubtargetInfo.h
llvm::WebAssemblySubtarget
Definition: WebAssemblySubtarget.h:35
WebAssemblyGenSubtargetInfo
llvm::WebAssemblyInstrInfo
Definition: WebAssemblyInstrInfo.h:38
llvm::WebAssemblySelectionDAGInfo
Definition: WebAssemblySelectionDAGInfo.h:22
llvm::WebAssemblySubtarget::hasSIMD128
bool hasSIMD128() const
Definition: WebAssemblySubtarget.h:92
llvm::WebAssemblySubtarget::getFrameLowering
const WebAssemblyFrameLowering * getFrameLowering() const override
Definition: WebAssemblySubtarget.h:72
llvm::WebAssemblySubtarget::useAA
bool useAA() const override
Definition: WebAssemblySubtarget.cpp:61
llvm::WebAssemblySubtarget::getSelectionDAGInfo
const WebAssemblySelectionDAGInfo * getSelectionDAGInfo() const override
Definition: WebAssemblySubtarget.h:69
TM
const char LLVMTargetMachineRef TM
Definition: PassBuilderBindings.cpp:47
llvm::WebAssemblySubtarget::hasAtomics
bool hasAtomics() const
Definition: WebAssemblySubtarget.h:94
llvm::WebAssemblySubtarget::enableIndirectBrExpand
bool enableIndirectBrExpand() const override
Definition: WebAssemblySubtarget.h:86
llvm::WebAssemblyInstrInfo::getRegisterInfo
const WebAssemblyRegisterInfo & getRegisterInfo() const
Definition: WebAssemblyInstrInfo.h:44
llvm::WebAssemblySubtarget::hasSignExt
bool hasSignExt() const
Definition: WebAssemblySubtarget.h:96