diff --git a/src/emulator/pin/causalityTool.cpp b/src/emulator/pin/causalityTool.cpp index dae50d3..707d612 100755 --- a/src/emulator/pin/causalityTool.cpp +++ b/src/emulator/pin/causalityTool.cpp @@ -215,6 +215,18 @@ void sendTimerPacket(int tid, bool compulsory) { } } } +bool isThreadBeyondNumberOfCores(int threadID) +{ + int index; + for(index=0; index < MaxNumActiveThreads; index++) + { + if(threadMapping[index] == (unsigned int)threadID) + return false; + if(isThreadActive[index] == false) + return false; + } + return true; +} int findThreadMapping(unsigned int id) { int index; @@ -223,9 +235,10 @@ int findThreadMapping(unsigned int id) if(threadMapping[index] == id) return index; } - cout<<"FATAL ERROR : ThreadMapping cannot resolve"; - fflush(stdout); - exit(0); +// cout<<"FATAL ERROR : ThreadMapping cannot resolve " << id << endl; + return 1; +// fflush(stdout); +// exit(0); } #define cmp(a) (rtn_name->find(a) != string::npos) @@ -257,10 +270,19 @@ int findParentSegment(long parent) return index; } cout<<"FATAL ERROR--- cannot find parent\n"; - return -1; + return 0; } VOID ThreadStart(THREADID threadid, CONTEXT *ctxt, INT32 flags, VOID *v) { +cout << "threadstart() : tid = " << threadid << " " << isThreadBeyondNumberOfCores((int)threadid) << endl; + if(isThreadBeyondNumberOfCores((int)threadid)) { + return; + } + + if(threadid != 45) { + return; + } + PIN_MutexLock(&mainLockForPintool); numThreads++; livethreads++; @@ -294,6 +316,7 @@ VOID ThreadStart(THREADID threadid, CONTEXT *ctxt, INT32 flags, VOID *v) { fflush(stdout); pumpingStatus[i] = true; threadid = findThreadMapping(threadid); + cout << "app thread mapped to tejas thread " << threadid << endl; tst->onThread_start(threadid); while (tst->analysisFn(threadid, parent, CHILD_START, PIN_GetParentTid()) == -1) { PIN_Yield(); @@ -324,6 +347,9 @@ VOID ThreadFini(THREADID tid, const CONTEXT *ctxt, INT32 flags, VOID *v) { //Pass a memory read record VOID RecordMemRead(THREADID tid, VOID * ip, VOID * addr) { + + if(tid != 45) + return; tid= findThreadMapping(tid); if (!isActive(tid)) return; @@ -350,6 +376,9 @@ VOID RecordMemRead(THREADID tid, VOID * ip, VOID * addr) { // Pass a memory write record VOID RecordMemWrite(THREADID tid, VOID * ip, VOID * addr) { + if(tid != 45) + return; + tid= findThreadMapping(tid); if (!isActive(tid)) return; @@ -374,6 +403,9 @@ VOID RecordMemWrite(THREADID tid, VOID * ip, VOID * addr) { } VOID BrnFun(THREADID tid, ADDRINT tadr, BOOL taken, VOID *ip) { + + if(tid != 45) + return; tid= findThreadMapping(tid); if (!isActive(tid)) return; @@ -538,20 +570,37 @@ VOID printip(THREADID tid, VOID *ip, char *asmString) { instructionIgnorePhase = true; } - if(numInsToSimulate > 0 && totalNumCISC >= (numInsToIgnore + numInsToSimulate)) + if(numInsToSimulate > 0) { - // Now, we will write -2 packet in shared memory. - // This will ensure that complete emulator (PIN) gets stopped. - while (tst->onSubset_finish((int)tid, (numCISC[tid])) == -1) { - PIN_Yield(); + bool subsetDone = false; +// for(int i = 0; i < MaxNumActiveThreads; i++) +// { +// if(numCISC[i] >= (numInsToIgnore + numInsToSimulate)) +// { +// subsetDone = true; +// break; +// } +// } + if(numCISC[0] >= (numInsToIgnore + numInsToSimulate)) + { + subsetDone = true; } - cout<<"subset finish called by thread "<onSubset_finish((int)tid, (numCISC[tid])) == -1) { + PIN_Yield(); + } - tst->setSubsetsimComplete(true); - // threadAlive[tid] = false; - waitForThreadsAndTerminatePin(); + cout<<"subset finish called by thread "<setSubsetsimComplete(true); + // threadAlive[tid] = false; + waitForThreadsAndTerminatePin(); + } } } else @@ -664,8 +713,13 @@ void Image(IMG img,VOID *v) { // Pin calls this function every time a new instruction is encountered VOID Instruction(INS ins, VOID *v) { - //int tid = IARG_THREAD_ID; + int tid = IARG_THREAD_ID; + //cout << "thread = " << tid << endl; + if(isThreadBeyondNumberOfCores(tid)) + return; + if(tid != 45) + return; char *asmChar = NULL; if(traceMethod==File) { @@ -1014,4 +1068,4 @@ const char* findType(int type) { default: return "ADD THIS IN encoding.h"; } -} \ No newline at end of file +} diff --git a/src/simulator/emulatorinterface/translator/visaHandler/AES.java b/src/simulator/emulatorinterface/translator/visaHandler/AES.java new file mode 100644 index 0000000..b7ad51c --- /dev/null +++ b/src/simulator/emulatorinterface/translator/visaHandler/AES.java @@ -0,0 +1,15 @@ +package emulatorinterface.translator.visaHandler; + +import emulatorinterface.DynamicInstructionBuffer; +import generic.Instruction; +import generic.InstructionTable; + +public class AES implements DynamicInstructionHandler +{ + public int handle(int microOpIndex, + Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer) + { + //nothing to be done in such cases + return ++microOpIndex; + } +} \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/visaHandler/BitScan.java b/src/simulator/emulatorinterface/translator/visaHandler/BitScan.java new file mode 100644 index 0000000..cdbaabb --- /dev/null +++ b/src/simulator/emulatorinterface/translator/visaHandler/BitScan.java @@ -0,0 +1,15 @@ +package emulatorinterface.translator.visaHandler; + +import emulatorinterface.DynamicInstructionBuffer; +import generic.Instruction; +import generic.InstructionTable; + +public class BitScan implements DynamicInstructionHandler +{ + public int handle(int microOpIndex, + Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer) + { + //nothing to be done in such cases + return ++microOpIndex; + } +} \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/visaHandler/CPUID.java b/src/simulator/emulatorinterface/translator/visaHandler/CPUID.java new file mode 100644 index 0000000..c3ad492 --- /dev/null +++ b/src/simulator/emulatorinterface/translator/visaHandler/CPUID.java @@ -0,0 +1,14 @@ +package emulatorinterface.translator.visaHandler; + +import emulatorinterface.DynamicInstructionBuffer; +import generic.Instruction; + +public class CPUID implements DynamicInstructionHandler +{ + public int handle(int microOpIndex, + Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer) + { + //nothing to be done in such cases + return ++microOpIndex; + } +} diff --git a/src/simulator/emulatorinterface/translator/visaHandler/FMA.java b/src/simulator/emulatorinterface/translator/visaHandler/FMA.java new file mode 100644 index 0000000..c385977 --- /dev/null +++ b/src/simulator/emulatorinterface/translator/visaHandler/FMA.java @@ -0,0 +1,15 @@ +package emulatorinterface.translator.visaHandler; + +import emulatorinterface.DynamicInstructionBuffer; +import generic.Instruction; +import generic.InstructionTable; + +public class FMA implements DynamicInstructionHandler +{ + public int handle(int microOpIndex, + Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer) + { + //nothing to be done in such cases + return ++microOpIndex; + } +} \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/visaHandler/Mov.java b/src/simulator/emulatorinterface/translator/visaHandler/FloatMov.java similarity index 100% rename from src/simulator/emulatorinterface/translator/visaHandler/Mov.java rename to src/simulator/emulatorinterface/translator/visaHandler/FloatMov.java diff --git a/src/simulator/emulatorinterface/translator/visaHandler/FloatVectorALU.java b/src/simulator/emulatorinterface/translator/visaHandler/FloatVectorALU.java new file mode 100644 index 0000000..772d740 --- /dev/null +++ b/src/simulator/emulatorinterface/translator/visaHandler/FloatVectorALU.java @@ -0,0 +1,15 @@ +package emulatorinterface.translator.visaHandler; + +import emulatorinterface.DynamicInstructionBuffer; +import generic.Instruction; +import generic.InstructionTable; + +public class FloatVectorALU implements DynamicInstructionHandler +{ + public int handle(int microOpIndex, + Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer) + { + //nothing to be done in such cases + return ++microOpIndex; + } +} \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/visaHandler/FloatVectorMul.java b/src/simulator/emulatorinterface/translator/visaHandler/FloatVectorMul.java new file mode 100644 index 0000000..410eec0 --- /dev/null +++ b/src/simulator/emulatorinterface/translator/visaHandler/FloatVectorMul.java @@ -0,0 +1,15 @@ +package emulatorinterface.translator.visaHandler; + +import emulatorinterface.DynamicInstructionBuffer; +import generic.Instruction; +import generic.InstructionTable; + +public class FloatVectorMul implements DynamicInstructionHandler +{ + public int handle(int microOpIndex, + Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer) + { + //nothing to be done in such cases + return ++microOpIndex; + } +} \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/visaHandler/IntegerVectorALU.java b/src/simulator/emulatorinterface/translator/visaHandler/IntegerVectorALU.java new file mode 100644 index 0000000..0374cd5 --- /dev/null +++ b/src/simulator/emulatorinterface/translator/visaHandler/IntegerVectorALU.java @@ -0,0 +1,15 @@ +package emulatorinterface.translator.visaHandler; + +import emulatorinterface.DynamicInstructionBuffer; +import generic.Instruction; +import generic.InstructionTable; + +public class IntegerVectorALU implements DynamicInstructionHandler +{ + public int handle(int microOpIndex, + Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer) + { + //nothing to be done in such cases + return ++microOpIndex; + } +} diff --git a/src/simulator/emulatorinterface/translator/visaHandler/IntegerVectorMul.java b/src/simulator/emulatorinterface/translator/visaHandler/IntegerVectorMul.java new file mode 100644 index 0000000..1c075d6 --- /dev/null +++ b/src/simulator/emulatorinterface/translator/visaHandler/IntegerVectorMul.java @@ -0,0 +1,15 @@ +package emulatorinterface.translator.visaHandler; + +import emulatorinterface.DynamicInstructionBuffer; +import generic.Instruction; +import generic.InstructionTable; + +public class IntegerVectorMul implements DynamicInstructionHandler +{ + public int handle(int microOpIndex, + Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer) + { + //nothing to be done in such cases + return ++microOpIndex; + } +} diff --git a/src/simulator/emulatorinterface/translator/visaHandler/LEA.java b/src/simulator/emulatorinterface/translator/visaHandler/LEA.java new file mode 100644 index 0000000..ba23250 --- /dev/null +++ b/src/simulator/emulatorinterface/translator/visaHandler/LEA.java @@ -0,0 +1,15 @@ +package emulatorinterface.translator.visaHandler; + +import emulatorinterface.DynamicInstructionBuffer; +import generic.Instruction; +import generic.InstructionTable; + +public class LEA implements DynamicInstructionHandler +{ + public int handle(int microOpIndex, + Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer) + { + //nothing to be done in such cases + return ++microOpIndex; + } +} \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/visaHandler/LFence.java b/src/simulator/emulatorinterface/translator/visaHandler/LFence.java new file mode 100644 index 0000000..961bc16 --- /dev/null +++ b/src/simulator/emulatorinterface/translator/visaHandler/LFence.java @@ -0,0 +1,14 @@ +package emulatorinterface.translator.visaHandler; + +import emulatorinterface.DynamicInstructionBuffer; +import generic.Instruction; + +public class LFence implements DynamicInstructionHandler +{ + public int handle(int microOpIndex, + Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer) + { + //nothing to be done in such cases + return ++microOpIndex; + } +} diff --git a/src/simulator/emulatorinterface/translator/visaHandler/LoadAGU.java b/src/simulator/emulatorinterface/translator/visaHandler/LoadAGU.java new file mode 100644 index 0000000..7afc67d --- /dev/null +++ b/src/simulator/emulatorinterface/translator/visaHandler/LoadAGU.java @@ -0,0 +1,15 @@ +package emulatorinterface.translator.visaHandler; + +import emulatorinterface.DynamicInstructionBuffer; +import generic.Instruction; +import generic.InstructionTable; + +public class LoadAGU implements DynamicInstructionHandler +{ + public int handle(int microOpIndex, + Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer) + { + //nothing to be done in such cases + return ++microOpIndex; + } +} \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/visaHandler/MFence.java b/src/simulator/emulatorinterface/translator/visaHandler/MFence.java new file mode 100644 index 0000000..84a4be2 --- /dev/null +++ b/src/simulator/emulatorinterface/translator/visaHandler/MFence.java @@ -0,0 +1,14 @@ +package emulatorinterface.translator.visaHandler; + +import emulatorinterface.DynamicInstructionBuffer; +import generic.Instruction; + +public class MFence implements DynamicInstructionHandler +{ + public int handle(int microOpIndex, + Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer) + { + //nothing to be done in such cases + return ++microOpIndex; + } +} diff --git a/src/simulator/emulatorinterface/translator/visaHandler/ReadPrefetch.java b/src/simulator/emulatorinterface/translator/visaHandler/ReadPrefetch.java new file mode 100644 index 0000000..038e67e --- /dev/null +++ b/src/simulator/emulatorinterface/translator/visaHandler/ReadPrefetch.java @@ -0,0 +1,25 @@ +package emulatorinterface.translator.visaHandler; + +import emulatorinterface.DynamicInstructionBuffer; +import generic.Instruction; + +public class ReadPrefetch implements DynamicInstructionHandler +{ + public int handle(int microOpIndex, + Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer) + { + long memoryReadAddress; + memoryReadAddress = dynamicInstructionBuffer. + getSingleLoadAddress(microOp.getCISCProgramCounter()); + + if(memoryReadAddress != -1) + { + microOp.setSourceOperand1MemValue(memoryReadAddress); + return ++microOpIndex; + } + else + { + return -1; + } + } +} \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/visaHandler/SFence.java b/src/simulator/emulatorinterface/translator/visaHandler/SFence.java new file mode 100644 index 0000000..46d797d --- /dev/null +++ b/src/simulator/emulatorinterface/translator/visaHandler/SFence.java @@ -0,0 +1,14 @@ +package emulatorinterface.translator.visaHandler; + +import emulatorinterface.DynamicInstructionBuffer; +import generic.Instruction; + +public class SFence implements DynamicInstructionHandler +{ + public int handle(int microOpIndex, + Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer) + { + //nothing to be done in such cases + return ++microOpIndex; + } +} diff --git a/src/simulator/emulatorinterface/translator/visaHandler/StoreAGU.java b/src/simulator/emulatorinterface/translator/visaHandler/StoreAGU.java new file mode 100644 index 0000000..fdb8126 --- /dev/null +++ b/src/simulator/emulatorinterface/translator/visaHandler/StoreAGU.java @@ -0,0 +1,15 @@ +package emulatorinterface.translator.visaHandler; + +import emulatorinterface.DynamicInstructionBuffer; +import generic.Instruction; +import generic.InstructionTable; + +public class StoreAGU implements DynamicInstructionHandler +{ + public int handle(int microOpIndex, + Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer) + { + //nothing to be done in such cases + return ++microOpIndex; + } +} \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/visaHandler/VectorFMA.java b/src/simulator/emulatorinterface/translator/visaHandler/VectorFMA.java new file mode 100644 index 0000000..1d379c8 --- /dev/null +++ b/src/simulator/emulatorinterface/translator/visaHandler/VectorFMA.java @@ -0,0 +1,15 @@ +package emulatorinterface.translator.visaHandler; + +import emulatorinterface.DynamicInstructionBuffer; +import generic.Instruction; +import generic.InstructionTable; + +public class VectorFMA implements DynamicInstructionHandler +{ + public int handle(int microOpIndex, + Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer) + { + //nothing to be done in such cases + return ++microOpIndex; + } +} \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/visaHandler/VectorShuffle.java b/src/simulator/emulatorinterface/translator/visaHandler/VectorShuffle.java new file mode 100644 index 0000000..3263558 --- /dev/null +++ b/src/simulator/emulatorinterface/translator/visaHandler/VectorShuffle.java @@ -0,0 +1,15 @@ +package emulatorinterface.translator.visaHandler; + +import emulatorinterface.DynamicInstructionBuffer; +import generic.Instruction; +import generic.InstructionTable; + +public class VectorShuffle implements DynamicInstructionHandler +{ + public int handle(int microOpIndex, + Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer) + { + //nothing to be done in such cases + return ++microOpIndex; + } +} \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/visaHandler/VectorString.java b/src/simulator/emulatorinterface/translator/visaHandler/VectorString.java new file mode 100644 index 0000000..4ba1ca2 --- /dev/null +++ b/src/simulator/emulatorinterface/translator/visaHandler/VectorString.java @@ -0,0 +1,15 @@ +package emulatorinterface.translator.visaHandler; + +import emulatorinterface.DynamicInstructionBuffer; +import generic.Instruction; +import generic.InstructionTable; + +public class VectorString implements DynamicInstructionHandler +{ + public int handle(int microOpIndex, + Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer) + { + //nothing to be done in such cases + return ++microOpIndex; + } +} \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/visaHandler/VisaHandlerSelector.java b/src/simulator/emulatorinterface/translator/visaHandler/VisaHandlerSelector.java index 4ad89f8..fa04d1b 100755 --- a/src/simulator/emulatorinterface/translator/visaHandler/VisaHandlerSelector.java +++ b/src/simulator/emulatorinterface/translator/visaHandler/VisaHandlerSelector.java @@ -12,14 +12,31 @@ public class VisaHandlerSelector private static DynamicInstructionHandler floatALU; private static DynamicInstructionHandler floatMul; private static DynamicInstructionHandler floatDiv; + private static DynamicInstructionHandler integerVectorALU; + private static DynamicInstructionHandler integerVectorMul; + private static DynamicInstructionHandler floatVectorALU; + private static DynamicInstructionHandler floatVectorMul; + private static DynamicInstructionHandler FMA; + private static DynamicInstructionHandler vectorFMA; + private static DynamicInstructionHandler loadAGU; private static DynamicInstructionHandler load; + private static DynamicInstructionHandler storeAGU; private static DynamicInstructionHandler store; private static DynamicInstructionHandler jump; private static DynamicInstructionHandler branch; - private static DynamicInstructionHandler mov; - private static DynamicInstructionHandler xchg; + private static DynamicInstructionHandler AES; + private static DynamicInstructionHandler vectorString; + private static DynamicInstructionHandler bitScan; + private static DynamicInstructionHandler vectorShuffle; + private static DynamicInstructionHandler LEA; private static DynamicInstructionHandler acceleratedOp; private static DynamicInstructionHandler nop; + private static DynamicInstructionHandler cpuid; + private static DynamicInstructionHandler mfence; + private static DynamicInstructionHandler sfence; + private static DynamicInstructionHandler lfence; + private static DynamicInstructionHandler readprefetch; + private static DynamicInstructionHandler writeprefetch; private static DynamicInstructionHandler interrupt; public static DynamicInstructionHandler selectHandler(OperationType operationType) @@ -54,9 +71,33 @@ public class VisaHandlerSelector case floatDiv: return floatDiv; + case integerVectorALU: + return integerVectorALU; + + case integerVectorMul: + return integerVectorMul; + + case floatVectorALU: + return floatVectorALU; + + case floatVectorMul: + return floatVectorMul; + + case FMA: + return FMA; + + case vectorFMA: + return vectorFMA; + + case loadAGU: + return loadAGU; + case load: return load; + case storeAGU: + return storeAGU; + case store: return store; @@ -66,15 +107,42 @@ public class VisaHandlerSelector case branch: return branch; - case mov: - return mov; + case AES: + return AES; - case xchg: - return xchg; + case vectorString: + return vectorString; + + case bitScan: + return bitScan; + + case vectorShuffle: + return vectorShuffle; + + case LEA: + return LEA; case acceleratedOp: return acceleratedOp; + case cpuid: + return cpuid; + + case mfence: + return mfence; + + case sfence: + return sfence; + + case lfence: + return lfence; + + case read_prefetch: + return readprefetch; + + case write_prefetch: + return writeprefetch; + case nop: return nop; @@ -97,14 +165,31 @@ public class VisaHandlerSelector floatALU = new FloatALU(); floatMul = new FloatMul(); floatDiv = new FloatDiv(); + integerVectorALU = new IntegerVectorALU(); + integerVectorMul = new IntegerVectorMul(); + floatVectorALU = new FloatVectorALU(); + floatVectorMul = new FloatVectorMul(); + FMA = new FMA(); + vectorFMA = new VectorFMA(); + loadAGU = new LoadAGU(); load = new Load(); + storeAGU = new StoreAGU(); store = new Store(); jump = new Jump(); branch = new Branch(); - mov = new Mov(); - xchg = new Xchg(); + AES = new AES(); + vectorString = new VectorString(); + bitScan = new BitScan(); + vectorShuffle = new VectorShuffle(); + LEA = new LEA(); acceleratedOp = new AcceleratedOp(); nop = new NOP(); + cpuid = new CPUID(); + mfence = new MFence(); + sfence = new SFence(); + lfence = new LFence(); + readprefetch = new ReadPrefetch(); + writeprefetch = new WritePrefetch(); interrupt = new Interrupt(); } } diff --git a/src/simulator/emulatorinterface/translator/visaHandler/WritePrefetch.java b/src/simulator/emulatorinterface/translator/visaHandler/WritePrefetch.java new file mode 100644 index 0000000..896716c --- /dev/null +++ b/src/simulator/emulatorinterface/translator/visaHandler/WritePrefetch.java @@ -0,0 +1,25 @@ +package emulatorinterface.translator.visaHandler; + +import emulatorinterface.DynamicInstructionBuffer; +import generic.Instruction; + +public class WritePrefetch implements DynamicInstructionHandler +{ + public int handle(int microOpIndex, + Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer) + { + long memoryWriteAddress; + memoryWriteAddress = dynamicInstructionBuffer. + getSingleStoreAddress(microOp.getCISCProgramCounter()); + + if(memoryWriteAddress!=-1) + { + microOp.setSourceOperand1MemValue(memoryWriteAddress); + return ++microOpIndex; + } + else + { + return -1; + } + } +} \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/AES.java b/src/simulator/emulatorinterface/translator/x86/instruction/AES.java new file mode 100644 index 0000000..4a3750f --- /dev/null +++ b/src/simulator/emulatorinterface/translator/x86/instruction/AES.java @@ -0,0 +1,97 @@ +/***************************************************************************** +Tejas Simulator +------------------------------------------------------------------------------------------------------------ + +Copyright [2010] [Indian Institute of Technology, Delhi] +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +------------------------------------------------------------------------------------------------------------ + +*****************************************************************************/ + +package emulatorinterface.translator.x86.instruction; + +import emulatorinterface.translator.InvalidInstructionException; +import emulatorinterface.translator.x86.operand.OperandTranslator; +import emulatorinterface.translator.x86.registers.TempRegisterNum; +import generic.Instruction; +import generic.Operand; +import generic.InstructionList; + +public class AES implements X86StaticInstructionHandler{ + public void handle(long instructionPointer, + Operand operand1, Operand operand2, Operand operand3, + InstructionList instructionArrayList, + TempRegisterNum tempRegisterNum) + throws InvalidInstructionException + { + if(operand1 != null && operand1.isFloatRegisterOperand() + && operand2 != null && (operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) + && (operand3 == null || operand3.isFloatRegisterOperand() || operand3.isMemoryOperand()) + && (!(operand2.isMemoryOperand() && operand3.isMemoryOperand()))) + { + Operand srcOpnd1, srcOpnd2, destOpnd; + + destOpnd = operand1; + + if(operand3 == null) + { + srcOpnd1 = operand1; + if(operand2.isFloatRegisterOperand()) + { + srcOpnd2 = operand2; + } + else + { + srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false); + } + } + else + { + srcOpnd1 = operand2; + if(operand3.isFloatRegisterOperand()) + { + srcOpnd2 = operand3; + } + else + { + srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand3, instructionArrayList, tempRegisterNum, false); + } + } + + instructionArrayList.appendInstruction(Instruction.getAES(srcOpnd1, srcOpnd2, destOpnd)); + } + else if(operand1 != null && operand1.isFloatRegisterOperand() + && operand2 != null && (operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) + && operand3 == null) + { + Operand srcOpnd1, srcOpnd2, destOpnd; + + destOpnd = operand1; + if(operand2.isFloatRegisterOperand()) + { + srcOpnd1 = operand2; + } + else + { + srcOpnd1 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false); + } + srcOpnd2 = null; + + instructionArrayList.appendInstruction(Instruction.getAES(srcOpnd1, srcOpnd2, destOpnd)); + } + else + { + misc.Error.invalidOperation("AES with two source operands ", operand1, operand2, operand3); + } + } +} \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/AccumulatorAdjustments.java b/src/simulator/emulatorinterface/translator/x86/instruction/AccumulatorAdjustments.java new file mode 100755 index 0000000..cfee677 --- /dev/null +++ b/src/simulator/emulatorinterface/translator/x86/instruction/AccumulatorAdjustments.java @@ -0,0 +1,53 @@ +/***************************************************************************** + Tejas Simulator +------------------------------------------------------------------------------------------------------------ + + Copyright [2010] [Indian Institute of Technology, Delhi] + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +------------------------------------------------------------------------------------------------------------ + + Contributors: Prathmesh Kallurkar +*****************************************************************************/ + +package emulatorinterface.translator.x86.instruction; + + +import emulatorinterface.translator.InvalidInstructionException; +import emulatorinterface.translator.x86.registers.Registers; +import emulatorinterface.translator.x86.registers.TempRegisterNum; +import generic.Instruction; +import generic.Operand; +import generic.InstructionList; + +public class AccumulatorAdjustments implements X86StaticInstructionHandler +{ + public void handle(long instructionPointer, + Operand operand1, Operand operand2, Operand operand3, + InstructionList instructionArrayList, + TempRegisterNum tempRegisterNum) + throws InvalidInstructionException + { + if((operand1==null || operand1.isImmediateOperand()) && operand2==null && operand3==null) + { + Operand accumulatorRegister = Registers.getAccumulatorRegister(); + + //Perform integer alu operation + instructionArrayList.appendInstruction(Instruction.getIntALUInstruction( + null, accumulatorRegister, accumulatorRegister)); + } + else + { + misc.Error.invalidOperation("accumulator adjustments ", operand1, operand2, operand3); + } + } +} \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/BitScan.java b/src/simulator/emulatorinterface/translator/x86/instruction/BitScan.java new file mode 100644 index 0000000..a3c7048 --- /dev/null +++ b/src/simulator/emulatorinterface/translator/x86/instruction/BitScan.java @@ -0,0 +1,60 @@ +/***************************************************************************** +Tejas Simulator +------------------------------------------------------------------------------------------------------------ + +Copyright [2010] [Indian Institute of Technology, Delhi] +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +------------------------------------------------------------------------------------------------------------ + +*****************************************************************************/ + +package emulatorinterface.translator.x86.instruction; + +import emulatorinterface.translator.InvalidInstructionException; +import emulatorinterface.translator.x86.operand.OperandTranslator; +import emulatorinterface.translator.x86.registers.TempRegisterNum; +import generic.Instruction; +import generic.Operand; +import generic.InstructionList; + +public class BitScan implements X86StaticInstructionHandler{ + public void handle(long instructionPointer, + Operand operand1, Operand operand2, Operand operand3, + InstructionList instructionArrayList, + TempRegisterNum tempRegisterNum) + throws InvalidInstructionException + { + if(operand1 != null && operand1.isFloatRegisterOperand() + && operand2 != null && (operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) + && operand3 == null) + { + Operand srcOpnd1, destOpnd; + + destOpnd = operand1; + if(operand2.isFloatRegisterOperand()) + { + srcOpnd1 = operand2; + } + else + { + srcOpnd1 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false); + } + + instructionArrayList.appendInstruction(Instruction.getBitScan(srcOpnd1, destOpnd)); + } + else + { + misc.Error.invalidOperation("bit scan ", operand1, operand2, operand3); + } + } +} \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/FloatingPointComplexOperation.java b/src/simulator/emulatorinterface/translator/x86/instruction/CPUID.java old mode 100755 new mode 100644 similarity index 85% rename from src/simulator/emulatorinterface/translator/x86/instruction/FloatingPointComplexOperation.java rename to src/simulator/emulatorinterface/translator/x86/instruction/CPUID.java index f782ba0..5f18e38 --- a/src/simulator/emulatorinterface/translator/x86/instruction/FloatingPointComplexOperation.java +++ b/src/simulator/emulatorinterface/translator/x86/instruction/CPUID.java @@ -21,20 +21,19 @@ package emulatorinterface.translator.x86.instruction; - import emulatorinterface.translator.InvalidInstructionException; import emulatorinterface.translator.x86.registers.TempRegisterNum; +import generic.Instruction; import generic.Operand; import generic.InstructionList; -public class FloatingPointComplexOperation implements X86StaticInstructionHandler +public class CPUID implements X86StaticInstructionHandler { public void handle(long instructionPointer, Operand operand1, Operand operand2, Operand operand3, - InstructionList instructionArrayList, - TempRegisterNum tempRegisterNum) + InstructionList instructionArrayList, TempRegisterNum tempRegisterNum) throws InvalidInstructionException { - //TODO : Must do something !! + instructionArrayList.appendInstruction(Instruction.getCPUIDInstruction()); } } \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/Call.java b/src/simulator/emulatorinterface/translator/x86/instruction/Call.java index bfb90ee..26cbdfa 100755 --- a/src/simulator/emulatorinterface/translator/x86/instruction/Call.java +++ b/src/simulator/emulatorinterface/translator/x86/instruction/Call.java @@ -23,6 +23,7 @@ package emulatorinterface.translator.x86.instruction; import emulatorinterface.translator.InvalidInstructionException; +import emulatorinterface.translator.x86.registers.Registers; import emulatorinterface.translator.x86.registers.TempRegisterNum; import generic.InstructionList; import generic.Operand; @@ -41,14 +42,14 @@ public class Call implements X86StaticInstructionHandler TempRegisterNum tempRegisterNum) throws InvalidInstructionException { - //push the next instruction pointer on to the stack - //TODO Check if the NEXT_INSTRUCTION can be computed - Operand nextInstruction = Operand.getImmediateOperand(); - new Push().handle(instructionPointer, nextInstruction, null, null, instructionArrayList, tempRegisterNum); - if((operand1.isImmediateOperand() || operand1.isIntegerRegisterOperand() || operand1.isMemoryOperand()) && operand2==null && operand3==null) { + //push the next instruction pointer on to the stack + //TODO Check if the NEXT_INSTRUCTION can be computed + Operand nextInstruction = Registers.getInstructionPointer(); + new Push().handle(instructionPointer, nextInstruction, null, null, instructionArrayList, tempRegisterNum); + //Unconditional jump to a new location (new UnconditionalJump()).handle(instructionPointer, operand1, null, null, instructionArrayList, tempRegisterNum); } diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/CmpExchange.java b/src/simulator/emulatorinterface/translator/x86/instruction/CmpExchange.java new file mode 100644 index 0000000..49deb93 --- /dev/null +++ b/src/simulator/emulatorinterface/translator/x86/instruction/CmpExchange.java @@ -0,0 +1,93 @@ +/***************************************************************************** + Tejas Simulator +------------------------------------------------------------------------------------------------------------ + + Copyright [2010] [Indian Institute of Technology, Delhi] + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +------------------------------------------------------------------------------------------------------------ + + Contributors: Prathmesh Kallurkar +*****************************************************************************/ + +package emulatorinterface.translator.x86.instruction; + + + +import emulatorinterface.translator.InvalidInstructionException; +import emulatorinterface.translator.x86.operand.OperandTranslator; +import emulatorinterface.translator.x86.registers.Registers; +import emulatorinterface.translator.x86.registers.TempRegisterNum; +import generic.Instruction; +import generic.Operand; +import generic.InstructionList; + + +public class CmpExchange implements X86StaticInstructionHandler +{ + public void handle(long instructionPointer, + Operand operand1, Operand operand2, Operand operand3, + InstructionList instructionArrayList, + TempRegisterNum tempRegisterNum) + throws InvalidInstructionException + { + if( + (operand1.isIntegerRegisterOperand() || operand1.isMemoryOperand()) && + (operand2.isIntegerRegisterOperand()) && + (operand3==null)) + { + Operand operand1ValueOperand; + if(operand1.isMemoryOperand()) + { + operand1ValueOperand = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, true); + } + else + { + operand1ValueOperand = operand1; + } + + //compare + instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand1ValueOperand, operand2, Registers.getEFlagsRegister())); + + /* + * TODO + * currently implementing both the success and failure outcomes of the comparison + * in reality, only one of the outcomes can happen dynamically + */ + + //if equal + if(operand1.isMemoryOperand()) + { + OperandTranslator.processDestinationMemoryOperand(operand2, operand1, instructionArrayList, tempRegisterNum); + } + else + { + instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand2, null, operand1)); + } + + //if not equal + if(operand1.isMemoryOperand()) + { + OperandTranslator.processSourceMemoryOperand(operand1, Registers.getAccumulatorRegister(), instructionArrayList, tempRegisterNum); + } + else + { + instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand1, null, Registers.getAccumulatorRegister())); + } + } + + else + { + misc.Error.invalidOperation("Integer operation ", operand1, operand2, operand3); + } + } +} \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/CmpExchangeByte.java b/src/simulator/emulatorinterface/translator/x86/instruction/CmpExchangeByte.java new file mode 100644 index 0000000..c6dcf1a --- /dev/null +++ b/src/simulator/emulatorinterface/translator/x86/instruction/CmpExchangeByte.java @@ -0,0 +1,75 @@ +/***************************************************************************** + Tejas Simulator +------------------------------------------------------------------------------------------------------------ + + Copyright [2010] [Indian Institute of Technology, Delhi] + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +------------------------------------------------------------------------------------------------------------ + + Contributors: Prathmesh Kallurkar +*****************************************************************************/ + +package emulatorinterface.translator.x86.instruction; + + + +import emulatorinterface.translator.InvalidInstructionException; +import emulatorinterface.translator.x86.operand.OperandTranslator; +import emulatorinterface.translator.x86.registers.Registers; +import emulatorinterface.translator.x86.registers.TempRegisterNum; +import generic.Instruction; +import generic.Operand; +import generic.InstructionList; + + +public class CmpExchangeByte implements X86StaticInstructionHandler +{ + public void handle(long instructionPointer, + Operand operand1, Operand operand2, Operand operand3, + InstructionList instructionArrayList, + TempRegisterNum tempRegisterNum) + throws InvalidInstructionException + { + if( + (operand1.isMemoryOperand()) && + (operand2 == null) && + (operand3==null)) + { + Operand operand1ValueOperand = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, true); + + //compare + Operand tempComparisonResult = Registers.getTempIntReg(tempRegisterNum); + instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getAccumulatorRegister(), operand1ValueOperand, tempComparisonResult)); + instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getDestinationIndexRegister(), tempComparisonResult, Registers.getEFlagsRegister())); + + /* + * TODO + * currently implementing both the success and failure outcomes of the comparison + * in reality, only one of the outcomes can happen dynamically + */ + + //if equal + OperandTranslator.processDestinationMemoryOperand(Registers.getCounterRegister(), operand1, instructionArrayList, tempRegisterNum); + OperandTranslator.processDestinationMemoryOperand(Registers.getBaseIndexRegister(), operand1, instructionArrayList, tempRegisterNum); + + //if not equal + OperandTranslator.processSourceMemoryOperand(operand1, Registers.getAccumulatorRegister(), instructionArrayList, tempRegisterNum); + OperandTranslator.processSourceMemoryOperand(operand1, Registers.getDestinationIndexRegister(), instructionArrayList, tempRegisterNum); + } + + else + { + misc.Error.invalidOperation("Integer operation ", operand1, operand2, operand3); + } + } +} \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalJump.java b/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalJump.java index c3da11c..779b139 100755 --- a/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalJump.java +++ b/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalJump.java @@ -22,6 +22,7 @@ package emulatorinterface.translator.x86.instruction; import emulatorinterface.translator.InvalidInstructionException; import emulatorinterface.translator.x86.operand.OperandTranslator; +import emulatorinterface.translator.x86.registers.Registers; import emulatorinterface.translator.x86.registers.TempRegisterNum; import generic.Instruction; import generic.InstructionList; @@ -40,14 +41,13 @@ public class ConditionalJump implements X86StaticInstructionHandler && operand2==null && operand3==null) { jumpLocation = operand1; - instructionArrayList.appendInstruction(Instruction.getBranchInstruction(jumpLocation)); + instructionArrayList.appendInstruction(Instruction.getBranchInstruction(jumpLocation, Registers.getEFlagsRegister())); } else if(operand1.isMemoryOperand() && operand2==null && operand3==null) { - jumpLocation = OperandTranslator.getLocationToStoreValue(operand1, tempRegisterNum); - instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand1, jumpLocation)); - instructionArrayList.appendInstruction(Instruction.getBranchInstruction(jumpLocation)); + jumpLocation = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, true); + instructionArrayList.appendInstruction(Instruction.getBranchInstruction(jumpLocation, Registers.getEFlagsRegister())); } else diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalLoop.java b/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalLoop.java new file mode 100644 index 0000000..871a85e --- /dev/null +++ b/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalLoop.java @@ -0,0 +1,56 @@ +/***************************************************************************** + Tejas Simulator +------------------------------------------------------------------------------------------------------------ + + Copyright [2010] [Indian Institute of Technology, Delhi] + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +------------------------------------------------------------------------------------------------------------ + + Contributors: Prathmesh Kallurkar +*****************************************************************************/ + +package emulatorinterface.translator.x86.instruction; + +import emulatorinterface.translator.InvalidInstructionException; +import emulatorinterface.translator.x86.registers.Registers; +import emulatorinterface.translator.x86.registers.TempRegisterNum; +import generic.Instruction; +import generic.Operand; +import generic.InstructionList; + +public class ConditionalLoop implements X86StaticInstructionHandler +{ + public void handle(long instructionPointer, + Operand operand1, Operand operand2, Operand operand3, + InstructionList instructionArrayList, + TempRegisterNum tempRegisterNum) + throws InvalidInstructionException + { + if(operand1.isImmediateOperand() && operand2==null && operand3==null) + { + Operand counterRegister = Registers.getCounterRegister(); + + //cx=cx-1 + instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(counterRegister, + Registers.getEFlagsRegister(), counterRegister)); + + //Perform a conditional jump + instructionArrayList.appendInstruction(Instruction.getBranchInstruction(operand1, Registers.getEFlagsRegister())); + } + + else + { + misc.Error.invalidOperation("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 99d78d6..206d184 100755 --- a/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalMove.java +++ b/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalMove.java @@ -22,6 +22,8 @@ package emulatorinterface.translator.x86.instruction; import emulatorinterface.translator.InvalidInstructionException; +import emulatorinterface.translator.x86.operand.OperandTranslator; +import emulatorinterface.translator.x86.registers.Registers; import emulatorinterface.translator.x86.registers.TempRegisterNum; import generic.Instruction; import generic.Operand; @@ -42,7 +44,7 @@ public class ConditionalMove implements X86StaticInstructionHandler (operand2.isIntegerRegisterOperand() || operand2.isImmediateOperand()) && (operand3==null)) { - instructionArrayList.appendInstruction(Instruction.getMoveInstruction(operand1, operand2)); + instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand2, Registers.getEFlagsRegister(), operand1)); } //if operand1 = register and operand2 = memory - load @@ -50,25 +52,26 @@ public class ConditionalMove implements X86StaticInstructionHandler operand2.isMemoryOperand() && operand3==null) { - instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand2, operand1)); + Operand sourceOperand = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, true); + instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(sourceOperand, Registers.getEFlagsRegister(), operand1)); } - //if operand1 = memory and operand2 = memory - store - else if((operand1.isMemoryOperand()) && - (operand2.isImmediateOperand() || operand2.isIntegerRegisterOperand()) && - (operand3==null)) - { - instructionArrayList.appendInstruction(Instruction.getStoreInstruction(operand2, 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 - //Then we will store op2 to [temporary-register] - else if(operand1.isMemoryOperand() && operand2.isMemoryOperand() && operand3==null) - { - misc.Error.invalidOperation("Conditional Move", operand1, operand2, operand3); - } +// //if operand1 = memory and operand2 = memory - store +// else if((operand1.isMemoryOperand()) && +// (operand2.isImmediateOperand() || operand2.isIntegerRegisterOperand()) && +// (operand3==null)) +// { +// instructionArrayList.appendInstruction(Instruction.getStoreInstruction(operand2, 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 +// //Then we will store op2 to [temporary-register] +// else if(operand1.isMemoryOperand() && operand2.isMemoryOperand() && operand3==null) +// { +// misc.Error.invalidOperation("Conditional Move", operand1, operand2, operand3); +// } else { diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalSet.java b/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalSet.java index 690eb0e..e82bd02 100755 --- a/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalSet.java +++ b/src/simulator/emulatorinterface/translator/x86/instruction/ConditionalSet.java @@ -1,6 +1,7 @@ package emulatorinterface.translator.x86.instruction; import emulatorinterface.translator.InvalidInstructionException; +import emulatorinterface.translator.x86.registers.Registers; import emulatorinterface.translator.x86.registers.TempRegisterNum; import generic.Instruction; import generic.Operand; @@ -17,14 +18,14 @@ public class ConditionalSet implements X86StaticInstructionHandler if((operand1.isIntegerRegisterOperand()) && operand2==null && operand3==null) { - instructionArrayList.appendInstruction(Instruction.getMoveInstruction(operand1, - Operand.getImmediateOperand())); + instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getEFlagsRegister(), + Operand.getImmediateOperand(), operand1)); } else if(operand1.isMemoryOperand()) { instructionArrayList.appendInstruction(Instruction.getStoreInstruction(operand1, - Operand.getImmediateOperand())); + Registers.getEFlagsRegister())); } else diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/Exchange.java b/src/simulator/emulatorinterface/translator/x86/instruction/Exchange.java index 3719dd3..9141542 100755 --- a/src/simulator/emulatorinterface/translator/x86/instruction/Exchange.java +++ b/src/simulator/emulatorinterface/translator/x86/instruction/Exchange.java @@ -22,6 +22,7 @@ package emulatorinterface.translator.x86.instruction; import emulatorinterface.translator.InvalidInstructionException; +import emulatorinterface.translator.x86.operand.OperandTranslator; import emulatorinterface.translator.x86.registers.Registers; import emulatorinterface.translator.x86.registers.TempRegisterNum; import generic.InstructionList; @@ -36,39 +37,46 @@ public class Exchange implements X86StaticInstructionHandler TempRegisterNum tempRegisterNum) throws InvalidInstructionException { - //operand1 is a register and operand2 is also a register - if((operand1.isIntegerRegisterOperand()) && - (operand2.isIntegerRegisterOperand())&& - operand3==null) + if((operand1.isIntegerRegisterOperand() || operand1.isMemoryOperand()) + && (operand2 == null || operand2.isIntegerRegisterOperand()) + && operand3 == null + && (!(operand1.isMemoryOperand() && operand2 == null))) { - instructionArrayList.appendInstruction(Instruction.getExchangeInstruction(operand1, operand2)); - } - - //operand1 is memory operand and operand2 is a register - else if((operand1.isMemoryOperand() || operand1.isIntegerRegisterOperand()) && - (operand2.isMemoryOperand() || operand2.isIntegerRegisterOperand()) && - operand3==null) - { - Operand memLocation = null, tempRegister = null, register = null; - - tempRegister = Registers.getTempIntReg(tempRegisterNum); - - if(operand1.isMemoryOperand() && !operand2.isMemoryOperand()) { - memLocation = operand1; - register = operand2; - } else if(operand2.isMemoryOperand() && !operand1.isMemoryOperand()) { - memLocation = operand2; - register = operand1; - } else { - misc.Error.invalidOperation("Exchange", operand1, operand2, operand3); + Operand operand1Value; + if(operand1.isMemoryOperand()) + { + operand1Value = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, true); + } + else + { + operand1Value = operand1; } - //temp = mem - instructionArrayList.appendInstruction(Instruction.getLoadInstruction(memLocation, tempRegister)); - //mem = reg - instructionArrayList.appendInstruction(Instruction.getStoreInstruction(memLocation, register)); - // reg = temp - instructionArrayList.appendInstruction(Instruction.getMoveInstruction(register, tempRegister)); + Operand operand2Reg; + if(operand2.isIntegerRegisterOperand()) + { + operand2Reg = operand2; + } + else + { + operand2Reg = Registers.getAccumulatorRegister(); + } + + Operand temp = Registers.getTempIntReg(tempRegisterNum); + + //temp = operand2 + instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand2Reg, null, temp)); + //operand2 = operand1 + instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand1Value, null, operand2Reg)); + //operand1 = temp + if(operand1.isMemoryOperand()) + { + OperandTranslator.processDestinationMemoryOperand(temp, operand1, instructionArrayList, tempRegisterNum); + } + else + { + instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(temp, null, operand1)); + } } else diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/ExchangeAndAdd.java b/src/simulator/emulatorinterface/translator/x86/instruction/ExchangeAndAdd.java index 3d3c48b..122ff24 100755 --- a/src/simulator/emulatorinterface/translator/x86/instruction/ExchangeAndAdd.java +++ b/src/simulator/emulatorinterface/translator/x86/instruction/ExchangeAndAdd.java @@ -22,8 +22,11 @@ package emulatorinterface.translator.x86.instruction; import emulatorinterface.translator.InvalidInstructionException; +import emulatorinterface.translator.x86.operand.OperandTranslator; +import emulatorinterface.translator.x86.registers.Registers; import emulatorinterface.translator.x86.registers.TempRegisterNum; import generic.Operand; +import generic.Instruction; import generic.InstructionList; public class ExchangeAndAdd implements X86StaticInstructionHandler @@ -34,12 +37,39 @@ public class ExchangeAndAdd implements X86StaticInstructionHandler TempRegisterNum tempRegisterNum) throws InvalidInstructionException { - //TODO Check if the add should be performed before exchange ?? - Exchange exchange = new Exchange(); - exchange.handle(instructionPointer, operand1, operand2, operand3, instructionArrayList, tempRegisterNum); - - //Perhaps the order will now change. - IntegerALUImplicitDestination addOperation = new IntegerALUImplicitDestination(); - addOperation.handle(instructionPointer, operand2, operand1, operand3, instructionArrayList, tempRegisterNum); + if(operand1.isMemoryOperand() && operand2.isIntegerRegisterOperand() && operand3 == null) + { + Operand memoryOpnd = operand1; + Operand registerOpnd = operand2; + + // memValueTemp = [memoryOpnd] + Operand memValueTemp = OperandTranslator.processSourceMemoryOperand(memoryOpnd, instructionArrayList, tempRegisterNum, true); + + // sumTemp = registerOpnd + memValueTemp + Operand sumTemp = Registers.getTempIntReg(tempRegisterNum); + instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(registerOpnd, memValueTemp, sumTemp)); + + // [memoryOpnd] = sumTemp + OperandTranslator.processDestinationMemoryOperand(sumTemp, memoryOpnd, instructionArrayList, tempRegisterNum); + + // registerOpnd = memValueTemp + instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(memValueTemp, null, registerOpnd)); + } + else if(operand1.isIntegerRegisterOperand() && operand2.isIntegerRegisterOperand() && operand3 == null) /*both operands are registers*/ + { + // sumTemp = sourceReg + destReg + Operand sumTemp = Registers.getTempIntReg(tempRegisterNum); + instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand1, operand2, sumTemp)); + + // sourceReg = destReg + instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand1, null, operand2)); + + // destReg = sumTemp + instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(sumTemp, null, operand1)); + } + else + { + misc.Error.invalidOperation("Exchange and Add ", operand1, operand2, operand3); + } } } diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/SingleOperandIntALUImplicitAccumulator.java b/src/simulator/emulatorinterface/translator/x86/instruction/ExtendEAXToEDX.java old mode 100755 new mode 100644 similarity index 77% rename from src/simulator/emulatorinterface/translator/x86/instruction/SingleOperandIntALUImplicitAccumulator.java rename to src/simulator/emulatorinterface/translator/x86/instruction/ExtendEAXToEDX.java index 4297f6e..683932b --- a/src/simulator/emulatorinterface/translator/x86/instruction/SingleOperandIntALUImplicitAccumulator.java +++ b/src/simulator/emulatorinterface/translator/x86/instruction/ExtendEAXToEDX.java @@ -27,10 +27,9 @@ import emulatorinterface.translator.x86.registers.Registers; import emulatorinterface.translator.x86.registers.TempRegisterNum; import generic.Instruction; import generic.Operand; -import generic.InstructionLinkedList; import generic.InstructionList; -public class SingleOperandIntALUImplicitAccumulator implements X86StaticInstructionHandler +public class ExtendEAXToEDX implements X86StaticInstructionHandler { public void handle(long instructionPointer, Operand operand1, Operand operand2, Operand operand3, @@ -38,26 +37,19 @@ public class SingleOperandIntALUImplicitAccumulator implements X86StaticInstruct TempRegisterNum tempRegisterNum) throws InvalidInstructionException { - if(operand1==null && operand2==null && operand3==null) + if((operand1==null || operand1.isImmediateOperand()) && operand2==null && operand3==null) { Operand accumulatorRegister = Registers.getAccumulatorRegister(); //Perform integer alu operation + instructionArrayList.appendInstruction(Instruction.getIntALUInstruction( + null, accumulatorRegister, Registers.getDataRegister())); instructionArrayList.appendInstruction(Instruction.getIntALUInstruction( null, accumulatorRegister, accumulatorRegister)); } - else if(operand1.isImmediateOperand() && operand2==null && operand3==null) - - { - Operand accumulatorRegister = Registers.getAccumulatorRegister(); - - //Perform integer alu operation - instructionArrayList.appendInstruction(Instruction.getIntALUInstruction( - operand1, accumulatorRegister, accumulatorRegister)); - } else { - misc.Error.invalidOperation("Integer ALU Operation involving an implicit accumulator", operand1, operand2, operand3); + misc.Error.invalidOperation("extending eax to edx:eax ", operand1, operand2, operand3); } } } \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/FMA.java b/src/simulator/emulatorinterface/translator/x86/instruction/FMA.java new file mode 100644 index 0000000..6b6c46a --- /dev/null +++ b/src/simulator/emulatorinterface/translator/x86/instruction/FMA.java @@ -0,0 +1,93 @@ +/***************************************************************************** + Tejas Simulator +------------------------------------------------------------------------------------------------------------ + + Copyright [2010] [Indian Institute of Technology, Delhi] + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +------------------------------------------------------------------------------------------------------------ + + Contributors: Prathmesh Kallurkar +*****************************************************************************/ + +package emulatorinterface.translator.x86.instruction; + + + +import emulatorinterface.translator.InvalidInstructionException; +import emulatorinterface.translator.x86.operand.OperandTranslator; +import emulatorinterface.translator.x86.registers.TempRegisterNum; +import generic.Instruction; +import generic.Operand; +import generic.InstructionList; + + +public class FMA implements X86StaticInstructionHandler +{ + public void handle(long instructionPointer, + Operand operand1, Operand operand2, Operand operand3, + InstructionList instructionArrayList, + TempRegisterNum tempRegisterNum) + throws InvalidInstructionException + { + if( + (operand1.isFloatRegisterOperand()) && + (operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) && + (operand3 == null)) + { + Operand srcOpnd1, srcOpnd2, destOpnd; + + srcOpnd1 = operand1; + + if(operand2.isMemoryOperand()) + { + srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false); + } + else + { + srcOpnd2 = operand2; + } + + destOpnd = operand1; + + instructionArrayList.appendInstruction(Instruction.getFMA(srcOpnd1, srcOpnd2, destOpnd)); + } + + else if( + (operand1.isFloatRegisterOperand()) && + (operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) && + (operand3 == null || operand3.isImmediateOperand() || operand3.isFloatRegisterOperand() || operand3.isMemoryOperand())) + { + Operand srcOpnd1, srcOpnd2, destOpnd; + + srcOpnd1 = operand2; + + if(operand3.isMemoryOperand()) + { + srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand3, instructionArrayList, tempRegisterNum, false); + } + else + { + srcOpnd2 = operand3; + } + + destOpnd = operand1; + + instructionArrayList.appendInstruction(Instruction.getFMA(srcOpnd1, srcOpnd2, destOpnd)); + } + + else + { + misc.Error.invalidOperation("Scalar FMA ", operand1, operand2, operand3); + } + } +} \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/FlagsLoad.java b/src/simulator/emulatorinterface/translator/x86/instruction/FlagsLoad.java new file mode 100644 index 0000000..74972ed --- /dev/null +++ b/src/simulator/emulatorinterface/translator/x86/instruction/FlagsLoad.java @@ -0,0 +1,29 @@ +package emulatorinterface.translator.x86.instruction; + +import emulatorinterface.translator.InvalidInstructionException; +import emulatorinterface.translator.x86.registers.Registers; +import emulatorinterface.translator.x86.registers.TempRegisterNum; +import generic.Instruction; +import generic.InstructionList; +import generic.Operand; + +public class FlagsLoad implements X86StaticInstructionHandler +{ + public void handle(long instructionPointer, + Operand operand1, Operand operand2, Operand operand3, + InstructionList instructionArrayList, + TempRegisterNum tempRegisterNum) + throws InvalidInstructionException + { + if(operand1 == null && operand2 == null && operand3 == null) + { + instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getAccumulatorRegister(), null, Registers.getEFlagsRegister())); + } + + else + { + misc.Error.invalidOperation("Flags Load ", operand1, operand2, operand3); + } + } + +} diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/FlagsModWithSrc.java b/src/simulator/emulatorinterface/translator/x86/instruction/FlagsModWithSrc.java new file mode 100644 index 0000000..dbc9a11 --- /dev/null +++ b/src/simulator/emulatorinterface/translator/x86/instruction/FlagsModWithSrc.java @@ -0,0 +1,29 @@ +package emulatorinterface.translator.x86.instruction; + +import emulatorinterface.translator.InvalidInstructionException; +import emulatorinterface.translator.x86.registers.Registers; +import emulatorinterface.translator.x86.registers.TempRegisterNum; +import generic.Instruction; +import generic.InstructionList; +import generic.Operand; + +public class FlagsModWithSrc implements X86StaticInstructionHandler +{ + public void handle(long instructionPointer, + Operand operand1, Operand operand2, Operand operand3, + InstructionList instructionArrayList, + TempRegisterNum tempRegisterNum) + throws InvalidInstructionException + { + if(operand1 == null && operand2 == null && operand3 == null) + { + instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getEFlagsRegister(), null, Registers.getEFlagsRegister())); + } + + else + { + misc.Error.invalidOperation("Flags Mod With Src", operand1, operand2, operand3); + } + } + +} diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/FlagsModWithoutSrc.java b/src/simulator/emulatorinterface/translator/x86/instruction/FlagsModWithoutSrc.java new file mode 100644 index 0000000..a828ac0 --- /dev/null +++ b/src/simulator/emulatorinterface/translator/x86/instruction/FlagsModWithoutSrc.java @@ -0,0 +1,29 @@ +package emulatorinterface.translator.x86.instruction; + +import emulatorinterface.translator.InvalidInstructionException; +import emulatorinterface.translator.x86.registers.Registers; +import emulatorinterface.translator.x86.registers.TempRegisterNum; +import generic.Instruction; +import generic.InstructionList; +import generic.Operand; + +public class FlagsModWithoutSrc implements X86StaticInstructionHandler +{ + public void handle(long instructionPointer, + Operand operand1, Operand operand2, Operand operand3, + InstructionList instructionArrayList, + TempRegisterNum tempRegisterNum) + throws InvalidInstructionException + { + if(operand1 == null && operand2 == null && operand3 == null) + { + instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(null, null, Registers.getEFlagsRegister())); + } + + else + { + misc.Error.invalidOperation("Flags Mod Without Src", operand1, operand2, operand3); + } + } + +} diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/FlagsStore.java b/src/simulator/emulatorinterface/translator/x86/instruction/FlagsStore.java new file mode 100644 index 0000000..dddf26d --- /dev/null +++ b/src/simulator/emulatorinterface/translator/x86/instruction/FlagsStore.java @@ -0,0 +1,29 @@ +package emulatorinterface.translator.x86.instruction; + +import emulatorinterface.translator.InvalidInstructionException; +import emulatorinterface.translator.x86.registers.Registers; +import emulatorinterface.translator.x86.registers.TempRegisterNum; +import generic.Instruction; +import generic.InstructionList; +import generic.Operand; + +public class FlagsStore implements X86StaticInstructionHandler +{ + public void handle(long instructionPointer, + Operand operand1, Operand operand2, Operand operand3, + InstructionList instructionArrayList, + TempRegisterNum tempRegisterNum) + throws InvalidInstructionException + { + if(operand1 == null && operand2 == null && operand3 == null) + { + instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getEFlagsRegister(), null, Registers.getAccumulatorRegister())); + } + + else + { + misc.Error.invalidOperation("Flags Store ", operand1, operand2, operand3); + } + } + +} diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/FloatALU.java b/src/simulator/emulatorinterface/translator/x86/instruction/FloatALU.java new file mode 100644 index 0000000..e2b01e7 --- /dev/null +++ b/src/simulator/emulatorinterface/translator/x86/instruction/FloatALU.java @@ -0,0 +1,93 @@ +/***************************************************************************** + Tejas Simulator +------------------------------------------------------------------------------------------------------------ + + Copyright [2010] [Indian Institute of Technology, Delhi] + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +------------------------------------------------------------------------------------------------------------ + + Contributors: Prathmesh Kallurkar +*****************************************************************************/ + +package emulatorinterface.translator.x86.instruction; + + + +import emulatorinterface.translator.InvalidInstructionException; +import emulatorinterface.translator.x86.operand.OperandTranslator; +import emulatorinterface.translator.x86.registers.TempRegisterNum; +import generic.Instruction; +import generic.Operand; +import generic.InstructionList; + + +public class FloatALU implements X86StaticInstructionHandler +{ + public void handle(long instructionPointer, + Operand operand1, Operand operand2, Operand operand3, + InstructionList instructionArrayList, + TempRegisterNum tempRegisterNum) + throws InvalidInstructionException + { + if( + (operand1.isFloatRegisterOperand()) && + (operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) && + (operand3 == null)) + { + Operand srcOpnd1, srcOpnd2, destOpnd; + + srcOpnd1 = operand1; + + if(operand2.isMemoryOperand()) + { + srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false); + } + else + { + srcOpnd2 = operand2; + } + + destOpnd = operand1; + + instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(srcOpnd1, srcOpnd2, destOpnd)); + } + + else if( + (operand1.isFloatRegisterOperand()) && + (operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) && + (operand3 == null || operand3.isImmediateOperand() || operand3.isFloatRegisterOperand() || operand3.isMemoryOperand())) + { + Operand srcOpnd1, srcOpnd2, destOpnd; + + srcOpnd1 = operand2; + + if(operand3.isMemoryOperand()) + { + srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand3, instructionArrayList, tempRegisterNum, false); + } + else + { + srcOpnd2 = operand3; + } + + destOpnd = operand1; + + instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(srcOpnd1, srcOpnd2, destOpnd)); + } + + else + { + misc.Error.invalidOperation("Float ALU ", operand1, operand2, operand3); + } + } +} \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/FloatCmp.java b/src/simulator/emulatorinterface/translator/x86/instruction/FloatCmp.java new file mode 100644 index 0000000..08a781b --- /dev/null +++ b/src/simulator/emulatorinterface/translator/x86/instruction/FloatCmp.java @@ -0,0 +1,71 @@ +/***************************************************************************** + Tejas Simulator +------------------------------------------------------------------------------------------------------------ + + Copyright [2010] [Indian Institute of Technology, Delhi] + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +------------------------------------------------------------------------------------------------------------ + + Contributors: Prathmesh Kallurkar +*****************************************************************************/ + +package emulatorinterface.translator.x86.instruction; + + + +import emulatorinterface.translator.InvalidInstructionException; +import emulatorinterface.translator.x86.operand.OperandTranslator; +import emulatorinterface.translator.x86.registers.Registers; +import emulatorinterface.translator.x86.registers.TempRegisterNum; +import generic.Instruction; +import generic.Operand; +import generic.InstructionList; + + +public class FloatCmp implements X86StaticInstructionHandler +{ + public void handle(long instructionPointer, + Operand operand1, Operand operand2, Operand operand3, + InstructionList instructionArrayList, + TempRegisterNum tempRegisterNum) + throws InvalidInstructionException + { + if( + (operand1.isFloatRegisterOperand()) && + (operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) && + (operand3 == null)) + { + Operand srcOpnd1, srcOpnd2, destOpnd; + + srcOpnd1 = operand1; + + if(operand2.isMemoryOperand()) + { + srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false); + } + else + { + srcOpnd2 = operand2; + } + + destOpnd = Registers.getEFlagsRegister(); + + instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(srcOpnd1, srcOpnd2, destOpnd)); + } + + else + { + misc.Error.invalidOperation("float compare ", operand1, operand2, operand3); + } + } +} \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/FloatDiv.java b/src/simulator/emulatorinterface/translator/x86/instruction/FloatDiv.java new file mode 100644 index 0000000..0c5d5e1 --- /dev/null +++ b/src/simulator/emulatorinterface/translator/x86/instruction/FloatDiv.java @@ -0,0 +1,93 @@ +/***************************************************************************** + Tejas Simulator +------------------------------------------------------------------------------------------------------------ + + Copyright [2010] [Indian Institute of Technology, Delhi] + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +------------------------------------------------------------------------------------------------------------ + + Contributors: Prathmesh Kallurkar +*****************************************************************************/ + +package emulatorinterface.translator.x86.instruction; + + + +import emulatorinterface.translator.InvalidInstructionException; +import emulatorinterface.translator.x86.operand.OperandTranslator; +import emulatorinterface.translator.x86.registers.TempRegisterNum; +import generic.Instruction; +import generic.Operand; +import generic.InstructionList; + + +public class FloatDiv implements X86StaticInstructionHandler +{ + public void handle(long instructionPointer, + Operand operand1, Operand operand2, Operand operand3, + InstructionList instructionArrayList, + TempRegisterNum tempRegisterNum) + throws InvalidInstructionException + { + if( + (operand1.isFloatRegisterOperand()) && + (operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) && + (operand3 == null)) + { + Operand srcOpnd1, srcOpnd2, destOpnd; + + srcOpnd1 = operand1; + + if(operand2.isMemoryOperand()) + { + srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false); + } + else + { + srcOpnd2 = operand2; + } + + destOpnd = operand1; + + instructionArrayList.appendInstruction(Instruction.getFloatingPointDivision(srcOpnd1, srcOpnd2, destOpnd)); + } + + else if( + (operand1.isFloatRegisterOperand()) && + (operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) && + (operand3 == null || operand3.isImmediateOperand() || operand3.isFloatRegisterOperand() || operand3.isMemoryOperand())) + { + Operand srcOpnd1, srcOpnd2, destOpnd; + + srcOpnd1 = operand2; + + if(operand3.isMemoryOperand()) + { + srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand3, instructionArrayList, tempRegisterNum, false); + } + else + { + srcOpnd2 = operand3; + } + + destOpnd = operand1; + + instructionArrayList.appendInstruction(Instruction.getFloatingPointDivision(srcOpnd1, srcOpnd2, destOpnd)); + } + + else + { + misc.Error.invalidOperation("Float Div ", operand1, operand2, operand3); + } + } +} \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/Move.java b/src/simulator/emulatorinterface/translator/x86/instruction/FloatMove.java old mode 100755 new mode 100644 similarity index 73% rename from src/simulator/emulatorinterface/translator/x86/instruction/Move.java rename to src/simulator/emulatorinterface/translator/x86/instruction/FloatMove.java index 1cc6912..7190b1e --- a/src/simulator/emulatorinterface/translator/x86/instruction/Move.java +++ b/src/simulator/emulatorinterface/translator/x86/instruction/FloatMove.java @@ -23,13 +23,14 @@ package emulatorinterface.translator.x86.instruction; import emulatorinterface.translator.InvalidInstructionException; +import emulatorinterface.translator.x86.operand.OperandTranslator; import emulatorinterface.translator.x86.registers.TempRegisterNum; import generic.Instruction; import generic.Operand; import generic.InstructionList; -public class Move implements X86StaticInstructionHandler +public class FloatMove implements X86StaticInstructionHandler { public void handle(long instructionPointer, Operand operand1, Operand operand2, Operand operand3, @@ -38,30 +39,30 @@ public class Move implements X86StaticInstructionHandler throws InvalidInstructionException { //if operand1 is a register and operand2 is a register/immediate, we will use normal move operation - if( (operand1.isIntegerRegisterOperand()) && - (operand2.isIntegerRegisterOperand() || operand2.isImmediateOperand()) && + if( (operand1.isIntegerRegisterOperand() || operand1.isFloatRegisterOperand()) && + (operand2.isIntegerRegisterOperand() || operand1.isFloatRegisterOperand() || operand2.isImmediateOperand()) && (operand3==null)) { - instructionArrayList.appendInstruction(Instruction.getMoveInstruction(operand1, operand2)); + instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(operand2, null, operand1)); } //if operand1 is register and operand2 is a memory-operand, we will use load operation - else if((operand1.isIntegerRegisterOperand()) && + else if((operand1.isIntegerRegisterOperand() || operand1.isFloatRegisterOperand()) && operand2.isMemoryOperand() && operand3==null) { //Obtain value at the memory location [operand2] - instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand2, operand1)); + OperandTranslator.processSourceMemoryOperand(operand2, operand1, instructionArrayList, tempRegisterNum); } //if the operand1 is a memory location and operand2 is a register/immediate then //it is a store operation else if((operand1.isMemoryOperand()) && - (operand2.isImmediateOperand() || operand2.isIntegerRegisterOperand()) && + (operand2.isImmediateOperand() || operand2.isIntegerRegisterOperand() || operand2.isFloatRegisterOperand()) && (operand3==null)) { - instructionArrayList.appendInstruction(Instruction.getStoreInstruction(operand1, operand2)); + OperandTranslator.processDestinationMemoryOperand(operand2, operand1, instructionArrayList, tempRegisterNum); } //TODO I doubt if this is a valid instruction !! Anyways found this in an object-code @@ -72,12 +73,12 @@ public class Move implements X86StaticInstructionHandler operand2.isMemoryOperand() && operand3==null) { - misc.Error.invalidOperation("Move", operand1, operand2, operand3); + misc.Error.invalidOperation("Float Move", operand1, operand2, operand3); } else { - misc.Error.invalidOperation("Move", operand1, operand2, operand3); + misc.Error.invalidOperation("Float Move", operand1, operand2, operand3); } } } diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/FloatMul.java b/src/simulator/emulatorinterface/translator/x86/instruction/FloatMul.java new file mode 100644 index 0000000..8063ebf --- /dev/null +++ b/src/simulator/emulatorinterface/translator/x86/instruction/FloatMul.java @@ -0,0 +1,93 @@ +/***************************************************************************** + Tejas Simulator +------------------------------------------------------------------------------------------------------------ + + Copyright [2010] [Indian Institute of Technology, Delhi] + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +------------------------------------------------------------------------------------------------------------ + + Contributors: Prathmesh Kallurkar +*****************************************************************************/ + +package emulatorinterface.translator.x86.instruction; + + + +import emulatorinterface.translator.InvalidInstructionException; +import emulatorinterface.translator.x86.operand.OperandTranslator; +import emulatorinterface.translator.x86.registers.TempRegisterNum; +import generic.Instruction; +import generic.Operand; +import generic.InstructionList; + + +public class FloatMul implements X86StaticInstructionHandler +{ + public void handle(long instructionPointer, + Operand operand1, Operand operand2, Operand operand3, + InstructionList instructionArrayList, + TempRegisterNum tempRegisterNum) + throws InvalidInstructionException + { + if( + (operand1.isFloatRegisterOperand()) && + (operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) && + (operand3 == null)) + { + Operand srcOpnd1, srcOpnd2, destOpnd; + + srcOpnd1 = operand1; + + if(operand2.isMemoryOperand()) + { + srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false); + } + else + { + srcOpnd2 = operand2; + } + + destOpnd = operand1; + + instructionArrayList.appendInstruction(Instruction.getFloatingPointMultiplication(srcOpnd1, srcOpnd2, destOpnd)); + } + + else if( + (operand1.isFloatRegisterOperand()) && + (operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) && + (operand3 == null || operand3.isImmediateOperand() || operand3.isFloatRegisterOperand() || operand3.isMemoryOperand())) + { + Operand srcOpnd1, srcOpnd2, destOpnd; + + srcOpnd1 = operand2; + + if(operand3.isMemoryOperand()) + { + srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand3, instructionArrayList, tempRegisterNum, false); + } + else + { + srcOpnd2 = operand3; + } + + destOpnd = operand1; + + instructionArrayList.appendInstruction(Instruction.getFloatingPointMultiplication(srcOpnd1, srcOpnd2, destOpnd)); + } + + else + { + misc.Error.invalidOperation("Float Mul ", operand1, operand2, operand3); + } + } +} \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/InstructionClass.java b/src/simulator/emulatorinterface/translator/x86/instruction/InstructionClass.java index dfa9c0f..50b0f9a 100755 --- a/src/simulator/emulatorinterface/translator/x86/instruction/InstructionClass.java +++ b/src/simulator/emulatorinterface/translator/x86/instruction/InstructionClass.java @@ -23,18 +23,26 @@ package emulatorinterface.translator.x86.instruction; public enum InstructionClass { - INTEGER_ALU_IMPLICIT_DESTINATION, - INTEGER_ALU_NO_IMPLICIT_DESTINATION, - SINGLE_OPERAND_INTEGER_ALU, - SINGLE_OPERAND_INTEGER_ALU_IMPLICIT_ACCUMULATOR, + INTEGER_ALU, + INTEGER_ALU_NO_FLAG_MOD, + INTEGER_ALU_USES_FLAGS, + INTEGER_COMPARE_TEST, + INTEGER_COMPARE_TEST_SET, + EXTEND_EAX_TO_EDX, + ACCUMULATOR_ADJUSTMENTS, SHIFT_OPERATION_THREE_OPERANDS, - MOVE, + INTEGER_MOVE, + INTEGER_MOVE_ACCUMULATOR, + FLOAT_MOVE, CONDITIONAL_MOVE, EXCHANGE, + CMP_XCHG, + CMP_XCHG_BYTE, EXCHANGE_AND_ADD, CONDITIONAL_JUMP, UNCONDITIONAL_JUMP, - LOOP, + CONDITIONAL_LOOP, + UNCONDITIONAL_LOOP, NOP, INTEGER_MULTIPLICATION, INTEGER_DIVISION, @@ -45,7 +53,11 @@ public enum InstructionClass //Stack Operations PUSH, + PUSH_ALL, + PUSH_FLAGS, POP, + POP_ALL, + POP_FLAGS, CALL, RETURN, LEAVE, @@ -53,8 +65,16 @@ public enum InstructionClass //String Operations STRING_MOVE, + STRING_LOAD, + STRING_STORE, STRING_COMPARE, + STRING_COMPARE_ACCUMULATOR, + //flag mods + FLAGS_MOD_WITHOUT_SRC, + FLAGS_MOD_WITH_SRC, + FLAGS_STORE, + FLAGS_LOAD, //Floating Point operations FLOATING_POINT_LOAD_CONSTANT, @@ -63,28 +83,65 @@ public enum InstructionClass FLOATING_POINT_MULTIPLICATION, FLOATING_POINT_DIVISION, FLOATING_POINT_ALU, - FLOATING_POINT_SINGLE_OPERAND_ALU, + FLOATING_POINT_NO_OPERAND_ALU, FLOATING_POINT_EXCHANGE, FLOATING_POINT_COMPLEX_OPERATION, FLOATING_POINT_COMPARE, FLOATING_POINT_CONDITIONAL_MOVE, FLOATING_POINT_LOAD_CONTROL_WORD, FLOATING_POINT_STORE_CONTROL_WORD, + FLOATING_POINT_EXAMINE, //Convert operations + CONVERT_FLOAT_TO_PACKED_INTEGER, CONVERT_FLOAT_TO_INTEGER, + CONVERT_PACKED_INTEGER_TO_FLOAT, CONVERT_INTEGER_TO_FLOAT, + CONVERT_FLOAT_TO_FLOAT, //Not Handled REPEAT, LOCK, - //TODO SSE Instructions - SSE_MOVE, - SSE_ALU, - SSE_MULTIPLICATION, - SSE_DIVISION, - SSE_COMPARE_PACKED_DATA, + //SSE Instructions + SSE_INTEGER, + SSE_INTEGER_MUL_ADD, + SSE_INTEGER_COMPARE, + SSE_INTEGER_MUL, + SSE_STORE, + SSE_FLOAT, + SSE_FMA, + SSE_FLOAT_COMPARE, + SSE_FLOAT_MUL, + SSE_FLOAT_DIV, + + //Float + FLOAT_ALU, + FMA, + FLOAT_COMPARE, + FLOAT_COMPARE_EXPLICIT_DEST, + FLOAT_MUL, + FLOAT_DIV, + LOAD_MXCSR, + STORE_MXCSR, + + AES, + VECTOR_STRING_DEST_ECX, + VECTOR_STRING_DEST_XMM0, + BIT_SCAN, + VECTOR_SHUFFLE, + SQRT, + + CPUID, + INTERRUPT_RETURN, + MFENCE, + SFENCE, + LFENCE, + + READ_PREFETCH_L1, + READ_PREFETCH_L2, + READ_PREFETCH_L3, + WRITE_PREFETCH, INVALID, } \ No newline at end of file diff --git a/src/simulator/emulatorinterface/translator/x86/instruction/InstructionClassTable.java b/src/simulator/emulatorinterface/translator/x86/instruction/InstructionClassTable.java index f72e4f8..7513735 100755 --- a/src/simulator/emulatorinterface/translator/x86/instruction/InstructionClassTable.java +++ b/src/simulator/emulatorinterface/translator/x86/instruction/InstructionClassTable.java @@ -30,78 +30,82 @@ public class InstructionClassTable { private static void createInstructionClassHandlerTable() { // create an empty hash-table for storing object references. instructionClassHandlerTable = new Hashtable(); + + instructionClassHandlerTable.put( + InstructionClass.AES, + new AES()); + + instructionClassHandlerTable.put( + InstructionClass.VECTOR_STRING_DEST_ECX, + new VectorStringDestECX()); + + instructionClassHandlerTable.put( + InstructionClass.VECTOR_STRING_DEST_XMM0, + new VectorStringDestXMM0()); instructionClassHandlerTable.put( - InstructionClass.INTEGER_ALU_IMPLICIT_DESTINATION, - new IntegerALUImplicitDestination()); + InstructionClass.STRING_COMPARE, + new StringCompare()); instructionClassHandlerTable.put( - InstructionClass.INTEGER_ALU_NO_IMPLICIT_DESTINATION, - new IntegerALUExplicitDestination()); + InstructionClass.STRING_COMPARE_ACCUMULATOR, + new StringCompareAccumulator()); instructionClassHandlerTable.put( - InstructionClass.SINGLE_OPERAND_INTEGER_ALU, - new SingleOperandIntALU()); + InstructionClass.FLAGS_MOD_WITHOUT_SRC, + new FlagsModWithoutSrc()); instructionClassHandlerTable.put( - InstructionClass.SINGLE_OPERAND_INTEGER_ALU_IMPLICIT_ACCUMULATOR, - new SingleOperandIntALUImplicitAccumulator()); + InstructionClass.FLAGS_MOD_WITH_SRC, + new FlagsModWithSrc()); instructionClassHandlerTable.put( - InstructionClass.SHIFT_OPERATION_THREE_OPERANDS, - new ShiftOperationThreeOperand()); + InstructionClass.FLAGS_STORE, + new FlagsStore()); instructionClassHandlerTable.put( - InstructionClass.MOVE, - new Move()); + InstructionClass.FLAGS_LOAD, + new FlagsLoad()); + + instructionClassHandlerTable.put( + InstructionClass.BIT_SCAN, + new BitScan()); + + instructionClassHandlerTable.put( + InstructionClass.VECTOR_SHUFFLE, + new VectorShuffle()); instructionClassHandlerTable.put( - InstructionClass.CONDITIONAL_MOVE, - new ConditionalMove()); + InstructionClass.LOAD_EFFECTIVE_ADDRESS, + new LoadEffectiveAddress()); instructionClassHandlerTable.put( - InstructionClass.EXCHANGE, - new Exchange()); + InstructionClass.INTEGER_ALU, + new IntegerALU()); instructionClassHandlerTable.put( - InstructionClass.EXCHANGE_AND_ADD, - new ExchangeAndAdd()); + InstructionClass.INTEGER_ALU_NO_FLAG_MOD, + new IntegerALUNoFlagMod()); instructionClassHandlerTable.put( - InstructionClass.CONDITIONAL_JUMP, - new ConditionalJump()); + InstructionClass.INTEGER_ALU_USES_FLAGS, + new IntegerALUUsesFlags()); instructionClassHandlerTable.put( - InstructionClass.UNCONDITIONAL_JUMP, - new UnconditionalJump()); + InstructionClass.INTEGER_COMPARE_TEST, + new IntegerCompareTest()); instructionClassHandlerTable.put( - InstructionClass.LOOP, - new Loop()); + InstructionClass.INTEGER_COMPARE_TEST_SET, + new IntegerCompareTestSet()); instructionClassHandlerTable.put( - InstructionClass.PUSH, - new Push()); + InstructionClass.EXTEND_EAX_TO_EDX, + new ExtendEAXToEDX()); instructionClassHandlerTable.put( - InstructionClass.POP, - new Pop()); - - instructionClassHandlerTable.put( - InstructionClass.CALL, - new Call()); - - instructionClassHandlerTable.put( - InstructionClass.INTERRUPT, - new Interrupt()); - - instructionClassHandlerTable.put( - InstructionClass.RETURN, - new ReturnOp()); - - instructionClassHandlerTable.put( - InstructionClass.NOP, - new NOP()); + InstructionClass.ACCUMULATOR_ADJUSTMENTS, + new AccumulatorAdjustments()); instructionClassHandlerTable.put( InstructionClass.INTEGER_MULTIPLICATION, @@ -112,88 +116,224 @@ public class InstructionClassTable { new IntegerDivision()); instructionClassHandlerTable.put( - InstructionClass.LOAD_EFFECTIVE_ADDRESS, - new LoadEffectiveAddress()); + InstructionClass.INTEGER_MOVE, + new IntegerMove()); instructionClassHandlerTable.put( - InstructionClass.FLOATING_POINT_LOAD_CONSTANT, - new FloatingPointLoadConstant()); + InstructionClass.INTEGER_MOVE_ACCUMULATOR, + new IntegerMoveAccumulator()); instructionClassHandlerTable.put( - InstructionClass.FLOATING_POINT_LOAD, - new FloatingPointLoad()); + InstructionClass.FLOAT_MOVE, + new FloatMove()); instructionClassHandlerTable.put( - InstructionClass.FLOATING_POINT_STORE, - new FloatingPointStore()); + InstructionClass.EXCHANGE, + new Exchange()); instructionClassHandlerTable.put( - InstructionClass.FLOATING_POINT_MULTIPLICATION, - new FloatingPointMultiplication()); + InstructionClass.CMP_XCHG, + new CmpExchange()); instructionClassHandlerTable.put( - InstructionClass.FLOATING_POINT_DIVISION, - new FloatingPointDivision()); + InstructionClass.CMP_XCHG_BYTE, + new CmpExchangeByte()); instructionClassHandlerTable.put( - InstructionClass.FLOATING_POINT_EXCHANGE, - new FloatingPointExchange()); - - instructionClassHandlerTable.put( - InstructionClass.FLOATING_POINT_ALU, - new FloatingPointALU()); - - instructionClassHandlerTable.put( - InstructionClass.FLOATING_POINT_SINGLE_OPERAND_ALU, - new FloatingPointSingleOperandALU()); - - instructionClassHandlerTable.put( - InstructionClass.FLOATING_POINT_COMPLEX_OPERATION, - new FloatingPointComplexOperation()); - - instructionClassHandlerTable.put( - InstructionClass.CONVERT_FLOAT_TO_INTEGER, - new ConvertFloatToInteger()); - - instructionClassHandlerTable.put( - InstructionClass.CONVERT_INTEGER_TO_FLOAT, - new ConvertIntegerToFloat()); + InstructionClass.EXCHANGE_AND_ADD, + new ExchangeAndAdd()); instructionClassHandlerTable.put( InstructionClass.STRING_MOVE, new StringMove()); instructionClassHandlerTable.put( - InstructionClass.STRING_COMPARE, - new StringCompare()); + InstructionClass.STRING_LOAD, + new StringLoad()); instructionClassHandlerTable.put( - InstructionClass.SSE_MOVE, - new SSEMove()); + InstructionClass.STRING_STORE, + new StringStore()); instructionClassHandlerTable.put( - InstructionClass.SSE_ALU, - new SSEALU()); + InstructionClass.PUSH, + new Push()); instructionClassHandlerTable.put( - InstructionClass.SSE_MULTIPLICATION, - new SSEMultiplication()); + InstructionClass.PUSH_ALL, + new PushAll()); instructionClassHandlerTable.put( - InstructionClass.SSE_DIVISION, - new SSEDivision()); + InstructionClass.PUSH_FLAGS, + new PushFlags()); + + instructionClassHandlerTable.put( + InstructionClass.POP, + new Pop()); + + instructionClassHandlerTable.put( + InstructionClass.POP_ALL, + new PopAll()); + + instructionClassHandlerTable.put( + InstructionClass.POP_FLAGS, + new PopFlags()); + + instructionClassHandlerTable.put( + InstructionClass.CONDITIONAL_MOVE, + new ConditionalMove()); instructionClassHandlerTable.put( - InstructionClass.SSE_COMPARE_PACKED_DATA, - new SSEComparePackedData()); - + InstructionClass.CONDITIONAL_SET, + new ConditionalSet()); + + instructionClassHandlerTable.put( + InstructionClass.UNCONDITIONAL_JUMP, + new UnconditionalJump()); + + instructionClassHandlerTable.put( + InstructionClass.CONDITIONAL_JUMP, + new ConditionalJump()); + + instructionClassHandlerTable.put( + InstructionClass.UNCONDITIONAL_LOOP, + new Loop()); + + instructionClassHandlerTable.put( + InstructionClass.CONDITIONAL_LOOP, + new ConditionalLoop()); + + instructionClassHandlerTable.put( + InstructionClass.CALL, + new Call()); + + instructionClassHandlerTable.put( + InstructionClass.RETURN, + new ReturnOp()); + + instructionClassHandlerTable.put( + InstructionClass.NOP, + new NOP()); + + instructionClassHandlerTable.put( + InstructionClass.INTERRUPT, + new Interrupt()); + + instructionClassHandlerTable.put( + InstructionClass.SSE_INTEGER, + new SSEInteger()); + + instructionClassHandlerTable.put( + InstructionClass.SSE_INTEGER_MUL_ADD, + new SSEIntegerMul()); + + instructionClassHandlerTable.put( + InstructionClass.SSE_INTEGER_COMPARE, + new SSEIntegerCmp()); + + instructionClassHandlerTable.put( + InstructionClass.SSE_INTEGER_MUL, + new SSEIntegerMul()); + + instructionClassHandlerTable.put( + InstructionClass.SSE_STORE, + new SSEStore()); + + instructionClassHandlerTable.put( + InstructionClass.SSE_FLOAT, + new SSEFloat()); + + instructionClassHandlerTable.put( + InstructionClass.SSE_FMA, + new SSEFMA()); + + instructionClassHandlerTable.put( + InstructionClass.SSE_FLOAT_COMPARE, + new SSEFloatCmp()); + + instructionClassHandlerTable.put( + InstructionClass.SSE_FLOAT_MUL, + new SSEFloatMul()); + + instructionClassHandlerTable.put( + InstructionClass.SSE_FLOAT_DIV, + new SSEFloatMul()); + + instructionClassHandlerTable.put( + InstructionClass.FLOAT_ALU, + new FloatALU()); + + instructionClassHandlerTable.put( + InstructionClass.FMA, + new FMA()); + + instructionClassHandlerTable.put( + InstructionClass.FLOAT_COMPARE, + new FloatCmp()); + + instructionClassHandlerTable.put( + InstructionClass.FLOAT_MUL, + new FloatMul()); + + instructionClassHandlerTable.put( + InstructionClass.FLOAT_DIV, + new FloatDiv()); + + instructionClassHandlerTable.put( + InstructionClass.LOAD_MXCSR, + new LoadMXCSR()); + + instructionClassHandlerTable.put( + InstructionClass.STORE_MXCSR, + new StoreMXCSR()); + + instructionClassHandlerTable.put( + InstructionClass.SQRT, + new FloatDiv()); + + instructionClassHandlerTable.put( + InstructionClass.FLOATING_POINT_LOAD_CONSTANT, + new X87FloatingPointLoadConstant()); + + instructionClassHandlerTable.put( + InstructionClass.FLOATING_POINT_LOAD, + new X87FloatingPointLoad()); + + instructionClassHandlerTable.put( + InstructionClass.FLOATING_POINT_STORE, + new X87FloatingPointStore()); + + instructionClassHandlerTable.put( + InstructionClass.FLOATING_POINT_MULTIPLICATION, + new X87FloatingPointMultiplication()); + + instructionClassHandlerTable.put( + InstructionClass.FLOATING_POINT_DIVISION, + new X87FloatingPointDivision()); + + instructionClassHandlerTable.put( + InstructionClass.FLOATING_POINT_ALU, + new X87FloatingPointALU()); + + instructionClassHandlerTable.put( + InstructionClass.FLOATING_POINT_NO_OPERAND_ALU, + new X87FloatingPointNoOperandALU()); + + instructionClassHandlerTable.put( + InstructionClass.FLOATING_POINT_EXCHANGE, + new X87FloatingPointExchange()); + + instructionClassHandlerTable.put( + InstructionClass.FLOATING_POINT_COMPLEX_OPERATION, + new X87FloatingPointComplexOperation()); + instructionClassHandlerTable.put( InstructionClass.FLOATING_POINT_COMPARE, - new FloatingPointCompare()); - + new X87FloatingPointCompare()); + instructionClassHandlerTable.put( InstructionClass.FLOATING_POINT_CONDITIONAL_MOVE, - new FloatingPointConditionalMove()); + new X87FloatingPointConditionalMove()); instructionClassHandlerTable.put( InstructionClass.LEAVE, @@ -201,108 +341,160 @@ public class InstructionClassTable { instructionClassHandlerTable.put( InstructionClass.FLOATING_POINT_LOAD_CONTROL_WORD, - new FloatingPointLoadControlWord()); + new X87FloatingPointLoadControlWord()); instructionClassHandlerTable.put( InstructionClass.FLOATING_POINT_STORE_CONTROL_WORD, - new FloatingPointStoreControlWord()); + new X87FloatingPointStoreControlWord()); instructionClassHandlerTable.put( - InstructionClass.CONDITIONAL_SET, - new ConditionalSet()); + InstructionClass.FLOATING_POINT_EXAMINE, + new X87FloatingPointExamine()); + + instructionClassHandlerTable.put( + InstructionClass.CPUID, + new CPUID()); + + instructionClassHandlerTable.put( + InstructionClass.INTERRUPT_RETURN, + new InterruptReturn()); + + instructionClassHandlerTable.put( + InstructionClass.MFENCE, + new MFence()); + + instructionClassHandlerTable.put( + InstructionClass.SFENCE, + new SFence()); + + instructionClassHandlerTable.put( + InstructionClass.LFENCE, + new LFence()); + + instructionClassHandlerTable.put( + InstructionClass.READ_PREFETCH_L1, + new ReadPrefetchL1()); + + instructionClassHandlerTable.put( + InstructionClass.READ_PREFETCH_L2, + new ReadPrefetchL2()); + + instructionClassHandlerTable.put( + InstructionClass.READ_PREFETCH_L3, + new ReadPrefetchL3()); + + instructionClassHandlerTable.put( + InstructionClass.WRITE_PREFETCH, + new WritePrefetch()); } private static void createInstructionClassTable() { instructionClassTable = new Hashtable(); + + String AES[] = "aesenc|vaesenc|aesenclast|vaesenclast|aesdec|vaesdec|aesdeclast|vaesdeclast|aesimc|vaesimc|aeskeygenassist|vaeskeygenassist".split("\\|"); + for(int i=0; i