diff --git a/src/simulator/emulatorinterface/RunnableThread.java b/src/simulator/emulatorinterface/RunnableThread.java index abc07a2..c8bd576 100755 --- a/src/simulator/emulatorinterface/RunnableThread.java +++ b/src/simulator/emulatorinterface/RunnableThread.java @@ -204,7 +204,8 @@ public class RunnableThread implements Encoding, Runnable { iNew.setDestinationOperandMemValue(Long.parseLong(splited[i+2])); iNew.setBranchTargetAddress(Long.parseLong(splited[i+3])); iNew.setBranchTaken(Boolean.parseBoolean(splited[i+4])); - iNew.setPredicateAndNotExecuted(Boolean.parseBoolean(splited[i+7])); + iNew.setPredicate(Boolean.parseBoolean(splited[i+7])); + iNew.setPredicateAndNotExecuted(Boolean.parseBoolean(splited[i+8])); //iNew.setSerialNo(Long.parseLong(splited[i+6])); } } diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalLoop.java b/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalLoop.java index 871a85e..11f5638 100644 --- a/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalLoop.java +++ b/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalLoop.java @@ -41,16 +41,20 @@ public class ConditionalLoop implements X86StaticInstructionHandler Operand counterRegister = Registers.getCounterRegister(); //cx=cx-1 - instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(counterRegister, - Registers.getEFlagsRegister(), counterRegister)); + Instruction newInstruction1 = Instruction.getIntALUInstruction(counterRegister, + Registers.getEFlagsRegister(), counterRegister); + newInstruction1.setPredicate(true); + instructionArrayList.appendInstruction(newInstruction1); //Perform a conditional jump - instructionArrayList.appendInstruction(Instruction.getBranchInstruction(operand1, Registers.getEFlagsRegister())); + Instruction newInstruction2 = Instruction.getBranchInstruction(operand1, Registers.getEFlagsRegister()); + newInstruction2.setPredicate(true); + instructionArrayList.appendInstruction(newInstruction2); } else { - misc.Error.invalidOperation("Loop", operand1, operand2, operand3); + misc.Error.invalidOperation("Conditional Loop", operand1, operand2, operand3); } } } \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalMove.java b/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalMove.java index e6b9a88..e579dbe 100755 --- a/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalMove.java +++ b/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalMove.java @@ -45,8 +45,12 @@ public class ConditionalMove implements X86StaticInstructionHandler (operand3==null)) { Operand temp = Registers.getTempIntReg(tempRegisterNum); - instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getEFlagsRegister(), operand1, temp)); - instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand2, temp, operand1)); + Instruction newInstruction1 = Instruction.getIntALUInstruction(Registers.getEFlagsRegister(), operand1, temp); + newInstruction1.setPredicate(true); + instructionArrayList.appendInstruction(newInstruction1); + Instruction newInstruction2 = Instruction.getIntALUInstruction(operand2, temp, operand1); + newInstruction2.setPredicate(true); + instructionArrayList.appendInstruction(newInstruction2); } //if operand1 = register and operand2 = memory - load @@ -55,9 +59,13 @@ public class ConditionalMove implements X86StaticInstructionHandler operand3==null) { Operand temp = Registers.getTempIntReg(tempRegisterNum); - instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getEFlagsRegister(), operand1, temp)); + Instruction newInstruction1 = Instruction.getIntALUInstruction(Registers.getEFlagsRegister(), operand1, temp); + newInstruction1.setPredicate(true); + instructionArrayList.appendInstruction(newInstruction1); Operand sourceOperand = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, true); - instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(sourceOperand, temp, operand1)); + Instruction newInstruction2 = Instruction.getIntALUInstruction(sourceOperand, temp, operand1); + newInstruction2.setPredicate(true); + instructionArrayList.appendInstruction(newInstruction2); } // //if operand1 = memory and operand2 = memory - store diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalSet.java b/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalSet.java index f002892..f81c972 100755 --- a/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalSet.java +++ b/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalSet.java @@ -18,14 +18,18 @@ public class ConditionalSet implements X86StaticInstructionHandler if((operand1.isIntegerRegisterOperand()) && operand2==null && operand3==null) { - instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getEFlagsRegister(), - operand1, operand1)); + Instruction newInstruction = Instruction.getIntALUInstruction(Registers.getEFlagsRegister(), + operand1, operand1); + newInstruction.setPredicate(true); + instructionArrayList.appendInstruction(newInstruction); } else if(operand1.isMemoryOperand()) { - instructionArrayList.appendInstruction(Instruction.getStoreInstruction(operand1, - Registers.getEFlagsRegister())); + Instruction newInstruction = Instruction.getStoreInstruction(operand1, + Registers.getEFlagsRegister()); + newInstruction.setPredicate(true); + instructionArrayList.appendInstruction(newInstruction); } else diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/InstructionClassTable.java b/src/simulator/emulatorinterface/translator/x86/instruction/InstructionClassTable.java index 3805322..3471674 100755 --- a/src/simulator/emulatorinterface/translator/x86/instruction/InstructionClassTable.java +++ b/src/simulator/emulatorinterface/translator/x86/instruction/InstructionClassTable.java @@ -599,7 +599,7 @@ public class InstructionClassTable { for (int i = 0; i < loop.length; i++) instructionClassTable.put(loop[i], InstructionClass.UNCONDITIONAL_LOOP); - String conditionalLoop[] = "loop|loopw|loopd|loope|looped|loopew|loopne|loopned|loopnew|loopz|loopzd|loopzw|loopnz|loopnzd|loopnzw" + String conditionalLoop[] = "loopw|loopd|loope|looped|loopew|loopne|loopned|loopnew|loopz|loopzd|loopzw|loopnz|loopnzd|loopnzw" .split("\\|"); for (int i = 0; i < conditionalLoop.length; i++) instructionClassTable.put(conditionalLoop[i], InstructionClass.CONDITIONAL_LOOP); diff --git a/src/simulator/generic/Instruction.java b/src/simulator/generic/Instruction.java index f5c7a80..06cee3b 100755 --- a/src/simulator/generic/Instruction.java +++ b/src/simulator/generic/Instruction.java @@ -44,6 +44,7 @@ public class Instruction implements Serializable private long serialNo; private int threadID; + private boolean isPredicate; private boolean isPredicateAndNotExecuted; public Instruction() @@ -51,6 +52,7 @@ public class Instruction implements Serializable this.sourceOperand1 = null; this.sourceOperand2 = null; this.destinationOperand = null; + isPredicate = false; isPredicateAndNotExecuted = false; } @@ -60,6 +62,7 @@ public class Instruction implements Serializable this.sourceOperand1 = null; this.sourceOperand2 = null; this.destinationOperand = null; + isPredicate = false; isPredicateAndNotExecuted = false; } @@ -70,6 +73,7 @@ public class Instruction implements Serializable this.sourceOperand1 = sourceOperand1; this.sourceOperand2 = sourceOperand2; this.destinationOperand = destinationOperand; + isPredicate = false; isPredicateAndNotExecuted = false; } @@ -80,6 +84,7 @@ public class Instruction implements Serializable this.sourceOperand1 = sourceOperand1; this.sourceOperand2 = sourceOperand2; this.destinationOperand = destinationOperand; + isPredicate = false; isPredicateAndNotExecuted = false; } @@ -130,6 +135,7 @@ public class Instruction implements Serializable this.serialNo = sourceInstruction.serialNo; this.threadID = sourceInstruction.threadID; + this.isPredicate = sourceInstruction.isPredicate; this.isPredicateAndNotExecuted = sourceInstruction.isPredicateAndNotExecuted; } @@ -500,6 +506,14 @@ public class Instruction implements Serializable this.destinationOperandMemValue = destinationOperandMemValue; } + public boolean isPredicate() { + return isPredicate; + } + + public void setPredicate(boolean isPredicate) { + this.isPredicate = isPredicate; + } + public boolean isPredicateAndNotExecuted() { return isPredicateAndNotExecuted; } diff --git a/src/simulator/pipeline/outoforder/ReorderBuffer.java b/src/simulator/pipeline/outoforder/ReorderBuffer.java index 686f39f..371c858 100755 --- a/src/simulator/pipeline/outoforder/ReorderBuffer.java +++ b/src/simulator/pipeline/outoforder/ReorderBuffer.java @@ -448,7 +448,7 @@ public class ReorderBuffer extends SimulationElement{ else bw.write(" null null null"); bw.write(" "+tmp.getSourceOperand1MemValue()+" "+ tmp.getSourceOperand2MemValue()+" "+tmp.getDestinationOperandMemValue()+" "+ - tmp.getBranchTargetAddress()+" "+tmp.isBranchTaken()+" "+tmp.getThreadID()+" "+tmp.getSerialNo()+" "+tmp.isPredicateAndNotExecuted()+"\n"); + tmp.getBranchTargetAddress()+" "+tmp.isBranchTaken()+" "+tmp.getThreadID()+" "+tmp.getSerialNo()+" "+tmp.isPredicate()+" "+tmp.isPredicateAndNotExecuted()+"\n"); } catch(Exception e) {