blob: c2ced236dbdf19fa4d0b515da2542f3135553c54 [file] [log] [blame]
Dan Gohman10e730a2015-06-29 23:51:55 +00001//=- 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"
David Blaikieb3bde2e2017-11-17 01:07:10 +000023#include "llvm/CodeGen/TargetSubtargetInfo.h"
Dan Gohman10e730a2015-06-29 23:51:55 +000024#include <string>
25
26#define GET_SUBTARGETINFO_HEADER
27#include "WebAssemblyGenSubtargetInfo.inc"
28
29namespace llvm {
30
31class WebAssemblySubtarget final : public WebAssemblyGenSubtargetInfo {
JF Bastien03855df2015-07-01 23:41:25 +000032 bool HasSIMD128;
Derek Schuff18ba1922017-08-30 18:07:45 +000033 bool HasAtomics;
Dan Gohmancdd48b82017-11-28 01:13:40 +000034 bool HasNontrappingFPToInt;
Dan Gohman5d2b9352018-01-19 17:16:24 +000035 bool HasSignExt;
Heejin Ahn9386bde2018-02-24 00:40:50 +000036 bool HasExceptionHandling;
Dan Gohman10e730a2015-06-29 23:51:55 +000037
38 /// String name of used CPU.
39 std::string CPUString;
40
41 /// What processor and OS we're targeting.
42 Triple TargetTriple;
43
44 WebAssemblyFrameLowering FrameLowering;
45 WebAssemblyInstrInfo InstrInfo;
46 WebAssemblySelectionDAGInfo TSInfo;
47 WebAssemblyTargetLowering TLInfo;
48
49 /// Initializes using CPUString and the passed in feature string so that we
50 /// can use initializer lists for subtarget initialization.
51 WebAssemblySubtarget &initializeSubtargetDependencies(StringRef FS);
52
53public:
54 /// This constructor initializes the data members to match that
55 /// of the specified triple.
56 WebAssemblySubtarget(const Triple &TT, const std::string &CPU,
57 const std::string &FS, const TargetMachine &TM);
58
59 const WebAssemblySelectionDAGInfo *getSelectionDAGInfo() const override {
60 return &TSInfo;
61 }
62 const WebAssemblyFrameLowering *getFrameLowering() const override {
63 return &FrameLowering;
64 }
65 const WebAssemblyTargetLowering *getTargetLowering() const override {
66 return &TLInfo;
67 }
JF Bastienb9073fb2015-07-22 21:28:15 +000068 const WebAssemblyInstrInfo *getInstrInfo() const override {
69 return &InstrInfo;
70 }
71 const WebAssemblyRegisterInfo *getRegisterInfo() const override {
72 return &getInstrInfo()->getRegisterInfo();
73 }
Dan Gohman10e730a2015-06-29 23:51:55 +000074 const Triple &getTargetTriple() const { return TargetTriple; }
75 bool enableMachineScheduler() const override;
Dan Gohman7615e462015-12-05 19:27:18 +000076 bool useAA() const override;
Dan Gohman10e730a2015-06-29 23:51:55 +000077
78 // Predicates used by WebAssemblyInstrInfo.td.
JF Bastien03855df2015-07-01 23:41:25 +000079 bool hasAddr64() const { return TargetTriple.isArch64Bit(); }
80 bool hasSIMD128() const { return HasSIMD128; }
Derek Schuff18ba1922017-08-30 18:07:45 +000081 bool hasAtomics() const { return HasAtomics; }
Dan Gohmancdd48b82017-11-28 01:13:40 +000082 bool hasNontrappingFPToInt() const { return HasNontrappingFPToInt; }
Dan Gohman5d2b9352018-01-19 17:16:24 +000083 bool hasSignExt() const { return HasSignExt; }
Heejin Ahn9386bde2018-02-24 00:40:50 +000084 bool hasExceptionHandling() const { return HasExceptionHandling; }
Dan Gohman10e730a2015-06-29 23:51:55 +000085
86 /// Parses features string setting specified subtarget options. Definition of
87 /// function is auto generated by tblgen.
88 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
89};
90
91} // end namespace llvm
92
93#endif