From: Julian Seward Date: Mon, 5 Jul 2004 01:15:34 +0000 (+0000) Subject: Mash around top-level library structure some more. X-Git-Tag: svn/VALGRIND_3_0_1^2~1286 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1ffd102b8c5a2f640e962078028fa51e9d380c9f;p=thirdparty%2Fvalgrind.git Mash around top-level library structure some more. git-svn-id: svn://svn.valgrind.org/vex/trunk@48 --- diff --git a/VEX/Makefile b/VEX/Makefile index 3ac3070606..b41a3aac14 100644 --- a/VEX/Makefile +++ b/VEX/Makefile @@ -1,42 +1,39 @@ -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 + diff --git a/VEX/priv/host-x86/isel_x86.c b/VEX/priv/host-x86/isel_x86.c index b62f3f8e76..ce4f624dbb 100644 --- a/VEX/priv/host-x86/isel_x86.c +++ b/VEX/priv/host-x86/isel_x86.c @@ -6,10 +6,7 @@ /*--- ---*/ /*---------------------------------------------------------------*/ -#include -#include - -#include "basictypes.h" +#include "libjit_basictypes.h" #include "ir_defs.h" #include "host_regs.h" #include "x86h_defs.h" diff --git a/VEX/priv/host-x86/x86h_defs.c b/VEX/priv/host-x86/x86h_defs.c index 170964309f..bf34905dd0 100644 --- a/VEX/priv/host-x86/x86h_defs.c +++ b/VEX/priv/host-x86/x86h_defs.c @@ -6,10 +6,7 @@ /*--- ---*/ /*---------------------------------------------------------------*/ -#include -#include - -#include "basictypes.h" +#include "libjit_basictypes.h" #include "host_regs.h" #include "x86h_defs.h" diff --git a/VEX/priv/host-x86/x86h_defs.h b/VEX/priv/host-x86/x86h_defs.h index c1a1021848..511f8863dd 100644 --- a/VEX/priv/host-x86/x86h_defs.h +++ b/VEX/priv/host-x86/x86h_defs.h @@ -6,8 +6,8 @@ /*--- ---*/ /*---------------------------------------------------------------*/ -#ifndef __X86H_DEFS_H -#define __X86H_DEFS_H +#ifndef __LIBJIT_X86H_DEFS_H +#define __LIBJIT_X86H_DEFS_H /* --------- Registers. --------- */ @@ -231,4 +231,4 @@ extern X86Instr* genSpill_X86 ( HReg rreg, Int offset ); extern X86Instr* genReload_X86 ( HReg rreg, Int offset ); -#endif /* ndef __X86H_DEFS_H */ +#endif /* ndef __LIBJIT_X86H_DEFS_H */ diff --git a/VEX/priv/ir/ir_defs.c b/VEX/priv/ir/ir_defs.c index 27ca1abf68..09c79d5376 100644 --- a/VEX/priv/ir/ir_defs.c +++ b/VEX/priv/ir/ir_defs.c @@ -6,10 +6,7 @@ /*--- ---*/ /*---------------------------------------------------------------*/ -#include -#include - -#include "basictypes.h" +#include "libjit_basictypes.h" #include "ir_defs.h" diff --git a/VEX/pub/basictypes.h b/VEX/priv/main/util.h similarity index 64% rename from VEX/pub/basictypes.h rename to VEX/priv/main/util.h index 61d2e18749..73eca365df 100644 --- a/VEX/pub/basictypes.h +++ b/VEX/priv/main/util.h @@ -1,29 +1,15 @@ /*---------------------------------------------------------------*/ /*--- ---*/ -/*--- 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. */ @@ -43,4 +29,8 @@ __attribute__ ((__noreturn__)) extern void panic ( Char* str ); -#endif /* ndef __BASICTYPES_H */ +#endif /* ndef __LIBJIT_UTIL_H */ + +/*---------------------------------------------------------------*/ +/*--- util.h ---*/ +/*---------------------------------------------------------------*/ diff --git a/VEX/pub/libjit.h b/VEX/pub/libjit.h new file mode 100644 index 0000000000..963db9bab9 --- /dev/null +++ b/VEX/pub/libjit.h @@ -0,0 +1,88 @@ + +/*---------------------------------------------------------------*/ +/*--- ---*/ +/*--- 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 ---*/ +/*---------------------------------------------------------------*/ diff --git a/VEX/pub/libjit_basictypes.h b/VEX/pub/libjit_basictypes.h new file mode 100644 index 0000000000..fd4e43eb58 --- /dev/null +++ b/VEX/pub/libjit_basictypes.h @@ -0,0 +1,34 @@ + +/*---------------------------------------------------------------*/ +/*--- ---*/ +/*--- 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 ---*/ +/*---------------------------------------------------------------*/ diff --git a/VEX/priv/ir/ir_defs.h b/VEX/pub/libjit_ir.h similarity index 94% rename from VEX/priv/ir/ir_defs.h rename to VEX/pub/libjit_ir.h index ae3082cd41..6421887a0c 100644 --- a/VEX/priv/ir/ir_defs.h +++ b/VEX/pub/libjit_ir.h @@ -1,13 +1,15 @@ /*---------------------------------------------------------------*/ /*--- ---*/ -/*--- 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" /*---------------------------------------------------------------*/ @@ -265,4 +267,9 @@ extern IRType lookupIRTypeEnv ( IRTypeEnv*, IRTemp ); extern IRType typeOfIRExpr ( IRTypeEnv*, IRExpr* ); -#endif /* ndef __IR_DEFS_H */ +#endif /* ndef __LIBJIT_IR_H */ + + +/*---------------------------------------------------------------*/ +/*--- libjit_ir.h ---*/ +/*---------------------------------------------------------------*/ diff --git a/VEX/test_main.c b/VEX/test_main.c index 99a8d7d9a5..98db2707b7 100644 --- a/VEX/test_main.c +++ b/VEX/test_main.c @@ -9,7 +9,7 @@ #include #include -#include "basictypes.h" +#include "libjit_basictypes.h" #include "ir_defs.h" #include "host_regs.h" #include "x86h_defs.h" diff --git a/VEX/arena.c b/VEX/unused/arena.c similarity index 100% rename from VEX/arena.c rename to VEX/unused/arena.c