xref: /freebsd/contrib/llvm-project/llvm/lib/Target/LoongArch/LoongArchSubtarget.h (revision 734e82fe33aa764367791a7d603b383996c6b40b)
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 HasLA32 = false;
35   bool HasLA64 = false;
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;
45   unsigned GRLen = 32;
46   MVT GRLenVT = MVT::i32;
47   LoongArchABI::ABI TargetABI = LoongArchABI::ABI_Unknown;
48   LoongArchFrameLowering FrameLowering;
49   LoongArchInstrInfo InstrInfo;
50   LoongArchRegisterInfo RegInfo;
51   LoongArchTargetLowering TLInfo;
52   SelectionDAGTargetInfo TSInfo;
53 
54   /// Initializes using the passed in CPU and feature strings so that we can
55   /// use initializer lists for subtarget initialization.
56   LoongArchSubtarget &initializeSubtargetDependencies(const Triple &TT,
57                                                       StringRef CPU,
58                                                       StringRef TuneCPU,
59                                                       StringRef FS,
60                                                       StringRef ABIName);
61 
62 public:
63   // Initializes the data members to match that of the specified triple.
64   LoongArchSubtarget(const Triple &TT, StringRef CPU, StringRef TuneCPU,
65                      StringRef FS, StringRef ABIName, const TargetMachine &TM);
66 
67   // Parses features string setting specified subtarget options. The
68   // definition of this function is auto-generated by tblgen.
69   void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
70 
71   const LoongArchFrameLowering *getFrameLowering() const override {
72     return &FrameLowering;
73   }
74   const LoongArchInstrInfo *getInstrInfo() const override { return &InstrInfo; }
75   const LoongArchRegisterInfo *getRegisterInfo() const override {
76     return &RegInfo;
77   }
78   const LoongArchTargetLowering *getTargetLowering() const override {
79     return &TLInfo;
80   }
81   const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
82     return &TSInfo;
83   }
84   bool is64Bit() const { return HasLA64; }
85   bool hasBasicF() const { return HasBasicF; }
86   bool hasBasicD() const { return HasBasicD; }
87   bool hasExtLSX() const { return HasExtLSX; }
88   bool hasExtLASX() const { return HasExtLASX; }
89   bool hasExtLVZ() const { return HasExtLVZ; }
90   bool hasExtLBT() const { return HasExtLBT; }
91   bool hasLaGlobalWithPcrel() const { return HasLaGlobalWithPcrel; }
92   bool hasLaGlobalWithAbs() const { return HasLaGlobalWithAbs; }
93   bool hasLaLocalWithAbs() const { return HasLaLocalWithAbs; }
94   MVT getGRLenVT() const { return GRLenVT; }
95   unsigned getGRLen() const { return GRLen; }
96   LoongArchABI::ABI getTargetABI() const { return TargetABI; }
97 };
98 } // end namespace llvm
99 
100 #endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHSUBTARGET_H
101