17330f729Sjoerg //=- WebAssemblySubtarget.h - Define Subtarget for the WebAssembly -*- C++ -*-// 27330f729Sjoerg // 37330f729Sjoerg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 47330f729Sjoerg // See https://llvm.org/LICENSE.txt for license information. 57330f729Sjoerg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 67330f729Sjoerg // 77330f729Sjoerg //===----------------------------------------------------------------------===// 87330f729Sjoerg /// 97330f729Sjoerg /// \file 107330f729Sjoerg /// This file declares the WebAssembly-specific subclass of 117330f729Sjoerg /// TargetSubtarget. 127330f729Sjoerg /// 137330f729Sjoerg //===----------------------------------------------------------------------===// 147330f729Sjoerg 157330f729Sjoerg #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYSUBTARGET_H 167330f729Sjoerg #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYSUBTARGET_H 177330f729Sjoerg 187330f729Sjoerg #include "WebAssemblyFrameLowering.h" 197330f729Sjoerg #include "WebAssemblyISelLowering.h" 207330f729Sjoerg #include "WebAssemblyInstrInfo.h" 217330f729Sjoerg #include "WebAssemblySelectionDAGInfo.h" 227330f729Sjoerg #include "llvm/CodeGen/TargetSubtargetInfo.h" 237330f729Sjoerg #include <string> 247330f729Sjoerg 257330f729Sjoerg #define GET_SUBTARGETINFO_ENUM 267330f729Sjoerg #define GET_SUBTARGETINFO_HEADER 277330f729Sjoerg #include "WebAssemblyGenSubtargetInfo.inc" 287330f729Sjoerg 297330f729Sjoerg namespace llvm { 307330f729Sjoerg 317330f729Sjoerg // Defined in WebAssemblyGenSubtargetInfo.inc. 327330f729Sjoerg extern const SubtargetFeatureKV 337330f729Sjoerg WebAssemblyFeatureKV[WebAssembly::NumSubtargetFeatures]; 347330f729Sjoerg 357330f729Sjoerg class WebAssemblySubtarget final : public WebAssemblyGenSubtargetInfo { 367330f729Sjoerg enum SIMDEnum { 377330f729Sjoerg NoSIMD, 387330f729Sjoerg SIMD128, 397330f729Sjoerg } SIMDLevel = NoSIMD; 407330f729Sjoerg 417330f729Sjoerg bool HasAtomics = false; 427330f729Sjoerg bool HasNontrappingFPToInt = false; 437330f729Sjoerg bool HasSignExt = false; 447330f729Sjoerg bool HasExceptionHandling = false; 457330f729Sjoerg bool HasBulkMemory = false; 467330f729Sjoerg bool HasMultivalue = false; 477330f729Sjoerg bool HasMutableGlobals = false; 487330f729Sjoerg bool HasTailCall = false; 49*82d56013Sjoerg bool HasReferenceTypes = false; 507330f729Sjoerg 517330f729Sjoerg /// What processor and OS we're targeting. 527330f729Sjoerg Triple TargetTriple; 537330f729Sjoerg 547330f729Sjoerg WebAssemblyFrameLowering FrameLowering; 557330f729Sjoerg WebAssemblyInstrInfo InstrInfo; 567330f729Sjoerg WebAssemblySelectionDAGInfo TSInfo; 577330f729Sjoerg WebAssemblyTargetLowering TLInfo; 587330f729Sjoerg 59*82d56013Sjoerg WebAssemblySubtarget &initializeSubtargetDependencies(StringRef CPU, 60*82d56013Sjoerg StringRef FS); 617330f729Sjoerg 627330f729Sjoerg public: 637330f729Sjoerg /// This constructor initializes the data members to match that 647330f729Sjoerg /// of the specified triple. 657330f729Sjoerg WebAssemblySubtarget(const Triple &TT, const std::string &CPU, 667330f729Sjoerg const std::string &FS, const TargetMachine &TM); 677330f729Sjoerg getSelectionDAGInfo()687330f729Sjoerg const WebAssemblySelectionDAGInfo *getSelectionDAGInfo() const override { 697330f729Sjoerg return &TSInfo; 707330f729Sjoerg } getFrameLowering()717330f729Sjoerg const WebAssemblyFrameLowering *getFrameLowering() const override { 727330f729Sjoerg return &FrameLowering; 737330f729Sjoerg } getTargetLowering()747330f729Sjoerg const WebAssemblyTargetLowering *getTargetLowering() const override { 757330f729Sjoerg return &TLInfo; 767330f729Sjoerg } getInstrInfo()777330f729Sjoerg const WebAssemblyInstrInfo *getInstrInfo() const override { 787330f729Sjoerg return &InstrInfo; 797330f729Sjoerg } getRegisterInfo()807330f729Sjoerg const WebAssemblyRegisterInfo *getRegisterInfo() const override { 817330f729Sjoerg return &getInstrInfo()->getRegisterInfo(); 827330f729Sjoerg } getTargetTriple()837330f729Sjoerg const Triple &getTargetTriple() const { return TargetTriple; } 847330f729Sjoerg bool enableAtomicExpand() const override; enableIndirectBrExpand()857330f729Sjoerg bool enableIndirectBrExpand() const override { return true; } 867330f729Sjoerg bool enableMachineScheduler() const override; 877330f729Sjoerg bool useAA() const override; 887330f729Sjoerg 897330f729Sjoerg // Predicates used by WebAssemblyInstrInfo.td. hasAddr64()907330f729Sjoerg bool hasAddr64() const { return TargetTriple.isArch64Bit(); } hasSIMD128()917330f729Sjoerg bool hasSIMD128() const { return SIMDLevel >= SIMD128; } hasAtomics()927330f729Sjoerg bool hasAtomics() const { return HasAtomics; } hasNontrappingFPToInt()937330f729Sjoerg bool hasNontrappingFPToInt() const { return HasNontrappingFPToInt; } hasSignExt()947330f729Sjoerg bool hasSignExt() const { return HasSignExt; } hasExceptionHandling()957330f729Sjoerg bool hasExceptionHandling() const { return HasExceptionHandling; } hasBulkMemory()967330f729Sjoerg bool hasBulkMemory() const { return HasBulkMemory; } hasMultivalue()977330f729Sjoerg bool hasMultivalue() const { return HasMultivalue; } hasMutableGlobals()987330f729Sjoerg bool hasMutableGlobals() const { return HasMutableGlobals; } hasTailCall()997330f729Sjoerg bool hasTailCall() const { return HasTailCall; } hasReferenceTypes()100*82d56013Sjoerg bool hasReferenceTypes() const { return HasReferenceTypes; } 1017330f729Sjoerg 1027330f729Sjoerg /// Parses features string setting specified subtarget options. Definition of 1037330f729Sjoerg /// function is auto generated by tblgen. 104*82d56013Sjoerg void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS); 1057330f729Sjoerg }; 1067330f729Sjoerg 1077330f729Sjoerg } // end namespace llvm 1087330f729Sjoerg 1097330f729Sjoerg #endif 110