1 //=- WebAssemblySubtarget.h - Define Subtarget for the WebAssembly -*- C++ -*-//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// \brief This file declares the WebAssembly-specific subclass of
12 /// TargetSubtarget.
13 ///
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYSUBTARGET_H
17 #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYSUBTARGET_H
18 
19 #include "WebAssemblyFrameLowering.h"
20 #include "WebAssemblyISelLowering.h"
21 #include "WebAssemblyInstrInfo.h"
22 #include "WebAssemblySelectionDAGInfo.h"
23 #include "llvm/Target/TargetSubtargetInfo.h"
24 #include <string>
25 
26 #define GET_SUBTARGETINFO_HEADER
27 #include "WebAssemblyGenSubtargetInfo.inc"
28 
29 namespace llvm {
30 
31 class WebAssemblySubtarget final : public WebAssemblyGenSubtargetInfo {
32   bool HasSIMD128;
33 
34   /// String name of used CPU.
35   std::string CPUString;
36 
37   /// What processor and OS we're targeting.
38   Triple TargetTriple;
39 
40   WebAssemblyFrameLowering FrameLowering;
41   WebAssemblyInstrInfo InstrInfo;
42   WebAssemblySelectionDAGInfo TSInfo;
43   WebAssemblyTargetLowering TLInfo;
44 
45   /// Initializes using CPUString and the passed in feature string so that we
46   /// can use initializer lists for subtarget initialization.
47   WebAssemblySubtarget &initializeSubtargetDependencies(StringRef FS);
48 
49 public:
50   /// This constructor initializes the data members to match that
51   /// of the specified triple.
52   WebAssemblySubtarget(const Triple &TT, const std::string &CPU,
53                        const std::string &FS, const TargetMachine &TM);
54 
getSelectionDAGInfo()55   const WebAssemblySelectionDAGInfo *getSelectionDAGInfo() const override {
56     return &TSInfo;
57   }
getFrameLowering()58   const WebAssemblyFrameLowering *getFrameLowering() const override {
59     return &FrameLowering;
60   }
getTargetLowering()61   const WebAssemblyTargetLowering *getTargetLowering() const override {
62     return &TLInfo;
63   }
getInstrInfo()64   const WebAssemblyInstrInfo *getInstrInfo() const override {
65     return &InstrInfo;
66   }
getRegisterInfo()67   const WebAssemblyRegisterInfo *getRegisterInfo() const override {
68     return &getInstrInfo()->getRegisterInfo();
69   }
getTargetTriple()70   const Triple &getTargetTriple() const { return TargetTriple; }
71   bool enableMachineScheduler() const override;
72   bool useAA() const override;
73 
74   // Predicates used by WebAssemblyInstrInfo.td.
hasAddr64()75   bool hasAddr64() const { return TargetTriple.isArch64Bit(); }
hasSIMD128()76   bool hasSIMD128() const { return HasSIMD128; }
77 
78   /// Parses features string setting specified subtarget options. Definition of
79   /// function is auto generated by tblgen.
80   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
81 };
82 
83 } // end namespace llvm
84 
85 #endif
86