LLVM API Documentation
00001 //=- llvm/CodeGen/ExactHazardRecognizer.h - Scheduling Support -*- C++ -*-=// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file implements the ExactHazardRecognizer class, which 00011 // implements hazard-avoidance heuristics for scheduling, based on the 00012 // scheduling itineraries specified for the target. 00013 // 00014 //===----------------------------------------------------------------------===// 00015 00016 #ifndef LLVM_CODEGEN_EXACTHAZARDRECOGNIZER_H 00017 #define LLVM_CODEGEN_EXACTHAZARDRECOGNIZER_H 00018 00019 #include "llvm/CodeGen/ScheduleHazardRecognizer.h" 00020 #include "llvm/CodeGen/ScheduleDAG.h" 00021 #include "llvm/Target/TargetInstrItineraries.h" 00022 00023 namespace llvm { 00024 class ExactHazardRecognizer : public ScheduleHazardRecognizer { 00025 // Itinerary data for the target. 00026 const InstrItineraryData &ItinData; 00027 00028 // Scoreboard to track function unit usage. Scoreboard[0] is a 00029 // mask of the FUs in use in the cycle currently being 00030 // schedule. Scoreboard[1] is a mask for the next cycle. The 00031 // Scoreboard is used as a circular buffer with the current cycle 00032 // indicated by ScoreboardHead. 00033 unsigned *Scoreboard; 00034 00035 // The maximum number of cycles monitored by the Scoreboard. This 00036 // value is determined based on the target itineraries to ensure 00037 // that all hazards can be tracked. 00038 unsigned ScoreboardDepth; 00039 00040 // Indices into the Scoreboard that represent the current cycle. 00041 unsigned ScoreboardHead; 00042 00043 // Return the scoreboard index to use for 'offset' cycles in the 00044 // future. 'offset' of 0 returns ScoreboardHead. 00045 unsigned getFutureIndex(unsigned offset); 00046 00047 // Print the scoreboard. 00048 void dumpScoreboard(); 00049 00050 public: 00051 ExactHazardRecognizer(const InstrItineraryData &ItinData); 00052 ~ExactHazardRecognizer(); 00053 00054 virtual HazardType getHazardType(SUnit *SU); 00055 virtual void Reset(); 00056 virtual void EmitInstruction(SUnit *SU); 00057 virtual void AdvanceCycle(); 00058 }; 00059 } 00060 00061 #endif