10b57cec5SDimitry Andric //=- WebAssemblySubtarget.h - Define Subtarget for the WebAssembly -*- C++ -*-// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric /// 90b57cec5SDimitry Andric /// \file 100b57cec5SDimitry Andric /// This file declares the WebAssembly-specific subclass of 110b57cec5SDimitry Andric /// TargetSubtarget. 120b57cec5SDimitry Andric /// 130b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 140b57cec5SDimitry Andric 150b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYSUBTARGET_H 160b57cec5SDimitry Andric #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYSUBTARGET_H 170b57cec5SDimitry Andric 180b57cec5SDimitry Andric #include "WebAssemblyFrameLowering.h" 190b57cec5SDimitry Andric #include "WebAssemblyISelLowering.h" 200b57cec5SDimitry Andric #include "WebAssemblyInstrInfo.h" 210b57cec5SDimitry Andric #include "WebAssemblySelectionDAGInfo.h" 220b57cec5SDimitry Andric #include "llvm/CodeGen/TargetSubtargetInfo.h" 230b57cec5SDimitry Andric #include <string> 240b57cec5SDimitry Andric 250b57cec5SDimitry Andric #define GET_SUBTARGETINFO_ENUM 260b57cec5SDimitry Andric #define GET_SUBTARGETINFO_HEADER 270b57cec5SDimitry Andric #include "WebAssemblyGenSubtargetInfo.inc" 280b57cec5SDimitry Andric 290b57cec5SDimitry Andric namespace llvm { 300b57cec5SDimitry Andric 310b57cec5SDimitry Andric // Defined in WebAssemblyGenSubtargetInfo.inc. 320b57cec5SDimitry Andric extern const SubtargetFeatureKV 330b57cec5SDimitry Andric WebAssemblyFeatureKV[WebAssembly::NumSubtargetFeatures]; 340b57cec5SDimitry Andric 350b57cec5SDimitry Andric class WebAssemblySubtarget final : public WebAssemblyGenSubtargetInfo { 360b57cec5SDimitry Andric enum SIMDEnum { 370b57cec5SDimitry Andric NoSIMD, 380b57cec5SDimitry Andric SIMD128, 390b57cec5SDimitry Andric UnimplementedSIMD128, 400b57cec5SDimitry Andric } SIMDLevel = NoSIMD; 410b57cec5SDimitry Andric 420b57cec5SDimitry Andric bool HasAtomics = false; 430b57cec5SDimitry Andric bool HasNontrappingFPToInt = false; 440b57cec5SDimitry Andric bool HasSignExt = false; 450b57cec5SDimitry Andric bool HasExceptionHandling = false; 460b57cec5SDimitry Andric bool HasBulkMemory = false; 470b57cec5SDimitry Andric bool HasMultivalue = false; 480b57cec5SDimitry Andric bool HasMutableGlobals = false; 490b57cec5SDimitry Andric bool HasTailCall = false; 50*5ffd83dbSDimitry Andric bool HasReferenceTypes = false; 510b57cec5SDimitry Andric 520b57cec5SDimitry Andric /// What processor and OS we're targeting. 530b57cec5SDimitry Andric Triple TargetTriple; 540b57cec5SDimitry Andric 550b57cec5SDimitry Andric WebAssemblyFrameLowering FrameLowering; 560b57cec5SDimitry Andric WebAssemblyInstrInfo InstrInfo; 570b57cec5SDimitry Andric WebAssemblySelectionDAGInfo TSInfo; 580b57cec5SDimitry Andric WebAssemblyTargetLowering TLInfo; 590b57cec5SDimitry Andric 60*5ffd83dbSDimitry Andric WebAssemblySubtarget &initializeSubtargetDependencies(StringRef CPU, 61*5ffd83dbSDimitry Andric StringRef FS); 620b57cec5SDimitry Andric 630b57cec5SDimitry Andric public: 640b57cec5SDimitry Andric /// This constructor initializes the data members to match that 650b57cec5SDimitry Andric /// of the specified triple. 660b57cec5SDimitry Andric WebAssemblySubtarget(const Triple &TT, const std::string &CPU, 670b57cec5SDimitry Andric const std::string &FS, const TargetMachine &TM); 680b57cec5SDimitry Andric 690b57cec5SDimitry Andric const WebAssemblySelectionDAGInfo *getSelectionDAGInfo() const override { 700b57cec5SDimitry Andric return &TSInfo; 710b57cec5SDimitry Andric } 720b57cec5SDimitry Andric const WebAssemblyFrameLowering *getFrameLowering() const override { 730b57cec5SDimitry Andric return &FrameLowering; 740b57cec5SDimitry Andric } 750b57cec5SDimitry Andric const WebAssemblyTargetLowering *getTargetLowering() const override { 760b57cec5SDimitry Andric return &TLInfo; 770b57cec5SDimitry Andric } 780b57cec5SDimitry Andric const WebAssemblyInstrInfo *getInstrInfo() const override { 790b57cec5SDimitry Andric return &InstrInfo; 800b57cec5SDimitry Andric } 810b57cec5SDimitry Andric const WebAssemblyRegisterInfo *getRegisterInfo() const override { 820b57cec5SDimitry Andric return &getInstrInfo()->getRegisterInfo(); 830b57cec5SDimitry Andric } 840b57cec5SDimitry Andric const Triple &getTargetTriple() const { return TargetTriple; } 850b57cec5SDimitry Andric bool enableAtomicExpand() const override; 860b57cec5SDimitry Andric bool enableIndirectBrExpand() const override { return true; } 870b57cec5SDimitry Andric bool enableMachineScheduler() const override; 880b57cec5SDimitry Andric bool useAA() const override; 890b57cec5SDimitry Andric 900b57cec5SDimitry Andric // Predicates used by WebAssemblyInstrInfo.td. 910b57cec5SDimitry Andric bool hasAddr64() const { return TargetTriple.isArch64Bit(); } 920b57cec5SDimitry Andric bool hasSIMD128() const { return SIMDLevel >= SIMD128; } 930b57cec5SDimitry Andric bool hasUnimplementedSIMD128() const { 940b57cec5SDimitry Andric return SIMDLevel >= UnimplementedSIMD128; 950b57cec5SDimitry Andric } 960b57cec5SDimitry Andric bool hasAtomics() const { return HasAtomics; } 970b57cec5SDimitry Andric bool hasNontrappingFPToInt() const { return HasNontrappingFPToInt; } 980b57cec5SDimitry Andric bool hasSignExt() const { return HasSignExt; } 990b57cec5SDimitry Andric bool hasExceptionHandling() const { return HasExceptionHandling; } 1000b57cec5SDimitry Andric bool hasBulkMemory() const { return HasBulkMemory; } 1010b57cec5SDimitry Andric bool hasMultivalue() const { return HasMultivalue; } 1020b57cec5SDimitry Andric bool hasMutableGlobals() const { return HasMutableGlobals; } 1030b57cec5SDimitry Andric bool hasTailCall() const { return HasTailCall; } 104*5ffd83dbSDimitry Andric bool hasReferenceTypes() const { return HasReferenceTypes; } 1050b57cec5SDimitry Andric 1060b57cec5SDimitry Andric /// Parses features string setting specified subtarget options. Definition of 1070b57cec5SDimitry Andric /// function is auto generated by tblgen. 1080b57cec5SDimitry Andric void ParseSubtargetFeatures(StringRef CPU, StringRef FS); 1090b57cec5SDimitry Andric }; 1100b57cec5SDimitry Andric 1110b57cec5SDimitry Andric } // end namespace llvm 1120b57cec5SDimitry Andric 1130b57cec5SDimitry Andric #endif 114