blob: b6f3e6b4a108483cb4af736293b710dfb1e8ab5a [file] [log] [blame]
Dan Gohman10e730a2015-06-29 23:51:55 +00001//=- WebAssemblySubtarget.h - Define Subtarget for the WebAssembly -*- C++ -*-//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Dan Gohman10e730a2015-06-29 23:51:55 +00006//
7//===----------------------------------------------------------------------===//
8///
9/// \file
Adrian Prantl5f8f34e42018-05-01 15:54:18 +000010/// This file declares the WebAssembly-specific subclass of
Dan Gohman10e730a2015-06-29 23:51:55 +000011/// TargetSubtarget.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYSUBTARGET_H
16#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYSUBTARGET_H
17
18#include "WebAssemblyFrameLowering.h"
19#include "WebAssemblyISelLowering.h"
20#include "WebAssemblyInstrInfo.h"
21#include "WebAssemblySelectionDAGInfo.h"
David Blaikieb3bde2e2017-11-17 01:07:10 +000022#include "llvm/CodeGen/TargetSubtargetInfo.h"
Dan Gohman10e730a2015-06-29 23:51:55 +000023#include <string>
24
25#define GET_SUBTARGETINFO_HEADER
26#include "WebAssemblyGenSubtargetInfo.inc"
27
28namespace llvm {
29
30class WebAssemblySubtarget final : public WebAssemblyGenSubtargetInfo {
Thomas Lively64a39a12019-01-10 22:32:11 +000031 enum SIMDEnum {
32 NoSIMD,
33 SIMD128,
34 UnimplementedSIMD128,
35 } SIMDLevel = NoSIMD;
36
37 bool HasAtomics = false;
38 bool HasNontrappingFPToInt = false;
39 bool HasSignExt = false;
40 bool HasExceptionHandling = false;
Thomas Lively88058d42019-01-31 21:02:19 +000041 bool HasBulkMemory = false;
Dan Gohman10e730a2015-06-29 23:51:55 +000042
43 /// String name of used CPU.
44 std::string CPUString;
45
46 /// What processor and OS we're targeting.
47 Triple TargetTriple;
48
49 WebAssemblyFrameLowering FrameLowering;
50 WebAssemblyInstrInfo InstrInfo;
51 WebAssemblySelectionDAGInfo TSInfo;
52 WebAssemblyTargetLowering TLInfo;
53
54 /// Initializes using CPUString and the passed in feature string so that we
55 /// can use initializer lists for subtarget initialization.
56 WebAssemblySubtarget &initializeSubtargetDependencies(StringRef FS);
57
58public:
59 /// This constructor initializes the data members to match that
60 /// of the specified triple.
61 WebAssemblySubtarget(const Triple &TT, const std::string &CPU,
62 const std::string &FS, const TargetMachine &TM);
63
64 const WebAssemblySelectionDAGInfo *getSelectionDAGInfo() const override {
65 return &TSInfo;
66 }
67 const WebAssemblyFrameLowering *getFrameLowering() const override {
68 return &FrameLowering;
69 }
70 const WebAssemblyTargetLowering *getTargetLowering() const override {
71 return &TLInfo;
72 }
JF Bastienb9073fb2015-07-22 21:28:15 +000073 const WebAssemblyInstrInfo *getInstrInfo() const override {
74 return &InstrInfo;
75 }
76 const WebAssemblyRegisterInfo *getRegisterInfo() const override {
77 return &getInstrInfo()->getRegisterInfo();
78 }
Dan Gohman10e730a2015-06-29 23:51:55 +000079 const Triple &getTargetTriple() const { return TargetTriple; }
80 bool enableMachineScheduler() const override;
Dan Gohman7615e462015-12-05 19:27:18 +000081 bool useAA() const override;
Dan Gohman10e730a2015-06-29 23:51:55 +000082
83 // Predicates used by WebAssemblyInstrInfo.td.
JF Bastien03855df2015-07-01 23:41:25 +000084 bool hasAddr64() const { return TargetTriple.isArch64Bit(); }
Thomas Lively64a39a12019-01-10 22:32:11 +000085 bool hasSIMD128() const { return SIMDLevel >= SIMD128; }
86 bool hasUnimplementedSIMD128() const {
87 return SIMDLevel >= UnimplementedSIMD128;
88 }
Derek Schuff18ba1922017-08-30 18:07:45 +000089 bool hasAtomics() const { return HasAtomics; }
Dan Gohmancdd48b82017-11-28 01:13:40 +000090 bool hasNontrappingFPToInt() const { return HasNontrappingFPToInt; }
Dan Gohman5d2b9352018-01-19 17:16:24 +000091 bool hasSignExt() const { return HasSignExt; }
Heejin Ahn9386bde2018-02-24 00:40:50 +000092 bool hasExceptionHandling() const { return HasExceptionHandling; }
Thomas Lively88058d42019-01-31 21:02:19 +000093 bool hasBulkMemory() const { return HasBulkMemory; }
Dan Gohman10e730a2015-06-29 23:51:55 +000094
95 /// Parses features string setting specified subtarget options. Definition of
96 /// function is auto generated by tblgen.
97 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
98};
99
100} // end namespace llvm
101
102#endif