Coverage Report

Created: 2017-10-03 07:32

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/lib/Target/Hexagon/HexagonHazardRecognizer.h
Line
Count
Source
1
//===--- HexagonHazardRecognizer.h - Hexagon Post RA Hazard Recognizer ----===//
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
// This file defines the hazard recognizer for scheduling on Hexagon.
10
//===----------------------------------------------------------------------===//
11
12
#ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONPROFITRECOGNIZER_H
13
#define LLVM_LIB_TARGET_HEXAGON_HEXAGONPROFITRECOGNIZER_H
14
15
#include "HexagonInstrInfo.h"
16
#include "HexagonSubtarget.h"
17
#include "llvm/ADT/SmallSet.h"
18
#include "llvm/CodeGen/DFAPacketizer.h"
19
#include "llvm/CodeGen/ScheduleHazardRecognizer.h"
20
21
namespace llvm {
22
23
class HexagonHazardRecognizer : public ScheduleHazardRecognizer {
24
  DFAPacketizer *Resources;
25
  const HexagonInstrInfo *TII;
26
  unsigned PacketNum;
27
  // If the packet contains a potential dot cur instruction. This is
28
  // used for the scheduling priority function.
29
  SUnit *UsesDotCur;
30
  // The packet number when a dor cur is emitted. If its use is not generated
31
  // in the same packet, then try to wait another cycle before emitting.
32
  int DotCurPNum;
33
  // The set of registers defined by instructions in the current packet.
34
  SmallSet<unsigned, 8> RegDefs;
35
36
public:
37
  HexagonHazardRecognizer(const InstrItineraryData *II,
38
                          const HexagonInstrInfo *HII,
39
                          const HexagonSubtarget &ST)
40
    : Resources(ST.createDFAPacketizer(II)), TII(HII), PacketNum(0),
41
863
    UsesDotCur(nullptr), DotCurPNum(-1) { }
42
43
863
  ~HexagonHazardRecognizer() override {
44
863
    if (Resources)
45
863
      delete Resources;
46
863
  }
47
48
  /// This callback is invoked when a new block of instructions is about to be
49
  /// scheduled. The hazard state is set to an initialized state.
50
  void Reset() override;
51
52
  /// Return the hazard type of emitting this node.  There are three
53
  /// possible results.  Either:
54
  ///  * NoHazard: it is legal to issue this instruction on this cycle.
55
  ///  * Hazard: issuing this instruction would stall the machine.  If some
56
  ///     other instruction is available, issue it first.
57
  HazardType getHazardType(SUnit *SU, int stalls) override;
58
59
  /// This callback is invoked when an instruction is emitted to be scheduled,
60
  /// to advance the hazard state.
61
  void EmitInstruction(SUnit *) override;
62
63
  /// This callback may be invoked if getHazardType returns NoHazard. If, even
64
  /// though there is no hazard, it would be better to schedule another
65
  /// available instruction, this callback should return true.
66
  bool ShouldPreferAnother(SUnit *) override;
67
68
  /// This callback is invoked whenever the next top-down instruction to be
69
  /// scheduled cannot issue in the current cycle, either because of latency
70
  /// or resource conflicts.  This should increment the internal state of the
71
  /// hazard recognizer so that previously "Hazard" instructions will now not
72
  /// be hazards.
73
  void AdvanceCycle() override;
74
};
75
76
} // end namespace llvm
77
78
#endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONPROFITRECOGNIZER_H