//===-- PPCHazardRecognizers.cpp - PowerPC Hazard Recognizer Impls --------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file implements hazard recognizers for scheduling on PowerPC processors. // //===----------------------------------------------------------------------===// #include "PPCHazardRecognizers.h" #include "PPCInstrInfo.h" #include "PPCSubtarget.h" #include "llvm/CodeGen/ScheduleDAG.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" usingnamespacellvm; #define DEBUG_TYPE … bool PPCDispatchGroupSBHazardRecognizer::isLoadAfterStore(SUnit *SU) { … } bool PPCDispatchGroupSBHazardRecognizer::isBCTRAfterSet(SUnit *SU) { … } // FIXME: Remove this when we don't need this: namespace llvm { namespace PPC { extern int getNonRecordFormOpcode(uint16_t); } } // FIXME: A lot of code in PPCDispatchGroupSBHazardRecognizer is P7 specific. bool PPCDispatchGroupSBHazardRecognizer::mustComeFirst(const MCInstrDesc *MCID, unsigned &NSlots) { … } ScheduleHazardRecognizer::HazardType PPCDispatchGroupSBHazardRecognizer::getHazardType(SUnit *SU, int Stalls) { … } bool PPCDispatchGroupSBHazardRecognizer::ShouldPreferAnother(SUnit *SU) { … } unsigned PPCDispatchGroupSBHazardRecognizer::PreEmitNoops(SUnit *SU) { … } void PPCDispatchGroupSBHazardRecognizer::EmitInstruction(SUnit *SU) { … } void PPCDispatchGroupSBHazardRecognizer::AdvanceCycle() { … } void PPCDispatchGroupSBHazardRecognizer::RecedeCycle() { … } void PPCDispatchGroupSBHazardRecognizer::Reset() { … } void PPCDispatchGroupSBHazardRecognizer::EmitNoop() { … } //===----------------------------------------------------------------------===// // PowerPC 970 Hazard Recognizer // // This models the dispatch group formation of the PPC970 processor. Dispatch // groups are bundles of up to five instructions that can contain various mixes // of instructions. The PPC970 can dispatch a peak of 4 non-branch and one // branch instruction per-cycle. // // There are a number of restrictions to dispatch group formation: some // instructions can only be issued in the first slot of a dispatch group, & some // instructions fill an entire dispatch group. Additionally, only branches can // issue in the 5th (last) slot. // // Finally, there are a number of "structural" hazards on the PPC970. These // conditions cause large performance penalties due to misprediction, recovery, // and replay logic that has to happen. These cases include setting a CTR and // branching through it in the same dispatch group, and storing to an address, // then loading from the same address within a dispatch group. To avoid these // conditions, we insert no-op instructions when appropriate. // // FIXME: This is missing some significant cases: // 1. Modeling of microcoded instructions. // 2. Handling of serialized operations. // 3. Handling of the esoteric cases in "Resource-based Instruction Grouping". // PPCHazardRecognizer970::PPCHazardRecognizer970(const ScheduleDAG &DAG) : … { … } void PPCHazardRecognizer970::EndDispatchGroup() { … } PPCII::PPC970_Unit PPCHazardRecognizer970::GetInstrType(unsigned Opcode, bool &isFirst, bool &isSingle, bool &isCracked, bool &isLoad, bool &isStore) { … } /// isLoadOfStoredAddress - If we have a load from the previously stored pointer /// as indicated by StorePtr1/StorePtr2/StoreSize, return true. bool PPCHazardRecognizer970:: isLoadOfStoredAddress(uint64_t LoadSize, int64_t LoadOffset, const Value *LoadValue) const { … } /// getHazardType - We return hazard for any non-branch instruction that would /// terminate the dispatch group. We turn NoopHazard for any /// instructions that wouldn't terminate the dispatch group that would cause a /// pipeline flush. ScheduleHazardRecognizer::HazardType PPCHazardRecognizer970:: getHazardType(SUnit *SU, int Stalls) { … } void PPCHazardRecognizer970::EmitInstruction(SUnit *SU) { … } void PPCHazardRecognizer970::AdvanceCycle() { … } void PPCHazardRecognizer970::Reset() { … }