Skip to contentSkip to conversation

Don' use T[x] in helper

PATCH Laurent Desnogues 1 participant 1 message Mar 24, 2009 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): -4209888356038288037@unknownmsgid

Laurent Desnogues

author Acked-by
#1 lore raw

2009/3/24 Torbjörn Andersson <[email protected]>:

Quoted 11 lines

I hit a strange issue with add_cc, can't really explain how it appeared but it did. The patch below solved my problem.

Can someone make a qualified guess why? I'm compling with gcc 4.

However, T0 and T1 in a helper should not be used, because it creates a unnecessary dependency between translate.c and op_helper.c. Am I correct?

Further, if we cannot trust T0 and T1 in a helper, what about the global env-variable?

Your patch is correct and the previous code works by accident since add_cc is called this way:

gen_helper_add_cc(cpu_T[0], cpu_T[0], cpu_T[1])

What I find strange is that you had issue with the code in svn. I didn't have before I fixed it, but it was perhaps using some old compiler at that time.

Laurent

Quoted 15 lines

/Best regards Torbjörn Andersson

Index: op_helper.c
===================================================================

op_helper.c (working copy) renamed from op_helper.c (revision 6883) +1 -1
@@ -307,7 +307,7 @@
 uint32_t HELPER (add_cc)(uint32_t a, uint32_t b)
 {
    uint32_t result;
-    result = T0 + T1;
+    result = a + b;
    env->NF = env->ZF = result;
    env->CF = result < a;
    env->VF = (a ^ b ^ -1) & (a ^ result);