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 |
| 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 | |
| 29 | namespace llvm { |
| 30 | |
| 31 | class WebAssemblySubtarget final : public WebAssemblyGenSubtargetInfo { |
JF Bastien | 03855df | 2015-07-01 23:41:25 +0000 | [diff] [blame] | 32 | bool HasSIMD128; |
Derek Schuff | 18ba192 | 2017-08-30 18:07:45 +0000 | [diff] [blame^] | 33 | bool HasAtomics; |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 34 | |
| 35 | /// String name of used CPU. |
| 36 | std::string CPUString; |
| 37 | |
| 38 | /// What processor and OS we're targeting. |
| 39 | Triple TargetTriple; |
| 40 | |
| 41 | WebAssemblyFrameLowering FrameLowering; |
| 42 | WebAssemblyInstrInfo InstrInfo; |
| 43 | WebAssemblySelectionDAGInfo TSInfo; |
| 44 | WebAssemblyTargetLowering TLInfo; |
| 45 | |
| 46 | /// Initializes using CPUString and the passed in feature string so that we |
| 47 | /// can use initializer lists for subtarget initialization. |
| 48 | WebAssemblySubtarget &initializeSubtargetDependencies(StringRef FS); |
| 49 | |
| 50 | public: |
| 51 | /// This constructor initializes the data members to match that |
| 52 | /// of the specified triple. |
| 53 | WebAssemblySubtarget(const Triple &TT, const std::string &CPU, |
| 54 | const std::string &FS, const TargetMachine &TM); |
| 55 | |
| 56 | const WebAssemblySelectionDAGInfo *getSelectionDAGInfo() const override { |
| 57 | return &TSInfo; |
| 58 | } |
| 59 | const WebAssemblyFrameLowering *getFrameLowering() const override { |
| 60 | return &FrameLowering; |
| 61 | } |
| 62 | const WebAssemblyTargetLowering *getTargetLowering() const override { |
| 63 | return &TLInfo; |
| 64 | } |
JF Bastien | b9073fb | 2015-07-22 21:28:15 +0000 | [diff] [blame] | 65 | const WebAssemblyInstrInfo *getInstrInfo() const override { |
| 66 | return &InstrInfo; |
| 67 | } |
| 68 | const WebAssemblyRegisterInfo *getRegisterInfo() const override { |
| 69 | return &getInstrInfo()->getRegisterInfo(); |
| 70 | } |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 71 | const Triple &getTargetTriple() const { return TargetTriple; } |
| 72 | bool enableMachineScheduler() const override; |
Dan Gohman | 7615e46 | 2015-12-05 19:27:18 +0000 | [diff] [blame] | 73 | bool useAA() const override; |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 74 | |
| 75 | // Predicates used by WebAssemblyInstrInfo.td. |
JF Bastien | 03855df | 2015-07-01 23:41:25 +0000 | [diff] [blame] | 76 | bool hasAddr64() const { return TargetTriple.isArch64Bit(); } |
| 77 | bool hasSIMD128() const { return HasSIMD128; } |
Derek Schuff | 18ba192 | 2017-08-30 18:07:45 +0000 | [diff] [blame^] | 78 | bool hasAtomics() const { return HasAtomics; } |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 79 | |
| 80 | /// Parses features string setting specified subtarget options. Definition of |
| 81 | /// function is auto generated by tblgen. |
| 82 | void ParseSubtargetFeatures(StringRef CPU, StringRef FS); |
| 83 | }; |
| 84 | |
| 85 | } // end namespace llvm |
| 86 | |
| 87 | #endif |