Remove PPCScoreboardHazardRecognizer
[oota-llvm.git] / lib / Target / PowerPC / PPCHazardRecognizers.h
1 //===-- PPCHazardRecognizers.h - PowerPC Hazard Recognizers -----*- 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 defines hazard recognizers for scheduling on PowerPC processors.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef PPCHAZRECS_H
15 #define PPCHAZRECS_H
16
17 #include "PPCInstrInfo.h"
18 #include "llvm/CodeGen/ScheduleHazardRecognizer.h"
19 #include "llvm/CodeGen/ScoreboardHazardRecognizer.h"
20 #include "llvm/CodeGen/SelectionDAGNodes.h"
21
22 namespace llvm {
23
24 /// PPCHazardRecognizer970 - This class defines a finite state automata that
25 /// models the dispatch logic on the PowerPC 970 (aka G5) processor.  This
26 /// promotes good dispatch group formation and implements noop insertion to
27 /// avoid structural hazards that cause significant performance penalties (e.g.
28 /// setting the CTR register then branching through it within a dispatch group),
29 /// or storing then loading from the same address within a dispatch group.
30 class PPCHazardRecognizer970 : public ScheduleHazardRecognizer {
31   const TargetMachine &TM;
32
33   unsigned NumIssued;  // Number of insts issued, including advanced cycles.
34
35   // Various things that can cause a structural hazard.
36
37   // HasCTRSet - If the CTR register is set in this group, disallow BCTRL.
38   bool HasCTRSet;
39
40   // StoredPtr - Keep track of the address of any store.  If we see a load from
41   // the same address (or one that aliases it), disallow the store.  We can have
42   // up to four stores in one dispatch group, hence we track up to 4.
43   //
44   // This is null if we haven't seen a store yet.  We keep track of both
45   // operands of the store here, since we support [r+r] and [r+i] addressing.
46   const Value *StoreValue[4];
47   int64_t StoreOffset[4];
48   uint64_t StoreSize[4];
49   unsigned NumStores;
50
51 public:
52   PPCHazardRecognizer970(const TargetMachine &TM);
53   virtual HazardType getHazardType(SUnit *SU, int Stalls);
54   virtual void EmitInstruction(SUnit *SU);
55   virtual void AdvanceCycle();
56   virtual void Reset();
57
58 private:
59   /// EndDispatchGroup - Called when we are finishing a new dispatch group.
60   ///
61   void EndDispatchGroup();
62
63   /// GetInstrType - Classify the specified powerpc opcode according to its
64   /// pipeline.
65   PPCII::PPC970_Unit GetInstrType(unsigned Opcode,
66                                   bool &isFirst, bool &isSingle,bool &isCracked,
67                                   bool &isLoad, bool &isStore);
68
69   bool isLoadOfStoredAddress(uint64_t LoadSize, int64_t LoadOffset,
70                              const Value *LoadValue) const;
71 };
72
73 } // end namespace llvm
74
75 #endif
76