2006-03-07 06:32:48 +00:00
|
|
|
//===-- PPCHazardRecognizers.h - PowerPC Hazard Recognizers -----*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2006-03-07 06:32:48 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines hazard recognizers for scheduling on PowerPC processors.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef PPCHAZRECS_H
|
|
|
|
#define PPCHAZRECS_H
|
|
|
|
|
2009-01-15 22:18:12 +00:00
|
|
|
#include "llvm/CodeGen/ScheduleHazardRecognizer.h"
|
|
|
|
#include "llvm/CodeGen/SelectionDAGNodes.h"
|
2006-03-12 09:13:49 +00:00
|
|
|
#include "PPCInstrInfo.h"
|
2006-03-07 06:32:48 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
/// PPCHazardRecognizer970 - This class defines a finite state automata that
|
|
|
|
/// models the dispatch logic on the PowerPC 970 (aka G5) processor. This
|
|
|
|
/// promotes good dispatch group formation and implements noop insertion to
|
|
|
|
/// avoid structural hazards that cause significant performance penalties (e.g.
|
|
|
|
/// setting the CTR register then branching through it within a dispatch group),
|
|
|
|
/// or storing then loading from the same address within a dispatch group.
|
2009-01-15 22:18:12 +00:00
|
|
|
class PPCHazardRecognizer970 : public ScheduleHazardRecognizer {
|
2006-03-12 09:13:49 +00:00
|
|
|
const TargetInstrInfo &TII;
|
2006-03-07 06:32:48 +00:00
|
|
|
|
2006-03-12 09:13:49 +00:00
|
|
|
unsigned NumIssued; // Number of insts issued, including advanced cycles.
|
2006-03-07 06:32:48 +00:00
|
|
|
|
|
|
|
// Various things that can cause a structural hazard.
|
|
|
|
|
|
|
|
// HasCTRSet - If the CTR register is set in this group, disallow BCTRL.
|
|
|
|
bool HasCTRSet;
|
|
|
|
|
|
|
|
// StoredPtr - Keep track of the address of any store. If we see a load from
|
2006-03-12 09:13:49 +00:00
|
|
|
// the same address (or one that aliases it), disallow the store. We can have
|
|
|
|
// up to four stores in one dispatch group, hence we track up to 4.
|
2006-03-07 06:32:48 +00:00
|
|
|
//
|
|
|
|
// This is null if we haven't seen a store yet. We keep track of both
|
|
|
|
// operands of the store here, since we support [r+r] and [r+i] addressing.
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue StorePtr1[4], StorePtr2[4];
|
2006-03-12 09:13:49 +00:00
|
|
|
unsigned StoreSize[4];
|
|
|
|
unsigned NumStores;
|
2006-03-07 06:32:48 +00:00
|
|
|
|
|
|
|
public:
|
2006-03-12 09:13:49 +00:00
|
|
|
PPCHazardRecognizer970(const TargetInstrInfo &TII);
|
2009-01-15 22:18:12 +00:00
|
|
|
virtual HazardType getHazardType(SUnit *SU);
|
|
|
|
virtual void EmitInstruction(SUnit *SU);
|
2006-03-07 06:32:48 +00:00
|
|
|
virtual void AdvanceCycle();
|
|
|
|
|
|
|
|
private:
|
|
|
|
/// EndDispatchGroup - Called when we are finishing a new dispatch group.
|
|
|
|
///
|
|
|
|
void EndDispatchGroup();
|
|
|
|
|
|
|
|
/// GetInstrType - Classify the specified powerpc opcode according to its
|
|
|
|
/// pipeline.
|
2006-03-12 09:13:49 +00:00
|
|
|
PPCII::PPC970_Unit GetInstrType(unsigned Opcode,
|
2006-03-13 05:20:04 +00:00
|
|
|
bool &isFirst, bool &isSingle,bool &isCracked,
|
2006-03-12 09:13:49 +00:00
|
|
|
bool &isLoad, bool &isStore);
|
2006-03-07 06:32:48 +00:00
|
|
|
|
|
|
|
bool isLoadOfStoredAddress(unsigned LoadSize,
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue Ptr1, SDValue Ptr2) const;
|
2006-03-07 06:32:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
2006-03-07 16:19:46 +00:00
|
|
|
#endif
|
|
|
|
|