BINARY_SB(mulhsb, "(%s * %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(shlb, "((orc_uint8)%s) << %s")
BINARY_SB(shrsb, "%s >> %s")
BINARY_UB(shrub, "((orc_uint8)%s) >> %s")
UNARY_SB(signb, "ORC_CLAMP(%s,-1,1)")
BINARY_SW(mulhsw, "(%s * %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(shlw, "((orc_uint16)%s) << %s")
BINARY_SW(shrsw, "%s >> %s")
BINARY_UW(shruw, "((orc_uint16)%s) >> %s")
UNARY_SW(signw, "ORC_CLAMP(%s,-1,1)")
BINARY_SW(xorw, "%s ^ %s")
UNARY_SL(absl, "ORC_ABS(%s)")
-BINARY_SL(addl, "%s + %s")
+BINARY_SL(addl, "((orc_uint32)%s) + ((orc_uint32)%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_UL(maxul, "ORC_MAX((orc_uint32)%s, (orc_uint32)%s)")
BINARY_SL(minsl, "ORC_MIN(%s, %s)")
BINARY_UL(minul, "ORC_MIN((orc_uint32)%s, (orc_uint32)%s)")
-BINARY_SL(mulll, "(%s * %s) & 0xffffffff")
+BINARY_SL(mulll, "(((orc_uint32)%s) * ((orc_uint32)%s)) & 0xffffffff")
BINARY_SL(mulhsl, "((orc_int64)%s * (orc_int64)%s) >> 32")
BINARY_UL(mulhul, "((orc_uint64)(orc_uint32)%s * (orc_uint64)(orc_uint32)%s) >> 32")
BINARY_SL(orl, "%s | %s")
-BINARY_SL(shll, "%s << %s")
+BINARY_SL(shll, "((orc_uint32)%s) << %s")
BINARY_SL(shrsl, "%s >> %s")
BINARY_UL(shrul, "((orc_uint32)%s) >> %s")
UNARY_SL(signl, "ORC_CLAMP(%s,-1,1)")
-BINARY_SL(subl, "%s - %s")
+BINARY_SL(subl, "((orc_uint32)%s) - ((orc_uint32)%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")
BINARY_SQ(andnq, "(~%s) & %s")
BINARY_SQ(orq, "%s | %s")
BINARY_SQ(xorq, "%s ^ %s")
-BINARY_SQ(addq, "%s + %s")
-BINARY_SQ(subq, "%s - %s")
-BINARY_SQ(shlq, "%s << %s")
+BINARY_SQ(addq, "((orc_uint64)%s) + ((orc_uint64)%s)")
+BINARY_SQ(subq, "((orc_uint64)%s) - ((orc_uint64)%s)")
+BINARY_SQ(shlq, "((orc_uint64)%s) << %s")
BINARY_SQ(shrsq, "%s >> %s")
BINARY_UQ(shruq, "((orc_uint64)%s) >> %s")
UNARY_LW(convuusql, "ORC_CLAMP_UL((orc_uint64)%s)")
BINARY_BW(mulsbw, "%s * %s")
-BINARY_BW(mulubw, "((orc_uint8)%s) * ((orc_uint8)%s)")
+BINARY_BW(mulubw, "((orc_uint16)((orc_uint8)%s)) * ((orc_uint16)((orc_uint8)%s))")
BINARY_WL(mulswl, "%s * %s")
-BINARY_WL(muluwl, "((orc_uint16)%s) * ((orc_uint16)%s)")
+BINARY_WL(muluwl, "((orc_uint32)((orc_uint16)%s)) * ((orc_uint32)((orc_uint16)%s))")
BINARY_LQ(mulslq, "((orc_int64)%s) * ((orc_int64)%s)")
BINARY_LQ(mululq, "((orc_uint64)((orc_uint32)%s)) * ((orc_uint64)((orc_uint32)%s))")
/* 0: loadb */
var32 = ptr4[i];
/* 1: shlb */
- var33 = var32 << ((orc_union64 *)(ex->src_ptrs[1]))->i;
+ var33 = ((orc_uint8)var32) << ((orc_union64 *)(ex->src_ptrs[1]))->i;
/* 2: storeb */
ptr0[i] = var33;
}
/* 0: loadw */
var32 = ptr4[i];
/* 1: shlw */
- var33.i = var32.i << ((orc_union64 *)(ex->src_ptrs[1]))->i;
+ var33.i = ((orc_uint16)var32.i) << ((orc_union64 *)(ex->src_ptrs[1]))->i;
/* 2: storew */
ptr0[i] = var33;
}
/* 1: loadl */
var33 = ptr5[i];
/* 2: addl */
- var34.i = var32.i + var33.i;
+ var34.i = ((orc_uint32)var32.i) + ((orc_uint32)var33.i);
/* 3: storel */
ptr0[i] = var34;
}
/* 1: loadl */
var33 = ptr5[i];
/* 2: mulll */
- var34.i = (var32.i * var33.i) & 0xffffffff;
+ var34.i = (((orc_uint32)var32.i) * ((orc_uint32)var33.i)) & 0xffffffff;
/* 3: storel */
ptr0[i] = var34;
}
/* 0: loadl */
var32 = ptr4[i];
/* 1: shll */
- var33.i = var32.i << ((orc_union64 *)(ex->src_ptrs[1]))->i;
+ var33.i = ((orc_uint32)var32.i) << ((orc_union64 *)(ex->src_ptrs[1]))->i;
/* 2: storel */
ptr0[i] = var33;
}
/* 1: loadl */
var33 = ptr5[i];
/* 2: subl */
- var34.i = var32.i - var33.i;
+ var34.i = ((orc_uint32)var32.i) - ((orc_uint32)var33.i);
/* 3: storel */
ptr0[i] = var34;
}
/* 1: loadq */
var33 = ptr5[i];
/* 2: addq */
- var34.i = var32.i + var33.i;
+ var34.i = ((orc_uint64)var32.i) + ((orc_uint64)var33.i);
/* 3: storeq */
ptr0[i] = var34;
}
/* 1: loadq */
var33 = ptr5[i];
/* 2: subq */
- var34.i = var32.i - var33.i;
+ var34.i = ((orc_uint64)var32.i) - ((orc_uint64)var33.i);
/* 3: storeq */
ptr0[i] = var34;
}
/* 0: loadq */
var32 = ptr4[i];
/* 1: shlq */
- var33.i = var32.i << ((orc_union64 *)(ex->src_ptrs[1]))->i;
+ var33.i = ((orc_uint64)var32.i) << ((orc_union64 *)(ex->src_ptrs[1]))->i;
/* 2: storeq */
ptr0[i] = var33;
}
/* 0: loadb */
var32 = ptr4[i];
/* 1: splatbl */
- var33.i = ((var32&0xff) << 24) | ((var32&0xff)<<16) | ((var32&0xff) << 8) | (var32&0xff);
+ var33.i = ((((orc_uint32)var32)&0xff) << 24) | ((((orc_uint32)var32)&0xff)<<16) | ((((orc_uint32)var32)&0xff) << 8) | (((orc_uint32)var32)&0xff);
/* 2: storel */
ptr0[i] = var33;
}
/* 1: loadb */
var33 = ptr5[i];
/* 2: mulubw */
- var34.i = ((orc_uint8)var32) * ((orc_uint8)var33);
+ var34.i = ((orc_uint16)((orc_uint8)var32)) * ((orc_uint16)((orc_uint8)var33));
/* 3: storew */
ptr0[i] = var34;
}
/* 1: loadw */
var33 = ptr5[i];
/* 2: muluwl */
- var34.i = ((orc_uint16)var32.i) * ((orc_uint16)var33.i);
+ var34.i = ((orc_uint32)((orc_uint16)var32.i)) * ((orc_uint32)((orc_uint16)var33.i));
/* 3: storel */
ptr0[i] = var34;
}
/* 0: loadl */
var32 = ptr4[i];
/* 1: accl */
- var12.i = var12.i + var32.i;
+ var12.i = ((orc_uint32)var12.i) + ((orc_uint32)var32.i);
}
- ((orc_union32 *)ex->dest_ptrs[0])->i += var12.i;
+ ((orc_union32 *)ex->dest_ptrs[0])->i += (orc_uint32)var12.i;
}
/* 2: accsadubl */
var12.i = var12.i + ORC_ABS((orc_int32)(orc_uint8)var32 - (orc_int32)(orc_uint8)var33);
}
- ((orc_union32 *)ex->dest_ptrs[0])->i += var12.i;
+ ((orc_union32 *)ex->dest_ptrs[0])->i += (orc_uint32)var12.i;
}
ORC_ASM_CODE(compiler," *%s = %s;\n",
varnames[i], varname);
} else if (compiler->target_flags & ORC_TARGET_C_OPCODE) {
- ORC_ASM_CODE(compiler," ((orc_union32 *)ex->dest_ptrs[%d])->i += %s;\n",
- i - ORC_VAR_A1, varname);
+ ORC_ASM_CODE(compiler," ((orc_union32 *)ex->dest_ptrs[%d])->i += (orc_uint%d)%s;\n",
+ i - ORC_VAR_A1, var->size * 8, varname);
} else {
ORC_ASM_CODE(compiler," ex->accumulators[%d] = %s;\n",
i - ORC_VAR_A1, varname);
c_get_name_int (dest, p, insn, insn->dest_args[0]);
c_get_name_int (src1, p, insn, insn->src_args[0]);
- ORC_ASM_CODE(p," %s = %s + %s;\n", dest, dest, src1);
+ ORC_ASM_CODE(p," %s = ((orc_uint32)%s) + ((orc_uint32)%s);\n", dest, dest, src1);
}
static void
c_get_name_int (src, p, insn, insn->src_args[0]);
ORC_ASM_CODE(p,
- " %s = ((%s&0xff) << 24) | ((%s&0xff)<<16) | ((%s&0xff) << 8) | (%s&0xff);\n",
+ " %s = ((((orc_uint32)%s)&0xff) << 24) | ((((orc_uint32)%s)&0xff)<<16)"
+ " | ((((orc_uint32)%s)&0xff) << 8) | (((orc_uint32)%s)&0xff);\n",
dest, src, src, src, src);
}