WebAssemblySubtarget.h revision 288943
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
29namespace llvm {
30
31class 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
49public:
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
55  const WebAssemblySelectionDAGInfo *getSelectionDAGInfo() const override {
56    return &TSInfo;
57  }
58  const WebAssemblyFrameLowering *getFrameLowering() const override {
59    return &FrameLowering;
60  }
61  const WebAssemblyTargetLowering *getTargetLowering() const override {
62    return &TLInfo;
63  }
64  const Triple &getTargetTriple() const { return TargetTriple; }
65  bool enableMachineScheduler() const override;
66  bool useAA() const override { return true; }
67
68  // Predicates used by WebAssemblyInstrInfo.td.
69  bool hasAddr64() const { return TargetTriple.isArch64Bit(); }
70  bool hasSIMD128() const { return HasSIMD128; }
71
72  /// Parses features string setting specified subtarget options. Definition of
73  /// function is auto generated by tblgen.
74  void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
75};
76
77} // end namespace llvm
78
79#endif
80