1 //===-- PPCHazardRecognizers.h - PowerPC Hazard Recognizers -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines hazard recognizers for scheduling on PowerPC processors.
12 //===----------------------------------------------------------------------===//
17 #include "PPCInstrInfo.h"
18 #include "llvm/CodeGen/ScheduleHazardRecognizer.h"
19 #include "llvm/CodeGen/ScoreboardHazardRecognizer.h"
20 #include "llvm/CodeGen/SelectionDAGNodes.h"
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;
33 unsigned NumIssued; // Number of insts issued, including advanced cycles.
35 // Various things that can cause a structural hazard.
37 // HasCTRSet - If the CTR register is set in this group, disallow BCTRL.
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.
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];
52 PPCHazardRecognizer970(const TargetMachine &TM);
53 virtual HazardType getHazardType(SUnit *SU, int Stalls);
54 virtual void EmitInstruction(SUnit *SU);
55 virtual void AdvanceCycle();
59 /// EndDispatchGroup - Called when we are finishing a new dispatch group.
61 void EndDispatchGroup();
63 /// GetInstrType - Classify the specified powerpc opcode according to its
65 PPCII::PPC970_Unit GetInstrType(unsigned Opcode,
66 bool &isFirst, bool &isSingle,bool &isCracked,
67 bool &isLoad, bool &isStore);
69 bool isLoadOfStoredAddress(uint64_t LoadSize, int64_t LoadOffset,
70 const Value *LoadValue) const;
73 } // end namespace llvm