blob: e6ee2f54c5e2250898667a03b7173fffbfc459de [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;
Dan Gohman10e730a2015-06-29 23:51:55 +000041
42 /// String name of used CPU.
43 std::string CPUString;
44
45 /// What processor and OS we're targeting.
46 Triple TargetTriple;
47
48 WebAssemblyFrameLowering FrameLowering;
49 WebAssemblyInstrInfo InstrInfo;
50 WebAssemblySelectionDAGInfo TSInfo;
51 WebAssemblyTargetLowering TLInfo;
52
53 /// Initializes using CPUString and the passed in feature string so that we
54 /// can use initializer lists for subtarget initialization.
55 WebAssemblySubtarget &initializeSubtargetDependencies(StringRef FS);
56
57public:
58 /// This constructor initializes the data members to match that
59 /// of the specified triple.
60 WebAssemblySubtarget(const Triple &TT, const std::string &CPU,
61 const std::string &FS, const TargetMachine &TM);
62
63 const WebAssemblySelectionDAGInfo *getSelectionDAGInfo() const override {
64 return &TSInfo;
65 }
66 const WebAssemblyFrameLowering *getFrameLowering() const override {
67 return &FrameLowering;
68 }
69 const WebAssemblyTargetLowering *getTargetLowering() const override {
70 return &TLInfo;
71 }
JF Bastienb9073fb2015-07-22 21:28:15 +000072 const WebAssemblyInstrInfo *getInstrInfo() const override {
73 return &InstrInfo;
74 }
75 const WebAssemblyRegisterInfo *getRegisterInfo() const override {
76 return &getInstrInfo()->getRegisterInfo();
77 }
Dan Gohman10e730a2015-06-29 23:51:55 +000078 const Triple &getTargetTriple() const { return TargetTriple; }
79 bool enableMachineScheduler() const override;
Dan Gohman7615e462015-12-05 19:27:18 +000080 bool useAA() const override;
Dan Gohman10e730a2015-06-29 23:51:55 +000081
82 // Predicates used by WebAssemblyInstrInfo.td.
JF Bastien03855df2015-07-01 23:41:25 +000083 bool hasAddr64() const { return TargetTriple.isArch64Bit(); }
Thomas Lively64a39a12019-01-10 22:32:11 +000084 bool hasSIMD128() const { return SIMDLevel >= SIMD128; }
85 bool hasUnimplementedSIMD128() const {
86 return SIMDLevel >= UnimplementedSIMD128;
87 }
Derek Schuff18ba1922017-08-30 18:07:45 +000088 bool hasAtomics() const { return HasAtomics; }
Dan Gohmancdd48b82017-11-28 01:13:40 +000089 bool hasNontrappingFPToInt() const { return HasNontrappingFPToInt; }
Dan Gohman5d2b9352018-01-19 17:16:24 +000090 bool hasSignExt() const { return HasSignExt; }
Heejin Ahn9386bde2018-02-24 00:40:50 +000091 bool hasExceptionHandling() const { return HasExceptionHandling; }
Dan Gohman10e730a2015-06-29 23:51:55 +000092
93 /// Parses features string setting specified subtarget options. Definition of
94 /// function is auto generated by tblgen.
95 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
96};
97
98} // end namespace llvm
99
100#endif