LLVM  8.0.1
HexagonSubtarget.h
Go to the documentation of this file.
1 //===- HexagonSubtarget.h - Define Subtarget for the Hexagon ----*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the Hexagon specific subclass of TargetSubtarget.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONSUBTARGET_H
15 #define LLVM_LIB_TARGET_HEXAGON_HEXAGONSUBTARGET_H
16 
17 #include "HexagonDepArch.h"
18 #include "HexagonFrameLowering.h"
19 #include "HexagonISelLowering.h"
20 #include "HexagonInstrInfo.h"
21 #include "HexagonRegisterInfo.h"
23 #include "llvm/ADT/SmallSet.h"
24 #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 
35 namespace llvm {
36 
37 class MachineInstr;
38 class SDep;
39 class SUnit;
40 class TargetMachine;
41 class Triple;
42 
44  virtual void anchor();
45 
46  bool UseHVX64BOps = false;
47  bool UseHVX128BOps = false;
48 
49  bool UseLongCalls = false;
50  bool UseMemops = false;
51  bool UsePackets = false;
52  bool UseNewValueJumps = false;
53  bool UseNewValueStores = false;
54  bool UseSmallData = false;
55  bool UseZRegOps = false;
56 
57  bool HasMemNoShuf = false;
58  bool EnableDuplex = false;
59  bool ReservedR19 = false;
60  bool NoreturnStackElim = false;
61 
62 public:
66  /// True if the target should use Back-Skip-Back scheduling. This is the
67  /// default for V60.
69 
71  void apply(ScheduleDAGInstrs *DAG) override;
72  };
74  void apply(ScheduleDAGInstrs *DAG) override;
75  };
77  void apply(ScheduleDAGInstrs *DAG) override;
78  private:
79  bool shouldTFRICallBind(const HexagonInstrInfo &HII,
80  const SUnit &Inst1, const SUnit &Inst2) const;
81  };
83  void apply(ScheduleDAGInstrs *DAG) override;
84  };
85 
86 private:
87  std::string CPUString;
88  HexagonInstrInfo InstrInfo;
89  HexagonRegisterInfo RegInfo;
90  HexagonTargetLowering TLInfo;
92  HexagonFrameLowering FrameLowering;
93  InstrItineraryData InstrItins;
94 
95 public:
96  HexagonSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
97  const TargetMachine &TM);
98 
99  /// getInstrItins - Return the instruction itineraries based on subtarget
100  /// selection.
101  const InstrItineraryData *getInstrItineraryData() const override {
102  return &InstrItins;
103  }
104  const HexagonInstrInfo *getInstrInfo() const override { return &InstrInfo; }
105  const HexagonRegisterInfo *getRegisterInfo() const override {
106  return &RegInfo;
107  }
108  const HexagonTargetLowering *getTargetLowering() const override {
109  return &TLInfo;
110  }
111  const HexagonFrameLowering *getFrameLowering() const override {
112  return &FrameLowering;
113  }
115  return &TSInfo;
116  }
117 
119  StringRef FS);
120 
121  /// ParseSubtargetFeatures - Parses features string setting specified
122  /// subtarget options. Definition of function is auto generated by tblgen.
124 
125  bool hasV5Ops() const {
127  }
128  bool hasV5OpsOnly() const {
130  }
131  bool hasV55Ops() const {
133  }
134  bool hasV55OpsOnly() const {
136  }
137  bool hasV60Ops() const {
139  }
140  bool hasV60OpsOnly() const {
142  }
143  bool hasV62Ops() const {
145  }
146  bool hasV62OpsOnly() const {
148  }
149  bool hasV65Ops() const {
151  }
152  bool hasV65OpsOnly() const {
154  }
155  bool hasV66Ops() const {
157  }
158  bool hasV66OpsOnly() const {
160  }
161 
162  bool useLongCalls() const { return UseLongCalls; }
163  bool useMemops() const { return UseMemops; }
164  bool usePackets() const { return UsePackets; }
165  bool useNewValueJumps() const { return UseNewValueJumps; }
166  bool useNewValueStores() const { return UseNewValueStores; }
167  bool useSmallData() const { return UseSmallData; }
168  bool useZRegOps() const { return UseZRegOps; }
169 
170  bool useHVXOps() const {
171  return HexagonHVXVersion > Hexagon::ArchEnum::NoArch;
172  }
173  bool useHVX128BOps() const { return useHVXOps() && UseHVX128BOps; }
174  bool useHVX64BOps() const { return useHVXOps() && UseHVX64BOps; }
175 
176  bool hasMemNoShuf() const { return HasMemNoShuf; }
177  bool hasReservedR19() const { return ReservedR19; }
178  bool usePredicatedCalls() const;
179 
180  bool noreturnStackElim() const { return NoreturnStackElim; }
181 
182  bool useBSBScheduling() const { return UseBSBScheduling; }
183  bool enableMachineScheduler() const override;
184 
185  // Always use the TargetLowering default scheduler.
186  // FIXME: This will use the vliw scheduler which is probably just hurting
187  // compiler time and will be removed eventually anyway.
188  bool enableMachineSchedDefaultSched() const override { return false; }
189 
190  AntiDepBreakMode getAntiDepBreakMode() const override { return ANTIDEP_ALL; }
191  bool enablePostRAScheduler() const override { return true; }
192 
193  bool enableSubRegLiveness() const override;
194 
195  const std::string &getCPUString () const { return CPUString; }
196 
198  return HexagonArchVersion;
199  }
200 
201  void getPostRAMutations(
202  std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations)
203  const override;
204 
205  void getSMSMutations(
206  std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations)
207  const override;
208 
209  /// Enable use of alias analysis during code generation (during MI
210  /// scheduling, DAGCombine, etc.).
211  bool useAA() const override;
212 
213  /// Perform target specific adjustments to the latency of a schedule
214  /// dependency.
215  void adjustSchedDependency(SUnit *def, SUnit *use, SDep& dep) const override;
216 
217  unsigned getVectorLength() const {
218  assert(useHVXOps());
219  if (useHVX64BOps())
220  return 64;
221  if (useHVX128BOps())
222  return 128;
223  llvm_unreachable("Invalid HVX vector length settings");
224  }
225 
227  static MVT Types[] = { MVT::i8, MVT::i16, MVT::i32 };
228  return makeArrayRef(Types);
229  }
230 
231  bool isHVXVectorType(MVT VecTy, bool IncludeBool = false) const {
232  if (!VecTy.isVector() || !useHVXOps())
233  return false;
234  MVT ElemTy = VecTy.getVectorElementType();
235  if (!IncludeBool && ElemTy == MVT::i1)
236  return false;
237 
238  unsigned HwLen = getVectorLength();
239  unsigned NumElems = VecTy.getVectorNumElements();
240  ArrayRef<MVT> ElemTypes = getHVXElementTypes();
241 
242  if (IncludeBool && ElemTy == MVT::i1) {
243  // Special case for the v512i1, etc.
244  if (8*HwLen == NumElems)
245  return true;
246  // Boolean HVX vector types are formed from regular HVX vector types
247  // by replacing the element type with i1.
248  for (MVT T : ElemTypes)
249  if (NumElems * T.getSizeInBits() == 8*HwLen)
250  return true;
251  return false;
252  }
253 
254  unsigned VecWidth = VecTy.getSizeInBits();
255  if (VecWidth != 8*HwLen && VecWidth != 16*HwLen)
256  return false;
257  return llvm::any_of(ElemTypes, [ElemTy] (MVT T) { return ElemTy == T; });
258  }
259 
260  unsigned getTypeAlignment(MVT Ty) const {
261  if (isHVXVectorType(Ty, true))
262  return getVectorLength();
263  return Ty.getSizeInBits() / 8;
264  }
265 
266  unsigned getL1CacheLineSize() const;
267  unsigned getL1PrefetchDistance() const;
268 
269 private:
270  // Helper function responsible for increasing the latency only.
271  void updateLatency(MachineInstr &SrcInst, MachineInstr &DstInst, SDep &Dep)
272  const;
273  void restoreLatency(SUnit *Src, SUnit *Dst) const;
274  void changeLatency(SUnit *Src, SUnit *Dst, unsigned Lat) const;
275  bool isBestZeroLatency(SUnit *Src, SUnit *Dst, const HexagonInstrInfo *TII,
276  SmallSet<SUnit*, 4> &ExclSrc, SmallSet<SUnit*, 4> &ExclDst) const;
277 };
278 
279 } // end namespace llvm
280 
281 #endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONSUBTARGET_H
AntiDepBreakMode getAntiDepBreakMode() const override
bool noreturnStackElim() const
This class represents lattice values for constants.
Definition: AllocatorList.h:24
bool isVector() const
Return true if this is a vector value type.
Hexagon::ArchEnum HexagonArchVersion
unsigned getVectorNumElements() const
ArrayRef< MVT > getHVXElementTypes() const
Mutate the DAG as a postpass after normal DAG building.
void getSMSMutations(std::vector< std::unique_ptr< ScheduleDAGMutation >> &Mutations) const override
const Hexagon::ArchEnum & getHexagonArchVersion() const
const HexagonFrameLowering * getFrameLowering() const override
const InstrItineraryData * getInstrItineraryData() const override
getInstrItins - Return the instruction itineraries based on subtarget selection.
HexagonSubtarget & initializeSubtargetDependencies(StringRef CPU, StringRef FS)
unsigned getL1CacheLineSize() const
bool enablePostRAScheduler() const override
const HexagonInstrInfo * TII
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:451
const HexagonRegisterInfo * getRegisterInfo() const override
Hexagon::ArchEnum HexagonHVXVersion
unsigned getSizeInBits() const
const HexagonTargetLowering * getTargetLowering() const override
unsigned getL1PrefetchDistance() const
HexagonSubtarget(const Triple &TT, StringRef CPU, StringRef FS, const TargetMachine &TM)
#define T
const std::string & getCPUString() const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
Itinerary data supplied by a subtarget to be used by a target.
MVT getVectorElementType() const
Scheduling dependency.
Definition: ScheduleDAG.h:50
Machine Value Type.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition: SmallSet.h:135
CodeGenOpt::Level OptLevel
void apply(ScheduleDAGInstrs *DAG) override
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:1193
bool useAA() const override
Enable use of alias analysis during code generation (during MI scheduling, DAGCombine, etc.).
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
bool isHVXVectorType(MVT VecTy, bool IncludeBool=false) const
bool enableMachineScheduler() const override
void getPostRAMutations(std::vector< std::unique_ptr< ScheduleDAGMutation >> &Mutations) const override
bool UseBSBScheduling
True if the target should use Back-Skip-Back scheduling.
bool enableSubRegLiveness() const override
void adjustSchedDependency(SUnit *def, SUnit *use, SDep &dep) const override
Perform target specific adjustments to the latency of a schedule dependency.
A ScheduleDAG for scheduling lists of MachineInstr.
Representation of each machine instruction.
Definition: MachineInstr.h:64
bool enableMachineSchedDefaultSched() const override
void ParseSubtargetFeatures(StringRef CPU, StringRef FS)
ParseSubtargetFeatures - Parses features string setting specified subtarget options.
unsigned getVectorLength() const
unsigned getTypeAlignment(MVT Ty) const
pgo instr use
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const HexagonInstrInfo * getInstrInfo() const override
const HexagonSelectionDAGInfo * getSelectionDAGInfo() const override
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:59
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
bool useNewValueStores() const
Scheduling unit. This is a node in the scheduling DAG.
Definition: ScheduleDAG.h:246