+/* Tests in detail the core arithmetic for pcmp{e,i}str{i,m} using
+ pcmpistri to drive it. Does not check the e-vs-i or i-vs-m
+ aspect. */
+
#include <string.h>
#include <stdio.h>
#include <assert.h>
-typedef unsigned char V128[16];
typedef unsigned int UInt;
typedef signed int Int;
typedef unsigned char UChar;
#define False ((Bool)0)
#define True ((Bool)1)
+//typedef unsigned char V128[16];
+typedef
+ union {
+ UChar uChar[16];
+ UInt uInt[4];
+ }
+ V128;
+
#define SHIFT_O 11
#define SHIFT_S 7
#define SHIFT_Z 6
assert(xx < 16);
xx = (xx << 4) | xx;
assert(xx < 256);
- (*dst)[i] = xx;
+ dst->uChar[i] = xx;
}
}
{
UInt i, res = 0;
for (i = 0; i < 16; i++) {
- res |= (((*arg)[i] == 0) ? 1 : 0) << i;
+ res |= ((arg->uChar[i] == 0) ? 1 : 0) << i;
}
return res;
}
assert((zmaskL >> 16) == 0);
assert((zmaskR >> 16) == 0);
+ /* Explicitly reject any imm8 values that haven't been validated,
+ even if they would probably work. Life is too short to have
+ unvalidated cases in the code base. */
+ switch (imm8) {
+ case 0x02: case 0x08: case 0x0C: case 0x12: case 0x1A:
+ case 0x3A: case 0x44: case 0x4A:
+ break;
+ default:
+ return False;
+ }
+
UInt fmt = (imm8 >> 0) & 3; // imm8[1:0] data format
UInt agg = (imm8 >> 2) & 3; // imm8[3:2] aggregation fn
UInt pol = (imm8 >> 4) & 3; // imm8[5:4] polarity
0x4A, False/*!isSTRM*/
);
assert(ok);
- resECX = *(UInt*)(&resV[0]);
+ resECX = resV.uInt[0];
return (resOSZACP << 16) | resECX;
}
0x3A, False/*!isSTRM*/
);
assert(ok);
- resECX = *(UInt*)(&resV[0]);
+ resECX = resV.uInt[0];
return (resOSZACP << 16) | resECX;
}
"popq %%rdx" "\n\t"
"movq %%rcx, %0" "\n\t"
"movq %%rdx, %1" "\n\t"
- : /*out*/ "=r"(res), "=r"(flags) : "r"/*in*/(&block[0][0])
+ : /*out*/ "=r"(res), "=r"(flags) : "r"/*in*/(&block[0])
: "rcx","rdx","xmm0","xmm2","xmm11","cc","memory"
);
return ((flags & 0x8D5) << 16) | (res & 0xFFFF);
0x0C, False/*!isSTRM*/
);
assert(ok);
- resECX = *(UInt*)(&resV[0]);
+ resECX = resV.uInt[0];
return (resOSZACP << 16) | resECX;
}
0x08, False/*!isSTRM*/
);
assert(ok);
- resECX = *(UInt*)(&resV[0]);
+ resECX = resV.uInt[0];
return (resOSZACP << 16) | resECX;
}
0x1A, False/*!isSTRM*/
);
assert(ok);
- resECX = *(UInt*)(&resV[0]);
+ resECX = resV.uInt[0];
return (resOSZACP << 16) | resECX;
}
0x02, False/*!isSTRM*/
);
assert(ok);
- resECX = *(UInt*)(&resV[0]);
+ resECX = resV.uInt[0];
return (resOSZACP << 16) | resECX;
}
0x12, False/*!isSTRM*/
);
assert(ok);
- resECX = *(UInt*)(&resV[0]);
+ resECX = resV.uInt[0];
return (resOSZACP << 16) | resECX;
}
0x44, False/*!isSTRM*/
);
assert(ok);
- resECX = *(UInt*)(&resV[0]);
+ resECX = resV.uInt[0];
return (resOSZACP << 16) | resECX;
}