|
From: Christian B. <bor...@de...> - 2010-12-15 14:13:54
|
This patch adds an Iop for an I64/I64 -> I128 devision, where the lo half
of the result is div and the hi half is mod. This will be used for the
s390x dsgr, dsg,dsgf and dsgfr instructions. These instruction use a register
pair for the result(I128).
In theory we could reuse Iop_DivS64 and then Iop_MullS64+Iop_Sub64
together with a scratch register. I have checked the other architectures,
and I have not found an example of doing it that way (which is expensive
anyway).
This simple patch just defines the appripriate Iop. The memcheck
implementation is also provided.
---
VEX/priv/ir_defs.c | 5 +++++
VEX/pub/libvex_ir.h | 3 +++
memcheck/mc_translate.c | 1 +
3 files changed, 9 insertions(+)
--- valgrind-upstream.orig/VEX/priv/ir_defs.c
+++ valgrind-upstream/VEX/priv/ir_defs.c
@@ -222,6 +222,8 @@ void ppIROp ( IROp op )
case Iop_DivModU128to64: vex_printf("DivModU128to64"); return;
case Iop_DivModS128to64: vex_printf("DivModS128to64"); return;
+ case Iop_DivModS64to64: vex_printf("DivModS64to64"); return;
+
case Iop_16HIto8: vex_printf("16HIto8"); return;
case Iop_16to8: vex_printf("16to8"); return;
case Iop_8HLto16: vex_printf("8HLto16"); return;
@@ -2108,6 +2110,9 @@ void typeOfPrimop ( IROp op,
case Iop_DivModU128to64: case Iop_DivModS128to64:
BINARY(Ity_I128,Ity_I64, Ity_I128);
+ case Iop_DivModS64to64:
+ BINARY(Ity_I64,Ity_I64, Ity_I128);
+
case Iop_16HIto8: case Iop_16to8:
UNARY(Ity_I16, Ity_I8);
case Iop_8HLto16:
--- valgrind-upstream.orig/VEX/pub/libvex_ir.h
+++ valgrind-upstream/VEX/pub/libvex_ir.h
@@ -469,6 +469,9 @@ typedef
// of which lo half is div and hi half is mod
Iop_DivModS128to64, // ditto, signed
+ Iop_DivModS64to64, // :: I64,I64 -> I128
+ // of which lo half is div and hi half is mod
+
/* Integer conversions. Some of these are redundant (eg
Iop_64to8 is the same as Iop_64to32 and then Iop_32to8), but
having a complete set reduces the typical dynamic size of IR
--- valgrind-upstream.orig/memcheck/mc_translate.c
+++ valgrind-upstream/memcheck/mc_translate.c
@@ -2892,6 +2892,7 @@ IRAtom* expr2vbits_Binop ( MCEnv* mce,
case Iop_32HLto64:
return assignNew('V', mce, Ity_I64, binop(op, vatom1, vatom2));
+ case Iop_DivModS64to64:
case Iop_MullS64:
case Iop_MullU64: {
IRAtom* vLo64 = mkLeft64(mce, mkUifU64(mce, vatom1,vatom2));
|