LLVM API Documentation
00001 //=- llvm/CodeGen/ScheduleHazardRecognizer.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 ScheduleHazardRecognizer class, which implements 00011 // hazard-avoidance heuristics for scheduling. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_CODEGEN_SCHEDULEHAZARDRECOGNIZER_H 00016 #define LLVM_CODEGEN_SCHEDULEHAZARDRECOGNIZER_H 00017 00018 namespace llvm { 00019 00020 class SUnit; 00021 00022 /// HazardRecognizer - This determines whether or not an instruction can be 00023 /// issued this cycle, and whether or not a noop needs to be inserted to handle 00024 /// the hazard. 00025 class ScheduleHazardRecognizer { 00026 public: 00027 virtual ~ScheduleHazardRecognizer(); 00028 00029 enum HazardType { 00030 NoHazard, // This instruction can be emitted at this cycle. 00031 Hazard, // This instruction can't be emitted at this cycle. 00032 NoopHazard // This instruction can't be emitted, and needs noops. 00033 }; 00034 00035 /// getHazardType - Return the hazard type of emitting this node. There are 00036 /// three possible results. Either: 00037 /// * NoHazard: it is legal to issue this instruction on this cycle. 00038 /// * Hazard: issuing this instruction would stall the machine. If some 00039 /// other instruction is available, issue it first. 00040 /// * NoopHazard: issuing this instruction would break the program. If 00041 /// some other instruction can be issued, do so, otherwise issue a noop. 00042 virtual HazardType getHazardType(SUnit *) { 00043 return NoHazard; 00044 } 00045 00046 /// EmitInstruction - This callback is invoked when an instruction is 00047 /// emitted, to advance the hazard state. 00048 virtual void EmitInstruction(SUnit *) {} 00049 00050 /// AdvanceCycle - This callback is invoked when no instructions can be 00051 /// issued on this cycle without a hazard. This should increment the 00052 /// internal state of the hazard recognizer so that previously "Hazard" 00053 /// instructions will now not be hazards. 00054 virtual void AdvanceCycle() {} 00055 00056 /// EmitNoop - This callback is invoked when a noop was added to the 00057 /// instruction stream. 00058 virtual void EmitNoop() { 00059 // Default implementation: count it as a cycle. 00060 AdvanceCycle(); 00061 } 00062 }; 00063 00064 } 00065 00066 #endif