diff mbox

Clean up definition of MAX_OPC_PARAM

Message ID 20100427212335.GA6194@zubnet.me.uk
State New
Headers show

Commit Message

Stuart Brady April 27, 2010, 9:23 p.m. UTC
MAX_OPC_PARAM is intended to refer to the maximum number of entries used
in gen_opparam_buf[] for any single helper call.  It is currently defined
as 10, but for 32-bit archs, the correct value (with a maximum for four
helper arguments) is 14, and for 64-bit archs, only 9 entries are needed.

tcg_gen_callN() fills four entries with the function address, flags,
number of args, etc. and on 32-bit archs uses a further two entries per
argument (with a maximum of four helper arguments), plus two more for the
return value.  On 64-bit archs, only half as many entries are used for the
args and the return value.

In reality, TBs tend not to consist purely of helper calls exceeding the
stated 10 gen_opparam_buf[] entries, so this would never actually be a
problem on 32-bit archs, but the definition is still rather confusing.

Signed-off-by: Stuart Brady <sdb@zubnet.me.uk>
---

Comments

Blue Swirl May 1, 2010, 9:06 p.m. UTC | #1
Thanks, applied.

On 4/28/10, Stuart Brady <sdb@zubnet.me.uk> wrote:
> MAX_OPC_PARAM is intended to refer to the maximum number of entries used
>  in gen_opparam_buf[] for any single helper call.  It is currently defined
>  as 10, but for 32-bit archs, the correct value (with a maximum for four
>  helper arguments) is 14, and for 64-bit archs, only 9 entries are needed.
>
>  tcg_gen_callN() fills four entries with the function address, flags,
>  number of args, etc. and on 32-bit archs uses a further two entries per
>  argument (with a maximum of four helper arguments), plus two more for the
>  return value.  On 64-bit archs, only half as many entries are used for the
>  args and the return value.
>
>  In reality, TBs tend not to consist purely of helper calls exceeding the
>  stated 10 gen_opparam_buf[] entries, so this would never actually be a
>  problem on 32-bit archs, but the definition is still rather confusing.
>
>  Signed-off-by: Stuart Brady <sdb@zubnet.me.uk>
>  ---
>  diff --git a/exec-all.h b/exec-all.h
>  index 4bae1e2..1016de2 100644
>  --- a/exec-all.h
>  +++ b/exec-all.h
>  @@ -44,8 +44,20 @@ typedef struct TranslationBlock TranslationBlock;
>
>   /* XXX: make safe guess about sizes */
>   #define MAX_OP_PER_INSTR 96
>  -/* A Call op needs up to 6 + 2N parameters (N = number of arguments).  */
>  -#define MAX_OPC_PARAM 10
>  +
>  +#if HOST_LONG_BITS == 32
>  +#define MAX_OPC_PARAM_PER_ARG 2
>  +#else
>  +#define MAX_OPC_PARAM_PER_ARG 1
>  +#endif
>  +#define MAX_OPC_PARAM_IARGS 4
>  +#define MAX_OPC_PARAM_OARGS 1
>  +#define MAX_OPC_PARAM_ARGS (MAX_OPC_PARAM_IARGS + MAX_OPC_PARAM_OARGS)
>  +
>  +/* A Call op needs up to 4 + 2N parameters on 32-bit archs,
>  + * and up to 4 + N parameters on 64-bit archs
>  + * (N = number of input arguments + output arguments).  */
>  +#define MAX_OPC_PARAM (4 + (MAX_OPC_PARAM_PER_ARG * MAX_OPC_PARAM_ARGS))
>   #define OPC_BUF_SIZE 640
>   #define OPC_MAX_SIZE (OPC_BUF_SIZE - MAX_OP_PER_INSTR)
>
>
>
>
diff mbox

Patch

diff --git a/exec-all.h b/exec-all.h
index 4bae1e2..1016de2 100644
--- a/exec-all.h
+++ b/exec-all.h
@@ -44,8 +44,20 @@  typedef struct TranslationBlock TranslationBlock;
 
 /* XXX: make safe guess about sizes */
 #define MAX_OP_PER_INSTR 96
-/* A Call op needs up to 6 + 2N parameters (N = number of arguments).  */
-#define MAX_OPC_PARAM 10
+
+#if HOST_LONG_BITS == 32
+#define MAX_OPC_PARAM_PER_ARG 2
+#else
+#define MAX_OPC_PARAM_PER_ARG 1
+#endif
+#define MAX_OPC_PARAM_IARGS 4
+#define MAX_OPC_PARAM_OARGS 1
+#define MAX_OPC_PARAM_ARGS (MAX_OPC_PARAM_IARGS + MAX_OPC_PARAM_OARGS)
+
+/* A Call op needs up to 4 + 2N parameters on 32-bit archs,
+ * and up to 4 + N parameters on 64-bit archs
+ * (N = number of input arguments + output arguments).  */
+#define MAX_OPC_PARAM (4 + (MAX_OPC_PARAM_PER_ARG * MAX_OPC_PARAM_ARGS))
 #define OPC_BUF_SIZE 640
 #define OPC_MAX_SIZE (OPC_BUF_SIZE - MAX_OP_PER_INSTR)