📄 dependenceflowgraph.java
字号:
Float fstOp = null; Float scndOp = null; if(firstOp.isFloatConstant()) fstOp = new Float(((FloatConstantOperand)firstOp).getValue()); else if(firstOp.isDoubleConstant()) fstOp = new Float(((DoubleConstantOperand)firstOp).getValue()); else if(firstOp.isIntConstant()) fstOp = new Float(((IntConstantOperand)firstOp).getValue()); else if(firstOp.isLongConstant()) fstOp = new Float(((LongConstantOperand)firstOp).getValue()); if(secndOp.isFloatConstant()) scndOp = new Float(((FloatConstantOperand)secndOp).getValue()); else if(secndOp.isDoubleConstant()) scndOp = new Float(((DoubleConstantOperand)secndOp).getValue()); else if(secndOp.isIntConstant()) scndOp = new Float(((IntConstantOperand)secndOp).getValue()); else if(secndOp.isLongConstant()) scndOp = new Float(((LongConstantOperand)secndOp).getValue()); float value; if(fstOp == null && scndOp == null) { /*System.out.println("fst and 2nd ops null " + inst); System.out.println("fst ops " + firstOp); System.out.println("fst ops " + fstOp); System.out.println("2nd ops " + scndOp); System.out.println("2nd ops " + secndOp);*/ return true; } value = fstOp == null ? scndOp.floatValue() : fstOp.floatValue(); if(opName.matches(".*[aA][dD][dD].*")) { aload0 += value; } else if(opName.matches(".*[sS][uU][bB].*")) { aload0 = fstOp == null ? aload0-value : value-aload0; //aload0 -= value; } else if(opName.matches(".*[mM][uU][lL].*")) { aload0 *= value; } else if(opName.matches(".*[dD][iI][vV].*")) { aload0 = fstOp == null ? aload0/value : value/aload0; //aload0 /= value; } else if(opName.matches(".*[sS][hH][lL].*")) { aload0 *= Math.pow(2, value); } else if(opName.matches(".*[sS][hH][rR].*")) { aload0 *= Math.pow(1/2, value); } } else { return true; //System.out.println("else " + inst); } } System.out.println("aload0 " + aload0 + " loopEnd0 " + loopEnd0); float astore0 = loopEnd0; for (Iterator it2 = loopEndToStore.iterator(); it2.hasNext();) { DependenceFlowNode nodeTmp = (DependenceFlowNode)it2.next(); Instruction inst = nodeTmp.getInstruction(); if(inst == null) continue; //System.out.println("inst " + inst); if((Cast.conforms(inst))|| (Store.conforms(inst))|| (Load.conforms(inst))|| (Getelementptr.conforms(inst))) continue; else if(Binary.conforms(inst)) { String opName = inst.operator().toString(); Operand firstOp = Binary.getVal1(inst); Operand secndOp = Binary.getVal2(inst); Float fstOp = null; Float scndOp = null; if(firstOp.isFloatConstant()) fstOp = new Float(((FloatConstantOperand)firstOp).getValue()); else if(firstOp.isDoubleConstant()) fstOp = new Float(((DoubleConstantOperand)firstOp).getValue()); else if(firstOp.isIntConstant()) fstOp = new Float(((IntConstantOperand)firstOp).getValue()); else if(firstOp.isLongConstant()) fstOp = new Float(((LongConstantOperand)firstOp).getValue()); if(secndOp.isFloatConstant()) scndOp = new Float(((FloatConstantOperand)secndOp).getValue()); else if(secndOp.isDoubleConstant()) scndOp = new Float(((DoubleConstantOperand)secndOp).getValue()); else if(secndOp.isIntConstant()) scndOp = new Float(((IntConstantOperand)secndOp).getValue()); else if(secndOp.isLongConstant()) scndOp = new Float(((LongConstantOperand)secndOp).getValue()); float value; if(fstOp == null && scndOp == null) { /*System.out.println("fst and 2nd ops null " + inst); System.out.println("fst ops " + firstOp); System.out.println("fst ops " + fstOp); System.out.println("2nd ops " + scndOp); System.out.println("2nd ops " + secndOp);*/ return true; } value = fstOp == null ? scndOp.floatValue() : fstOp.floatValue(); if(opName.matches(".*[aA][dD][dD].*")) { astore0 += value; } else if(opName.matches(".*[sS][uU][bB].*")) { astore0 = fstOp == null ? astore0-value : value-astore0; //astore0 -= value; } else if(opName.matches(".*[mM][uU][lL].*")) { astore0 *= value; } else if(opName.matches(".*[dD][iI][vV].*")) { astore0 = fstOp == null ? astore0/value : value/astore0; //astore0 /= value; } else if(opName.matches(".*[sS][hH][lL].*")) { astore0 *= Math.pow(2, value); } else if(opName.matches(".*[sS][hH][rR].*")) { astore0 *= Math.pow(1/2, value); } } else { return true; //System.out.println("else " + inst); } } System.out.println("astore0 " + astore0 + " loopEnd0 " + loopEnd0); float start1 = loopEnd0; float loopEnd1 = start1; for (Iterator it2 = backEdgeToLoopEnd.iterator(); it2.hasNext();) { DependenceFlowNode nodeTmp = (DependenceFlowNode)it2.next(); Instruction inst = nodeTmp.getInstruction(); if(inst == null) continue; //System.out.println("inst " + inst); if((Cast.conforms(inst))|| (Store.conforms(inst))|| (Load.conforms(inst))|| (Getelementptr.conforms(inst))) continue; else if(Binary.conforms(inst)) { String opName = inst.operator().toString(); Operand firstOp = Binary.getVal1(inst); Operand secndOp = Binary.getVal2(inst); Float fstOp = null; Float scndOp = null; if(firstOp.isFloatConstant()) fstOp = new Float(((FloatConstantOperand)firstOp).getValue()); else if(firstOp.isDoubleConstant()) fstOp = new Float(((DoubleConstantOperand)firstOp).getValue()); else if(firstOp.isIntConstant()) fstOp = new Float(((IntConstantOperand)firstOp).getValue()); else if(firstOp.isLongConstant()) fstOp = new Float(((LongConstantOperand)firstOp).getValue()); if(secndOp.isFloatConstant()) scndOp = new Float(((FloatConstantOperand)secndOp).getValue()); else if(secndOp.isDoubleConstant()) scndOp = new Float(((DoubleConstantOperand)secndOp).getValue()); else if(secndOp.isIntConstant()) scndOp = new Float(((IntConstantOperand)secndOp).getValue()); else if(secndOp.isLongConstant()) scndOp = new Float(((LongConstantOperand)secndOp).getValue()); float value; if(fstOp == null && scndOp == null) { /*System.out.println("fst and 2nd ops null " + inst); System.out.println("fst ops " + firstOp); System.out.println("fst ops " + fstOp); System.out.println("2nd ops " + scndOp); System.out.println("2nd ops " + secndOp);*/ return true; } value = fstOp == null ? scndOp.floatValue() : fstOp.floatValue(); if(opName.matches(".*[aA][dD][dD].*")) { loopEnd1 += value; } else if(opName.matches(".*[sS][uU][bB].*")) { loopEnd1 = fstOp == null ? loopEnd1-value : value-loopEnd1; //loopEnd1 -= value; } else if(opName.matches(".*[mM][uU][lL].*")) { loopEnd1 *= value; } else if(opName.matches(".*[dD][iI][vV].*")) { loopEnd1 = fstOp == null ? loopEnd1/value : value/loopEnd1; //loopEnd1 /= value; } else if(opName.matches(".*[sS][hH][lL].*")) { loopEnd1 *= Math.pow(2, value); } else if(opName.matches(".*[sS][hH][rR].*")) { loopEnd1 *= Math.pow(1/2, value); } } else { return true; //System.out.println("else " + inst); } } System.out.println("start1 " + start1 + " loopEnd1 " + loopEnd1); float aload1 = loopEnd1; for (Iterator it2 = loopEndToLoad.iterator(); it2.hasNext();) { DependenceFlowNode nodeTmp = (DependenceFlowNode)it2.next(); Instruction inst = nodeTmp.getInstruction(); if(inst == null) continue; //System.out.println("inst " + inst); if((Cast.conforms(inst))|| (Store.conforms(inst))|| (Load.conforms(inst))|| (Getelementptr.conforms(inst))) continue; else if(Binary.conforms(inst)) { String opName = inst.operator().toString(); Operand firstOp = Binary.getVal1(inst); Operand secndOp = Binary.getVal2(inst); Float fstOp = null; Float scndOp = null; if(firstOp.isFloatConstant()) fstOp = new Float(((FloatConstantOperand)firstOp).getValue()); else if(firstOp.isDoubleConstant()) fstOp = new Float(((DoubleConstantOperand)firstOp).getValue()); else if(firstOp.isIntConstant()) fstOp = new Float(((IntConstantOperand)firstOp).getValue()); else if(firstOp.isLongConstant()) fstOp = new Float(((LongConstantOperand)firstOp).getValue()); if(secndOp.isFloatConstant()) scndOp = new Float(((FloatConstantOperand)secndOp).getValue()); else if(secndOp.isDoubleConstant()) scndOp = new Float(((DoubleConstantOperand)secndOp).getValue()); else if(secndOp.isIntConstant()) scndOp = new Float(((IntConstantOperand)secndOp).getValue()); else if(secndOp.isLongConstant()) scndOp = new Float(((LongConstantOperand)secndOp).getValue()); float value; if(fstOp == null && scndOp == null) { /*System.out.println("fst and 2nd ops null " + inst); System.out.println("fst ops " + firstOp); System.out.println("fst ops " + fstOp); System.out.println("2nd ops " + scndOp); System.out.println("2nd ops " + secndOp);*/ return true; } value = fstOp == null ? scndOp.floatValue() : fstOp.floatValue(); if(opName.matches(".*[aA][dD][dD].*")) { aload1 += value; } else if(opName.matches(".*[sS][uU][bB].*")) { aload1 = fstOp == null ? aload1-value : value-aload1; //aload1 -= value; } else if(opName.matches(".*[mM][uU][lL].*")) { aload1 *= value; } else if(opName.matches(".*[dD][iI][vV].*")) { aload1 = fstOp == null ? aload1/value : value/aload1; //aload1 /= value; } else if(opName.matches(".*[sS][hH][lL].*")) { aload1 *= Math.pow(2, value); } else if(opName.matches(".*[sS][hH][rR].*")) { aload1 *= Math.pow(1/2, value); } } else { return true; //System.out.println("else " + inst); } } System.out.println("aload1 " + aload1 + " loopEnd1 " + loopEnd1); float astore1 = loopEnd1; for (Iterator it2 = loopEndToStore.iterator(); it2.hasNext();) { DependenceFlowNode nodeTmp = (DependenceFlowNode)it2.next(); Instruction inst = nodeTmp.getInstruction(); if(inst == null) continue; //System.out.println("inst " + inst); if((Cast.conforms(inst))|| (Store.conforms(inst))|| (Load.conforms(inst))|| (Getelementptr.conforms(inst))) continue; else if(Binary.conforms(inst)) { String opName = inst.operator().toString(); Operand firstOp = Binary.getVal1(inst); Operand secndOp = Binary.getVal2(inst); Float fstOp = null; Float scndOp = null; if(firstOp.isFloatConstant()) fstOp = new Float(((FloatConstantOperand)firstOp).getValue()); else if(firstOp.isDoubleConstant()) fstOp = new Float(((DoubleConstantOperand)firstOp).getValue()); else if(firstOp.isIntConstant()) fstOp = new Float(((IntConstantOperand)firstOp).getValue()); else if(firstOp.isLongConstant()) fstOp = new Float(((LongConstantOperand)firstOp).getValue()); if(secndOp.isFloatConstant()) scndOp = new Float(((FloatConstantOperand)secndOp).getValue());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -