Browse code

[2SF] A few commits from the asmjit project.

Naram Qashat authored on 2014/10/24 04:28:29
Showing 2 changed files
... ...
@@ -869,22 +869,22 @@ static bool X86Assembler_dumpInstruction(StringBuilder& sb,
869 869
   return true;
870 870
 }
871 871
 
872
-static bool X86Assembler_dumpComment(StringBuilder& sb, size_t len, const uint8_t* binData, size_t binLength, size_t dispSize, const char* comment) {
873
-  size_t currentLength = len;
874
-  size_t commentLength = comment ? StringUtil::nlen(comment, kMaxCommentLength) : 0;
872
+static bool X86Assembler_dumpComment(StringBuilder& sb, size_t len, const uint8_t* binData, size_t binLen, size_t dispLen, size_t imLen, const char* comment) {
873
+  size_t currentLen = len;
874
+  size_t commentLen = comment ? StringUtil::nlen(comment, kMaxCommentLength) : 0;
875 875
 
876
-  ASMJIT_ASSERT(binLength >= dispSize);
876
+  ASMJIT_ASSERT(binLen >= dispLen);
877 877
 
878
-  if (binLength || commentLength) {
878
+  if (binLen || commentLen) {
879 879
     size_t align = 36;
880 880
     char sep = ';';
881 881
 
882
-    for (size_t i = (binLength == 0); i < 2; i++) {
882
+    for (size_t i = (binLen == 0); i < 2; i++) {
883 883
       size_t begin = sb.getLength();
884 884
 
885 885
       // Append align.
886
-      if (currentLength < align) {
887
-        if (!sb.appendChars(' ', align - currentLength))
886
+      if (currentLen < align) {
887
+        if (!sb.appendChars(' ', align - currentLen))
888 888
           return false;
889 889
       }
890 890
 
... ...
@@ -896,19 +896,21 @@ static bool X86Assembler_dumpComment(StringBuilder& sb, size_t len, const uint8_
896 896
 
897 897
       // Append binary data or comment.
898 898
       if (i == 0) {
899
-        if (!sb.appendHex(binData, binLength - dispSize))
899
+        if (!sb.appendHex(binData, binLen - dispLen - imLen))
900 900
           return false;
901
-        if (!sb.appendChars('.', dispSize * 2))
901
+        if (!sb.appendChars('.', dispLen * 2))
902 902
           return false;
903
-        if (commentLength == 0)
903
+        if (!sb.appendHex(binData + binLen - imLen, imLen))
904
+          return false;
905
+        if (commentLen == 0)
904 906
           break;
905 907
       }
906 908
       else {
907
-        if (!sb.appendString(comment, commentLength))
909
+        if (!sb.appendString(comment, commentLen))
908 910
           return false;
909 911
       }
910 912
 
911
-      currentLength += sb.getLength() - begin;
913
+      currentLen += sb.getLength() - begin;
912 914
       align += 22;
913 915
       sep = '|';
914 916
     }
... ...
@@ -4114,6 +4116,9 @@ _EmitDisplacement:
4114 4116
       EMIT_BYTE(0x01);
4115 4117
     else // if (dispSize == 4)
4116 4118
       EMIT_DWORD(0x04040404);
4119
+
4120
+    if (imLen != 0)
4121
+      goto _EmitImm;
4117 4122
   }
4118 4123
 
4119 4124
   // --------------------------------------------------------------------------
... ...
@@ -4138,9 +4143,9 @@ _EmitDone:
4138 4143
     X86Assembler_dumpInstruction(sb, Arch, code, options, o0, o1, o2, o3, loggerOptions);
4139 4144
 
4140 4145
     if ((loggerOptions & (1 << kLoggerOptionBinaryForm)) != 0)
4141
-      X86Assembler_dumpComment(sb, sb.getLength(), self->_cursor, static_cast<intptr_t>(cursor - self->_cursor), dispSize, self->_comment);
4146
+      X86Assembler_dumpComment(sb, sb.getLength(), self->_cursor, static_cast<intptr_t>(cursor - self->_cursor), dispSize, imLen, self->_comment);
4142 4147
     else
4143
-      X86Assembler_dumpComment(sb, sb.getLength(), nullptr, 0, 0, self->_comment);
4148
+      X86Assembler_dumpComment(sb, sb.getLength(), nullptr, 0, 0, 0, self->_comment);
4144 4149
 
4145 4150
 # ifdef ASMJIT_DEBUG
4146 4151
     if (self->_logger)
... ...
@@ -1798,6 +1798,22 @@ ASMJIT_ENUM(kX86FpCw) {
1798 1798
   kX86FpCw_IC_Affine      = 0x1000
1799 1799
 };
1800 1800
 
1801
+// ============================================================================
1802
+// [asmjit::kX86Cmp]
1803
+// ============================================================================
1804
+
1805
+//! X86/X64 Compare immediate encodings.
1806
+ASMJIT_ENUM(kX86Cmp) {
1807
+  kX86CmpEq = 0,
1808
+  kX86CmpLt = 1,
1809
+  kX86CmpLe = 2,
1810
+  kX86CmpUnordered = 3,
1811
+  kX86CmpNotEq = 4,
1812
+  kX86CmpNotLt = 5,
1813
+  kX86CmpNotLe = 6,
1814
+  kX86CmpOrdered = 7
1815
+};
1816
+
1801 1817
 // ============================================================================
1802 1818
 // [asmjit::kX86Prefetch]
1803 1819
 // ============================================================================