schedule.java

来自「一种将c高级语言转化给VHDL的编译器」· Java 代码 · 共 595 行 · 第 1/2 页

JAVA
595
字号
    }    else if(Getelementptr.conforms(inst)){      //outIsPrimal = true;      defList.add(Getelementptr.getResult(inst));      int i = 0;      while(Getelementptr.hasVal(inst, i)) {        useList.add(Getelementptr.getValOperand(inst, i));	i++;      }    }    else    {      int numDefs = inst.getNumberOfDefs();      for(int i = 0; i < numDefs; i++) {	op_Operand = inst.getOperand(i);	if(op_Operand != null) {	  defList.add(op_Operand);	  if(op_Operand.isPrimal())	    outIsPrimal = true;	}      }      int total = inst.getNumberOfOperands();      for(int i = numDefs; i < total; i++) {	op_Operand = inst.getOperand(i);	if(op_Operand != null)	  useList.add(op_Operand);      }    }        //ignore predicates when scheduling unless, ignorePredsNicht is true or     //one of the defs is a primal    if(outIsPrimal || ignorePredsNicht) {      BooleanEquation predTmp = inst.getPredicate();      if(predTmp != null) {	LinkedList BoolsTmp = predTmp.listBooleanOperands();	for (Iterator itin = ((LinkedList)BoolsTmp.clone()).iterator(); 	     itin.hasNext(); ) {	  op_Operand = (Operand)itin.next();	  useList.add(op_Operand);	}      }    }  }     //method: getDataBase  //return the database, in case this might be useful someday...  /** obsolete   *    * @return NA   */  public ArrayList getDataBase() {return _instList;}     /** checks if at least one input to an instruction is primal   *    * @param uselist list of all operands used by an instruction   * @return true if at least one input is primal; false if all inputs are     *	  nonprimal   */  public boolean insArePrimalsOrOtherBlckDefnd(ArrayList uselist) {    boolean isPrimal = false;    for (Iterator its = ((ArrayList)uselist.clone()).iterator();       its.hasNext(); ) {      Operand op_Operand = (Operand)its.next();      if(op_Operand != null) {	if(op_Operand.isPrimal())	  isPrimal = true;	      }    }    return isPrimal;  }    /** checks that all defs are not primal   *    * @param deflist list of defs for an instruction   * @return true if no output is primal; false if at least one output is      *	  primal   */  public boolean areOutsNotPrimals(ArrayList deflist) {    boolean isNotPrimal = true;    for (Iterator its = ((ArrayList)deflist.clone()).iterator();       its.hasNext(); ) {      Operand op_Operand = (Operand)its.next();      if(op_Operand != null)	if(op_Operand.isPrimal())	  isNotPrimal = false;    }    return isNotPrimal;  }    /** checks if all inputs to an instruction are constants   *    * @param uselist list of inputs for an instruction   * @return true if all inputs are constant; false if at least one input is   *	  not constant   */  public boolean inputsAllConsts(ArrayList uselist) {    boolean isConst = true;    for (Iterator its = ((ArrayList)uselist.clone()).iterator();       its.hasNext(); ) {      Operand op_Operand = (Operand)its.next();      if(op_Operand != null)	if(!(op_Operand.isConstant())) 	  isConst = false;    }    return isConst;  }    /** checks if all inputs to an instruction are primal or constant or a type    *  or a TRUE or FALSE   *    * @param uselist list of all operands used by an instruction   * @return true if all inputs are is one of the above listed operands;       *	  false if at least one input is not   */  public boolean inputsAllPrimalsOrConsts(ArrayList uselist) {    boolean isAllPrimal = true;    for (Iterator its = ((ArrayList)uselist.clone()).iterator();       its.hasNext(); ) {      Operand op_Operand = (Operand)its.next();      if(op_Operand != null)	if((!(op_Operand.isPrimal()))&&(!(op_Operand.isConstant()))&&           (!(op_Operand.isType()))&&(op_Operand != BooleanOperand.TRUE)&&             (op_Operand != BooleanOperand.FALSE))	  isAllPrimal = false;    }    return isAllPrimal;  }    /** checks if all inputs to an instruction are primal   *    * @param uselist list of all operands used by an instruction   * @return true if all inputs are primal; false if at least input is         *	  nonprimal   */  public boolean inputsAllPrimals(ArrayList uselist) {    boolean isAllPrimal = true;    for (Iterator its = ((ArrayList)uselist.clone()).iterator();       its.hasNext(); ) {      Operand op_Operand = (Operand)its.next();      if(op_Operand != null)	if(!(op_Operand.isPrimal()))	  isAllPrimal = false;    }    return isAllPrimal;  }    /** Given the uselist of a possible child instruction and the deflist for a    *  possible parent instruction, check if the parent instruction could be    *  the predecessor of the child.   *    * @param uselist list of all operands used by the possible child    *	 instruction   * @param deflist list of defs for the possible parent instruction   * @return true if the one instruction is a predecessor of the another   */  public boolean isInstrPred(ArrayList uselist, ArrayList deflist) {    boolean isPred = false;    for (Iterator its = ((ArrayList)deflist.clone()).iterator();       its.hasNext(); ) {      Operand op_Operand = (Operand)its.next();      if(op_Operand != null)	if(uselist.contains(op_Operand)) {	isPred = true;	continue;      }    }    return isPred;  }    /** this method has something to do with the resource limitations checking,    *  but unfortunately, I can't remember exactly what.   *    * @param instrList list of instructions from the hyperblock   * @param maxRank time to search for matches with in the       *	 instruction list   * @return true if there are no times equal to maxRank   */  public boolean noDuplicateTimes(HashSet instrList, float maxRank) {    for (Iterator its = ((HashSet)instrList.clone()).iterator();       its.hasNext(); ) {      Instruction inst = (Instruction)its.next();      if(inst.getExecTime() == maxRank)	return false;	          }    return true;       }      /** The execution time for a given instruction.  Normally, this function    *  just calls the Instruction method, getRunLength, but in the case of    *  AStores or ALoads, the latency saved in the chip information file is    *  used instead.   *    * @param inst instruction   * @param chipInfo contains chip and board information such as      *	 where arrays have been stored to memory and the availability of      *	 hardware.   * @return latency for a given operation   */  public float getInstrRunLength(Instruction inst, ChipDef chipInfo) {    float latency = inst.getRunLength();    if(!GlobalOptions.packInstructions && latency<1)      latency=1;    //System.out.println(" instr "+inst+" latency "+latency);    return latency;  }    /** sort lists of instructions or hashsets...   *    * @param o_list a list which needs sorting   */  /*public void sort(ArrayList o_list) {    class DoubleCompare implements Comparator {            /** compare function used by sort.  sorts hashmaps based on their size        *  and instructions in a list depending on the size of their execution        *  windows.         *        * @param o1 input 1       * @param o2 input 2       * @return -1, 0, or 1 depending on if o1 or o2 is greater or if they are        *     equal             public int compare(Object o1, Object o2) {		if (o1 instanceof HashSet	      	&& o2 instanceof HashSet) {	     	  HashSet p1 = (HashSet)o1;	     	  HashSet p2 = (HashSet)o2;	     	  if( p1.size() < p2.size()) {  	  	    return -1;  		    } else if( p1.size() > p2.size() ){ 	   	    return 1;	      	    } else {			    return 0;	       	  }	   	} else if (o1 instanceof Instruction		 	&& o2 instanceof Instruction) { 	 	  Instruction p1 = (Instruction)o1;	     	  Instruction p2 = (Instruction)o2;	     	  if( ((Float)(_windowMaxGlobal.get(p1))).floatValue()              - ((Float)(_windowMinGlobal.get(p1))).floatValue() <	      ((Float)(_windowMaxGlobal.get(p2))).floatValue()              - ((Float)(_windowMinGlobal.get(p2))).floatValue()) {	       	    return -1;  		  } else if( ((Float)(_windowMaxGlobal.get(p1))).floatValue()        	     - ((Float)(_windowMinGlobal.get(p1))).floatValue() >		     ((Float)(_windowMaxGlobal.get(p2))).floatValue()        	     - ((Float)(_windowMinGlobal.get(p2))).floatValue() ){	      	    return 1;	      	    } else {			    return 0;	       	  }	   	/*} else if (o1 instanceof Instruction  	   	&& o2 instanceof Instruction) { 	 	  Instruction p1 = (Instruction)o1;	     	  Instruction p2 = (Instruction)o2;	     	  if (p1.getExecClkCnt() > p2.getExecClkCnt()) {	    	    return 1;	       	    } else if (p1.getExecClkCnt() < p2.getExecClkCnt()) {	     	    return -1;         	    } else {			    return 0;	       	  } 	  } else {	    	  throw new ClassCastException("Not Instruction");	  	}            }        }	         Collections.sort(o_list, new DoubleCompare());    }*/  /*private void sort(ArrayList o_list) {    class DoubleCompare implements Comparator {            public int compare(Object o1, Object o2) {		if (o1 instanceof Instruction		  	&& o2 instanceof Instruction) { 	 	  Instruction p1 = (Instruction)o1;	     	  Instruction p2 = (Instruction)o2;	     	  if (((Integer)(((ArrayList)(compareInfo.get(p1))).get(0))).intValue() > ((Integer)(((ArrayList)(compareInfo.get(p2))).get(0))).intValue()) {  	  	    return 1;	       	    } else if (((Integer)(((ArrayList)(compareInfo.get(p1))).get(0))).intValue() < ((Integer)(((ArrayList)(compareInfo.get(p2))).get(0))).intValue()) { 	   	    return -1;         	    } else {			    return 0;	       	  }	   	  } else {	    	  throw new ClassCastException("Not Instruction");	  	}            }        }	         Collections.sort(o_list, new DoubleCompare());    }*/}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?