LLVM 24.0.0git
LoongArchSubtarget.h
Go to the documentation of this file.
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
18#include "LoongArchInstrInfo.h"
22#include "llvm/IR/DataLayout.h"
24
25#define GET_SUBTARGETINFO_HEADER
26#include "LoongArchGenSubtargetInfo.inc"
27
28namespace llvm {
29class StringRef;
30
32 virtual void anchor();
33
34#define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER) \
35 bool ATTRIBUTE = DEFAULT;
36#include "LoongArchGenSubtargetInfo.inc"
37
38 unsigned GRLen = 32;
39 // TODO: The default value is empirical and conservative. Override the
40 // default in initializeProperties once we support optimizing for more
41 // uarches.
43 MVT GRLenVT = MVT::i32;
45 LoongArchFrameLowering FrameLowering;
46 LoongArchInstrInfo InstrInfo;
47 LoongArchTargetLowering TLInfo;
48 std::unique_ptr<const SelectionDAGTargetInfo> TSInfo;
49
50 Align PrefFunctionAlignment;
51 Align PrefLoopAlignment;
52 unsigned MaxBytesForAlignment;
53
54 // Software prefetch settings for LoopDataPrefetch, set in
55 // initializeProperties. A PrefetchDistance of 0 disables the pass.
56 unsigned PrefetchDistance;
57 unsigned MinPrefetchStride;
58 unsigned MaxPrefetchIterationsAhead;
59
60 /// Initializes using the passed in CPU and feature strings so that we can
61 /// use initializer lists for subtarget initialization.
62 LoongArchSubtarget &initializeSubtargetDependencies(const Triple &TT,
63 StringRef CPU,
64 StringRef TuneCPU,
65 StringRef FS,
66 StringRef ABIName);
67
68 /// Initialize properties based on the selected processor family.
69 void initializeProperties(StringRef TuneCPU);
70
71public:
72 // Initializes the data members to match that of the specified triple.
73 LoongArchSubtarget(const Triple &TT, StringRef CPU, StringRef TuneCPU,
74 StringRef FS, StringRef ABIName, const TargetMachine &TM);
75
77
78 // Parses features string setting specified subtarget options. The
79 // definition of this function is auto-generated by tblgen.
81
82 const LoongArchFrameLowering *getFrameLowering() const override {
83 return &FrameLowering;
84 }
85 const LoongArchInstrInfo *getInstrInfo() const override { return &InstrInfo; }
86 const LoongArchRegisterInfo *getRegisterInfo() const override {
87 return &InstrInfo.getRegisterInfo();
88 }
90 return &TLInfo;
91 }
92
93 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override;
94
95#define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER) \
96 bool GETTER() const { return ATTRIBUTE; }
97#include "LoongArchGenSubtargetInfo.inc"
98
99 bool is64Bit() const { return HasLA64; }
100 MVT getGRLenVT() const { return GRLenVT; }
101 unsigned getGRLen() const { return GRLen; }
102 LoongArchABI::ABI getTargetABI() const { return TargetABI; }
103 bool isSoftFPABI() const {
104 return TargetABI == LoongArchABI::ABI_LP64S ||
105 TargetABI == LoongArchABI::ABI_ILP32S;
106 }
107 bool isXRaySupported() const override { return is64Bit(); }
108 Align getPrefFunctionAlignment() const { return PrefFunctionAlignment; }
109 Align getPrefLoopAlignment() const { return PrefLoopAlignment; }
110 unsigned getMaxBytesForAlignment() const { return MaxBytesForAlignment; }
111 unsigned getMaxInterleaveFactor() const { return MaxInterleaveFactor; }
112 unsigned getPrefetchDistance() const override { return PrefetchDistance; }
113 unsigned getMinPrefetchStride(unsigned NumMemAccesses,
114 unsigned NumStridedMemAccesses,
115 unsigned NumPrefetches,
116 bool HasCall) const override {
117 return MinPrefetchStride;
118 }
119 unsigned getMaxPrefetchIterationsAhead() const override {
120 return MaxPrefetchIterationsAhead;
121 }
122 bool enableWritePrefetching() const override { return true; }
123 bool enableMachineScheduler() const override { return true; }
124 bool useAA() const override;
125};
126} // end namespace llvm
127
128#endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHSUBTARGET_H
static const unsigned MaxInterleaveFactor
Maximum vectorization interleave count.
const LoongArchRegisterInfo * getRegisterInfo() const override
const SelectionDAGTargetInfo * getSelectionDAGInfo() const override
const LoongArchTargetLowering * getTargetLowering() const override
bool useAA() const override
const LoongArchInstrInfo * getInstrInfo() const override
unsigned getPrefetchDistance() const override
unsigned getMaxBytesForAlignment() const
bool enableMachineScheduler() const override
bool enableWritePrefetching() const override
unsigned getMaxInterleaveFactor() const
LoongArchSubtarget(const Triple &TT, StringRef CPU, StringRef TuneCPU, StringRef FS, StringRef ABIName, const TargetMachine &TM)
bool isXRaySupported() const override
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS)
LoongArchABI::ABI getTargetABI() const
~LoongArchSubtarget() override
const LoongArchFrameLowering * getFrameLowering() const override
unsigned getMinPrefetchStride(unsigned NumMemAccesses, unsigned NumStridedMemAccesses, unsigned NumPrefetches, bool HasCall) const override
unsigned getMaxPrefetchIterationsAhead() const override
Machine Value Type.
Targets can subclass this to parameterize the SelectionDAG lowering and instruction selection process...
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
This is an optimization pass for GlobalISel generic memory operations.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39