-INCLUDES = include/arena.h \
- include/basictypes.h include/ir_defs.h \
- include/host_regs.h include/x86h_defs.h
+PUB_HEADERS = pub/libjit_basictypes.h \
+ pub/libjit_ir.h \
+ pub/libjit.h
-##OBJS = basictypes.o ir_defs.o arena.o linker.o dispatch.o
-OBJS = basictypes.o ir_defs.o host_regs.o \
- x86h_defs.o isel_x86.o reg_alloc.o test_main.o
+PRIV_HEADERS = priv/ir/ir_defs.h \
+ priv/host-x86/x86h_defs.h \
+ priv/host-generic/host_regs.h
-GCC = gcc341
-##GCC = gcc
-CC_OPTS = -g -Wall -Wshadow -Iinclude
+LIB_OBJS = priv/ir/ir_defs.o \
+ priv/host-x86/x86h_defs.o \
+ priv/host-x86/isel_x86.o \
+ priv/host-generic/host_regs.o \
+ priv/host-generic/reg_alloc.o
-all: $(OBJS)
- $(GCC) $(CC_OPTS) -o vex $(OBJS)
+PUB_INCLUDES = -Ipub
+
+PRIV_INCLUDES = -Ipub -Ipriv/ir -Ipriv/host-generic -Ipriv/host-x86
+
+APP_OBJS = test_main.o
+
+
+CC = gcc341
+CCFLAGS = -g -Wall -Wshadow
+
+all: libjit.a $(APP_OBJS)
+ $(CC) $(CCFLAGS) -o vex $(APP_OBJS) libjit.a
+
+libjit.a: $(LIB_OBJS)
+ ar clq libjit.a $(LIB_OBJS)
+
+%.o: %.c
+ $(CC) $(CCFLAGS) $(PRIV_INCLUDES) -c -o $@ $<
clean:
- rm -f *.o vex
-
-basictypes.o: basictypes.c $(INCLUDES)
- $(GCC) $(CC_OPTS) -c basictypes.c
-ir_defs.o: ir_defs.c $(INCLUDES)
- $(GCC) $(CC_OPTS) -c ir_defs.c
-host_regs.o: host_regs.c $(INCLUDES)
- $(GCC) $(CC_OPTS) -c host_regs.c
-x86h_defs.o: x86h_defs.c $(INCLUDES)
- $(GCC) $(CC_OPTS) -c x86h_defs.c
-isel_x86.o: isel_x86.c $(INCLUDES)
- $(GCC) $(CC_OPTS) -c isel_x86.c
-reg_alloc.o: reg_alloc.c $(INCLUDES)
- $(GCC) $(CC_OPTS) -c reg_alloc.c
-arena.o: arena.c $(INCLUDES)
- $(GCC) $(CC_OPTS) -c arena.c
-linker.o: linker.c $(INCLUDES)
- $(GCC) $(CC_OPTS) -c linker.c
-dispatch.o: dispatch.c $(INCLUDES)
- $(GCC) $(CC_OPTS) -c dispatch.c
-
-test_main.o: test_main.c $(INCLUDES)
- $(GCC) $(CC_OPTS) -c test_main.c
+ rm -f $(APP_OBJS) $(LIB_OBJS) libjit.a vex
+
/*--- ---*/
/*---------------------------------------------------------------*/
-#include <stdio.h>
-#include <malloc.h>
-
-#include "basictypes.h"
+#include "libjit_basictypes.h"
#include "ir_defs.h"
#include "host_regs.h"
#include "x86h_defs.h"
/*--- ---*/
/*---------------------------------------------------------------*/
-#include <stdio.h>
-#include <malloc.h>
-
-#include "basictypes.h"
+#include "libjit_basictypes.h"
#include "host_regs.h"
#include "x86h_defs.h"
/*--- ---*/
/*---------------------------------------------------------------*/
-#ifndef __X86H_DEFS_H
-#define __X86H_DEFS_H
+#ifndef __LIBJIT_X86H_DEFS_H
+#define __LIBJIT_X86H_DEFS_H
/* --------- Registers. --------- */
extern X86Instr* genReload_X86 ( HReg rreg, Int offset );
-#endif /* ndef __X86H_DEFS_H */
+#endif /* ndef __LIBJIT_X86H_DEFS_H */
/*--- ---*/
/*---------------------------------------------------------------*/
-#include <stdio.h>
-#include <malloc.h>
-
-#include "basictypes.h"
+#include "libjit_basictypes.h"
#include "ir_defs.h"
/*---------------------------------------------------------------*/
/*--- ---*/
-/*--- This file (basictypes.h) is ---*/
+/*--- This file (util.h) is ---*/
/*--- Copyright (c) 2004 OpenWorks LLP. All rights reserved. ---*/
/*--- ---*/
/*---------------------------------------------------------------*/
-#ifndef __BASICTYPES_H
-#define __BASICTYPES_H
+#ifndef __LIBJIT_UTIL_H
+#define __LIBJIT_UTIL_H
-typedef unsigned char UChar;
-typedef char Char; /* platform-dependent signfulness */
-
-typedef unsigned short UShort;
-typedef signed short Short;
-
-typedef unsigned int UInt;
-typedef signed int Int;
-
-typedef unsigned long long int ULong;
-typedef signed long long int Long;
-
-typedef unsigned char Bool;
-#define True ((Bool)1)
-#define False ((Bool)0)
+#include "libjit_basictypes.h"
/* Stuff for panicking and assertion. */
extern void panic ( Char* str );
-#endif /* ndef __BASICTYPES_H */
+#endif /* ndef __LIBJIT_UTIL_H */
+
+/*---------------------------------------------------------------*/
+/*--- util.h ---*/
+/*---------------------------------------------------------------*/
--- /dev/null
+
+/*---------------------------------------------------------------*/
+/*--- ---*/
+/*--- This file (libjit.h) is ---*/
+/*--- Copyright (c) 2004 OpenWorks LLP. All rights reserved. ---*/
+/*--- ---*/
+/*---------------------------------------------------------------*/
+
+#ifndef __LIBJIT_H
+#define __LIBJIT_H
+
+
+#include "libjit_basictypes.h"
+#include "libjit_ir.h"
+
+
+/*---------------------------------------------------------------*/
+/*--- Top-level interface to the library. ---*/
+/*---------------------------------------------------------------*/
+
+
+/* Initialise the translator. */
+
+extern Bool LibJIT_Init (
+ /* failure exit function */
+ void (*failure_exit) ( void ),
+ /* logging output function */
+ void (*log_bytes) ( Char*, Int nbytes ),
+ /* debug paranoia level */
+ Int debuglevel,
+ /* verbosity level */
+ Int verbosity,
+ /* Are we supporting valgrind checking? */
+ Bool valgrind_support,
+ /* Max # guest insns per bb */
+ Int guest_insns_per_bb
+);
+
+
+/* Storage management: clear the area, and allocate from it. */
+
+extern void LibJIT_Clear ( Bool show_stats );
+
+extern void* LibJIT_Alloc ( Int nbytes );
+
+
+/* Translate a basic block. */
+
+typedef
+ enum { InsnSetX86, InsnSetARM }
+ InsnSet;
+
+typedef
+ enum { TransOK, TransAccessFail, TransOutputFull }
+ TranslateResult;
+
+extern
+TranslateResult LibJIT_Translate (
+ /* The instruction sets we are translating from and to. */
+ InsnSet iset_guest,
+ InsnSet iset_host,
+ /* IN: the block to translate, and its guest address. */
+ Char* guest_bytes,
+ Addr64 guest_bytes_addr,
+ /* OUT: the number of bytes actually read */
+ Int* guest_bytes_read,
+ /* IN: a place to put the resulting code, and its size */
+ Char* host_bytes,
+ 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, an access check function for guest code. */
+ Bool (*byte_accessible) ( Addr64 )
+);
+
+
+/* Show accumulated statistics. */
+
+extern void LibJIT_ShowStats ( void );
+
+
+endif /* ndef __LIBJIT_H */
+
+/*---------------------------------------------------------------*/
+/*--- libjit.h ---*/
+/*---------------------------------------------------------------*/
--- /dev/null
+
+/*---------------------------------------------------------------*/
+/*--- ---*/
+/*--- This file (libjit_basictypes.h) is ---*/
+/*--- Copyright (c) 2004 OpenWorks LLP. All rights reserved. ---*/
+/*--- ---*/
+/*---------------------------------------------------------------*/
+
+#ifndef __LIBJIT_BASICTYPES_H
+#define __LIBJIT_BASICTYPES_H
+
+typedef unsigned char UChar;
+typedef char Char; /* platform-dependent signfulness */
+
+typedef unsigned short UShort;
+typedef signed short Short;
+
+typedef unsigned int UInt;
+typedef signed int Int;
+
+typedef unsigned long long int ULong;
+typedef signed long long int Long;
+
+typedef unsigned char Bool;
+#define True ((Bool)1)
+#define False ((Bool)0)
+
+
+#endif /* ndef __LIBJIT_BASICTYPES_H */
+
+
+/*---------------------------------------------------------------*/
+/*--- libjit_basictypes.h ---*/
+/*---------------------------------------------------------------*/
/*---------------------------------------------------------------*/
/*--- ---*/
-/*--- This file (ir_defs.h) is ---*/
+/*--- This file (libjit_ir.h) is ---*/
/*--- Copyright (c) 2004 OpenWorks LLP. All rights reserved. ---*/
/*--- ---*/
/*---------------------------------------------------------------*/
-#ifndef __IR_DEFS_H
-#define __IR_DEFS_H
+#ifndef __LIBJIT_IR_H
+#define __LIBJIT_IR_H
+
+#include "libjit_basictypes.h"
/*---------------------------------------------------------------*/
extern IRType typeOfIRExpr ( IRTypeEnv*, IRExpr* );
-#endif /* ndef __IR_DEFS_H */
+#endif /* ndef __LIBJIT_IR_H */
+
+
+/*---------------------------------------------------------------*/
+/*--- libjit_ir.h ---*/
+/*---------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
-#include "basictypes.h"
+#include "libjit_basictypes.h"
#include "ir_defs.h"
#include "host_regs.h"
#include "x86h_defs.h"