From 271f715f7c9da045047a100fe4199558df1e8e28 Mon Sep 17 00:00:00 2001 From: "rajshekar.k" Date: Wed, 11 Aug 2021 16:01:08 +0530 Subject: [PATCH] more bugs fixes in the translator --- .../translator/x86/instruction/FloatMove.java | 8 +++++++- .../translator/x86/instruction/InstructionClassTable.java | 8 ++++---- .../translator/x86/instruction/IntegerMove.java | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/FloatMove.java b/src/simulator/emulatorinterface/translator/x86/instruction/FloatMove.java index 7190b1e..6ca07f6 100644 --- a/src/simulator/emulatorinterface/translator/x86/instruction/FloatMove.java +++ b/src/simulator/emulatorinterface/translator/x86/instruction/FloatMove.java @@ -40,7 +40,7 @@ public class FloatMove implements X86StaticInstructionHandler { //if operand1 is a register and operand2 is a register/immediate, we will use normal move operation if( (operand1.isIntegerRegisterOperand() || operand1.isFloatRegisterOperand()) && - (operand2.isIntegerRegisterOperand() || operand1.isFloatRegisterOperand() || operand2.isImmediateOperand()) && + (operand2.isIntegerRegisterOperand() || operand2.isFloatRegisterOperand() || operand2.isImmediateOperand()) && (operand3==null)) { instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(operand2, null, operand1)); @@ -65,6 +65,11 @@ public class FloatMove implements X86StaticInstructionHandler OperandTranslator.processDestinationMemoryOperand(operand2, operand1, instructionArrayList, tempRegisterNum); } + else if(operand1.isFloatRegisterOperand() && operand2.isFloatRegisterOperand() && operand3.isFloatRegisterOperand()) + { + instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(operand2, operand3, operand1)); + } + //TODO I doubt if this is a valid instruction !! Anyways found this in an object-code //operand1 can be a data-stored in memory and operand2 can be immediate/register. //first, we load the value at location into temporary register @@ -82,3 +87,4 @@ public class FloatMove implements X86StaticInstructionHandler } } } + diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/InstructionClassTable.java b/src/simulator/emulatorinterface/translator/x86/instruction/InstructionClassTable.java index 3471674..c2e88bf 100755 --- a/src/simulator/emulatorinterface/translator/x86/instruction/InstructionClassTable.java +++ b/src/simulator/emulatorinterface/translator/x86/instruction/InstructionClassTable.java @@ -513,7 +513,7 @@ public class InstructionClassTable { instructionClassTable.put(integerMoveAccumulator[i], InstructionClass.INTEGER_MOVE_ACCUMULATOR); - String floatMove[] = "movddup".split("\\|"); + String floatMove[] = "movddup|movss|vmovss|movsd|vmovsd".split("\\|"); for (int i = 0; i < floatMove.length; i++) instructionClassTable.put(floatMove[i], InstructionClass.FLOAT_MOVE); @@ -599,7 +599,7 @@ public class InstructionClassTable { for (int i = 0; i < loop.length; i++) instructionClassTable.put(loop[i], InstructionClass.UNCONDITIONAL_LOOP); - String conditionalLoop[] = "loopw|loopd|loope|looped|loopew|loopne|loopned|loopnew|loopz|loopzd|loopzw|loopnz|loopnzd|loopnzw" + String conditionalLoop[] = "loop|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); @@ -667,7 +667,7 @@ public class InstructionClassTable { for (int i = 0; i < SSEFloatDiv.length; i++) instructionClassTable.put(SSEFloatDiv[i], InstructionClass.SSE_FLOAT_DIV); - String FloatALU[] = "addss|addsd|subss|subsd|vaddss|vaddsd|vsubss|vsubsd|roundss|roundsd|vfixupimmsd|vfixupimmss|vfpclasssd|vfpclassss|vgetexpsd|vgetexpss|vgetmantss|vgetmantsd|vrangesd|vrangess|vrcp14sd|vrcp14ss|vreducesd|vreducess|vrndscalesd|vrndscaless|vscalefsd|vscalefss|minsd|vminsd|minss|vminss|cvtsi2ss|cvtsi2sd|cvtusi2ss|cvtusi2sd|cvtss2si|cvtsd2si|cvtss2usi|cvtsd2usi|cvttsi2ss|cvttsi2sd|cvttusi2ss|cvttusi2sd|cvttss2si|cvttsd2si|cvttss2usi|cvttsd2usi|vcvtsi2ss|vcvtsi2sd|vcvtusi2ss|vcvtusi2sd|vcvtss2si|vcvtsd2si|vcvtss2usi|vcvtsd2usi|vcvttsi2ss|vcvttsi2sd|vcvttusi2ss|vcvttusi2sd|vcvttss2si|vcvttsd2si|vcvttss2usi|vcvttsd2usi|cmpeqsd|vcmpeqsd|cmpltsd|vcmpltsd|cmplesd|vcmplesd|cmpunordsd|vcmpunordsd|cmpneqsd|vcmpneqsd|cmpnltsd|vcmpnltsd|cmpnlesd|vcmpnlesd|cmpordsd|vcmpordsd|vcmpeq_uqsd|vcmpngesd|vcmpngtsd|vcmpfalsesd|vcmpneq_oqsd|vcmpgesd|vcmpgtsd|vcmptruesd|vcmpeq_ossd|vcmplt_oqsd|vcmple_oqsd|vcmpunord_ssd|vcmpneq_ussd|vcmpnlt_uqsd|vcmpnle_uqsd|vcmpord_ssd|vcmpeq_ussd|vcmpnge_uqsd|vcmpngt_uqsd|vcmpfalse_ossd|vcmpneq_ossd|vcmpge_oqsd|vcmpgt_oqsd|vcmptrue_ussd|cmpeqss|vcmpeqss|cmpltss|vcmpltss|cmpless|vcmpless|cmpunordss|vcmpunordss|cmpneqss|vcmpneqss|cmpnltss|vcmpnltss|cmpnless|vcmpnless|cmpordss|vcmpordss|vcmpeq_uqss|vcmpngess|vcmpngtss|vcmpfalsess|vcmpneq_oqss|vcmpgess|vcmpgtss|vcmptruess|vcmpeq_osss|vcmplt_oqss|vcmple_oqss|vcmpunord_sss|vcmpneq_usss|vcmpnlt_uqss|vcmpnle_uqss|vcmpord_sss|vcmpeq_usss|vcmpnge_uqss|vcmpngt_uqss|vcmpfalse_osss|vcmpneq_osss|vcmpge_oqss|vcmpgt_oqss|vcmptrue_usss|movss|vmovss|movsd|vmovsd|maxsd|vmaxsd|maxss|vmaxss|minsd|vminsd|minss|vminss|cvtsd2ss|vcvtsd2ss|cvtss2sd|vcvtss2sd|cmpsd|vcmpsd".split("\\|"); + String FloatALU[] = "addss|addsd|subss|subsd|vaddss|vaddsd|vsubss|vsubsd|roundss|roundsd|vfixupimmsd|vfixupimmss|vfpclasssd|vfpclassss|vgetexpsd|vgetexpss|vgetmantss|vgetmantsd|vrangesd|vrangess|vrcp14sd|vrcp14ss|vreducesd|vreducess|vrndscalesd|vrndscaless|vscalefsd|vscalefss|minsd|vminsd|minss|vminss|cvtsi2ss|cvtsi2sd|cvtusi2ss|cvtusi2sd|cvtss2si|cvtsd2si|cvtss2usi|cvtsd2usi|cvttsi2ss|cvttsi2sd|cvttusi2ss|cvttusi2sd|cvttss2si|cvttsd2si|cvttss2usi|cvttsd2usi|vcvtsi2ss|vcvtsi2sd|vcvtusi2ss|vcvtusi2sd|vcvtss2si|vcvtsd2si|vcvtss2usi|vcvtsd2usi|vcvttsi2ss|vcvttsi2sd|vcvttusi2ss|vcvttusi2sd|vcvttss2si|vcvttsd2si|vcvttss2usi|vcvttsd2usi|cmpeqsd|vcmpeqsd|cmpltsd|vcmpltsd|cmplesd|vcmplesd|cmpunordsd|vcmpunordsd|cmpneqsd|vcmpneqsd|cmpnltsd|vcmpnltsd|cmpnlesd|vcmpnlesd|cmpordsd|vcmpordsd|vcmpeq_uqsd|vcmpngesd|vcmpngtsd|vcmpfalsesd|vcmpneq_oqsd|vcmpgesd|vcmpgtsd|vcmptruesd|vcmpeq_ossd|vcmplt_oqsd|vcmple_oqsd|vcmpunord_ssd|vcmpneq_ussd|vcmpnlt_uqsd|vcmpnle_uqsd|vcmpord_ssd|vcmpeq_ussd|vcmpnge_uqsd|vcmpngt_uqsd|vcmpfalse_ossd|vcmpneq_ossd|vcmpge_oqsd|vcmpgt_oqsd|vcmptrue_ussd|cmpeqss|vcmpeqss|cmpltss|vcmpltss|cmpless|vcmpless|cmpunordss|vcmpunordss|cmpneqss|vcmpneqss|cmpnltss|vcmpnltss|cmpnless|vcmpnless|cmpordss|vcmpordss|vcmpeq_uqss|vcmpngess|vcmpngtss|vcmpfalsess|vcmpneq_oqss|vcmpgess|vcmpgtss|vcmptruess|vcmpeq_osss|vcmplt_oqss|vcmple_oqss|vcmpunord_sss|vcmpneq_usss|vcmpnlt_uqss|vcmpnle_uqss|vcmpord_sss|vcmpeq_usss|vcmpnge_uqss|vcmpngt_uqss|vcmpfalse_osss|vcmpneq_osss|vcmpge_oqss|vcmpgt_oqss|vcmptrue_usss|maxsd|vmaxsd|maxss|vmaxss|minsd|vminsd|minss|vminss|cvtsd2ss|vcvtsd2ss|cvtss2sd|vcvtss2sd|cmpsd|vcmpsd".split("\\|"); for (int i = 0; i < FloatALU.length; i++) instructionClassTable.put(FloatALU[i], InstructionClass.FLOAT_ALU); @@ -879,4 +879,4 @@ public class InstructionClassTable { return handler; } -} \ No newline at end of file +} diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/IntegerMove.java b/src/simulator/emulatorinterface/translator/x86/instruction/IntegerMove.java index dcb253b..cf3b3be 100755 --- a/src/simulator/emulatorinterface/translator/x86/instruction/IntegerMove.java +++ b/src/simulator/emulatorinterface/translator/x86/instruction/IntegerMove.java @@ -40,7 +40,7 @@ public class IntegerMove implements X86StaticInstructionHandler { //if operand1 is a register and operand2 is a register/immediate, we will use normal move operation if( (operand1.isIntegerRegisterOperand() || operand1.isFloatRegisterOperand()) && - (operand2.isIntegerRegisterOperand() || operand1.isFloatRegisterOperand() || operand2.isImmediateOperand()) && + (operand2.isIntegerRegisterOperand() || operand2.isFloatRegisterOperand() || operand2.isImmediateOperand()) && (operand3==null)) { instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand2, null, operand1));