Various changes needed to get Addrcheck supported:

* Rearrange iropt pipeline so that tree-building is
  no longer anything to do with optimisation, but is
  instead done post-instrumentation

* Allow two instrumentation functions to be passed to
  LibVEX_Translate, not one, so that valgrind can also 
  do an sp-update pass

* Add a type VexGuestLayoutInfo for describing the guest
  state, for the benefit of instrumenters.



git-svn-id: svn://svn.valgrind.org/vex/trunk@447 8f6e269a-dfd6-0310-a8e1-e2731360e62c
diff --git a/priv/main/vex_main.c b/priv/main/vex_main.c
index 0615ecf..c1887df 100644
--- a/priv/main/vex_main.c
+++ b/priv/main/vex_main.c
@@ -129,8 +129,9 @@
    Int    host_bytes_size,
    /* OUT: how much of the output area is used. */
    Int* host_bytes_used,
-   /* IN: optionally, an instrumentation function. */
-   IRBB* (*instrument) ( IRBB* ),
+   /* IN: optionally, two instrumentation functions. */
+   IRBB* (*instrument1) ( IRBB*, VexGuestLayoutInfo* ),
+   IRBB* (*instrument2) ( IRBB*, VexGuestLayoutInfo* ),
    HWord (*tool_findhelper) ( Char* ),
    /* IN: optionally, an access check function for guest code. */
    Bool (*byte_accessible) ( Addr64 ),
@@ -158,14 +159,16 @@
    IRExpr*      (*specHelper)  ( Char*, IRExpr** );
    Bool         (*preciseMemExnsFn) ( Int, Int );
 
-   Bool         host_is_bigendian = False;
-   IRBB*        irbb;
-   HInstrArray* vcode;
-   HInstrArray* rcode;
-   Int          i, j, k, out_used, saved_verbosity, guest_sizeB;
-   UChar        insn_bytes[32];
-   IRType       guest_word_size;
+   VexGuestLayoutInfo* guest_layout;
+   Bool                host_is_bigendian = False;
+   IRBB*               irbb;
+   HInstrArray*        vcode;
+   HInstrArray*        rcode;
+   Int                 i, j, k, out_used, saved_verbosity, guest_sizeB;
+   UChar               insn_bytes[32];
+   IRType              guest_word_size;
 
+   guest_layout           = NULL;
    available_real_regs    = NULL;
    n_available_real_regs  = 0;
    isMove                 = NULL;
@@ -219,6 +222,7 @@
          specHelper       = x86guest_spechelper;
          guest_sizeB      = sizeof(VexGuestX86State);
 	 guest_word_size  = Ity_I32;
+         guest_layout     = &x86guest_layout;
          break;
       default:
          vpanic("LibVEX_Translate: unsupported guest insn set");
@@ -262,12 +266,17 @@
    }
 
    /* Get the thing instrumented. */
-   if (instrument) {
-      irbb = (*instrument)(irbb);
+   if (instrument1)
+      irbb = (*instrument1)(irbb, guest_layout);
+   if (instrument2)
+      irbb = (*instrument2)(irbb, guest_layout);
+      
+   if (instrument1 || instrument2)
       sanityCheckIRBB(irbb, guest_word_size);
-   }
 
    /* Turn it into virtual-registerised code. */
+   do_deadcode_BB( irbb );
+   do_treebuild_BB( irbb );
    vcode = iselBB ( irbb, findHelper, tool_findhelper );
 
    if (vex_verbosity > 0) {