1 //===- LoongArchSubtarget.h - Define Subtarget for the LoongArch -*- C++ -*-==// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file declares the LoongArch specific subclass of TargetSubtargetInfo. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_LIB_TARGET_LOONGARCH_LOONGARCHSUBTARGET_H 14 #define LLVM_LIB_TARGET_LOONGARCH_LOONGARCHSUBTARGET_H 15 16 #include "LoongArchFrameLowering.h" 17 #include "LoongArchISelLowering.h" 18 #include "LoongArchInstrInfo.h" 19 #include "LoongArchRegisterInfo.h" 20 #include "MCTargetDesc/LoongArchBaseInfo.h" 21 #include "llvm/CodeGen/SelectionDAGTargetInfo.h" 22 #include "llvm/CodeGen/TargetSubtargetInfo.h" 23 #include "llvm/IR/DataLayout.h" 24 #include "llvm/Target/TargetMachine.h" 25 26 #define GET_SUBTARGETINFO_HEADER 27 #include "LoongArchGenSubtargetInfo.inc" 28 29 namespace llvm { 30 class StringRef; 31 32 class LoongArchSubtarget : public LoongArchGenSubtargetInfo { 33 virtual void anchor(); 34 bool HasLA64 = false; 35 bool HasBasicF = false; 36 bool HasBasicD = false; 37 bool HasExtLSX = false; 38 bool HasExtLASX = false; 39 bool HasExtLVZ = false; 40 bool HasExtLBT = false; 41 unsigned GRLen = 32; 42 MVT GRLenVT = MVT::i32; 43 LoongArchABI::ABI TargetABI = LoongArchABI::ABI_Unknown; 44 LoongArchFrameLowering FrameLowering; 45 LoongArchInstrInfo InstrInfo; 46 LoongArchRegisterInfo RegInfo; 47 LoongArchTargetLowering TLInfo; 48 49 /// Initializes using the passed in CPU and feature strings so that we can 50 /// use initializer lists for subtarget initialization. 51 LoongArchSubtarget &initializeSubtargetDependencies(const Triple &TT, 52 StringRef CPU, 53 StringRef TuneCPU, 54 StringRef FS, 55 StringRef ABIName); 56 57 public: 58 // Initializes the data members to match that of the specified triple. 59 LoongArchSubtarget(const Triple &TT, StringRef CPU, StringRef TuneCPU, 60 StringRef FS, StringRef ABIName, const TargetMachine &TM); 61 62 // Parses features string setting specified subtarget options. The 63 // definition of this function is auto-generated by tblgen. 64 void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS); 65 66 const LoongArchFrameLowering *getFrameLowering() const override { 67 return &FrameLowering; 68 } 69 const LoongArchInstrInfo *getInstrInfo() const override { return &InstrInfo; } 70 const LoongArchRegisterInfo *getRegisterInfo() const override { 71 return &RegInfo; 72 } 73 const LoongArchTargetLowering *getTargetLowering() const override { 74 return &TLInfo; 75 } 76 bool is64Bit() const { return HasLA64; } 77 bool hasBasicF() const { return HasBasicF; } 78 bool hasBasicD() const { return HasBasicD; } 79 bool hasExtLSX() const { return HasExtLSX; } 80 bool hasExtLASX() const { return HasExtLASX; } 81 bool hasExtLVZ() const { return HasExtLVZ; } 82 bool hasExtLBT() const { return HasExtLBT; } 83 MVT getGRLenVT() const { return GRLenVT; } 84 unsigned getGRLen() const { return GRLen; } 85 LoongArchABI::ABI getTargetABI() const { return TargetABI; } 86 }; 87 } // end namespace llvm 88 89 #endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHSUBTARGET_H 90