LLVM 22.0.0git
HexagonSubtarget.h
Go to the documentation of this file.
1//===- HexagonSubtarget.h - Define Subtarget for the Hexagon ----*- 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 Hexagon specific subclass of TargetSubtarget.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONSUBTARGET_H
14#define LLVM_LIB_TARGET_HEXAGON_HEXAGONSUBTARGET_H
15
16#include "HexagonDepArch.h"
18#include "HexagonISelLowering.h"
19#include "HexagonInstrInfo.h"
20#include "HexagonRegisterInfo.h"
22#include "llvm/ADT/SmallSet.h"
23#include "llvm/ADT/StringRef.h"
28#include <memory>
29#include <string>
30#include <vector>
31
32#define GET_SUBTARGETINFO_HEADER
33#include "HexagonGenSubtargetInfo.inc"
34
35namespace llvm {
36
37class MachineInstr;
38class SDep;
39class SUnit;
40class TargetMachine;
41class Triple;
42
44 virtual void anchor();
45
46 bool UseHVX64BOps = false;
47 bool UseHVX128BOps = false;
48
49 bool UseAudioOps = false;
50 bool UseCompound = false;
51 bool UseLongCalls = false;
52 bool UseMemops = false;
53 bool UsePackets = false;
54 bool UseNewValueJumps = false;
55 bool UseNewValueStores = false;
56 bool UseSmallData = false;
57 bool UseZRegOps = false;
58 bool UseHVXIEEEFPOps = false;
59 bool UseHVXQFloatOps = false;
60 bool UseHVXFloatingPoint = false;
61 bool UseCabac = false;
62
63 bool HasPreV65 = false;
64 bool HasMemNoShuf = false;
65 bool EnableDuplex = false;
66 bool ReservedR19 = false;
67 bool NoreturnStackElim = false;
68
69public:
73 /// True if the target should use Back-Skip-Back scheduling. This is the
74 /// default for V60.
76
78 void apply(ScheduleDAGInstrs *DAG) override;
79 };
81 void apply(ScheduleDAGInstrs *DAG) override;
82 };
84 void apply(ScheduleDAGInstrs *DAG) override;
85 private:
86 bool shouldTFRICallBind(const HexagonInstrInfo &HII,
87 const SUnit &Inst1, const SUnit &Inst2) const;
88 };
90 void apply(ScheduleDAGInstrs *DAG) override;
91 };
92
93private:
94 enum HexagonProcFamilyEnum { Others, TinyCore };
95
96 std::string CPUString;
97 HexagonProcFamilyEnum HexagonProcFamily = Others;
98 Triple TargetTriple;
99
100 // The following objects can use the TargetTriple, so they must be
101 // declared after it.
102 HexagonInstrInfo InstrInfo;
106 HexagonFrameLowering FrameLowering;
107 InstrItineraryData InstrItins;
108
109public:
110 HexagonSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
111 const TargetMachine &TM);
112
113 const Triple &getTargetTriple() const { return TargetTriple; }
114 bool isEnvironmentMusl() const {
115 return TargetTriple.getEnvironment() == Triple::Musl;
116 }
117
118 /// getInstrItins - Return the instruction itineraries based on subtarget
119 /// selection.
121 return &InstrItins;
122 }
123 const HexagonInstrInfo *getInstrInfo() const override { return &InstrInfo; }
124 const HexagonRegisterInfo *getRegisterInfo() const override {
125 return &RegInfo;
126 }
127 const HexagonTargetLowering *getTargetLowering() const override {
128 return &TLInfo;
129 }
130 const HexagonFrameLowering *getFrameLowering() const override {
131 return &FrameLowering;
132 }
134 return &TSInfo;
135 }
136
138 StringRef FS);
139
140 /// ParseSubtargetFeatures - Parses features string setting specified
141 /// subtarget options. Definition of function is auto generated by tblgen.
143
144 bool isXRaySupported() const override { return true; }
145
146 bool hasV5Ops() const {
148 }
149 bool hasV5OpsOnly() const {
151 }
152 bool hasV55Ops() const {
154 }
155 bool hasV55OpsOnly() const {
157 }
158 bool hasV60Ops() const {
160 }
161 bool hasV60OpsOnly() const {
163 }
164 bool hasV62Ops() const {
166 }
167 bool hasV62OpsOnly() const {
169 }
170 bool hasV65Ops() const {
172 }
173 bool hasV65OpsOnly() const {
175 }
176 bool hasV66Ops() const {
178 }
179 bool hasV66OpsOnly() const {
181 }
182 bool hasV67Ops() const {
184 }
185 bool hasV67OpsOnly() const {
187 }
188 bool hasV68Ops() const {
190 }
191 bool hasV68OpsOnly() const {
193 }
194 bool hasV69Ops() const {
196 }
197 bool hasV69OpsOnly() const {
199 }
200 bool hasV71Ops() const {
202 }
203 bool hasV71OpsOnly() const {
205 }
206 bool hasV73Ops() const {
208 }
209 bool hasV73OpsOnly() const {
211 }
212 bool hasV75Ops() const {
214 }
215 bool hasV75OpsOnly() const {
217 }
218 bool hasV79Ops() const {
220 }
221 bool hasV79OpsOnly() const {
223 }
224 bool useHVXV79Ops() const {
226 }
227
228 bool useAudioOps() const { return UseAudioOps; }
229 bool useCompound() const { return UseCompound; }
230 bool useLongCalls() const { return UseLongCalls; }
231 bool useMemops() const { return UseMemops; }
232 bool usePackets() const { return UsePackets; }
233 bool useNewValueJumps() const { return UseNewValueJumps; }
234 bool useNewValueStores() const { return UseNewValueStores; }
235 bool useSmallData() const { return UseSmallData; }
236 bool useZRegOps() const { return UseZRegOps; }
237 bool useCabac() const { return UseCabac; }
238
239 bool isTinyCore() const { return HexagonProcFamily == TinyCore; }
240 bool isTinyCoreWithDuplex() const { return isTinyCore() && EnableDuplex; }
241
242 bool useHVXIEEEFPOps() const { return UseHVXIEEEFPOps && useHVXOps(); }
243 bool useHVXQFloatOps() const {
244 return UseHVXQFloatOps && HexagonHVXVersion >= Hexagon::ArchEnum::V68;
245 }
246 bool useHVXFloatingPoint() const { return UseHVXFloatingPoint; }
247 bool useHVXOps() const {
249 }
250 bool useHVXV60Ops() const {
252 }
253 bool useHVXV62Ops() const {
255 }
256 bool useHVXV65Ops() const {
258 }
259 bool useHVXV66Ops() const {
261 }
262 bool useHVXV67Ops() const {
264 }
265 bool useHVXV68Ops() const {
267 }
268 bool useHVXV69Ops() const {
270 }
271 bool useHVXV71Ops() const {
273 }
274 bool useHVXV73Ops() const {
276 }
277 bool useHVX128BOps() const { return useHVXOps() && UseHVX128BOps; }
278 bool useHVX64BOps() const { return useHVXOps() && UseHVX64BOps; }
279
280 bool hasMemNoShuf() const { return HasMemNoShuf; }
281 bool hasReservedR19() const { return ReservedR19; }
282 bool usePredicatedCalls() const;
283
284 bool noreturnStackElim() const { return NoreturnStackElim; }
285
286 bool useBSBScheduling() const { return UseBSBScheduling; }
287 bool enableMachineScheduler() const override;
288
289 // Always use the TargetLowering default scheduler.
290 // FIXME: This will use the vliw scheduler which is probably just hurting
291 // compiler time and will be removed eventually anyway.
292 bool enableMachineSchedDefaultSched() const override { return false; }
293
294 // For use with PostRAScheduling: get the anti-dependence breaking that should
295 // be performed before post-RA scheduling.
296 AntiDepBreakMode getAntiDepBreakMode() const override { return ANTIDEP_ALL; }
297 /// True if the subtarget should run a scheduler after register
298 /// allocation.
299 bool enablePostRAScheduler() const override { return true; }
300
301 bool enableSubRegLiveness() const override;
302
303 const std::string &getCPUString () const { return CPUString; }
304
308
310 std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations)
311 const override;
312
313 void getSMSMutations(
314 std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations)
315 const override;
316
317 /// Enable use of alias analysis during code generation (during MI
318 /// scheduling, DAGCombine, etc.).
319 bool useAA() const override;
320
321 /// Perform target specific adjustments to the latency of a schedule
322 /// dependency.
323 void adjustSchedDependency(SUnit *Def, int DefOpIdx, SUnit *Use, int UseOpIdx,
324 SDep &Dep,
325 const TargetSchedModel *SchedModel) const override;
326
327 unsigned getVectorLength() const {
328 assert(useHVXOps());
329 if (useHVX64BOps())
330 return 64;
331 if (useHVX128BOps())
332 return 128;
333 llvm_unreachable("Invalid HVX vector length settings");
334 }
335
337 static MVT Types[] = {MVT::i8, MVT::i16, MVT::i32};
338 static MVT TypesV68[] = {MVT::i8, MVT::i16, MVT::i32, MVT::f16, MVT::f32};
339
341 return ArrayRef(TypesV68);
342 return ArrayRef(Types);
343 }
344
345 bool isHVXElementType(MVT Ty, bool IncludeBool = false) const;
346 bool isHVXVectorType(EVT VecTy, bool IncludeBool = false) const;
347 bool isTypeForHVX(Type *VecTy, bool IncludeBool = false) const;
348
350 if (isHVXVectorType(Ty, true))
351 return Align(getVectorLength());
352 return Align(std::max<unsigned>(1, Ty.getSizeInBits() / 8));
353 }
354
355 unsigned getL1CacheLineSize() const;
356 unsigned getL1PrefetchDistance() const;
357
358 Intrinsic::ID getIntrinsicId(unsigned Opc) const;
359
360private:
361 // Helper function responsible for increasing the latency only.
362 int updateLatency(MachineInstr &SrcInst, MachineInstr &DstInst,
363 bool IsArtificial, int Latency) const;
364 void restoreLatency(SUnit *Src, SUnit *Dst) const;
365 void changeLatency(SUnit *Src, SUnit *Dst, unsigned Lat) const;
366 bool isBestZeroLatency(SUnit *Src, SUnit *Dst, const HexagonInstrInfo *TII,
368 SmallPtrSet<SUnit *, 4> &ExclDst) const;
369};
370
371} // end namespace llvm
372
373#endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONSUBTARGET_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
const HexagonInstrInfo * TII
This file defines the SmallSet class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:41
bool isTinyCoreWithDuplex() const
const InstrItineraryData * getInstrItineraryData() const override
getInstrItins - Return the instruction itineraries based on subtarget selection.
Hexagon::ArchEnum HexagonArchVersion
void adjustSchedDependency(SUnit *Def, int DefOpIdx, SUnit *Use, int UseOpIdx, SDep &Dep, const TargetSchedModel *SchedModel) const override
Perform target specific adjustments to the latency of a schedule dependency.
bool enableMachineSchedDefaultSched() const override
const HexagonInstrInfo * getInstrInfo() const override
const HexagonFrameLowering * getFrameLowering() const override
Hexagon::ArchEnum HexagonHVXVersion
const HexagonRegisterInfo * getRegisterInfo() const override
const Hexagon::ArchEnum & getHexagonArchVersion() const
void getSMSMutations(std::vector< std::unique_ptr< ScheduleDAGMutation > > &Mutations) const override
HexagonSubtarget(const Triple &TT, StringRef CPU, StringRef FS, const TargetMachine &TM)
bool isHVXVectorType(EVT VecTy, bool IncludeBool=false) const
const Triple & getTargetTriple() const
void getPostRAMutations(std::vector< std::unique_ptr< ScheduleDAGMutation > > &Mutations) const override
const HexagonTargetLowering * getTargetLowering() const override
bool UseBSBScheduling
True if the target should use Back-Skip-Back scheduling.
unsigned getL1PrefetchDistance() const
ArrayRef< MVT > getHVXElementTypes() const
bool enableSubRegLiveness() const override
Align getTypeAlignment(MVT Ty) const
unsigned getVectorLength() const
AntiDepBreakMode getAntiDepBreakMode() const override
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS)
ParseSubtargetFeatures - Parses features string setting specified subtarget options.
unsigned getL1CacheLineSize() const
bool isTypeForHVX(Type *VecTy, bool IncludeBool=false) const
Intrinsic::ID getIntrinsicId(unsigned Opc) const
HexagonSubtarget & initializeSubtargetDependencies(StringRef CPU, StringRef FS)
const HexagonSelectionDAGInfo * getSelectionDAGInfo() const override
bool enableMachineScheduler() const override
bool enablePostRAScheduler() const override
True if the subtarget should run a scheduler after register allocation.
bool isHVXElementType(MVT Ty, bool IncludeBool=false) const
const std::string & getCPUString() const
bool isXRaySupported() const override
bool useAA() const override
Enable use of alias analysis during code generation (during MI scheduling, DAGCombine,...
Itinerary data supplied by a subtarget to be used by a target.
Machine Value Type.
Representation of each machine instruction.
Scheduling dependency.
Definition ScheduleDAG.h:51
Scheduling unit. This is a node in the scheduling DAG.
A ScheduleDAG for scheduling lists of MachineInstr.
Mutate the DAG as a postpass after normal DAG building.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
Primary interface to the complete machine description for the target machine.
Provide an instruction scheduling machine model to CodeGen passes.
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
A Use represents the edge between a Value definition and its users.
Definition Use.h:35
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:82
ArrayRef(const T &OneElt) -> ArrayRef< T >
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
Extended Value Type.
Definition ValueTypes.h:35
void apply(ScheduleDAGInstrs *DAG) override
void apply(ScheduleDAGInstrs *DAG) override
void apply(ScheduleDAGInstrs *DAG) override
void apply(ScheduleDAGInstrs *DAG) override