181ad6265SDimitry Andric //===- LoongArchSubtarget.h - Define Subtarget for the LoongArch -*- C++ -*-==// 281ad6265SDimitry Andric // 381ad6265SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 481ad6265SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 581ad6265SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 681ad6265SDimitry Andric // 781ad6265SDimitry Andric //===----------------------------------------------------------------------===// 881ad6265SDimitry Andric // 981ad6265SDimitry Andric // This file declares the LoongArch specific subclass of TargetSubtargetInfo. 1081ad6265SDimitry Andric // 1181ad6265SDimitry Andric //===----------------------------------------------------------------------===// 1281ad6265SDimitry Andric 1381ad6265SDimitry Andric #ifndef LLVM_LIB_TARGET_LOONGARCH_LOONGARCHSUBTARGET_H 1481ad6265SDimitry Andric #define LLVM_LIB_TARGET_LOONGARCH_LOONGARCHSUBTARGET_H 1581ad6265SDimitry Andric 1681ad6265SDimitry Andric #include "LoongArchFrameLowering.h" 1781ad6265SDimitry Andric #include "LoongArchISelLowering.h" 1881ad6265SDimitry Andric #include "LoongArchInstrInfo.h" 1981ad6265SDimitry Andric #include "LoongArchRegisterInfo.h" 2081ad6265SDimitry Andric #include "MCTargetDesc/LoongArchBaseInfo.h" 2181ad6265SDimitry Andric #include "llvm/CodeGen/SelectionDAGTargetInfo.h" 2281ad6265SDimitry Andric #include "llvm/CodeGen/TargetSubtargetInfo.h" 2381ad6265SDimitry Andric #include "llvm/IR/DataLayout.h" 2481ad6265SDimitry Andric #include "llvm/Target/TargetMachine.h" 2581ad6265SDimitry Andric 2681ad6265SDimitry Andric #define GET_SUBTARGETINFO_HEADER 2781ad6265SDimitry Andric #include "LoongArchGenSubtargetInfo.inc" 2881ad6265SDimitry Andric 2981ad6265SDimitry Andric namespace llvm { 3081ad6265SDimitry Andric class StringRef; 3181ad6265SDimitry Andric 3281ad6265SDimitry Andric class LoongArchSubtarget : public LoongArchGenSubtargetInfo { 3381ad6265SDimitry Andric virtual void anchor(); 34*bdd1243dSDimitry Andric bool HasLA32 = false; 3581ad6265SDimitry Andric bool HasLA64 = false; 3681ad6265SDimitry Andric bool HasBasicF = false; 3781ad6265SDimitry Andric bool HasBasicD = false; 3881ad6265SDimitry Andric bool HasExtLSX = false; 3981ad6265SDimitry Andric bool HasExtLASX = false; 4081ad6265SDimitry Andric bool HasExtLVZ = false; 4181ad6265SDimitry Andric bool HasExtLBT = false; 42*bdd1243dSDimitry Andric bool HasLaGlobalWithPcrel = false; 43*bdd1243dSDimitry Andric bool HasLaGlobalWithAbs = false; 44*bdd1243dSDimitry Andric bool HasLaLocalWithAbs = false; 4581ad6265SDimitry Andric unsigned GRLen = 32; 4681ad6265SDimitry Andric MVT GRLenVT = MVT::i32; 4781ad6265SDimitry Andric LoongArchABI::ABI TargetABI = LoongArchABI::ABI_Unknown; 4881ad6265SDimitry Andric LoongArchFrameLowering FrameLowering; 4981ad6265SDimitry Andric LoongArchInstrInfo InstrInfo; 5081ad6265SDimitry Andric LoongArchRegisterInfo RegInfo; 5181ad6265SDimitry Andric LoongArchTargetLowering TLInfo; 52*bdd1243dSDimitry Andric SelectionDAGTargetInfo TSInfo; 5381ad6265SDimitry Andric 5481ad6265SDimitry Andric /// Initializes using the passed in CPU and feature strings so that we can 5581ad6265SDimitry Andric /// use initializer lists for subtarget initialization. 5681ad6265SDimitry Andric LoongArchSubtarget &initializeSubtargetDependencies(const Triple &TT, 5781ad6265SDimitry Andric StringRef CPU, 5881ad6265SDimitry Andric StringRef TuneCPU, 5981ad6265SDimitry Andric StringRef FS, 6081ad6265SDimitry Andric StringRef ABIName); 6181ad6265SDimitry Andric 6281ad6265SDimitry Andric public: 6381ad6265SDimitry Andric // Initializes the data members to match that of the specified triple. 6481ad6265SDimitry Andric LoongArchSubtarget(const Triple &TT, StringRef CPU, StringRef TuneCPU, 6581ad6265SDimitry Andric StringRef FS, StringRef ABIName, const TargetMachine &TM); 6681ad6265SDimitry Andric 6781ad6265SDimitry Andric // Parses features string setting specified subtarget options. The 6881ad6265SDimitry Andric // definition of this function is auto-generated by tblgen. 6981ad6265SDimitry Andric void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS); 7081ad6265SDimitry Andric 7181ad6265SDimitry Andric const LoongArchFrameLowering *getFrameLowering() const override { 7281ad6265SDimitry Andric return &FrameLowering; 7381ad6265SDimitry Andric } 7481ad6265SDimitry Andric const LoongArchInstrInfo *getInstrInfo() const override { return &InstrInfo; } 7581ad6265SDimitry Andric const LoongArchRegisterInfo *getRegisterInfo() const override { 7681ad6265SDimitry Andric return &RegInfo; 7781ad6265SDimitry Andric } 7881ad6265SDimitry Andric const LoongArchTargetLowering *getTargetLowering() const override { 7981ad6265SDimitry Andric return &TLInfo; 8081ad6265SDimitry Andric } 81*bdd1243dSDimitry Andric const SelectionDAGTargetInfo *getSelectionDAGInfo() const override { 82*bdd1243dSDimitry Andric return &TSInfo; 83*bdd1243dSDimitry Andric } 8481ad6265SDimitry Andric bool is64Bit() const { return HasLA64; } 8581ad6265SDimitry Andric bool hasBasicF() const { return HasBasicF; } 8681ad6265SDimitry Andric bool hasBasicD() const { return HasBasicD; } 8781ad6265SDimitry Andric bool hasExtLSX() const { return HasExtLSX; } 8881ad6265SDimitry Andric bool hasExtLASX() const { return HasExtLASX; } 8981ad6265SDimitry Andric bool hasExtLVZ() const { return HasExtLVZ; } 9081ad6265SDimitry Andric bool hasExtLBT() const { return HasExtLBT; } 91*bdd1243dSDimitry Andric bool hasLaGlobalWithPcrel() const { return HasLaGlobalWithPcrel; } 92*bdd1243dSDimitry Andric bool hasLaGlobalWithAbs() const { return HasLaGlobalWithAbs; } 93*bdd1243dSDimitry Andric bool hasLaLocalWithAbs() const { return HasLaLocalWithAbs; } 9481ad6265SDimitry Andric MVT getGRLenVT() const { return GRLenVT; } 9581ad6265SDimitry Andric unsigned getGRLen() const { return GRLen; } 9681ad6265SDimitry Andric LoongArchABI::ABI getTargetABI() const { return TargetABI; } 9781ad6265SDimitry Andric }; 98972a253aSDimitry Andric } // end namespace llvm 9981ad6265SDimitry Andric 10081ad6265SDimitry Andric #endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHSUBTARGET_H 101