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 185f757f3fSDimitry Andric #include "MCTargetDesc/WebAssemblyMCTargetDesc.h" 190b57cec5SDimitry Andric #include "WebAssemblyFrameLowering.h" 200b57cec5SDimitry Andric #include "WebAssemblyISelLowering.h" 210b57cec5SDimitry Andric #include "WebAssemblyInstrInfo.h" 220b57cec5SDimitry Andric #include "WebAssemblySelectionDAGInfo.h" 230b57cec5SDimitry Andric #include "llvm/CodeGen/TargetSubtargetInfo.h" 240b57cec5SDimitry Andric #include <string> 250b57cec5SDimitry Andric 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, 39349cc55cSDimitry Andric RelaxedSIMD, 400b57cec5SDimitry Andric } SIMDLevel = NoSIMD; 410b57cec5SDimitry Andric 420b57cec5SDimitry Andric bool HasAtomics = false; 430b57cec5SDimitry Andric bool HasBulkMemory = false; 44*0fca6ea1SDimitry Andric bool HasExceptionHandling = false; 45*0fca6ea1SDimitry Andric bool HasExtendedConst = false; 46*0fca6ea1SDimitry Andric bool HasHalfPrecision = false; 47*0fca6ea1SDimitry Andric bool HasMultiMemory = false; 480b57cec5SDimitry Andric bool HasMultivalue = false; 490b57cec5SDimitry Andric bool HasMutableGlobals = false; 50*0fca6ea1SDimitry Andric bool HasNontrappingFPToInt = false; 515ffd83dbSDimitry Andric bool HasReferenceTypes = false; 52*0fca6ea1SDimitry Andric bool HasSignExt = false; 53*0fca6ea1SDimitry Andric bool HasTailCall = false; 540b57cec5SDimitry Andric 550b57cec5SDimitry Andric /// What processor and OS we're targeting. 560b57cec5SDimitry Andric Triple TargetTriple; 570b57cec5SDimitry Andric 580b57cec5SDimitry Andric WebAssemblyFrameLowering FrameLowering; 590b57cec5SDimitry Andric WebAssemblyInstrInfo InstrInfo; 600b57cec5SDimitry Andric WebAssemblySelectionDAGInfo TSInfo; 610b57cec5SDimitry Andric WebAssemblyTargetLowering TLInfo; 620b57cec5SDimitry Andric 635ffd83dbSDimitry Andric WebAssemblySubtarget &initializeSubtargetDependencies(StringRef CPU, 645ffd83dbSDimitry Andric StringRef FS); 650b57cec5SDimitry Andric 660b57cec5SDimitry Andric public: 670b57cec5SDimitry Andric /// This constructor initializes the data members to match that 680b57cec5SDimitry Andric /// of the specified triple. 690b57cec5SDimitry Andric WebAssemblySubtarget(const Triple &TT, const std::string &CPU, 700b57cec5SDimitry Andric const std::string &FS, const TargetMachine &TM); 710b57cec5SDimitry Andric getSelectionDAGInfo()720b57cec5SDimitry Andric const WebAssemblySelectionDAGInfo *getSelectionDAGInfo() const override { 730b57cec5SDimitry Andric return &TSInfo; 740b57cec5SDimitry Andric } getFrameLowering()750b57cec5SDimitry Andric const WebAssemblyFrameLowering *getFrameLowering() const override { 760b57cec5SDimitry Andric return &FrameLowering; 770b57cec5SDimitry Andric } getTargetLowering()780b57cec5SDimitry Andric const WebAssemblyTargetLowering *getTargetLowering() const override { 790b57cec5SDimitry Andric return &TLInfo; 800b57cec5SDimitry Andric } getInstrInfo()810b57cec5SDimitry Andric const WebAssemblyInstrInfo *getInstrInfo() const override { 820b57cec5SDimitry Andric return &InstrInfo; 830b57cec5SDimitry Andric } getRegisterInfo()840b57cec5SDimitry Andric const WebAssemblyRegisterInfo *getRegisterInfo() const override { 850b57cec5SDimitry Andric return &getInstrInfo()->getRegisterInfo(); 860b57cec5SDimitry Andric } getTargetTriple()870b57cec5SDimitry Andric const Triple &getTargetTriple() const { return TargetTriple; } 880b57cec5SDimitry Andric bool enableAtomicExpand() const override; enableIndirectBrExpand()890b57cec5SDimitry Andric bool enableIndirectBrExpand() const override { return true; } 900b57cec5SDimitry Andric bool enableMachineScheduler() const override; 910b57cec5SDimitry Andric bool useAA() const override; 920b57cec5SDimitry Andric 930b57cec5SDimitry Andric // Predicates used by WebAssemblyInstrInfo.td. hasAddr64()940b57cec5SDimitry Andric bool hasAddr64() const { return TargetTriple.isArch64Bit(); } hasAtomics()950b57cec5SDimitry Andric bool hasAtomics() const { return HasAtomics; } hasBulkMemory()960b57cec5SDimitry Andric bool hasBulkMemory() const { return HasBulkMemory; } hasExceptionHandling()97*0fca6ea1SDimitry Andric bool hasExceptionHandling() const { return HasExceptionHandling; } hasExtendedConst()98*0fca6ea1SDimitry Andric bool hasExtendedConst() const { return HasExtendedConst; } hasHalfPrecision()99*0fca6ea1SDimitry Andric bool hasHalfPrecision() const { return HasHalfPrecision; } hasMultiMemory()100*0fca6ea1SDimitry Andric bool hasMultiMemory() const { return HasMultiMemory; } hasMultivalue()1010b57cec5SDimitry Andric bool hasMultivalue() const { return HasMultivalue; } hasMutableGlobals()1020b57cec5SDimitry Andric bool hasMutableGlobals() const { return HasMutableGlobals; } hasNontrappingFPToInt()103*0fca6ea1SDimitry Andric bool hasNontrappingFPToInt() const { return HasNontrappingFPToInt; } hasReferenceTypes()1045ffd83dbSDimitry Andric bool hasReferenceTypes() const { return HasReferenceTypes; } hasRelaxedSIMD()105*0fca6ea1SDimitry Andric bool hasRelaxedSIMD() const { return SIMDLevel >= RelaxedSIMD; } hasSignExt()106*0fca6ea1SDimitry Andric bool hasSignExt() const { return HasSignExt; } hasSIMD128()107*0fca6ea1SDimitry Andric bool hasSIMD128() const { return SIMDLevel >= SIMD128; } hasTailCall()108*0fca6ea1SDimitry Andric bool hasTailCall() const { return HasTailCall; } 1090b57cec5SDimitry Andric 1100b57cec5SDimitry Andric /// Parses features string setting specified subtarget options. Definition of 1110b57cec5SDimitry Andric /// function is auto generated by tblgen. 112e8d8bef9SDimitry Andric void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS); 1130b57cec5SDimitry Andric }; 1140b57cec5SDimitry Andric 1150b57cec5SDimitry Andric } // end namespace llvm 1160b57cec5SDimitry Andric 1170b57cec5SDimitry Andric #endif 118