LLVM  9.0.0svn
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  UnimplementedSIMD128,
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 HasMutableGlobals = false;
48 
49  /// String name of used CPU.
50  std::string CPUString;
51 
52  /// What processor and OS we're targeting.
53  Triple TargetTriple;
54 
55  WebAssemblyFrameLowering FrameLowering;
56  WebAssemblyInstrInfo InstrInfo;
59 
60  /// Initializes using CPUString and the passed in feature string so that we
61  /// can use initializer lists for subtarget initialization.
62  WebAssemblySubtarget &initializeSubtargetDependencies(StringRef FS);
63 
64 public:
65  /// This constructor initializes the data members to match that
66  /// of the specified triple.
67  WebAssemblySubtarget(const Triple &TT, const std::string &CPU,
68  const std::string &FS, const TargetMachine &TM);
69 
71  return &TSInfo;
72  }
73  const WebAssemblyFrameLowering *getFrameLowering() const override {
74  return &FrameLowering;
75  }
76  const WebAssemblyTargetLowering *getTargetLowering() const override {
77  return &TLInfo;
78  }
79  const WebAssemblyInstrInfo *getInstrInfo() const override {
80  return &InstrInfo;
81  }
82  const WebAssemblyRegisterInfo *getRegisterInfo() const override {
83  return &getInstrInfo()->getRegisterInfo();
84  }
85  const Triple &getTargetTriple() const { return TargetTriple; }
86  bool enableAtomicExpand() const override;
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 hasUnimplementedSIMD128() const {
94  return SIMDLevel >= UnimplementedSIMD128;
95  }
96  bool hasAtomics() const { return HasAtomics; }
97  bool hasNontrappingFPToInt() const { return HasNontrappingFPToInt; }
98  bool hasSignExt() const { return HasSignExt; }
99  bool hasExceptionHandling() const { return HasExceptionHandling; }
100  bool hasBulkMemory() const { return HasBulkMemory; }
101  bool hasMutableGlobals() const { return HasMutableGlobals; }
102 
103  /// Parses features string setting specified subtarget options. Definition of
104  /// function is auto generated by tblgen.
106 };
107 
108 } // end namespace llvm
109 
110 #endif
This file defines the interfaces that WebAssembly uses to lower LLVM code into a selection DAG...
bool enableMachineScheduler() const override
This class represents lattice values for constants.
Definition: AllocatorList.h:23
const WebAssemblyRegisterInfo & getRegisterInfo() const
const WebAssemblyFrameLowering * getFrameLowering() const override
const SubtargetFeatureKV WebAssemblyFeatureKV[WebAssembly::NumSubtargetFeatures]
void ParseSubtargetFeatures(StringRef CPU, StringRef FS)
Parses features string setting specified subtarget options.
const Triple & getTargetTriple() const
const WebAssemblySelectionDAGInfo * getSelectionDAGInfo() const override
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
const WebAssemblyTargetLowering * getTargetLowering() const override
This file contains the WebAssembly implementation of the TargetInstrInfo class.
This file defines the WebAssembly subclass for SelectionDAGTargetInfo.
const WebAssemblyRegisterInfo * getRegisterInfo() const override
This class implements WebAssembly-specific bits of TargetFrameLowering class.
bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition: Triple.cpp:1288
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.
bool enableAtomicExpand() const override
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:65
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
const WebAssemblyInstrInfo * getInstrInfo() const override