WebAssemblySubtarget.h revision 327952
1117864Speter//=- WebAssemblySubtarget.h - Define Subtarget for the WebAssembly -*- C++ -*-// 2117864Speter// 3117864Speter// The LLVM Compiler Infrastructure 4117864Speter// 5117864Speter// This file is distributed under the University of Illinois Open Source 6117864Speter// License. See LICENSE.TXT for details. 7117864Speter// 8117864Speter//===----------------------------------------------------------------------===// 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/CodeGen/TargetSubtargetInfo.h" 24#include <string> 25 26#define GET_SUBTARGETINFO_HEADER 27#include "WebAssemblyGenSubtargetInfo.inc" 28 29namespace llvm { 30 31class WebAssemblySubtarget final : public WebAssemblyGenSubtargetInfo { 32 bool HasSIMD128; 33 bool HasAtomics; 34 bool HasNontrappingFPToInt; 35 36 /// String name of used CPU. 37 std::string CPUString; 38 39 /// What processor and OS we're targeting. 40 Triple TargetTriple; 41 42 WebAssemblyFrameLowering FrameLowering; 43 WebAssemblyInstrInfo InstrInfo; 44 WebAssemblySelectionDAGInfo TSInfo; 45 WebAssemblyTargetLowering TLInfo; 46 47 /// Initializes using CPUString and the passed in feature string so that we 48 /// can use initializer lists for subtarget initialization. 49 WebAssemblySubtarget &initializeSubtargetDependencies(StringRef FS); 50 51public: 52 /// This constructor initializes the data members to match that 53 /// of the specified triple. 54 WebAssemblySubtarget(const Triple &TT, const std::string &CPU, 55 const std::string &FS, const TargetMachine &TM); 56 57 const WebAssemblySelectionDAGInfo *getSelectionDAGInfo() const override { 58 return &TSInfo; 59 } 60 const WebAssemblyFrameLowering *getFrameLowering() const override { 61 return &FrameLowering; 62 } 63 const WebAssemblyTargetLowering *getTargetLowering() const override { 64 return &TLInfo; 65 } 66 const WebAssemblyInstrInfo *getInstrInfo() const override { 67 return &InstrInfo; 68 } 69 const WebAssemblyRegisterInfo *getRegisterInfo() const override { 70 return &getInstrInfo()->getRegisterInfo(); 71 } 72 const Triple &getTargetTriple() const { return TargetTriple; } 73 bool enableMachineScheduler() const override; 74 bool useAA() const override; 75 76 // Predicates used by WebAssemblyInstrInfo.td. 77 bool hasAddr64() const { return TargetTriple.isArch64Bit(); } 78 bool hasSIMD128() const { return HasSIMD128; } 79 bool hasAtomics() const { return HasAtomics; } 80 bool hasNontrappingFPToInt() const { return HasNontrappingFPToInt; } 81 82 /// Parses features string setting specified subtarget options. Definition of 83 /// function is auto generated by tblgen. 84 void ParseSubtargetFeatures(StringRef CPU, StringRef FS); 85}; 86 87} // end namespace llvm 88 89#endif 90