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 void mirFileLoaded(MachineFunction &MF) const override;
96
97#define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER) \
98 bool GETTER() const { return ATTRIBUTE; }
99#include "LoongArchGenSubtargetInfo.inc"
100
101 bool is64Bit() const { return HasLA64; }
102 MVT getGRLenVT() const { return GRLenVT; }
103 unsigned getGRLen() const { return GRLen; }
104 LoongArchABI::ABI getTargetABI() const { return TargetABI; }
105 bool isSoftFPABI() const {
106 return TargetABI == LoongArchABI::ABI_LP64S ||
107 TargetABI == LoongArchABI::ABI_ILP32S;
108 }
109 bool isXRaySupported() const override { return is64Bit(); }
110 Align getPrefFunctionAlignment() const { return PrefFunctionAlignment; }
111 Align getPrefLoopAlignment() const { return PrefLoopAlignment; }
112 unsigned getMaxBytesForAlignment() const { return MaxBytesForAlignment; }
113 unsigned getMaxInterleaveFactor() const { return MaxInterleaveFactor; }
114 unsigned getPrefetchDistance() const override { return PrefetchDistance; }
115 unsigned getMinPrefetchStride(unsigned NumMemAccesses,
116 unsigned NumStridedMemAccesses,
117 unsigned NumPrefetches,
118 bool HasCall) const override {
119 return MinPrefetchStride;
120 }
121 unsigned getMaxPrefetchIterationsAhead() const override {
122 return MaxPrefetchIterationsAhead;
123 }
124 bool enableWritePrefetching() const override { return true; }
125 bool enableMachineScheduler() const override { return true; }
126 bool useAA() const override;
127};
128} // end namespace llvm
129
130#endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHSUBTARGET_H
static const unsigned MaxInterleaveFactor
Maximum vectorization interleave count.
const LoongArchRegisterInfo * getRegisterInfo() const override
void mirFileLoaded(MachineFunction &MF) 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