From: David Schleef Date: Wed, 9 Jun 2010 23:14:32 +0000 (-0700) Subject: convert from stdint types to orc types X-Git-Tag: orc-0.4.6~86 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=27c572f26b36105a71bdbddcc07318dd2b158c53;p=platform%2Fupstream%2Forc.git convert from stdint types to orc types --- diff --git a/configure.ac b/configure.ac index 93cea8f..a120c96 100644 --- a/configure.ac +++ b/configure.ac @@ -43,8 +43,6 @@ AS_HOST_DEFINES() AC_C_BIGENDIAN -AX_CREATE_STDINT_H([orc/orc-stdint.h]) - AC_FUNC_MMAP() AC_CHECK_HEADERS([inttypes.h]) diff --git a/examples/example1.c b/examples/example1.c index 0d21b75..ad1630d 100644 --- a/examples/example1.c +++ b/examples/example1.c @@ -6,11 +6,11 @@ #define N 10 -int16_t a[N]; -int16_t b[N]; -int16_t c[N]; +orc_int16 a[N]; +orc_int16 b[N]; +orc_int16 c[N]; -void add_s16(int16_t *dest, int16_t *src1, int16_t *src2, int n); +void add_s16(orc_int16 *dest, orc_int16 *src1, orc_int16 *src2, int n); int @@ -39,7 +39,7 @@ main (int argc, char *argv[]) } void -add_s16(int16_t *dest, int16_t *src1, int16_t *src2, int n) +add_s16(orc_int16 *dest, orc_int16 *src1, orc_int16 *src2, int n) { static OrcProgram *p = NULL; OrcExecutor _ex; diff --git a/examples/mt19937ar.c b/examples/mt19937ar.c index f23b50e..604abbf 100644 --- a/examples/mt19937ar.c +++ b/examples/mt19937ar.c @@ -57,12 +57,12 @@ /* mag01[x] = x * MATRIX_A for x=0,1 */ -static const uint32_t mag01[2]={0x0UL, MATRIX_A}; +static const orc_uint32 mag01[2]={0x0UL, MATRIX_A}; void -mt19937_ref (uint32_t *d, uint32_t *mt) +mt19937_ref (orc_uint32 *d, orc_uint32 *mt) { - uint32_t y; + orc_uint32 y; int kk; for (kk=0;kksrc_values[0]; src = ex->src_values[1]; @@ -94,7 +94,7 @@ mulhslw (OrcOpcodeExecutor *ex, void *user) sh = scale >> 16; sl = scale & 0xffff; - ex->dest_values[0] = (int32_t) ((src * sl) >> 16) + (src * sh); + ex->dest_values[0] = (orc_int32) ((src * sl) >> 16) + (src * sh); } static OrcStaticOpcode opcodes[] = { @@ -112,19 +112,19 @@ register_instr (void) } static void -do_volume_c (int16_t *dest, const int32_t *vols, const int16_t *samp, int len) +do_volume_c (orc_int16 *dest, const orc_int32 *vols, const orc_int16 *samp, int len) { int i; for (i = 0; i < len; i++) { - int32_t t, hi, lo; + orc_int32 t, hi, lo; hi = vols[i] >> 16; lo = vols[i] & 0xffff; - t = (int32_t)(samp[i]); + t = (orc_int32)(samp[i]); t = ((t * lo) >> 16) + (t * hi); - dest[i] = (int16_t) ORC_CLAMP (t, -0x8000, 0x7FFF); + dest[i] = (orc_int16) ORC_CLAMP (t, -0x8000, 0x7FFF); } } @@ -132,9 +132,9 @@ do_volume_c (int16_t *dest, const int32_t *vols, const int16_t *samp, int len) static void do_volume_backup (OrcExecutor *ex) { - int16_t *dest; - int32_t *vols; - const int16_t *samp; + orc_int16 *dest; + orc_int32 *vols; + const orc_int16 *samp; int len; dest = ex->arrays[ORC_VAR_D1]; @@ -174,7 +174,7 @@ make_volume_orc() } static void -do_volume_orc (int16_t *dest, int32_t *volumes, int16_t *samp, int length) +do_volume_orc (orc_int16 *dest, orc_int32 *volumes, orc_int16 *samp, int length) { OrcExecutor _ex; OrcExecutor *ex = &_ex; @@ -191,7 +191,7 @@ do_volume_orc (int16_t *dest, int32_t *volumes, int16_t *samp, int length) orc_executor_run (ex); } -static uint64_t +static orc_uint64 get_timestamp () { #ifndef _MSC_VER @@ -208,15 +208,15 @@ get_timestamp () #define TIMES 100000 #define N 1024 -int16_t dest[N]; -int16_t samp[N]; -int32_t vols[N]; +orc_int16 dest[N]; +orc_int16 samp[N]; +orc_int32 vols[N]; int main (int argc, char *argv[]) { int i; - uint64_t start, stop; + orc_uint64 start, stop; /* orc_init() must be called before any other Orc function */ orc_init (); diff --git a/orc-test/orcrandom.c b/orc-test/orcrandom.c index a40112c..0f53963 100644 --- a/orc-test/orcrandom.c +++ b/orc-test/orcrandom.c @@ -21,7 +21,7 @@ orc_random_init (OrcRandomContext *context, int seed) void orc_random_bits (OrcRandomContext *context, void *data, int n_bytes) { - uint8_t *d = data; + orc_uint8 *d = data; int i; for(i=0;ix = 1103515245*context->x + 12345; diff --git a/orc-test/orctest.c b/orc-test/orctest.c index e1fa088..90e2cc7 100644 --- a/orc-test/orctest.c +++ b/orc-test/orctest.c @@ -342,7 +342,7 @@ void orc_test_random_bits (void *data, int n_bytes) { #if 1 - uint8_t *d = data; + orc_uint8 *d = data; int i; for(i=0;ielement_size) { case 1: - printf(" %4d", *(int8_t *)ptr); - return *(int8_t *)ptr; + printf(" %4d", *(orc_int8 *)ptr); + return *(orc_int8 *)ptr; case 2: - printf(" %5d", *(int16_t *)ptr); - return *(int16_t *)ptr; + printf(" %5d", *(orc_int16 *)ptr); + return *(orc_int16 *)ptr; case 4: - printf(" %10d", *(int32_t *)ptr); - return *(int32_t *)ptr; + printf(" %10d", *(orc_int32 *)ptr); + return *(orc_int32 *)ptr; case 8: - printf(" %20lld", (long long)*(int64_t *)ptr); - return *(int64_t *)ptr; + printf(" %20lld", (long long)*(orc_int64 *)ptr); + return *(orc_int64 *)ptr; default: return -1; } @@ -389,17 +389,17 @@ print_array_val_unsigned (OrcArray *array, int i, int j) switch (array->element_size) { case 1: - printf(" %4u", *(uint8_t *)ptr); - return *(int8_t *)ptr; + printf(" %4u", *(orc_uint8 *)ptr); + return *(orc_int8 *)ptr; case 2: - printf(" %5u", *(uint16_t *)ptr); - return *(int16_t *)ptr; + printf(" %5u", *(orc_uint16 *)ptr); + return *(orc_int16 *)ptr; case 4: - printf(" %10u", *(uint32_t *)ptr); - return *(int32_t *)ptr; + printf(" %10u", *(orc_uint32 *)ptr); + return *(orc_int32 *)ptr; case 8: - printf(" %20llu", (long long)*(uint64_t *)ptr); - return *(int64_t *)ptr; + printf(" %20llu", (long long)*(orc_uint64 *)ptr); + return *(orc_int64 *)ptr; default: return -1; } @@ -413,17 +413,17 @@ print_array_val_hex (OrcArray *array, int i, int j) switch (array->element_size) { case 1: - printf(" %02x", *(uint8_t *)ptr); - return *(int8_t *)ptr; + printf(" %02x", *(orc_uint8 *)ptr); + return *(orc_int8 *)ptr; case 2: - printf(" %04x", *(uint16_t *)ptr); - return *(int16_t *)ptr; + printf(" %04x", *(orc_uint16 *)ptr); + return *(orc_int16 *)ptr; case 4: - printf(" %08x", *(uint32_t *)ptr); - return *(int32_t *)ptr; + printf(" %08x", *(orc_uint32 *)ptr); + return *(orc_int32 *)ptr; case 8: - printf(" %016llx", (long long)*(uint64_t *)ptr); - return *(int64_t *)ptr; + printf(" %016llx", (long long)*(orc_uint64 *)ptr); + return *(orc_int64 *)ptr; default: return -1; } @@ -438,16 +438,16 @@ print_array_val_float (OrcArray *array, int i, int j) switch (array->element_size) { case 4: if (isnan(*(float *)ptr)) { - printf(" nan %08x", *(uint32_t *)ptr); + printf(" nan %08x", *(orc_uint32 *)ptr); /* This is to get around signaling/non-signaling nans in the output */ - return (*(uint32_t *)ptr) & 0xffbfffff; + return (*(orc_uint32 *)ptr) & 0xffbfffff; } else { printf(" %12.5g", *(float *)ptr); - return *(int32_t *)ptr; + return *(orc_int32 *)ptr; } case 8: printf(" %12.5g", *(double *)ptr); - return *(int64_t *)ptr; + return *(orc_int64 *)ptr; default: printf(" ERROR"); return -1; diff --git a/orc/Makefile.am b/orc/Makefile.am index 45b2dd6..7c4a304 100644 --- a/orc/Makefile.am +++ b/orc/Makefile.am @@ -84,12 +84,6 @@ pkginclude_HEADERS = \ orcpowerpc.h \ orcarm.h -nodist_pkginclude_HEADERS = orc-stdint.h - -DISTCLEANFILES = orc-stdint.h - - - orcfunctions: $(top_builddir)/tools/orcc$(EXEEXT) --implementation -o orcfunctions.c orcfunctions.orc $(top_builddir)/tools/orcc$(EXEEXT) --header -o orcfunctions.h orcfunctions.orc diff --git a/orc/opcodes.h b/orc/opcodes.h index f1d25dd..3b13344 100644 --- a/orc/opcodes.h +++ b/orc/opcodes.h @@ -1,113 +1,113 @@ UNARY_SB(absb, "ORC_ABS(%s)") BINARY_SB(addb, "%s + %s") BINARY_SB(addssb, "ORC_CLAMP_SB(%s + %s)") -BINARY_UB(addusb, "ORC_CLAMP_UB((uint8_t)%s + (uint8_t)%s)") +BINARY_UB(addusb, "ORC_CLAMP_UB((orc_uint8)%s + (orc_uint8)%s)") BINARY_SB(andb, "%s & %s") BINARY_SB(andnb, "(~%s) & %s") BINARY_SB(avgsb, "(%s + %s + 1)>>1") -BINARY_UB(avgub, "((uint8_t)%s + (uint8_t)%s + 1)>>1") +BINARY_UB(avgub, "((orc_uint8)%s + (orc_uint8)%s + 1)>>1") BINARY_SB(cmpeqb, "(%s == %s) ? (~0) : 0") BINARY_SB(cmpgtsb, "(%s > %s) ? (~0) : 0") UNARY_SB(copyb, "%s") BINARY_SB(maxsb, "ORC_MAX(%s, %s)") -BINARY_UB(maxub, "ORC_MAX((uint8_t)%s, (uint8_t)%s)") +BINARY_UB(maxub, "ORC_MAX((orc_uint8)%s, (orc_uint8)%s)") BINARY_SB(minsb, "ORC_MIN(%s, %s)") -BINARY_UB(minub, "ORC_MIN((uint8_t)%s, (uint8_t)%s)") +BINARY_UB(minub, "ORC_MIN((orc_uint8)%s, (orc_uint8)%s)") BINARY_SB(mullb, "(%s * %s) & 0xff") BINARY_SB(mulhsb, "(%s * %s) >> 8") -BINARY_UB(mulhub, "((uint32_t)(uint8_t)%s * (uint32_t)(uint8_t)%s) >> 8") +BINARY_UB(mulhub, "((orc_uint32)(orc_uint8)%s * (orc_uint32)(orc_uint8)%s) >> 8") BINARY_SB(orb, "%s | %s") BINARY_SB(shlb, "%s << %s") BINARY_SB(shrsb, "%s >> %s") -BINARY_UB(shrub, "((uint8_t)%s) >> %s") +BINARY_UB(shrub, "((orc_uint8)%s) >> %s") UNARY_SB(signb, "ORC_CLAMP(%s,-1,1)") BINARY_SB(subb, "%s - %s") BINARY_SB(subssb, "ORC_CLAMP_SB(%s - %s)") -BINARY_UB(subusb, "ORC_CLAMP_UB((uint8_t)%s - (uint8_t)%s)") +BINARY_UB(subusb, "ORC_CLAMP_UB((orc_uint8)%s - (orc_uint8)%s)") BINARY_SB(xorb, "%s ^ %s") UNARY_SW(absw, "ORC_ABS(%s)") BINARY_SW(addw, "%s + %s") BINARY_SW(addssw, "ORC_CLAMP_SW(%s + %s)") -BINARY_UW(addusw, "ORC_CLAMP_UW((uint16_t)%s + (uint16_t)%s)") +BINARY_UW(addusw, "ORC_CLAMP_UW((orc_uint16)%s + (orc_uint16)%s)") BINARY_SW(andw, "%s & %s") BINARY_SW(andnw, "(~%s) & %s") BINARY_SW(avgsw, "(%s + %s + 1)>>1") -BINARY_UW(avguw, "((uint16_t)%s + (uint16_t)%s + 1)>>1") +BINARY_UW(avguw, "((orc_uint16)%s + (orc_uint16)%s + 1)>>1") BINARY_SW(cmpeqw, "(%s == %s) ? (~0) : 0") BINARY_SW(cmpgtsw, "(%s > %s) ? (~0) : 0") UNARY_SW(copyw, "%s") BINARY_SW(maxsw, "ORC_MAX(%s, %s)") -BINARY_UW(maxuw, "ORC_MAX((uint16_t)%s, (uint16_t)%s)") +BINARY_UW(maxuw, "ORC_MAX((orc_uint16)%s, (orc_uint16)%s)") BINARY_SW(minsw, "ORC_MIN(%s, %s)") -BINARY_UW(minuw, "ORC_MIN((uint16_t)%s, (uint16_t)%s)") +BINARY_UW(minuw, "ORC_MIN((orc_uint16)%s, (orc_uint16)%s)") BINARY_SW(mullw, "(%s * %s) & 0xffff") BINARY_SW(mulhsw, "(%s * %s) >> 16") -BINARY_UW(mulhuw, "((uint32_t)((uint16_t)%s) * (uint32_t)((uint16_t)%s)) >> 16") +BINARY_UW(mulhuw, "((orc_uint32)((orc_uint16)%s) * (orc_uint32)((orc_uint16)%s)) >> 16") BINARY_SW(orw, "%s | %s") BINARY_SW(shlw, "%s << %s") BINARY_SW(shrsw, "%s >> %s") -BINARY_UW(shruw, "((uint16_t)%s) >> %s") +BINARY_UW(shruw, "((orc_uint16)%s) >> %s") UNARY_SW(signw, "ORC_CLAMP(%s,-1,1)") BINARY_SW(subw, "%s - %s") BINARY_SW(subssw, "ORC_CLAMP_SW(%s - %s)") -BINARY_UW(subusw, "ORC_CLAMP_UW((uint16_t)%s - (uint16_t)%s)") +BINARY_UW(subusw, "ORC_CLAMP_UW((orc_uint16)%s - (orc_uint16)%s)") BINARY_SW(xorw, "%s ^ %s") UNARY_SL(absl, "ORC_ABS(%s)") BINARY_SL(addl, "%s + %s") -BINARY_SL(addssl, "ORC_CLAMP_SL((int64_t)%s + (int64_t)%s)") -BINARY_UL(addusl, "ORC_CLAMP_UL((int64_t)(uint32_t)%s + (int64_t)(uint32_t)%s)") +BINARY_SL(addssl, "ORC_CLAMP_SL((orc_int64)%s + (orc_int64)%s)") +BINARY_UL(addusl, "ORC_CLAMP_UL((orc_int64)(orc_uint32)%s + (orc_int64)(orc_uint32)%s)") BINARY_SL(andl, "%s & %s") BINARY_SL(andnl, "(~%s) & %s") -BINARY_SL(avgsl, "((int64_t)%s + (int64_t)%s + 1)>>1") -BINARY_UL(avgul, "((uint64_t)(uint32_t)%s + (uint64_t)(uint32_t)%s + 1)>>1") +BINARY_SL(avgsl, "((orc_int64)%s + (orc_int64)%s + 1)>>1") +BINARY_UL(avgul, "((orc_uint64)(orc_uint32)%s + (orc_uint64)(orc_uint32)%s + 1)>>1") BINARY_SL(cmpeql, "(%s == %s) ? (~0) : 0") BINARY_SL(cmpgtsl, "(%s > %s) ? (~0) : 0") UNARY_SL(copyl, "%s") BINARY_SL(maxsl, "ORC_MAX(%s, %s)") -BINARY_UL(maxul, "ORC_MAX((uint32_t)%s, (uint32_t)%s)") +BINARY_UL(maxul, "ORC_MAX((orc_uint32)%s, (orc_uint32)%s)") BINARY_SL(minsl, "ORC_MIN(%s, %s)") -BINARY_UL(minul, "ORC_MIN((uint32_t)%s, (uint32_t)%s)") +BINARY_UL(minul, "ORC_MIN((orc_uint32)%s, (orc_uint32)%s)") BINARY_SL(mulll, "(%s * %s) & 0xffffffff") -BINARY_SL(mulhsl, "((int64_t)%s * (int64_t)%s) >> 32") -BINARY_UL(mulhul, "((uint64_t)%s * (uint64_t)%s) >> 32") +BINARY_SL(mulhsl, "((orc_int64)%s * (orc_int64)%s) >> 32") +BINARY_UL(mulhul, "((orc_uint64)%s * (orc_uint64)%s) >> 32") BINARY_SL(orl, "%s | %s") BINARY_SL(shll, "%s << %s") BINARY_SL(shrsl, "%s >> %s") -BINARY_UL(shrul, "((uint32_t)%s) >> %s") +BINARY_UL(shrul, "((orc_uint32)%s) >> %s") UNARY_SL(signl, "ORC_CLAMP(%s,-1,1)") BINARY_SL(subl, "%s - %s") -BINARY_SL(subssl, "ORC_CLAMP_SL((int64_t)%s - (int64_t)%s)") -BINARY_UL(subusl, "ORC_CLAMP_UL((int64_t)(uint32_t)%s - (int64_t)(uint32_t)%s)") +BINARY_SL(subssl, "ORC_CLAMP_SL((orc_int64)%s - (orc_int64)%s)") +BINARY_UL(subusl, "ORC_CLAMP_UL((orc_int64)(orc_uint32)%s - (orc_int64)(orc_uint32)%s)") BINARY_SL(xorl, "%s ^ %s") UNARY_BW(convsbw, "%s") -UNARY_BW(convubw, "(uint8_t)%s") +UNARY_BW(convubw, "(orc_uint8)%s") UNARY_WL(convswl, "%s") -UNARY_WL(convuwl, "(uint16_t)%s") +UNARY_WL(convuwl, "(orc_uint16)%s") UNARY_WB(convwb, "%s") UNARY_WB(convssswb, "ORC_CLAMP_SB(%s)") UNARY_WB(convsuswb, "ORC_CLAMP_UB(%s)") -UNARY_WB(convusswb, "ORC_CLAMP_SB((uint16_t)%s)") -UNARY_WB(convuuswb, "ORC_CLAMP_UB((uint16_t)%s)") +UNARY_WB(convusswb, "ORC_CLAMP_SB((orc_uint16)%s)") +UNARY_WB(convuuswb, "ORC_CLAMP_UB((orc_uint16)%s)") UNARY_LW(convlw, "%s") UNARY_LW(convssslw, "ORC_CLAMP_SW(%s)") UNARY_LW(convsuslw, "ORC_CLAMP_UW(%s)") -UNARY_LW(convusslw, "ORC_CLAMP_SW((uint32_t)%s)") -UNARY_LW(convuuslw, "ORC_CLAMP_UW((uint32_t)%s)") +UNARY_LW(convusslw, "ORC_CLAMP_SW((orc_uint32)%s)") +UNARY_LW(convuuslw, "ORC_CLAMP_UW((orc_uint32)%s)") BINARY_BW(mulsbw, "%s * %s") -BINARY_BW(mulubw, "(uint8_t)%s * (uint8_t)%s") +BINARY_BW(mulubw, "(orc_uint8)%s * (orc_uint8)%s") BINARY_WL(mulswl, "%s * %s") -BINARY_WL(muluwl, "(uint16_t)%s * (uint16_t)%s") +BINARY_WL(muluwl, "(orc_uint16)%s * (orc_uint16)%s") -BINARY_WL(mergewl, "((uint16_t)%s) | ((uint16_t)%s << 16)") -BINARY_BW(mergebw, "((uint8_t)%s) | ((uint8_t)%s << 8)") -UNARY_WB(select0wb, "(uint16_t)%s & 0xff") -UNARY_WB(select1wb, "((uint16_t)%s >> 8)&0xff") -UNARY_LW(select0lw, "(uint32_t)%s & 0xffff") -UNARY_LW(select1lw, "((uint32_t)%s >> 16)&0xffff") +BINARY_WL(mergewl, "((orc_uint16)%s) | ((orc_uint16)%s << 16)") +BINARY_BW(mergebw, "((orc_uint8)%s) | ((orc_uint8)%s << 8)") +UNARY_WB(select0wb, "(orc_uint16)%s & 0xff") +UNARY_WB(select1wb, "((orc_uint16)%s >> 8)&0xff") +UNARY_LW(select0lw, "(orc_uint32)%s & 0xffff") +UNARY_LW(select1lw, "((orc_uint32)%s >> 16)&0xffff") UNARY_UW(swapw, "ORC_SWAP_W(%s)") UNARY_UL(swapl, "ORC_SWAP_L(%s)") diff --git a/orc/orc.h b/orc/orc.h index 3f711be..d6e8bc6 100644 --- a/orc/orc.h +++ b/orc/orc.h @@ -3,7 +3,6 @@ #define _ORC_ORC_H_ #include -#include #include #include #include diff --git a/orc/orcarm.c b/orc/orcarm.c index adb7d45..6bfea2b 100644 --- a/orc/orcarm.c +++ b/orc/orcarm.c @@ -59,7 +59,7 @@ orc_arm_reg_name (int reg) } void -orc_arm_emit (OrcCompiler *compiler, uint32_t insn) +orc_arm_emit (OrcCompiler *compiler, orc_uint32 insn) { ORC_WRITE_UINT32_LE (compiler->codeptr, insn); compiler->codeptr+=4; @@ -138,7 +138,7 @@ orc_arm_do_fixups (OrcCompiler *compiler) for(i=0;in_fixups;i++){ unsigned char *label = compiler->labels[compiler->fixups[i].label]; unsigned char *ptr = compiler->fixups[i].ptr; - uint32_t code; + orc_uint32 code; int diff; if (compiler->fixups[i].type == 0) { @@ -169,7 +169,7 @@ orc_arm_emit_align (OrcCompiler *compiler, int align_shift) void orc_arm_emit_branch (OrcCompiler *compiler, int cond, int label) { - uint32_t code; + orc_uint32 code; code = 0x0afffffe; code |= (cond&0xf) << 28; @@ -182,7 +182,7 @@ orc_arm_emit_branch (OrcCompiler *compiler, int cond, int label) void orc_arm_emit_load_imm (OrcCompiler *compiler, int dest, int imm) { - uint32_t code; + orc_uint32 code; int shift2; unsigned int x; @@ -213,7 +213,7 @@ orc_arm_emit_load_imm (OrcCompiler *compiler, int dest, int imm) void orc_arm_emit_add_imm (OrcCompiler *compiler, int dest, int src1, int imm) { - uint32_t code; + orc_uint32 code; int shift2; unsigned int x; @@ -246,7 +246,7 @@ orc_arm_emit_add_imm (OrcCompiler *compiler, int dest, int src1, int imm) void orc_arm_emit_and_imm (OrcCompiler *compiler, int dest, int src1, int value) { - uint32_t code; + orc_uint32 code; code = 0xe2000000; code |= (src1&0xf) << 16; @@ -263,7 +263,7 @@ orc_arm_emit_and_imm (OrcCompiler *compiler, int dest, int src1, int value) void orc_arm_emit_cmp (OrcCompiler *compiler, int src1, int src2) { - uint32_t code; + orc_uint32 code; code = 0xe1500000; code |= (src1&0xf) << 16; @@ -278,7 +278,7 @@ orc_arm_emit_cmp (OrcCompiler *compiler, int src1, int src2) void orc_arm_emit_asr_imm (OrcCompiler *compiler, int dest, int src1, int value) { - uint32_t code; + orc_uint32 code; if (value == 0) { ORC_ERROR("bad immediate value"); @@ -298,7 +298,7 @@ orc_arm_emit_asr_imm (OrcCompiler *compiler, int dest, int src1, int value) void orc_arm_emit_lsl_imm (OrcCompiler *compiler, int dest, int src1, int value) { - uint32_t code; + orc_uint32 code; if (value == 0) { ORC_ERROR("bad immediate value"); @@ -318,7 +318,7 @@ orc_arm_emit_lsl_imm (OrcCompiler *compiler, int dest, int src1, int value) void orc_arm_emit_load_reg (OrcCompiler *compiler, int dest, int src1, int offset) { - uint32_t code; + orc_uint32 code; code = 0xe5900000; code |= (src1&0xf) << 16; @@ -334,7 +334,7 @@ orc_arm_emit_load_reg (OrcCompiler *compiler, int dest, int src1, int offset) void orc_arm_emit_store_reg (OrcCompiler *compiler, int src1, int dest, int offset) { - uint32_t code; + orc_uint32 code; code = 0xe5800000; code |= (dest&0xf) << 16; @@ -424,13 +424,13 @@ orc_arm_emit_cmp_imm (OrcCompiler *compiler, int src1, int value) */ void orc_arm_emit_dp (OrcCompiler *p, int type, OrcArmCond cond, OrcArmDP opcode, - int S, int Rd, int Rn, int Rm, int shift, uint32_t val) + int S, int Rd, int Rn, int Rm, int shift, orc_uint32 val) { - uint32_t code; + orc_uint32 code; int I = 0; int shifter_op; char shifter[64]; - uint32_t imm; + orc_uint32 imm; static const char *shift_names[] = { "LSL", "LSR", "ASR", "ROR" }; @@ -450,7 +450,7 @@ orc_arm_emit_dp (OrcCompiler *p, int type, OrcArmCond cond, OrcArmDP opcode, switch (type) { case 0: /* #imm */ - imm = (uint32_t) val; + imm = (orc_uint32) val; /* if imm <= 0xff we're done. It's recommanded that we choose the * smallest shifter value. Impossible values will overflow the shifter. */ while (imm > 0xff && shift < 16) { @@ -529,7 +529,7 @@ void orc_arm_emit_par (OrcCompiler *p, int op, int mode, OrcArmCond cond, int Rd, int Rn, int Rm) { - uint32_t code; + orc_uint32 code; static const int par_op[] = { 1, 3, 5, 7, 9, 15, 11, 5, 5 }; @@ -565,9 +565,9 @@ void orc_arm_emit_xt (OrcCompiler *p, int op, OrcArmCond cond, int Rd, int Rn, int Rm, int r8) { - uint32_t code; + orc_uint32 code; char shifter[64]; - static const uint32_t xt_opcodes[] = { + static const orc_uint32 xt_opcodes[] = { 0x06800070, 0x06a00070, 0x06b00070, 0x06c00070, 0x06e00070, 0x06f00070 }; static const char *xt_insn_names[] = { @@ -604,9 +604,9 @@ void orc_arm_emit_pkh (OrcCompiler *p, int op, OrcArmCond cond, int Rd, int Rn, int Rm, int sh) { - uint32_t code; + orc_uint32 code; char shifter[64]; - static const uint32_t pkh_opcodes[] = { 0x06800010, 0x06800050 }; + static const orc_uint32 pkh_opcodes[] = { 0x06800010, 0x06800050 }; static const char *pkh_insn_names[] = { "pkhbt", "pkhtb" }; if (sh > 0) { @@ -640,9 +640,9 @@ void orc_arm_emit_sat (OrcCompiler *p, int op, OrcArmCond cond, int Rd, int sat, int Rm, int sh, int asr) { - uint32_t code; + orc_uint32 code; char shifter[64]; - static const uint32_t sat_opcodes[] = { 0x06a00010, 0x06e00010, 0, 0 }; + static const orc_uint32 sat_opcodes[] = { 0x06a00010, 0x06e00010, 0, 0 }; static const char *sat_insn_names[] = { "ssat", "usat", "ssat16", "usat16" }; static const int par_mode[] = { 0, 0, 0x6a, 0x6e }; static const int par_op[] = { 0, 0, 3, 3 }; @@ -673,8 +673,8 @@ void orc_arm_emit_rv (OrcCompiler *p, int op, OrcArmCond cond, int Rd, int Rm) { - uint32_t code; - static const uint32_t rv_opcodes[] = { 0x06b00030, 0x06e000b0 }; + orc_uint32 code; + static const orc_uint32 rv_opcodes[] = { 0x06b00030, 0x06e000b0 }; static const char *rv_insn_names[] = { "rev", "rev16" }; code = arm_code_rv (rv_opcodes[op], cond, Rd, Rm); diff --git a/orc/orcarm.h b/orc/orcarm.h index 5a97441..8e58f9a 100644 --- a/orc/orcarm.h +++ b/orc/orcarm.h @@ -68,7 +68,7 @@ typedef enum { ORC_ARM_ROR } OrcArmShift; -void orc_arm_emit (OrcCompiler *compiler, uint32_t insn); +void orc_arm_emit (OrcCompiler *compiler, orc_uint32 insn); void orc_arm_emit_bx_lr (OrcCompiler *compiler); const char * orc_arm_reg_name (int reg); const char * orc_arm_cond_name (OrcArmCond cond); @@ -101,7 +101,7 @@ void orc_arm_add_fixup (OrcCompiler *compiler, int label, int type); void orc_arm_do_fixups (OrcCompiler *compiler); void orc_arm_emit_dp (OrcCompiler *p, int type, OrcArmCond cond, OrcArmDP opcode, - int S, int Rd, int Rn, int Rm, int shift, uint32_t val); + int S, int Rd, int Rn, int Rm, int shift, orc_uint32 val); void orc_arm_emit_par (OrcCompiler *p, int op, int mode, OrcArmCond cond, int Rd, int Rn, int Rm); void orc_arm_emit_xt (OrcCompiler *p, int op, OrcArmCond cond, diff --git a/orc/orccpu-x86.c b/orc/orccpu-x86.c index 4c9c119..3254f34 100644 --- a/orc/orccpu-x86.c +++ b/orc/orccpu-x86.c @@ -165,7 +165,7 @@ orc_mmx_getflags_cpuinfo (char *cpuinfo) #ifdef USE_I386_CPUID #ifdef _MSC_VER static void -get_cpuid (uint32_t op, uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d) +get_cpuid (orc_uint32 op, orc_uint32 *a, orc_uint32 *b, orc_uint32 *c, orc_uint32 *d) { int tmp[4]; __cpuid(tmp, op); @@ -178,7 +178,7 @@ get_cpuid (uint32_t op, uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d) #ifdef __i386__ static void -get_cpuid (uint32_t op, uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d) +get_cpuid (orc_uint32 op, orc_uint32 *a, orc_uint32 *b, orc_uint32 *c, orc_uint32 *d) { __asm__ ( " pushl %%ebx\n" @@ -192,7 +192,7 @@ get_cpuid (uint32_t op, uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d) #ifdef __amd64__ static void -get_cpuid (uint32_t op, uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d) +get_cpuid (orc_uint32 op, orc_uint32 *a, orc_uint32 *b, orc_uint32 *c, orc_uint32 *d) { __asm__ ( " pushq %%rbx\n" @@ -208,7 +208,7 @@ get_cpuid (uint32_t op, uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d) static void test_cpuid (void *ignored) { - uint32_t eax, ebx, ecx, edx; + orc_uint32 eax, ebx, ecx, edx; get_cpuid (0x00000000, &eax, &ebx, &ecx, &edx); } @@ -217,8 +217,8 @@ test_cpuid (void *ignored) static unsigned int orc_sse_detect_cpuid (void) { - uint32_t eax, ebx, ecx, edx; - uint32_t level; + orc_uint32 eax, ebx, ecx, edx; + orc_uint32 level; char vendor[13] = { 0 }; unsigned int sse_flags = 0; #if 0 @@ -233,8 +233,8 @@ orc_sse_detect_cpuid (void) } #endif - get_cpuid (0x00000000, &level, (uint32_t *)(vendor+0), - (uint32_t *)(vendor+8), (uint32_t *)(vendor+4)); + get_cpuid (0x00000000, &level, (orc_uint32 *)(vendor+0), + (orc_uint32 *)(vendor+8), (orc_uint32 *)(vendor+4)); ORC_DEBUG("cpuid %d %s", level, vendor); @@ -298,13 +298,13 @@ orc_sse_detect_cpuid (void) static unsigned int orc_mmx_detect_cpuid (void) { - uint32_t eax, ebx, ecx, edx; - uint32_t level; + orc_uint32 eax, ebx, ecx, edx; + orc_uint32 level; char vendor[13] = { 0 }; unsigned int mmx_flags = 0; - get_cpuid (0x00000000, &level, (uint32_t *)(vendor+0), - (uint32_t *)(vendor+8), (uint32_t *)(vendor+4)); + get_cpuid (0x00000000, &level, (orc_uint32 *)(vendor+0), + (orc_uint32 *)(vendor+8), (orc_uint32 *)(vendor+4)); ORC_DEBUG("cpuid %d %s", level, vendor); diff --git a/orc/orcexecutor.c b/orc/orcexecutor.c index 525f1a7..d37c76c 100644 --- a/orc/orcexecutor.c +++ b/orc/orcexecutor.c @@ -173,16 +173,16 @@ orc_executor_emulate (OrcExecutor *ex) switch (var->size) { case 1: - opcode_ex.src_values[k] = *(int8_t *)ptr; + opcode_ex.src_values[k] = *(orc_int8 *)ptr; break; case 2: - opcode_ex.src_values[k] = *(int16_t *)ptr; + opcode_ex.src_values[k] = *(orc_int16 *)ptr; break; case 4: - opcode_ex.src_values[k] = *(int32_t *)ptr; + opcode_ex.src_values[k] = *(orc_int32 *)ptr; break; case 8: - opcode_ex.src_values[k] = *(int64_t *)ptr; + opcode_ex.src_values[k] = *(orc_int64 *)ptr; break; default: ORC_ERROR("unhandled size %d", program->vars[insn->src_args[k]].size); @@ -208,16 +208,16 @@ orc_executor_emulate (OrcExecutor *ex) switch (var->size) { case 1: - *(int8_t *)ptr = opcode_ex.dest_values[k]; + *(orc_int8 *)ptr = opcode_ex.dest_values[k]; break; case 2: - *(int16_t *)ptr = opcode_ex.dest_values[k]; + *(orc_int16 *)ptr = opcode_ex.dest_values[k]; break; case 4: - *(int32_t *)ptr = opcode_ex.dest_values[k]; + *(orc_int32 *)ptr = opcode_ex.dest_values[k]; break; case 8: - *(int64_t *)ptr = opcode_ex.dest_values[k]; + *(orc_int64 *)ptr = opcode_ex.dest_values[k]; break; default: ORC_ERROR("unhandled size %d", program->vars[insn->dest_args[k]].size); diff --git a/orc/orcopcodes.c b/orc/orcopcodes.c index 004fcd1..587058d 100644 --- a/orc/orcopcodes.c +++ b/orc/orcopcodes.c @@ -267,85 +267,85 @@ orc_opcode_find_by_name (const char *name) static void convsbw (OrcOpcodeExecutor *ex, void *user) { - ex->dest_values[0] = (int8_t)(ex->src_values[0]); + ex->dest_values[0] = (orc_int8)(ex->src_values[0]); } static void convubw (OrcOpcodeExecutor *ex, void *user) { - ex->dest_values[0] = (uint8_t)(ex->src_values[0]); + ex->dest_values[0] = (orc_uint8)(ex->src_values[0]); } static void convswl (OrcOpcodeExecutor *ex, void *user) { - ex->dest_values[0] = (int16_t)(ex->src_values[0]); + ex->dest_values[0] = (orc_int16)(ex->src_values[0]); } static void convuwl (OrcOpcodeExecutor *ex, void *user) { - ex->dest_values[0] = (uint16_t)(ex->src_values[0]); + ex->dest_values[0] = (orc_uint16)(ex->src_values[0]); } static void convwb (OrcOpcodeExecutor *ex, void *user) { - ex->dest_values[0] = (int16_t)(ex->src_values[0]); + ex->dest_values[0] = (orc_int16)(ex->src_values[0]); } static void convssswb (OrcOpcodeExecutor *ex, void *user) { - ex->dest_values[0] = ORC_CLAMP_SB((int16_t)(ex->src_values[0])); + ex->dest_values[0] = ORC_CLAMP_SB((orc_int16)(ex->src_values[0])); } static void convsuswb (OrcOpcodeExecutor *ex, void *user) { - ex->dest_values[0] = ORC_CLAMP_UB((int16_t)(ex->src_values[0])); + ex->dest_values[0] = ORC_CLAMP_UB((orc_int16)(ex->src_values[0])); } static void convusswb (OrcOpcodeExecutor *ex, void *user) { - ex->dest_values[0] = MIN((int)(uint16_t)(ex->src_values[0]), ORC_SB_MAX); + ex->dest_values[0] = MIN((int)(orc_uint16)(ex->src_values[0]), ORC_SB_MAX); } static void convuuswb (OrcOpcodeExecutor *ex, void *user) { - ex->dest_values[0] = MIN((int)(uint16_t)(ex->src_values[0]), ORC_UB_MAX); + ex->dest_values[0] = MIN((int)(orc_uint16)(ex->src_values[0]), ORC_UB_MAX); } static void convlw (OrcOpcodeExecutor *ex, void *user) { - ex->dest_values[0] = (int32_t)(ex->src_values[0]); + ex->dest_values[0] = (orc_int32)(ex->src_values[0]); } static void convssslw (OrcOpcodeExecutor *ex, void *user) { - ex->dest_values[0] = ORC_CLAMP_SW((int32_t)(ex->src_values[0])); + ex->dest_values[0] = ORC_CLAMP_SW((orc_int32)(ex->src_values[0])); } static void convsuslw (OrcOpcodeExecutor *ex, void *user) { - ex->dest_values[0] = ORC_CLAMP_UW((int32_t)(ex->src_values[0])); + ex->dest_values[0] = ORC_CLAMP_UW((orc_int32)(ex->src_values[0])); } static void convusslw (OrcOpcodeExecutor *ex, void *user) { - ex->dest_values[0] = ORC_CLAMP_SW((uint32_t)(ex->src_values[0])); + ex->dest_values[0] = ORC_CLAMP_SW((orc_uint32)(ex->src_values[0])); } static void convuuslw (OrcOpcodeExecutor *ex, void *user) { - ex->dest_values[0] = ORC_CLAMP_UW((uint32_t)(ex->src_values[0])); + ex->dest_values[0] = ORC_CLAMP_UW((orc_uint32)(ex->src_values[0])); } #define UNARY(name,type,code) \ @@ -365,17 +365,17 @@ name (OrcOpcodeExecutor *ex, void *user) \ ex->dest_values[0] = ( type )( code ); \ } -#define UNARY_SB(name,code) UNARY(name, int8_t, code) -#define BINARY_SB(name,code) BINARY(name, int8_t, code) -#define BINARY_UB(name,code) BINARY(name, uint8_t, code) +#define UNARY_SB(name,code) UNARY(name, orc_int8, code) +#define BINARY_SB(name,code) BINARY(name, orc_int8, code) +#define BINARY_UB(name,code) BINARY(name, orc_uint8, code) -#define UNARY_SW(name,code) UNARY(name, int16_t, code) -#define BINARY_SW(name,code) BINARY(name, int16_t, code) -#define BINARY_UW(name,code) BINARY(name, uint16_t, code) +#define UNARY_SW(name,code) UNARY(name, orc_int16, code) +#define BINARY_SW(name,code) BINARY(name, orc_int16, code) +#define BINARY_UW(name,code) BINARY(name, orc_uint16, code) -#define UNARY_SL(name,code) UNARY(name, int32_t, code) -#define BINARY_SL(name,code) BINARY(name, int32_t, code) -#define BINARY_UL(name,code) BINARY(name, uint32_t, code) +#define UNARY_SL(name,code) UNARY(name, orc_int32, code) +#define BINARY_SL(name,code) BINARY(name, orc_int32, code) +#define BINARY_UL(name,code) BINARY(name, orc_uint32, code) UNARY_SB(absb, (a<0)?-a:a) BINARY_SB(addb, a + b) @@ -435,30 +435,30 @@ BINARY_SW(xorw, a ^ b) UNARY_SL(absl, (a<0)?-a:a) BINARY_SL(addl, a + b) -BINARY_SL(addssl, ORC_CLAMP_SL((int64_t)a + (int64_t)b)) -BINARY_UL(addusl, ORC_CLAMP_UL((uint64_t)(uint32_t)a + (uint64_t)(uint32_t)b)) +BINARY_SL(addssl, ORC_CLAMP_SL((orc_int64)a + (orc_int64)b)) +BINARY_UL(addusl, ORC_CLAMP_UL((orc_uint64)(orc_uint32)a + (orc_uint64)(orc_uint32)b)) BINARY_SL(andl, a & b) BINARY_SL(andnl, (~a) & b) -BINARY_SL(avgsl, ((int64_t)a + (int64_t)b + 1)>>1) -BINARY_UL(avgul, ((uint64_t)(uint32_t)a + (uint64_t)(uint32_t)b + 1)>>1) +BINARY_SL(avgsl, ((orc_int64)a + (orc_int64)b + 1)>>1) +BINARY_UL(avgul, ((orc_uint64)(orc_uint32)a + (orc_uint64)(orc_uint32)b + 1)>>1) BINARY_SL(cmpeql, (a == b) ? (~0) : 0) BINARY_SL(cmpgtsl, (a > b) ? (~0) : 0) UNARY_SL(copyl, a) BINARY_SL(maxsl, (a > b) ? a : b) -BINARY_UL(maxul, ((uint32_t)a > (uint32_t)b) ? a : b) +BINARY_UL(maxul, ((orc_uint32)a > (orc_uint32)b) ? a : b) BINARY_SL(minsl, (a < b) ? a : b) -BINARY_UL(minul, ((uint32_t)a < (uint32_t)b) ? a : b) +BINARY_UL(minul, ((orc_uint32)a < (orc_uint32)b) ? a : b) BINARY_SL(mulll, (a * b) & 0xffffffff) -BINARY_SL(mulhsl, ((int64_t)a * (int64_t)b) >> 32) -BINARY_UL(mulhul, ((uint64_t)a * (uint64_t)b) >> 32) +BINARY_SL(mulhsl, ((orc_int64)a * (orc_int64)b) >> 32) +BINARY_UL(mulhul, ((orc_uint64)a * (orc_uint64)b) >> 32) BINARY_SL(orl, a | b) BINARY_SL(shll, a << b) BINARY_SL(shrsl, a >> b) -BINARY_UL(shrul, ((uint32_t)a) >> b) +BINARY_UL(shrul, ((orc_uint32)a) >> b) UNARY_SL(signl, ORC_CLAMP(a,-1,1)) BINARY_SL(subl, a - b) -BINARY_SL(subssl, ORC_CLAMP_SL((int64_t)a - (int64_t)b)) -BINARY_UL(subusl, (((uint32_t)a) < ((uint32_t)b)) ? 0 : a - b) +BINARY_SL(subssl, ORC_CLAMP_SL((orc_int64)a - (orc_int64)b)) +BINARY_UL(subusl, (((orc_uint32)a) < ((orc_uint32)b)) ? 0 : a - b) BINARY_SL(xorl, a ^ b) @@ -470,13 +470,13 @@ name (OrcOpcodeExecutor *ex, void *user) \ ((type2)(type1)ex->src_values[1]); \ } -MUL(mulsbw, int8_t, int16_t) -MUL(mulubw, uint8_t, uint16_t) -MUL(mulswl, int16_t, int32_t) -MUL(muluwl, uint16_t, uint32_t) +MUL(mulsbw, orc_int8, orc_int16) +MUL(mulubw, orc_uint8, orc_uint16) +MUL(mulswl, orc_int16, orc_int32) +MUL(muluwl, orc_uint16, orc_uint32) #ifdef ENABLE_INT64 -MUL(mulslq, int32_t, int64_t) -MUL(mululq, uint32_t, uint64_t) +MUL(mulslq, orc_int32, orc_int64) +MUL(mululq, orc_uint32, orc_uint64) #endif #define ACC(name, type1) \ @@ -486,8 +486,8 @@ name (OrcOpcodeExecutor *ex, void *user) \ ex->dest_values[0] = ((type1)ex->src_values[0]); \ } -ACC(accw, int16_t); -ACC(accl, int32_t); +ACC(accw, orc_int16); +ACC(accl, orc_int32); static void swapw (OrcOpcodeExecutor *ex, void *user) @@ -563,8 +563,8 @@ static void mergewl (OrcOpcodeExecutor *ex, void *user) { union { - uint16_t u16[2]; - uint32_t u32; + orc_uint16 u16[2]; + orc_uint32 u32; } val; val.u16[0] = ex->src_values[0]; val.u16[1] = ex->src_values[1]; @@ -575,8 +575,8 @@ static void mergebw (OrcOpcodeExecutor *ex, void *user) { union { - uint8_t u8[2]; - uint16_t u16; + orc_uint8 u8[2]; + orc_uint16 u16; } val; val.u8[0] = ex->src_values[0]; val.u8[1] = ex->src_values[1]; @@ -586,8 +586,8 @@ mergebw (OrcOpcodeExecutor *ex, void *user) static void accsadubl (OrcOpcodeExecutor *ex, void *user) { - ex->dest_values[0] = abs((int)((uint8_t)ex->src_values[0]) - - (int)((uint8_t)ex->src_values[1])); + ex->dest_values[0] = abs((int)((orc_uint8)ex->src_values[0]) - + (int)((orc_uint8)ex->src_values[1])); } /* float ops */ diff --git a/orc/orcprogram.h b/orc/orcprogram.h index 1d6e2a2..6050b91 100644 --- a/orc/orcprogram.h +++ b/orc/orcprogram.h @@ -2,7 +2,6 @@ #ifndef _ORC_PROGRAM_H_ #define _ORC_PROGRAM_H_ -#include #include typedef struct _OrcOpcodeExecutor OrcOpcodeExecutor; diff --git a/orc/orcrules-arm.c b/orc/orcrules-arm.c index 3aff850..8774f3b 100644 --- a/orc/orcrules-arm.c +++ b/orc/orcrules-arm.c @@ -51,7 +51,7 @@ arm_rule_ ## opcode (OrcCompiler *p, void *user, OrcInstruction *insn) \ void orc_arm_loadw (OrcCompiler *compiler, int dest, int src1, int offset) { - uint32_t code; + orc_uint32 code; code = 0xe1d000b0; code |= (src1&0xf) << 16; @@ -68,7 +68,7 @@ orc_arm_loadw (OrcCompiler *compiler, int dest, int src1, int offset) void orc_arm_storew (OrcCompiler *compiler, int dest, int offset, int src1) { - uint32_t code; + orc_uint32 code; code = 0xe1c000b0; code |= (dest&0xf) << 16; @@ -391,7 +391,7 @@ arm_rule_mulhsb (OrcCompiler *p, void *user, OrcInstruction *insn) static void arm_rule_mulhub (OrcCompiler *p, void *user, OrcInstruction *insn) { - /* BINARY_UB(mulhub, "((uint32_t)(uint8_t)%s * (uint32_t)(uint8_t)%s) >> 8") */ + /* BINARY_UB(mulhub, "((orc_uint32)(uint8_t)%s * (orc_uint32)(uint8_t)%s) >> 8") */ int src1 = ORC_SRC_ARG (p, insn, 0); int src2 = ORC_SRC_ARG (p, insn, 1); int dest = ORC_DEST_ARG (p, insn, 0); @@ -792,7 +792,7 @@ arm_rule_mulhsw (OrcCompiler *p, void *user, OrcInstruction *insn) static void arm_rule_mulhuw (OrcCompiler *p, void *user, OrcInstruction *insn) { - /* BINARY_UW(mulhuw, "((uint32_t)((uint16_t)%s) * (uint32_t)((uint16_t)%s)) >> 16") */ + /* BINARY_UW(mulhuw, "((orc_uint32)((uint16_t)%s) * (orc_uint32)((uint16_t)%s)) >> 16") */ int src1 = ORC_SRC_ARG (p, insn, 0); int src2 = ORC_SRC_ARG (p, insn, 1); int dest = ORC_DEST_ARG (p, insn, 0); @@ -1351,13 +1351,13 @@ arm_rule_select1wb (OrcCompiler *p, void *user, OrcInstruction *insn) static void arm_rule_select0lw (OrcCompiler *p, void *user, OrcInstruction *insn) { - /* UNARY_LW(select0lw, "(uint32_t)%s & 0xffff") */ + /* UNARY_LW(select0lw, "(orc_uint32)%s & 0xffff") */ /* NOP */ } static void arm_rule_select1lw (OrcCompiler *p, void *user, OrcInstruction *insn) { - /* UNARY_LW(select1lw, "((uint32_t)%s >> 16)&0xffff") */ + /* UNARY_LW(select1lw, "((orc_uint32)%s >> 16)&0xffff") */ int src1 = ORC_SRC_ARG (p, insn, 0); int dest = ORC_DEST_ARG (p, insn, 0); diff --git a/orc/orcrules-neon.c b/orc/orcrules-neon.c index a33d491..0454413 100644 --- a/orc/orcrules-neon.c +++ b/orc/orcrules-neon.c @@ -208,7 +208,7 @@ orc_neon_emit_mov (OrcCompiler *compiler, int dest, int src) void orc_neon_load_halfvec_aligned (OrcCompiler *compiler, OrcVariable *var, int update) { - uint32_t code; + orc_uint32 code; ORC_ASM_CODE(compiler," vld1.32 %s[0], [%s]%s\n", orc_neon_reg_name (var->alloc), @@ -225,7 +225,7 @@ orc_neon_load_halfvec_aligned (OrcCompiler *compiler, OrcVariable *var, int upda void orc_neon_load_vec_aligned (OrcCompiler *compiler, OrcVariable *var, int update) { - uint32_t code; + orc_uint32 code; ORC_ASM_CODE(compiler," vld1.64 %s, [%s]%s\n", orc_neon_reg_name (var->alloc), @@ -243,7 +243,7 @@ void orc_neon_load_vec_unaligned (OrcCompiler *compiler, OrcVariable *var, int update) { - uint32_t code; + orc_uint32 code; ORC_ASM_CODE(compiler," vld1.64 %s, [%s]%s\n", orc_neon_reg_name (var->aligned_data + 1), @@ -273,7 +273,7 @@ void orc_neon_load_halfvec_unaligned (OrcCompiler *compiler, OrcVariable *var, int update) { - uint32_t code; + orc_uint32 code; ORC_ASM_CODE(compiler," vld1.32 %s[1], [%s]%s\n", orc_neon_reg_name (var->aligned_data), @@ -301,7 +301,7 @@ orc_neon_load_halfvec_unaligned (OrcCompiler *compiler, OrcVariable *var, void orc_neon_loadb (OrcCompiler *compiler, OrcVariable *var, int update) { - uint32_t code; + orc_uint32 code; int i; if (var->is_aligned && compiler->loop_shift == 3) { @@ -340,7 +340,7 @@ orc_neon_loadw (OrcCompiler *compiler, OrcVariable *var, int update) } else if (compiler->loop_shift == 2 && var->mask_alloc) { orc_neon_load_vec_unaligned (compiler, var, update); } else { - uint32_t code; + orc_uint32 code; int i; if (compiler->loop_shift == 2) { @@ -370,7 +370,7 @@ orc_neon_loadw (OrcCompiler *compiler, OrcVariable *var, int update) void orc_neon_loadl (OrcCompiler *compiler, OrcVariable *var, int update) { - uint32_t code; + orc_uint32 code; int i; if (var->is_aligned && compiler->loop_shift == 1) { @@ -396,7 +396,7 @@ orc_neon_loadl (OrcCompiler *compiler, OrcVariable *var, int update) void orc_neon_loadq (OrcCompiler *compiler, int dest, int src1, int update, int is_aligned) { - uint32_t code; + orc_uint32 code; ORC_ASM_CODE(compiler," vld1.64 %s, [%s]%s\n", orc_neon_reg_name (dest), @@ -414,7 +414,7 @@ orc_neon_loadq (OrcCompiler *compiler, int dest, int src1, int update, int is_al void orc_neon_storeb (OrcCompiler *compiler, int dest, int update, int src1, int is_aligned) { - uint32_t code; + orc_uint32 code; int i; if (is_aligned && compiler->loop_shift == 3) { @@ -448,7 +448,7 @@ orc_neon_storeb (OrcCompiler *compiler, int dest, int update, int src1, int is_a void orc_neon_storew (OrcCompiler *compiler, int dest, int update, int src1, int is_aligned) { - uint32_t code; + orc_uint32 code; int i; if (is_aligned && compiler->loop_shift == 2) { @@ -482,7 +482,7 @@ orc_neon_storew (OrcCompiler *compiler, int dest, int update, int src1, int is_a void orc_neon_storel (OrcCompiler *compiler, int dest, int update, int src1, int is_aligned) { - uint32_t code; + orc_uint32 code; int i; if (is_aligned && compiler->loop_shift == 2) { @@ -516,7 +516,7 @@ orc_neon_storel (OrcCompiler *compiler, int dest, int update, int src1, int is_a void orc_neon_storeq (OrcCompiler *compiler, int dest, int update, int src1, int is_aligned) { - uint32_t code; + orc_uint32 code; ORC_ASM_CODE(compiler," vst1.64 %s, [%s]%s\n", orc_neon_reg_name (src1), @@ -545,7 +545,7 @@ orc_neon_get_const_shift (unsigned int value) void orc_neon_emit_loadib (OrcCompiler *compiler, int reg, int value) { - uint32_t code; + orc_uint32 code; if (value == 0) { orc_neon_emit_binary_quad (compiler, "veor", 0xf3000110, reg, reg, reg); @@ -568,7 +568,7 @@ orc_neon_emit_loadib (OrcCompiler *compiler, int reg, int value) void orc_neon_emit_loadiw (OrcCompiler *compiler, int reg, int value) { - uint32_t code; + orc_uint32 code; int shift; int neg = FALSE; @@ -623,7 +623,7 @@ orc_neon_emit_loadiw (OrcCompiler *compiler, int reg, int value) void orc_neon_emit_loadil (OrcCompiler *compiler, int reg, int value) { - uint32_t code; + orc_uint32 code; int shift; int neg = FALSE; @@ -678,7 +678,7 @@ orc_neon_emit_loadil (OrcCompiler *compiler, int reg, int value) void orc_neon_emit_loadpb (OrcCompiler *compiler, int dest, int param) { - uint32_t code; + orc_uint32 code; orc_arm_emit_add_imm (compiler, compiler->gp_tmpreg, compiler->exec_reg, ORC_STRUCT_OFFSET(OrcExecutor, params[param])); @@ -696,7 +696,7 @@ orc_neon_emit_loadpb (OrcCompiler *compiler, int dest, int param) void orc_neon_emit_loadpw (OrcCompiler *compiler, int dest, int param) { - uint32_t code; + orc_uint32 code; orc_arm_emit_add_imm (compiler, compiler->gp_tmpreg, compiler->exec_reg, ORC_STRUCT_OFFSET(OrcExecutor, params[param])); @@ -714,7 +714,7 @@ orc_neon_emit_loadpw (OrcCompiler *compiler, int dest, int param) void orc_neon_emit_loadpl (OrcCompiler *compiler, int dest, int param) { - uint32_t code; + orc_uint32 code; orc_arm_emit_add_imm (compiler, compiler->gp_tmpreg, compiler->exec_reg, ORC_STRUCT_OFFSET(OrcExecutor, params[param])); @@ -827,7 +827,7 @@ orc_neon_rule_ ## opcode (OrcCompiler *p, void *user, OrcInstruction *insn) \ return; \ } \ if (p->loop_shift <= vec_shift) { \ - uint32_t x = code; \ + orc_uint32 x = code; \ ORC_ASM_CODE(p," " insn_name " %s, %s\n", \ orc_neon_reg_name (p->vars[insn->dest_args[0]].alloc), \ orc_neon_reg_name (p->vars[insn->src_args[0]].alloc)); \ @@ -836,7 +836,7 @@ orc_neon_rule_ ## opcode (OrcCompiler *p, void *user, OrcInstruction *insn) \ p->vars[insn->src_args[0]].alloc); \ orc_arm_emit (p, x); \ } else if (p->loop_shift == vec_shift + 1) { \ - uint32_t x = code; \ + orc_uint32 x = code; \ ORC_ASM_CODE(p," " insn_name " %s, %s\n", \ orc_neon_reg_name (p->vars[insn->dest_args[0]].alloc), \ orc_neon_reg_name (p->vars[insn->src_args[0]].alloc)); \ @@ -851,7 +851,7 @@ orc_neon_rule_ ## opcode (OrcCompiler *p, void *user, OrcInstruction *insn) \ typedef struct { - uint32_t code; + orc_uint32 code; char *name; int negate; int bits; @@ -884,7 +884,7 @@ static void orc_neon_rule_shift (OrcCompiler *p, void *user, OrcInstruction *insn) { int type = (unsigned long)user; - uint32_t code; + orc_uint32 code; if (p->vars[insn->src_args[1]].vartype == ORC_VAR_TYPE_CONST) { int shift = p->vars[insn->src_args[1]].value; @@ -959,7 +959,7 @@ orc_neon_rule_shift (OrcCompiler *p, void *user, OrcInstruction *insn) static void orc_neon_rule_shrsw (OrcCompiler *p, void *user, OrcInstruction *insn) { - uint32_t code; + orc_uint32 code; if (p->vars[insn->src_args[1]].vartype == ORC_VAR_TYPE_CONST) { code = 0xf2900010; ORC_ASM_CODE(p," vshr.s16 %s, %s, #%d\n", @@ -993,7 +993,7 @@ orc_neon_rule_shrsw (OrcCompiler *p, void *user, OrcInstruction *insn) static void orc_neon_rule_shrsl (OrcCompiler *p, void *user, OrcInstruction *insn) { - uint32_t code; + orc_uint32 code; if (p->vars[insn->src_args[1]].vartype == ORC_VAR_TYPE_CONST) { code = 0xf2900010; ORC_ASM_CODE(p," vshr.s32 %s, %s, #%d\n", @@ -1254,7 +1254,7 @@ orc_neon_rule_mergewl (OrcCompiler *p, void *user, OrcInstruction *insn) static void orc_neon_rule_accsadubl (OrcCompiler *p, void *user, OrcInstruction *insn) { - uint32_t x; + orc_uint32 x; x = 0xf3800700; ORC_ASM_CODE(p," vabdl.u8 %s, %s, %s\n", diff --git a/orc/orcutils.h b/orc/orcutils.h index 74e8d67..feb977d 100644 --- a/orc/orcutils.h +++ b/orc/orcutils.h @@ -28,7 +28,46 @@ #ifndef _ORC_UTILS_H_ #define _ORC_UTILS_H_ -#include +#ifndef _ORC_INTEGER_TYPEDEFS_ +#define _ORC_INTEGER_TYPEDEFS_ +#if defined(_x_STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L +#include +typedef int8_t orc_int8; +typedef int16_t orc_int16; +typedef int32_t orc_int32; +typedef int64_t orc_int64; +typedef uint8_t orc_uint8; +typedef uint16_t orc_uint16; +typedef uint32_t orc_uint32; +typedef uint64_t orc_uint64; +#elif defined(_MSC_VER) +typedef signed __int8 orc_int8; +typedef signed __int16 orc_int16; +typedef signed __int32 orc_int32; +typedef signed __int64 orc_int64; +typedef unsigned __int8 orc_uint8; +typedef unsigned __int16 orc_uint16; +typedef unsigned __int32 orc_uint32; +typedef unsigned __int64 orc_uint64; +#else +#include +typedef signed char orc_int8; +typedef short orc_int16; +typedef int orc_int32; +typedef unsigned char orc_uint8; +typedef unsigned short orc_uint16; +typedef unsigned int orc_uint32; +#if INT_MAX == LONG_MAX +typedef long long orc_int64; +typedef unsigned long long orc_uint64; +#else +typedef long orc_int64; +typedef unsigned long orc_uint64; +#endif +#endif +typedef union { orc_int32 i; float f; } orc_union32; +typedef union { orc_int64 i; double f; } orc_union64; +#endif #ifndef TRUE #define TRUE 1 @@ -55,18 +94,18 @@ typedef unsigned int orc_bool; #define ORC_PTR_OFFSET(ptr,offset) ((void *)(((unsigned char *)(ptr)) + (offset))) #define ORC_READ_UINT32_LE(ptr) \ - ((uint32_t)( \ - ((uint8_t *)(ptr))[0] | \ - (((uint8_t *)(ptr))[1]<<8) | \ - (((uint8_t *)(ptr))[2]<<16) | \ - (((uint8_t *)(ptr))[3]<<24))) + ((orc_uint32)( \ + ((orc_uint8 *)(ptr))[0] | \ + (((orc_uint8 *)(ptr))[1]<<8) | \ + (((orc_uint8 *)(ptr))[2]<<16) | \ + (((orc_uint8 *)(ptr))[3]<<24))) #define ORC_WRITE_UINT32_LE(ptr,val) \ do { \ - ((uint8_t *)ptr)[0] = ((val)>>0)&0xff; \ - ((uint8_t *)ptr)[1] = ((val)>>8)&0xff; \ - ((uint8_t *)ptr)[2] = ((val)>>16)&0xff; \ - ((uint8_t *)ptr)[3] = ((val)>>24)&0xff; \ + ((orc_uint8 *)ptr)[0] = ((val)>>0)&0xff; \ + ((orc_uint8 *)ptr)[1] = ((val)>>8)&0xff; \ + ((orc_uint8 *)ptr)[2] = ((val)>>16)&0xff; \ + ((orc_uint8 *)ptr)[3] = ((val)>>24)&0xff; \ } while(0) #endif diff --git a/testsuite/memcpy_speed.c b/testsuite/memcpy_speed.c index f0a2621..89b8d54 100644 --- a/testsuite/memcpy_speed.c +++ b/testsuite/memcpy_speed.c @@ -15,7 +15,7 @@ int main(int argc, char *argv[]) { char *s, *d; - uint8_t *src, *dest; + orc_uint8 *src, *dest; OrcProfile prof; OrcProfile prof_libc; double ave, std; @@ -32,7 +32,7 @@ main(int argc, char *argv[]) s = malloc(1024*1024*64+1024); d = malloc(1024*1024*64+1024); - src = ALIGN(s,128) + 1; + src = ALIGN(s,128); dest = ALIGN(d,128); orc_profile_init (&prof); diff --git a/testsuite/test_accsadubl.c b/testsuite/test_accsadubl.c index c4063b6..258fa14 100644 --- a/testsuite/test_accsadubl.c +++ b/testsuite/test_accsadubl.c @@ -12,10 +12,10 @@ int error = FALSE; void test_opcode (OrcStaticOpcode *opcode); -uint8_t array1[100]; -uint8_t array2[100]; +orc_uint8 array1[100]; +orc_uint8 array2[100]; -int orc_sad_u8 (uint8_t *s1, uint8_t *s2, int n); +int orc_sad_u8 (orc_uint8 *s1, orc_uint8 *s2, int n); int main (int argc, char *argv[]) @@ -45,7 +45,7 @@ for(n=0;n<20;n++){ int -orc_sad_u8 (uint8_t *s1, uint8_t *s2, int n) +orc_sad_u8 (orc_uint8 *s1, orc_uint8 *s2, int n) { static OrcProgram *p = NULL; OrcExecutor *ex; diff --git a/tools/orcc.c b/tools/orcc.c index 76b39ef..4a25649 100644 --- a/tools/orcc.c +++ b/tools/orcc.c @@ -168,8 +168,6 @@ main (int argc, char *argv[]) fprintf(output, "#endif\n"); fprintf(output, "#ifndef DISABLE_ORC\n"); fprintf(output, "#include \n"); - fprintf(output, "#else\n"); - print_exec_header (output); fprintf(output, "#endif\n"); if (include_file) { fprintf(output, "#include <%s>\n", include_file); @@ -257,77 +255,6 @@ main (int argc, char *argv[]) } -static void -print_exec_header (FILE *output) -{ -#if 0 - fprintf(output, - "typedef struct _OrcExecutor OrcExecutor;\n" - "typedef struct _OrcProgram OrcProgram;\n" - "#define ORC_N_VARIABLES 64\n" - "struct _OrcExecutor {\n" - " OrcProgram *program;\n" - " int n;\n" - " int counter1;\n" - " int counter2;\n" - " int counter3;\n" - " void *arrays[ORC_N_VARIABLES];\n" - " int params[ORC_N_VARIABLES];\n" - " int accumulators[4];\n" - "};\n" - "\n" - "enum {\n" - " ORC_VAR_D1,\n" - " ORC_VAR_D2,\n" - " ORC_VAR_D3,\n" - " ORC_VAR_D4,\n" - " ORC_VAR_S1,\n" - " ORC_VAR_S2,\n" - " ORC_VAR_S3,\n" - " ORC_VAR_S4,\n" - " ORC_VAR_S5,\n" - " ORC_VAR_S6,\n" - " ORC_VAR_S7,\n" - " ORC_VAR_S8,\n" - " ORC_VAR_A1,\n" - " ORC_VAR_A2,\n" - " ORC_VAR_A3,\n" - " ORC_VAR_A4,\n" - " ORC_VAR_C1,\n" - " ORC_VAR_C2,\n" - " ORC_VAR_C3,\n" - " ORC_VAR_C4,\n" - " ORC_VAR_C5,\n" - " ORC_VAR_C6,\n" - " ORC_VAR_C7,\n" - " ORC_VAR_C8,\n" - " ORC_VAR_P1,\n" - " ORC_VAR_P2,\n" - " ORC_VAR_P3,\n" - " ORC_VAR_P4,\n" - " ORC_VAR_P5,\n" - " ORC_VAR_P6,\n" - " ORC_VAR_P7,\n" - " ORC_VAR_P8,\n" - " ORC_VAR_T1,\n" - " ORC_VAR_T2,\n" - " ORC_VAR_T3,\n" - " ORC_VAR_T4,\n" - " ORC_VAR_T5,\n" - " ORC_VAR_T6,\n" - " ORC_VAR_T7,\n" - " ORC_VAR_T8,\n" - " ORC_VAR_T9,\n" - " ORC_VAR_T10,\n" - " ORC_VAR_T11,\n" - " ORC_VAR_T12,\n" - " ORC_VAR_T13,\n" - " ORC_VAR_T14,\n" - " ORC_VAR_T15\n" - "};\n"); -#endif -} - static char * get_barrier (const char *s) { @@ -349,39 +276,6 @@ get_barrier (const char *s) return barrier; } -#if 0 -static void -print_defines (FILE *output) -{ - fprintf(output, - "#define ORC_CLAMP(x,a,b) ((x)<(a) ? (a) : ((x)>(b) ? (b) : (x)))\n" - "#define ORC_ABS(a) ((a)<0 ? -(a) : (a))\n" - "#define ORC_MIN(a,b) ((a)<(b) ? (a) : (b))\n" - "#define ORC_MAX(a,b) ((a)>(b) ? (a) : (b))\n" - "#define ORC_SB_MAX 127\n" - "#define ORC_SB_MIN (-1-ORC_SB_MAX)\n" - "#define ORC_UB_MAX 255\n" - "#define ORC_UB_MIN 0\n" - "#define ORC_SW_MAX 32767\n" - "#define ORC_SW_MIN (-1-ORC_SW_MAX)\n" - "#define ORC_UW_MAX 65535\n" - "#define ORC_UW_MIN 0\n" - "#define ORC_SL_MAX 2147483647\n" - "#define ORC_SL_MIN (-1-ORC_SL_MAX)\n" - "#define ORC_UL_MAX 4294967295U\n" - "#define ORC_UL_MIN 0\n" - "#define ORC_CLAMP_SB(x) ORC_CLAMP(x,ORC_SB_MIN,ORC_SB_MAX)\n" - "#define ORC_CLAMP_UB(x) ORC_CLAMP(x,ORC_UB_MIN,ORC_UB_MAX)\n" - "#define ORC_CLAMP_SW(x) ORC_CLAMP(x,ORC_SW_MIN,ORC_SW_MAX)\n" - "#define ORC_CLAMP_UW(x) ORC_CLAMP(x,ORC_UW_MIN,ORC_UW_MAX)\n" - "#define ORC_CLAMP_SL(x) ORC_CLAMP(x,ORC_SL_MIN,ORC_SL_MAX)\n" - "#define ORC_CLAMP_UL(x) ORC_CLAMP(x,ORC_UL_MIN,ORC_UL_MAX)\n" - "#define ORC_SWAP_W(x) ((((x)&0xff)<<8) | (((x)&0xff00)>>8))\n" - "#define ORC_SWAP_L(x) ((((x)&0xff)<<24) | (((x)&0xff00)<<8) | (((x)&0xff0000)>>8) | (((x)&0xff000000)>>24))\n" - "#define ORC_PTR_OFFSET(ptr,offset) ((void *)(((unsigned char *)(ptr)) + (offset)))\n"); -} -#endif - static char * read_file (const char *filename) {