Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 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 |
Adrian Prantl | 5f8f34e4 | 2018-05-01 15:54:18 +0000 | [diff] [blame] | 11 | /// This file declares the WebAssembly-specific subclass of |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 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 Blaikie | b3bde2e | 2017-11-17 01:07:10 +0000 | [diff] [blame] | 23 | #include "llvm/CodeGen/TargetSubtargetInfo.h" |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 24 | #include <string> |
| 25 | |
| 26 | #define GET_SUBTARGETINFO_HEADER |
| 27 | #include "WebAssemblyGenSubtargetInfo.inc" |
| 28 | |
| 29 | namespace llvm { |
| 30 | |
| 31 | class WebAssemblySubtarget final : public WebAssemblyGenSubtargetInfo { |
Thomas Lively | 64a39a1 | 2019-01-10 22:32:11 +0000 | [diff] [blame^] | 32 | enum SIMDEnum { |
| 33 | NoSIMD, |
| 34 | SIMD128, |
| 35 | UnimplementedSIMD128, |
| 36 | } SIMDLevel = NoSIMD; |
| 37 | |
| 38 | bool HasAtomics = false; |
| 39 | bool HasNontrappingFPToInt = false; |
| 40 | bool HasSignExt = false; |
| 41 | bool HasExceptionHandling = false; |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 42 | |
| 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 | |
| 58 | public: |
| 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 Bastien | b9073fb | 2015-07-22 21:28:15 +0000 | [diff] [blame] | 73 | const WebAssemblyInstrInfo *getInstrInfo() const override { |
| 74 | return &InstrInfo; |
| 75 | } |
| 76 | const WebAssemblyRegisterInfo *getRegisterInfo() const override { |
| 77 | return &getInstrInfo()->getRegisterInfo(); |
| 78 | } |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 79 | const Triple &getTargetTriple() const { return TargetTriple; } |
| 80 | bool enableMachineScheduler() const override; |
Dan Gohman | 7615e46 | 2015-12-05 19:27:18 +0000 | [diff] [blame] | 81 | bool useAA() const override; |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 82 | |
| 83 | // Predicates used by WebAssemblyInstrInfo.td. |
JF Bastien | 03855df | 2015-07-01 23:41:25 +0000 | [diff] [blame] | 84 | bool hasAddr64() const { return TargetTriple.isArch64Bit(); } |
Thomas Lively | 64a39a1 | 2019-01-10 22:32:11 +0000 | [diff] [blame^] | 85 | bool hasSIMD128() const { return SIMDLevel >= SIMD128; } |
| 86 | bool hasUnimplementedSIMD128() const { |
| 87 | return SIMDLevel >= UnimplementedSIMD128; |
| 88 | } |
Derek Schuff | 18ba192 | 2017-08-30 18:07:45 +0000 | [diff] [blame] | 89 | bool hasAtomics() const { return HasAtomics; } |
Dan Gohman | cdd48b8 | 2017-11-28 01:13:40 +0000 | [diff] [blame] | 90 | bool hasNontrappingFPToInt() const { return HasNontrappingFPToInt; } |
Dan Gohman | 5d2b935 | 2018-01-19 17:16:24 +0000 | [diff] [blame] | 91 | bool hasSignExt() const { return HasSignExt; } |
Heejin Ahn | 9386bde | 2018-02-24 00:40:50 +0000 | [diff] [blame] | 92 | bool hasExceptionHandling() const { return HasExceptionHandling; } |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 93 | |
| 94 | /// Parses features string setting specified subtarget options. Definition of |
| 95 | /// function is auto generated by tblgen. |
| 96 | void ParseSubtargetFeatures(StringRef CPU, StringRef FS); |
| 97 | }; |
| 98 | |
| 99 | } // end namespace llvm |
| 100 | |
| 101 | #endif |