1 //===- LoongArchSubtarget.h - Define Subtarget for the LoongArch -*- C++ -*-==//
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
7 //===----------------------------------------------------------------------===//
9 // This file declares the LoongArch specific subclass of TargetSubtargetInfo.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_TARGET_LOONGARCH_LOONGARCHSUBTARGET_H
14 #define LLVM_LIB_TARGET_LOONGARCH_LOONGARCHSUBTARGET_H
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"
26 #define GET_SUBTARGETINFO_HEADER
27 #include "LoongArchGenSubtargetInfo.inc"
32 class LoongArchSubtarget : public LoongArchGenSubtargetInfo {
33 virtual void anchor();
36 bool HasBasicF = false;
37 bool HasBasicD = false;
38 bool HasExtLSX = false;
39 bool HasExtLASX = false;
40 bool HasExtLVZ = false;
41 bool HasExtLBT = false;
42 bool HasLaGlobalWithPcrel = false;
43 bool HasLaGlobalWithAbs = false;
44 bool HasLaLocalWithAbs = false;
47 MVT GRLenVT = MVT::i32;
48 LoongArchABI::ABI TargetABI = LoongArchABI::ABI_Unknown;
49 LoongArchFrameLowering FrameLowering;
50 LoongArchInstrInfo InstrInfo;
51 LoongArchRegisterInfo RegInfo;
52 LoongArchTargetLowering TLInfo;
53 SelectionDAGTargetInfo TSInfo;
55 Align PrefFunctionAlignment;
56 Align PrefLoopAlignment;
57 unsigned MaxBytesForAlignment;
59 /// Initializes using the passed in CPU and feature strings so that we can
60 /// use initializer lists for subtarget initialization.
61 LoongArchSubtarget &initializeSubtargetDependencies(const Triple &TT,
67 /// Initialize properties based on the selected processor family.
68 void initializeProperties(StringRef TuneCPU);
71 // Initializes the data members to match that of the specified triple.
72 LoongArchSubtarget(const Triple &TT, StringRef CPU, StringRef TuneCPU,
73 StringRef FS, StringRef ABIName, const TargetMachine &TM);
75 // Parses features string setting specified subtarget options. The
76 // definition of this function is auto-generated by tblgen.
77 void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
79 const LoongArchFrameLowering *getFrameLowering() const override {
80 return &FrameLowering;
82 const LoongArchInstrInfo *getInstrInfo() const override { return &InstrInfo; }
83 const LoongArchRegisterInfo *getRegisterInfo() const override {
86 const LoongArchTargetLowering *getTargetLowering() const override {
89 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
92 bool is64Bit() const { return HasLA64; }
93 bool hasBasicF() const { return HasBasicF; }
94 bool hasBasicD() const { return HasBasicD; }
95 bool hasExtLSX() const { return HasExtLSX; }
96 bool hasExtLASX() const { return HasExtLASX; }
97 bool hasExtLVZ() const { return HasExtLVZ; }
98 bool hasExtLBT() const { return HasExtLBT; }
99 bool hasLaGlobalWithPcrel() const { return HasLaGlobalWithPcrel; }
100 bool hasLaGlobalWithAbs() const { return HasLaGlobalWithAbs; }
101 bool hasLaLocalWithAbs() const { return HasLaLocalWithAbs; }
102 bool hasUAL() const { return HasUAL; }
103 MVT getGRLenVT() const { return GRLenVT; }
104 unsigned getGRLen() const { return GRLen; }
105 LoongArchABI::ABI getTargetABI() const { return TargetABI; }
106 bool isXRaySupported() const override { return is64Bit(); }
107 Align getPrefFunctionAlignment() const { return PrefFunctionAlignment; }
108 Align getPrefLoopAlignment() const { return PrefLoopAlignment; }
109 unsigned getMaxBytesForAlignment() const { return MaxBytesForAlignment; }
111 } // end namespace llvm
113 #endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHSUBTARGET_H