blob: ed25937dd59cef3dd698e23a841e49c8832ce4d6 [file] [log] [blame]
/*---------------------------------------------------------------*/
/*--- ---*/
/*--- This file (x86helpers.c) is ---*/
/*--- Copyright (c) 2004 OpenWorks LLP. All rights reserved. ---*/
/*--- ---*/
/*---------------------------------------------------------------*/
#include "libvex_basictypes.h"
#include "libvex_ir.h"
#include "vex_util.h"
#include "x86guest_defs.h"
/* This file contains helper functions for x86 guest code.
Calls to these functions are generated by the back end.
These calls are of course in the host machine code and
this file will be compiled to host machine code, so that
all makes sense.
x86guest_findhelper() is the only exported function.
Only change the signatures of these helper functions very
carefully. If you change the signature here, you'll have to change
the parameters passed to it in the IR calls constructed by
x86toIR.c.
*/
/* RUNS AS PART OF GENERATED CODE */
static UInt calculate_eflags_all ( UInt cc_op, UInt cc_src, UInt cc_dst )
{
switch (cc_op) {
default:
/* shouldn't really make these calls from generated code */
vex_printf("calculate_eflags_all: unhandled %d\n", cc_op);
vpanic("calculate_eflags_all");
}
}
/* RUNS AS PART OF GENERATED CODE */
static UInt calculate_eflags_c ( UInt cc_op, UInt cc_src, UInt cc_dst )
{
return calculate_eflags_all(cc_op,cc_src,cc_dst) & CC_MASK_C;
}
/* The only exported function. */
Addr64 x86guest_findhelper ( Char* function_name )
{
if (vex_streq(function_name, "calculate_eflags_all"))
return (Addr64)(& calculate_eflags_all);
if (vex_streq(function_name, "calculate_eflags_c"))
return (Addr64)(& calculate_eflags_c);
vex_printf("\nx86 guest: can't find helper: %s\n", function_name);
vpanic("x86guest_findhelper");
}
/*---------------------------------------------------------------*/
/*--- end x86helpers.c ---*/
/*---------------------------------------------------------------*/