LLVM  5.0.0
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 "HexagonFrameLowering.h"
18 #include "HexagonInstrInfo.h"
19 #include "HexagonISelLowering.h"
21 #include "llvm/ADT/SmallSet.h"
22 #include "llvm/ADT/StringRef.h"
26 #include <memory>
27 #include <string>
28 #include <vector>
29 
30 #define GET_SUBTARGETINFO_HEADER
31 #include "HexagonGenSubtargetInfo.inc"
32 
33 #define Hexagon_SMALL_DATA_THRESHOLD 8
34 #define Hexagon_SLOTS 4
35 
36 namespace llvm {
37 
38 class MachineInstr;
39 class SDep;
40 class SUnit;
41 class TargetMachine;
42 class Triple;
43 
45  virtual void anchor();
46 
47  bool UseMemOps, UseHVXOps, UseHVXDblOps;
48  bool UseLongCalls;
49  bool ModeIEEERndNear;
50 
51 public:
52 #include "HexagonDepArch.h"
53 
55  /// True if the target should use Back-Skip-Back scheduling. This is the
56  /// default for V60.
58 
60  public:
61  void apply(ScheduleDAGInstrs *DAG) override;
62  };
63 
64 private:
65  std::string CPUString;
66  HexagonInstrInfo InstrInfo;
67  HexagonTargetLowering TLInfo;
69  HexagonFrameLowering FrameLowering;
70  InstrItineraryData InstrItins;
71 
72  void initializeEnvironment();
73 
74 public:
75  HexagonSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
76  const TargetMachine &TM);
77 
78  /// getInstrItins - Return the instruction itineraries based on subtarget
79  /// selection.
80  const InstrItineraryData *getInstrItineraryData() const override {
81  return &InstrItins;
82  }
83  const HexagonInstrInfo *getInstrInfo() const override { return &InstrInfo; }
84  const HexagonRegisterInfo *getRegisterInfo() const override {
85  return &InstrInfo.getRegisterInfo();
86  }
87  const HexagonTargetLowering *getTargetLowering() const override {
88  return &TLInfo;
89  }
90  const HexagonFrameLowering *getFrameLowering() const override {
91  return &FrameLowering;
92  }
93  const HexagonSelectionDAGInfo *getSelectionDAGInfo() const override {
94  return &TSInfo;
95  }
96 
98  StringRef FS);
99 
100  /// ParseSubtargetFeatures - Parses features string setting specified
101  /// subtarget options. Definition of function is auto generated by tblgen.
103 
104  bool useMemOps() const { return UseMemOps; }
105  bool hasV5TOps() const { return getHexagonArchVersion() >= V5; }
106  bool hasV5TOpsOnly() const { return getHexagonArchVersion() == V5; }
107  bool hasV55TOps() const { return getHexagonArchVersion() >= V55; }
108  bool hasV55TOpsOnly() const { return getHexagonArchVersion() == V55; }
109  bool hasV60TOps() const { return getHexagonArchVersion() >= V60; }
110  bool hasV60TOpsOnly() const { return getHexagonArchVersion() == V60; }
111  bool hasV62TOps() const { return getHexagonArchVersion() >= V62; }
112  bool hasV62TOpsOnly() const { return getHexagonArchVersion() == V62; }
113 
114  bool modeIEEERndNear() const { return ModeIEEERndNear; }
115  bool useHVXOps() const { return UseHVXOps; }
116  bool useHVXDblOps() const { return UseHVXOps && UseHVXDblOps; }
117  bool useHVXSglOps() const { return UseHVXOps && !UseHVXDblOps; }
118  bool useLongCalls() const { return UseLongCalls; }
119  bool usePredicatedCalls() const;
120 
121  bool useBSBScheduling() const { return UseBSBScheduling; }
122  bool enableMachineScheduler() const override;
123 
124  // Always use the TargetLowering default scheduler.
125  // FIXME: This will use the vliw scheduler which is probably just hurting
126  // compiler time and will be removed eventually anyway.
127  bool enableMachineSchedDefaultSched() const override { return false; }
128 
129  AntiDepBreakMode getAntiDepBreakMode() const override { return ANTIDEP_ALL; }
130  bool enablePostRAScheduler() const override { return true; }
131 
132  bool enableSubRegLiveness() const override;
133 
134  const std::string &getCPUString () const { return CPUString; }
135 
136  // Threshold for small data section
137  unsigned getSmallDataThreshold() const {
139  }
140 
142  return HexagonArchVersion;
143  }
144 
145  void getPostRAMutations(
146  std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations)
147  const override;
148 
149  void getSMSMutations(
150  std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations)
151  const override;
152 
153  /// \brief Perform target specific adjustments to the latency of a schedule
154  /// dependency.
155  void adjustSchedDependency(SUnit *def, SUnit *use, SDep& dep) const override;
156 
157  unsigned getL1CacheLineSize() const;
158  unsigned getL1PrefetchDistance() const;
159 
160 private:
161  // Helper function responsible for increasing the latency only.
162  void updateLatency(MachineInstr &SrcInst, MachineInstr &DstInst, SDep &Dep)
163  const;
164  void restoreLatency(SUnit *Src, SUnit *Dst) const;
165  void changeLatency(SUnit *Src, SUnit *Dst, unsigned Lat) const;
166  bool isBestZeroLatency(SUnit *Src, SUnit *Dst, const HexagonInstrInfo *TII,
167  SmallSet<SUnit*, 4> &ExclSrc, SmallSet<SUnit*, 4> &ExclDst) const;
168 };
169 
170 } // end namespace llvm
171 
172 #endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONSUBTARGET_H
const HexagonArchEnum & getHexagonArchVersion() const
AntiDepBreakMode getAntiDepBreakMode() const override
Mutate the DAG as a postpass after normal DAG building.
void getSMSMutations(std::vector< std::unique_ptr< ScheduleDAGMutation >> &Mutations) const override
const HexagonFrameLowering * getFrameLowering() const override
bool usePredicatedCalls() const
const InstrItineraryData * getInstrItineraryData() const override
getInstrItins - Return the instruction itineraries based on subtarget selection.
unsigned getSmallDataThreshold() const
HexagonSubtarget & initializeSubtargetDependencies(StringRef CPU, StringRef FS)
bool enablePostRAScheduler() const override
const HexagonInstrInfo * TII
unsigned getL1CacheLineSize() const
const HexagonRegisterInfo * getRegisterInfo() const override
const HexagonRegisterInfo & getRegisterInfo() const
HexagonInstrInfo specifics.
const HexagonTargetLowering * getTargetLowering() const override
HexagonSubtarget(const Triple &TT, StringRef CPU, StringRef FS, const TargetMachine &TM)
Itinerary data supplied by a subtarget to be used by a target.
bool hasV60TOpsOnly() const
Scheduling dependency.
Definition: ScheduleDAG.h:50
HexagonArchEnum HexagonArchVersion
#define Hexagon_SMALL_DATA_THRESHOLD
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition: SmallSet.h:36
unsigned getL1PrefetchDistance() const
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
void apply(ScheduleDAGInstrs *DAG) override
bool useBSBScheduling() 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.
const std::string & getCPUString() const
A ScheduleDAG for scheduling lists of MachineInstr.
Representation of each machine instruction.
Definition: MachineInstr.h:59
bool enableMachineSchedDefaultSched() const override
void ParseSubtargetFeatures(StringRef CPU, StringRef FS)
ParseSubtargetFeatures - Parses features string setting specified subtarget options.
bool modeIEEERndNear() const
pgo instr use
const HexagonInstrInfo * getInstrInfo() const override
const HexagonSelectionDAGInfo * getSelectionDAGInfo() const override
bool hasV55TOpsOnly() const
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:56
bool hasV62TOpsOnly() const
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
Scheduling unit. This is a node in the scheduling DAG.
Definition: ScheduleDAG.h:247