xref: /freebsd/contrib/llvm-project/llvm/lib/Target/LoongArch/LoongArchSubtarget.h (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
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();
34bdd1243dSDimitry 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;
42bdd1243dSDimitry Andric   bool HasLaGlobalWithPcrel = false;
43bdd1243dSDimitry Andric   bool HasLaGlobalWithAbs = false;
44bdd1243dSDimitry Andric   bool HasLaLocalWithAbs = false;
45*06c3fb27SDimitry Andric   bool HasUAL = false;
4681ad6265SDimitry Andric   unsigned GRLen = 32;
4781ad6265SDimitry Andric   MVT GRLenVT = MVT::i32;
4881ad6265SDimitry Andric   LoongArchABI::ABI TargetABI = LoongArchABI::ABI_Unknown;
4981ad6265SDimitry Andric   LoongArchFrameLowering FrameLowering;
5081ad6265SDimitry Andric   LoongArchInstrInfo InstrInfo;
5181ad6265SDimitry Andric   LoongArchRegisterInfo RegInfo;
5281ad6265SDimitry Andric   LoongArchTargetLowering TLInfo;
53bdd1243dSDimitry Andric   SelectionDAGTargetInfo TSInfo;
5481ad6265SDimitry Andric 
55*06c3fb27SDimitry Andric   Align PrefFunctionAlignment;
56*06c3fb27SDimitry Andric   Align PrefLoopAlignment;
57*06c3fb27SDimitry Andric   unsigned MaxBytesForAlignment;
58*06c3fb27SDimitry Andric 
5981ad6265SDimitry Andric   /// Initializes using the passed in CPU and feature strings so that we can
6081ad6265SDimitry Andric   /// use initializer lists for subtarget initialization.
6181ad6265SDimitry Andric   LoongArchSubtarget &initializeSubtargetDependencies(const Triple &TT,
6281ad6265SDimitry Andric                                                       StringRef CPU,
6381ad6265SDimitry Andric                                                       StringRef TuneCPU,
6481ad6265SDimitry Andric                                                       StringRef FS,
6581ad6265SDimitry Andric                                                       StringRef ABIName);
6681ad6265SDimitry Andric 
67*06c3fb27SDimitry Andric   /// Initialize properties based on the selected processor family.
68*06c3fb27SDimitry Andric   void initializeProperties(StringRef TuneCPU);
69*06c3fb27SDimitry Andric 
7081ad6265SDimitry Andric public:
7181ad6265SDimitry Andric   // Initializes the data members to match that of the specified triple.
7281ad6265SDimitry Andric   LoongArchSubtarget(const Triple &TT, StringRef CPU, StringRef TuneCPU,
7381ad6265SDimitry Andric                      StringRef FS, StringRef ABIName, const TargetMachine &TM);
7481ad6265SDimitry Andric 
7581ad6265SDimitry Andric   // Parses features string setting specified subtarget options. The
7681ad6265SDimitry Andric   // definition of this function is auto-generated by tblgen.
7781ad6265SDimitry Andric   void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
7881ad6265SDimitry Andric 
7981ad6265SDimitry Andric   const LoongArchFrameLowering *getFrameLowering() const override {
8081ad6265SDimitry Andric     return &FrameLowering;
8181ad6265SDimitry Andric   }
8281ad6265SDimitry Andric   const LoongArchInstrInfo *getInstrInfo() const override { return &InstrInfo; }
8381ad6265SDimitry Andric   const LoongArchRegisterInfo *getRegisterInfo() const override {
8481ad6265SDimitry Andric     return &RegInfo;
8581ad6265SDimitry Andric   }
8681ad6265SDimitry Andric   const LoongArchTargetLowering *getTargetLowering() const override {
8781ad6265SDimitry Andric     return &TLInfo;
8881ad6265SDimitry Andric   }
89bdd1243dSDimitry Andric   const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
90bdd1243dSDimitry Andric     return &TSInfo;
91bdd1243dSDimitry Andric   }
9281ad6265SDimitry Andric   bool is64Bit() const { return HasLA64; }
9381ad6265SDimitry Andric   bool hasBasicF() const { return HasBasicF; }
9481ad6265SDimitry Andric   bool hasBasicD() const { return HasBasicD; }
9581ad6265SDimitry Andric   bool hasExtLSX() const { return HasExtLSX; }
9681ad6265SDimitry Andric   bool hasExtLASX() const { return HasExtLASX; }
9781ad6265SDimitry Andric   bool hasExtLVZ() const { return HasExtLVZ; }
9881ad6265SDimitry Andric   bool hasExtLBT() const { return HasExtLBT; }
99bdd1243dSDimitry Andric   bool hasLaGlobalWithPcrel() const { return HasLaGlobalWithPcrel; }
100bdd1243dSDimitry Andric   bool hasLaGlobalWithAbs() const { return HasLaGlobalWithAbs; }
101bdd1243dSDimitry Andric   bool hasLaLocalWithAbs() const { return HasLaLocalWithAbs; }
102*06c3fb27SDimitry Andric   bool hasUAL() const { return HasUAL; }
10381ad6265SDimitry Andric   MVT getGRLenVT() const { return GRLenVT; }
10481ad6265SDimitry Andric   unsigned getGRLen() const { return GRLen; }
10581ad6265SDimitry Andric   LoongArchABI::ABI getTargetABI() const { return TargetABI; }
106*06c3fb27SDimitry Andric   bool isXRaySupported() const override { return is64Bit(); }
107*06c3fb27SDimitry Andric   Align getPrefFunctionAlignment() const { return PrefFunctionAlignment; }
108*06c3fb27SDimitry Andric   Align getPrefLoopAlignment() const { return PrefLoopAlignment; }
109*06c3fb27SDimitry Andric   unsigned getMaxBytesForAlignment() const { return MaxBytesForAlignment; }
11081ad6265SDimitry Andric };
111972a253aSDimitry Andric } // end namespace llvm
11281ad6265SDimitry Andric 
11381ad6265SDimitry Andric #endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHSUBTARGET_H
114