WebAssemblySubtarget.h revision 355940
1178151Srpaulo//=- WebAssemblySubtarget.h - Define Subtarget for the WebAssembly -*- C++ -*-// 2178151Srpaulo// 3178151Srpaulo// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4178151Srpaulo// See https://llvm.org/LICENSE.txt for license information. 5178151Srpaulo// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6178151Srpaulo// 7178151Srpaulo//===----------------------------------------------------------------------===// 8178151Srpaulo/// 9178151Srpaulo/// \file 10178151Srpaulo/// This file declares the WebAssembly-specific subclass of 11178151Srpaulo/// TargetSubtarget. 12178151Srpaulo/// 13178151Srpaulo//===----------------------------------------------------------------------===// 14178151Srpaulo 15178151Srpaulo#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYSUBTARGET_H 16178151Srpaulo#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYSUBTARGET_H 17178151Srpaulo 18178151Srpaulo#include "WebAssemblyFrameLowering.h" 19178151Srpaulo#include "WebAssemblyISelLowering.h" 20178151Srpaulo#include "WebAssemblyInstrInfo.h" 21178151Srpaulo#include "WebAssemblySelectionDAGInfo.h" 22178151Srpaulo#include "llvm/CodeGen/TargetSubtargetInfo.h" 23178151Srpaulo#include <string> 24178151Srpaulo 25178151Srpaulo#define GET_SUBTARGETINFO_ENUM 26178151Srpaulo#define GET_SUBTARGETINFO_HEADER 27178151Srpaulo#include "WebAssemblyGenSubtargetInfo.inc" 28178151Srpaulo 29178151Srpaulonamespace llvm { 30178151Srpaulo 31178151Srpaulo// Defined in WebAssemblyGenSubtargetInfo.inc. 32178151Srpauloextern const SubtargetFeatureKV 33178151Srpaulo WebAssemblyFeatureKV[WebAssembly::NumSubtargetFeatures]; 34178151Srpaulo 35178151Srpauloclass WebAssemblySubtarget final : public WebAssemblyGenSubtargetInfo { 36178151Srpaulo enum SIMDEnum { 37178151Srpaulo NoSIMD, 38178151Srpaulo SIMD128, 39178151Srpaulo UnimplementedSIMD128, 40178151Srpaulo } SIMDLevel = NoSIMD; 41178151Srpaulo 42178151Srpaulo bool HasAtomics = false; 43178151Srpaulo bool HasNontrappingFPToInt = false; 44178151Srpaulo bool HasSignExt = false; 45178151Srpaulo bool HasExceptionHandling = false; 46178151Srpaulo bool HasBulkMemory = false; 47178151Srpaulo bool HasMultivalue = false; 48178151Srpaulo bool HasMutableGlobals = false; 49178151Srpaulo bool HasTailCall = false; 50178151Srpaulo 51178151Srpaulo /// String name of used CPU. 52178151Srpaulo std::string CPUString; 53178151Srpaulo 54178151Srpaulo /// What processor and OS we're targeting. 55178151Srpaulo Triple TargetTriple; 56178151Srpaulo 57178151Srpaulo WebAssemblyFrameLowering FrameLowering; 58178151Srpaulo WebAssemblyInstrInfo InstrInfo; 59178151Srpaulo WebAssemblySelectionDAGInfo TSInfo; 60178151Srpaulo WebAssemblyTargetLowering TLInfo; 61178151Srpaulo 62178151Srpaulo /// Initializes using CPUString and the passed in feature string so that we 63178151Srpaulo /// can use initializer lists for subtarget initialization. 64178151Srpaulo WebAssemblySubtarget &initializeSubtargetDependencies(StringRef FS); 65178151Srpaulo 66178151Srpaulopublic: 67178151Srpaulo /// This constructor initializes the data members to match that 68178151Srpaulo /// of the specified triple. 69178151Srpaulo WebAssemblySubtarget(const Triple &TT, const std::string &CPU, 70178151Srpaulo const std::string &FS, const TargetMachine &TM); 71178151Srpaulo 72178151Srpaulo const WebAssemblySelectionDAGInfo *getSelectionDAGInfo() const override { 73178151Srpaulo return &TSInfo; 74178151Srpaulo } 75178151Srpaulo const WebAssemblyFrameLowering *getFrameLowering() const override { 76178151Srpaulo return &FrameLowering; 77178151Srpaulo } 78178151Srpaulo const WebAssemblyTargetLowering *getTargetLowering() const override { 79178151Srpaulo return &TLInfo; 80178151Srpaulo } 81178151Srpaulo const WebAssemblyInstrInfo *getInstrInfo() const override { 82178151Srpaulo return &InstrInfo; 83178151Srpaulo } 84178151Srpaulo const WebAssemblyRegisterInfo *getRegisterInfo() const override { 85178151Srpaulo return &getInstrInfo()->getRegisterInfo(); 86178151Srpaulo } 87178151Srpaulo const Triple &getTargetTriple() const { return TargetTriple; } 88178151Srpaulo bool enableAtomicExpand() const override; 89178151Srpaulo bool enableIndirectBrExpand() const override { return true; } 90178151Srpaulo bool enableMachineScheduler() const override; 91178151Srpaulo bool useAA() const override; 92178151Srpaulo 93178151Srpaulo // Predicates used by WebAssemblyInstrInfo.td. 94178151Srpaulo bool hasAddr64() const { return TargetTriple.isArch64Bit(); } 95178151Srpaulo bool hasSIMD128() const { return SIMDLevel >= SIMD128; } 96178151Srpaulo bool hasUnimplementedSIMD128() const { 97178151Srpaulo return SIMDLevel >= UnimplementedSIMD128; 98178151Srpaulo } 99178151Srpaulo bool hasAtomics() const { return HasAtomics; } 100178151Srpaulo bool hasNontrappingFPToInt() const { return HasNontrappingFPToInt; } 101178151Srpaulo bool hasSignExt() const { return HasSignExt; } 102178151Srpaulo bool hasExceptionHandling() const { return HasExceptionHandling; } 103178151Srpaulo bool hasBulkMemory() const { return HasBulkMemory; } 104178151Srpaulo bool hasMultivalue() const { return HasMultivalue; } 105178151Srpaulo bool hasMutableGlobals() const { return HasMutableGlobals; } 106178151Srpaulo bool hasTailCall() const { return HasTailCall; } 107178151Srpaulo 108178151Srpaulo /// Parses features string setting specified subtarget options. Definition of 109178151Srpaulo /// function is auto generated by tblgen. 110178151Srpaulo void ParseSubtargetFeatures(StringRef CPU, StringRef FS); 111178151Srpaulo}; 112178151Srpaulo 113178151Srpaulo} // end namespace llvm 114178151Srpaulo 115178151Srpaulo#endif 116178151Srpaulo