blob: 5f7bb1bac265ae41d796a5e367a61e5187a9f3c7 [file] [log] [blame]
Chris Lattnerc6644182006-03-07 06:32:48 +00001//===-- PPCHazardRecognizers.h - PowerPC Hazard Recognizers -----*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Chris Lattner and is distributed under
6// the University of Illinois Open Source 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 "llvm/CodeGen/ScheduleDAG.h"
18
19namespace llvm {
20
21/// PPCHazardRecognizer970 - This class defines a finite state automata that
22/// models the dispatch logic on the PowerPC 970 (aka G5) processor. This
23/// promotes good dispatch group formation and implements noop insertion to
24/// avoid structural hazards that cause significant performance penalties (e.g.
25/// setting the CTR register then branching through it within a dispatch group),
26/// or storing then loading from the same address within a dispatch group.
27class PPCHazardRecognizer970 : public HazardRecognizer {
28 unsigned NumIssued; // Number of insts issued, including advanced cycles.
29
30 // Number of various types of instructions in the current dispatch group.
31 unsigned NumFXU; // Number of Fixed Point (integer) instructions
32 unsigned NumLSU; // Number of Load/Store instructions
33 unsigned NumFPU; // Number of Floating Point instructions
34 bool HasCR; // True if Condition Register instruction issued
Nate Begeman3acbe5d2006-03-07 08:30:27 +000035 bool HasSPR; // True if Special-Purpose Register instruction used
Chris Lattnerc6644182006-03-07 06:32:48 +000036 bool HasVALU; // True if Vector Arithmetic instruction issued
37 bool HasVPERM; // True if Vector Permute instruction issued
38
39 // Various things that can cause a structural hazard.
40
41 // HasCTRSet - If the CTR register is set in this group, disallow BCTRL.
42 bool HasCTRSet;
43
44 // StoredPtr - Keep track of the address of any store. If we see a load from
45 // the same address (or one that aliases it), disallow the store. We only
46 // need one pointer here, because there can only be two LSU operations and we
47 // only get an LSU reject if the first is a store and the second is a load.
48 //
49 // This is null if we haven't seen a store yet. We keep track of both
50 // operands of the store here, since we support [r+r] and [r+i] addressing.
51 SDOperand StorePtr1, StorePtr2;
52 unsigned StoreSize;
53
54public:
55 virtual void StartBasicBlock();
56 virtual HazardType getHazardType(SDNode *Node);
57 virtual void EmitInstruction(SDNode *Node);
58 virtual void AdvanceCycle();
59 virtual void EmitNoop();
60
61private:
62 /// EndDispatchGroup - Called when we are finishing a new dispatch group.
63 ///
64 void EndDispatchGroup();
65
66 enum PPC970InstrType {
Nate Begeman3acbe5d2006-03-07 08:30:27 +000067 FXU, FXU_FIRST, LSU_LD, LSU_ST, FPU, CR, SPR, VALU, VPERM, BR, PseudoInst
Chris Lattnerc6644182006-03-07 06:32:48 +000068 };
69
70 /// GetInstrType - Classify the specified powerpc opcode according to its
71 /// pipeline.
72 PPC970InstrType GetInstrType(unsigned Opcode);
73
74 bool isLoadOfStoredAddress(unsigned LoadSize,
75 SDOperand Ptr1, SDOperand Ptr2) const;
76};
77
78} // end namespace llvm
79
Chris Lattnerab5801c2006-03-07 16:19:46 +000080#endif
81