LLVM API Documentation

SPUHazardRecognizers.cpp

Go to the documentation of this file.
00001 //===-- SPUHazardRecognizers.cpp - Cell Hazard Recognizer Impls -----------===//
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 hazard recognizers for scheduling on Cell SPU
00011 // processors.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #define DEBUG_TYPE "sched"
00016 
00017 #include "SPUHazardRecognizers.h"
00018 #include "SPU.h"
00019 #include "SPUInstrInfo.h"
00020 #include "llvm/CodeGen/ScheduleDAG.h"
00021 #include "llvm/CodeGen/SelectionDAGNodes.h"
00022 #include "llvm/Support/Debug.h"
00023 
00024 using namespace llvm;
00025 
00026 //===----------------------------------------------------------------------===//
00027 // Cell SPU hazard recognizer
00028 //
00029 // This is the pipeline hazard recognizer for the Cell SPU processor. It does
00030 // very little right now.
00031 //===----------------------------------------------------------------------===//
00032 
00033 SPUHazardRecognizer::SPUHazardRecognizer(const TargetInstrInfo &tii) :
00034   TII(tii),
00035   EvenOdd(0)
00036 {
00037 }
00038 
00039 /// Return the pipeline hazard type encountered or generated by this
00040 /// instruction. Currently returns NoHazard.
00041 ///
00042 /// \return NoHazard
00043 ScheduleHazardRecognizer::HazardType
00044 SPUHazardRecognizer::getHazardType(SUnit *SU)
00045 {
00046   // Initial thoughts on how to do this, but this code cannot work unless the
00047   // function's prolog and epilog code are also being scheduled so that we can
00048   // accurately determine which pipeline is being scheduled.
00049 #if 0
00050   const SDNode *Node = SU->getNode()->getFlaggedMachineNode();
00051   ScheduleHazardRecognizer::HazardType retval = NoHazard;
00052   bool mustBeOdd = false;
00053 
00054   switch (Node->getOpcode()) {
00055   case SPU::LQDv16i8:
00056   case SPU::LQDv8i16:
00057   case SPU::LQDv4i32:
00058   case SPU::LQDv4f32:
00059   case SPU::LQDv2f64:
00060   case SPU::LQDr128:
00061   case SPU::LQDr64:
00062   case SPU::LQDr32:
00063   case SPU::LQDr16:
00064   case SPU::LQAv16i8:
00065   case SPU::LQAv8i16:
00066   case SPU::LQAv4i32:
00067   case SPU::LQAv4f32:
00068   case SPU::LQAv2f64:
00069   case SPU::LQAr128:
00070   case SPU::LQAr64:
00071   case SPU::LQAr32:
00072   case SPU::LQXv4i32:
00073   case SPU::LQXr128:
00074   case SPU::LQXr64:
00075   case SPU::LQXr32:
00076   case SPU::LQXr16:
00077   case SPU::STQDv16i8:
00078   case SPU::STQDv8i16:
00079   case SPU::STQDv4i32:
00080   case SPU::STQDv4f32:
00081   case SPU::STQDv2f64:
00082   case SPU::STQDr128:
00083   case SPU::STQDr64:
00084   case SPU::STQDr32:
00085   case SPU::STQDr16:
00086   case SPU::STQDr8:
00087   case SPU::STQAv16i8:
00088   case SPU::STQAv8i16:
00089   case SPU::STQAv4i32:
00090   case SPU::STQAv4f32:
00091   case SPU::STQAv2f64:
00092   case SPU::STQAr128:
00093   case SPU::STQAr64:
00094   case SPU::STQAr32:
00095   case SPU::STQAr16:
00096   case SPU::STQAr8:
00097   case SPU::STQXv16i8:
00098   case SPU::STQXv8i16:
00099   case SPU::STQXv4i32:
00100   case SPU::STQXv4f32:
00101   case SPU::STQXv2f64:
00102   case SPU::STQXr128:
00103   case SPU::STQXr64:
00104   case SPU::STQXr32:
00105   case SPU::STQXr16:
00106   case SPU::STQXr8:
00107   case SPU::RET:
00108     mustBeOdd = true;
00109     break;
00110   default:
00111     // Assume that this instruction can be on the even pipe
00112     break;
00113   }
00114 
00115   if (mustBeOdd && !EvenOdd)
00116     retval = Hazard;
00117 
00118   DOUT << "SPUHazardRecognizer EvenOdd " << EvenOdd << " Hazard " << retval << "\n";
00119   EvenOdd ^= 1;
00120   return retval;
00121 #else
00122   return NoHazard;
00123 #endif
00124 }
00125 
00126 void SPUHazardRecognizer::EmitInstruction(SUnit *SU)
00127 {
00128 }
00129 
00130 void SPUHazardRecognizer::AdvanceCycle()
00131 {
00132   DOUT << "SPUHazardRecognizer::AdvanceCycle\n";
00133 }
00134 
00135 void SPUHazardRecognizer::EmitNoop()
00136 {
00137   AdvanceCycle();
00138 }