/* Exported to library client. */
-HChar* LibVEX_Version ( void )
+const HChar* LibVEX_Version ( void )
{
return
#include "main/vex_svnversion.h"
vex_valgrind_support = valgrind_support;
vex_control = *vcon;
vex_initdone = True;
- LibVEX_SetAllocMode ( AllocModeTEMPORARY );
+ vexSetAllocMode ( VexAllocModeTEMP );
}
/* Exported to library client. */
-TranslateResult LibVEX_Translate (
+VexTranslateResult LibVEX_Translate (
/* The instruction sets we are translating from and to. */
VexArch arch_guest,
VexSubArch subarch_guest,
vex_traceflags = traceflags;
vassert(vex_initdone);
- LibVEX_ClearTemporary(False);
+ vexClearTEMP();
/* First off, check that the guest and host insn sets
if (irbb == NULL) {
/* Access failure. */
- LibVEX_ClearTemporary(False);
+ vexClearTEMP();
vex_traceflags = 0;
- return TransAccessFail;
+ return VexTransAccessFail;
}
/* If debugging, show the raw guest bytes for this bb. */
vex_printf("\n\n");
}
if (out_used + j > host_bytes_size) {
- LibVEX_ClearTemporary(False);
+ vexClearTEMP();
vex_traceflags = 0;
- return TransOutputFull;
+ return VexTransOutputFull;
}
for (k = 0; k < j; k++) {
host_bytes[out_used] = insn_bytes[k];
}
*host_bytes_used = out_used;
- LibVEX_ClearTemporary(False);
+ vexClearTEMP();
vex_traceflags = 0;
- return TransOK;
+ return VexTransOK;
}
static ULong temporary_count_allocs_TOT = 0;
/* The current allocation mode. */
-static AllocMode mode = AllocModeTEMPORARY;
+static VexAllocMode mode = VexAllocModeTEMP;
-/* Exported to library client. */
-
-void LibVEX_SetAllocMode ( AllocMode m )
+void vexSetAllocMode ( VexAllocMode m )
{
mode = m;
}
-/* Exported to library client. */
-
-AllocMode LibVEX_GetAllocMode ( void )
+VexAllocMode vexGetAllocMode ( void )
{
return mode;
}
return malloc(nbytes);
} else {
nbytes = (nbytes + ALIGN) & ~ALIGN;
- if (mode == AllocModeTEMPORARY) {
+ if (mode == VexAllocModeTEMP) {
if (temporary_used + nbytes > N_TEMPORARY_BYTES)
vpanic("VEX temporary storage exhausted.\n"
"Increase N_TEMPORARY_BYTES and recompile.");
# undef ALIGN
}
-/* Exported to library client. */
-
-void LibVEX_ClearTemporary ( Bool verb )
+void vexClearTEMP ( void )
{
/* vassert(vex_initdone); */ /* causes infinite assert loops */
temporary_bytes_allocd_TOT += (ULong)temporary_bytes_allocd;
temporary_count_allocs_TOT += (ULong)temporary_count_allocs;
- if (verb) {
- vex_printf("vex storage: P %d, T total %lld (%lld), T curr %d (%d)\n",
- permanent_used,
- (Long)temporary_bytes_allocd_TOT,
- (Long)temporary_count_allocs_TOT,
- temporary_bytes_allocd, temporary_count_allocs );
- }
temporary_used = 0;
temporary_bytes_allocd = 0;
temporary_count_allocs = 0;
}
+/* Exported to library client. */
+
+void LibVEX_ShowAllocStats ( void )
+{
+ vex_printf("vex storage: P %d, T total %lld (%lld), T curr %d (%d)\n",
+ permanent_used,
+ (Long)temporary_bytes_allocd_TOT,
+ (Long)temporary_count_allocs_TOT,
+ temporary_bytes_allocd, temporary_count_allocs );
+}
+
/*---------------------------------------------------------*/
/*--- Bombing out ---*/
}
-
-
/*---------------------------------------------------------------*/
/*--- end vex_util.c ---*/
/*---------------------------------------------------------------*/
/*---------------------------------------------------------------*/
-/*--- Top-level interface to the library. ---*/
+/*--- This file defines the top-level interface to LibVEX. ---*/
/*---------------------------------------------------------------*/
-/* Describes architectures and subarchitecture variants. */
+/*-------------------------------------------------------*/
+/*--- Architectures and architecture variants ---*/
+/*-------------------------------------------------------*/
typedef
enum {
extern const HChar* LibVEX_ppVexSubArch ( VexSubArch );
+/*-------------------------------------------------------*/
+/*--- Control of Vex's optimiser (iropt). ---*/
+/*-------------------------------------------------------*/
+
/* Control of Vex's optimiser. */
typedef
/* Write the default settings into *vcon. */
-extern void LibVEX_default_VexControl ( /*OUT*/ VexControl* vcon );
-
-
-/* Returns the Vex SVN version. */
-
-extern HChar* LibVEX_Version ( void );
+extern
+void LibVEX_default_VexControl ( /*OUT*/ VexControl* vcon );
-/* Initialise the translator. */
+/*-------------------------------------------------------*/
+/*--- Version information ---*/
+/*-------------------------------------------------------*/
-extern void LibVEX_Init (
- /* failure exit function */
- __attribute__ ((noreturn))
- void (*failure_exit) ( void ),
- /* logging output function */
- void (*log_bytes) ( Char*, Int nbytes ),
- /* debug paranoia level */
- Int debuglevel,
- /* Are we supporting valgrind checking? */
- Bool valgrind_support,
- /* Control ... */
- /*READONLY*/VexControl* vcon
-);
+/* Returns the Vex SVN version, as a statically allocated string. */
+extern const HChar* LibVEX_Version ( void );
-/* Storage management: clear the area, and allocate from it. */
-/* By default allocation occurs in the temporary area. However, it is
- possible to switch to permanent area allocation if that's what you
- want. Permanent area allocation is very limited, tho. */
+/*-------------------------------------------------------*/
+/*--- Storage management control ---*/
+/*-------------------------------------------------------*/
-typedef
- enum { AllocModeTEMPORARY, AllocModePERMANENT }
- AllocMode;
+/* Allocate in Vex's temporary allocation area. Be careful with this.
+ You can only call it inside an instrumentation or optimisation
+ callback that you have previously specified in a call to
+ LibVEX_Translate. The storage allocated will only stay alive until
+ translation of the current basic block is complete.
+ */
+extern void* LibVEX_Alloc ( Int nbytes );
-extern void LibVEX_SetAllocMode ( AllocMode );
-extern AllocMode LibVEX_GetAllocMode ( void );
+/* Show Vex allocation statistics. */
+extern void LibVEX_ShowAllocStats ( void );
-extern void LibVEX_ClearTemporary ( Bool show_stats );
-
-extern void* LibVEX_Alloc ( Int nbytes );
+/*-------------------------------------------------------*/
+/*--- Describing guest state layout ---*/
+/*-------------------------------------------------------*/
/* Describe the guest state enough that the instrumentation
functions can work. */
}
VexGuestLayout;
+/* A note about guest state layout.
+
+ LibVEX defines the layout for the guest state, in the file
+ pub/libvex_guest_<arch>.h. The struct will have an 8-aligned size.
+ Each translated bb is assumed to be entered with a specified
+ register pointing at such a struct. Beyond that is a shadow
+ state area with the same size as the struct. Beyond that is
+ a spill area that LibVEX may spill into. It must have size
+ LibVEX_N_SPILL_BYTES, and this must be a 16-aligned number.
+
+ On entry, the baseblock pointer register must be 8-aligned.
+*/
+
+#define LibVEX_N_SPILL_BYTES 768
+
-/* Translate a basic block. */
+/*-------------------------------------------------------*/
+/*--- Initialisation of the library ---*/
+/*-------------------------------------------------------*/
+
+/* Initialise the library. You must call this first. */
+
+extern void LibVEX_Init (
+ /* failure exit function */
+ __attribute__ ((noreturn))
+ void (*failure_exit) ( void ),
+ /* logging output function */
+ void (*log_bytes) ( Char*, Int nbytes ),
+ /* debug paranoia level */
+ Int debuglevel,
+ /* Are we supporting valgrind checking? */
+ Bool valgrind_support,
+ /* Control ... */
+ /*READONLY*/VexControl* vcon
+);
+
+
+/*-------------------------------------------------------*/
+/*--- Make a translation ---*/
+/*-------------------------------------------------------*/
typedef
- enum { TransOK, TransAccessFail, TransOutputFull }
- TranslateResult;
+ enum {
+ VexTransOK,
+ VexTransAccessFail,
+ VexTransOutputFull
+ }
+ VexTranslateResult;
extern
-TranslateResult LibVEX_Translate (
+VexTranslateResult LibVEX_Translate (
/* The instruction sets we are translating from and to. */
VexArch arch_guest,
VexSubArch subarch_guest,
);
-/* Show accumulated statistics. */
+/*-------------------------------------------------------*/
+/*--- Show accumulated statistics ---*/
+/*-------------------------------------------------------*/
extern void LibVEX_ShowStats ( void );
-
-/* A note about baseblock layout.
-
- LibVEX defines the layout for the guest state, in the file
- pub/libvex_guest_<arch>.h. The struct will have an 8-aligned size.
- Each translated bb is assumed to be entered with a specified
- register pointing at such a struct. Beyond that is a shadow
- state area with the same size as the struct. Beyond that is
- a spill area that LibVEX may spill into. It must have size
- LibVEX_N_SPILL_BYTES, and this will be a 16-aligned number.
-
- On entry, the baseblock pointer register must be 8-aligned.
-*/
-
-#define LibVEX_N_SPILL_BYTES 768
-
-
+/*-------------------------------------------------------*/
+/*--- Notes ---*/
+/*-------------------------------------------------------*/
/* Code generation conventions that need to be recorded somewhere.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~