diff --git a/ChangeLog b/ChangeLog index a57ee849d..d8de0b443 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2008-06-11 Paolo Bonzini + + * build-aux/lightning.m4: Adjust LIGHTNING_BACKENDS, don't + use suffix support to distinguish i386/x86_64. + * lightning/i386/Makefile.frag: Use LIGHTNING_TARGET_FILES + to distribute *-32.h and *-64.h files now. + * lightning/i386/asm-i386: Moved to... + * lightning/i386/asm.h: Include the appropriate subtarget file. + * lightning/i386/core-i386: Moved to... + * lightning/i386/core.h: Include the appropriate subtarget file. + * lightning/i386/fp.h: New, include the appropriate subtarget file. + * lightning/i386/asm-32: Do not include asm-i386.h. + * lightning/i386/asm-64.h: Likewise. + * lightning/i386/core-32: Do not include core-i386.h. + * lightning/i386/core-64.h: Likewise. + * lightning/Makefile.am: Adjust for renamed files. + + * configure.ac: Define LIGHTNING_TARGET here. + * opcode/disass.c: Change list of valid LIGHTNING_TARGET values. + + * lightningize.in: Robustify against missing subtarget files. + 2008-06-11 Paolo Bonzini * lightning/i386/core-32.h: Use MOVLir instead of jit_movi_l diff --git a/build-aux/lightning.m4 b/build-aux/lightning.m4 index b612d7c15..395916c61 100644 --- a/build-aux/lightning.m4 +++ b/build-aux/lightning.m4 @@ -1,17 +1,17 @@ dnl I'd like this to be edited in -*- Autoconf -*- mode... dnl # serial 2 LIGHTNING_CONFIGURE_IF_NOT_FOUND -m4_define([LIGHTNING_BACKENDS], [i386:-32 i386:-64 sparc ppc]) +m4_define([LIGHTNING_BACKENDS], [i386 i386:-32 i386:-64 sparc ppc]) AC_DEFUN([LIGHTNING_CONFIGURE_LINKS], [ suffix= -case "$host_cpu" in - i?86) cpu=i386; suffix=-32 ;; - x86_64) cpu=i386; suffix=-64 ;; - sparc*) cpu=sparc ;; - powerpc) cpu=ppc ;; - *) ;; +case "$target_cpu" in + i?86) cpu=i386 ;; + x86_64) cpu=i386 ;; + sparc*) cpu=sparc ;; + powerpc) cpu=ppc ;; + *) ;; esac if test -n "$cpu" && test -d "$srcdir/lightning/$cpu"; then $1 diff --git a/configure b/configure index 5be8631e6..79ac87e8e 100755 --- a/configure +++ b/configure @@ -3896,23 +3896,30 @@ fi -BACKENDS="i386:-32 i386:-64 sparc ppc" +BACKENDS="i386 i386:-32 i386:-64 sparc ppc" +case "$target_cpu" in + i?86) LIGHTNING_TARGET=LIGHTNING_I386 ;; + x86_64) LIGHTNING_TARGET=LIGHTNING_X86_64 ;; + sparc*) LIGHTNING_TARGET=LIGHTNING_SPARC ;; + powerpc) LIGHTNING_TARGET=LIGHTNING_PPC ;; + *) ;; +esac suffix= -case "$host_cpu" in - i?86) cpu=i386; suffix=-32 ;; - x86_64) cpu=i386; suffix=-64 ;; - sparc*) cpu=sparc ;; - powerpc) cpu=ppc ;; - *) ;; +case "$target_cpu" in + i?86) cpu=i386 ;; + x86_64) cpu=i386 ;; + sparc*) cpu=sparc ;; + powerpc) cpu=ppc ;; + *) ;; esac if test -n "$cpu" && test -d "$srcdir/lightning/$cpu"; then cat >>confdefs.h <<_ACEOF -#define LIGHTNING_TARGET `echo "LIGHTNING_$cpu$suffix" | $as_tr_cpp` +#define LIGHTNING_TARGET `echo "$LIGHTNING_TARGET" | $as_tr_cpp` _ACEOF lightning_frag=`cd $srcdir && pwd`/lightning/$cpu/Makefile.frag diff --git a/configure.ac b/configure.ac index 583f3edb5..65d7601a5 100644 --- a/configure.ac +++ b/configure.ac @@ -29,8 +29,15 @@ AC_EXEEXT BACKENDS="LIGHTNING_BACKENDS" AC_SUBST(BACKENDS) +case "$target_cpu" in + i?86) LIGHTNING_TARGET=LIGHTNING_I386 ;; + x86_64) LIGHTNING_TARGET=LIGHTNING_X86_64 ;; + sparc*) LIGHTNING_TARGET=LIGHTNING_SPARC ;; + powerpc) LIGHTNING_TARGET=LIGHTNING_PPC ;; + *) ;; +esac LIGHTNING_CONFIGURE_LINKS( - [AC_DEFINE_UNQUOTED(LIGHTNING_TARGET, [AS_TR_CPP([LIGHTNING_$cpu$suffix])], + [AC_DEFINE_UNQUOTED(LIGHTNING_TARGET, [AS_TR_CPP([$LIGHTNING_TARGET])], [Used to pick the appropriate disassembler, for debugging])], [AC_MSG_ERROR([cpu $target_cpu not supported])]) diff --git a/doc/lightningize.1 b/doc/lightningize.1 index b00f79ce2..28fef114d 100644 --- a/doc/lightningize.1 +++ b/doc/lightningize.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.28. -.TH LIGHTNINGIZE "1" "June 2007" "lightningize 1.2c" "User Commands" +.TH LIGHTNINGIZE "1" "June 2008" "lightningize 1.2c" "User Commands" .SH NAME lightningize \- manual page for lightningize 1.2c .SH SYNOPSIS diff --git a/lightning/Makefile.am b/lightning/Makefile.am index 5459d604b..e133d8590 100644 --- a/lightning/Makefile.am +++ b/lightning/Makefile.am @@ -1,9 +1,9 @@ DISTCLEANFILES = asm.h core.h funcs.h fp.h EXTRA_DIST = i386/Makefile.frag \ - i386/asm-32.h i386/asm-64.h i386/asm-i386.h \ - i386/core-32.h i386/core-64.h i386/core-i386.h \ - i386/fp-32.h i386/fp-64.h \ + i386/asm-32.h i386/asm-64.h i386/asm.h \ + i386/core-32.h i386/core-64.h i386/core.h \ + i386/fp-32.h i386/fp-64.h i386/fp.h \ i386/funcs.h \ sparc/asm.h sparc/core.h sparc/funcs.h sparc/fp.h \ ppc/asm.h ppc/core.h ppc/funcs.h ppc/fp.h diff --git a/lightning/Makefile.in b/lightning/Makefile.in index 35359d6aa..4e98eba55 100644 --- a/lightning/Makefile.in +++ b/lightning/Makefile.in @@ -173,9 +173,9 @@ target_os = @target_os@ target_vendor = @target_vendor@ DISTCLEANFILES = asm.h core.h funcs.h fp.h EXTRA_DIST = i386/Makefile.frag \ - i386/asm-32.h i386/asm-64.h i386/asm-i386.h \ - i386/core-32.h i386/core-64.h i386/core-i386.h \ - i386/fp-32.h i386/fp-64.h \ + i386/asm-32.h i386/asm-64.h i386/asm.h \ + i386/core-32.h i386/core-64.h i386/core.h \ + i386/fp-32.h i386/fp-64.h i386/fp.h \ i386/funcs.h \ sparc/asm.h sparc/core.h sparc/funcs.h sparc/fp.h \ ppc/asm.h ppc/core.h ppc/funcs.h ppc/fp.h diff --git a/lightning/i386/Makefile.frag b/lightning/i386/Makefile.frag index 78a56f817..59c01a279 100644 --- a/lightning/i386/Makefile.frag +++ b/lightning/i386/Makefile.frag @@ -1 +1,2 @@ -LIGHTNING_TARGET_FILES += i386/asm-i386.h i386/core-i386.h +LIGHTNING_TARGET_FILES += i386/asm-32.h i386/core-32.h \ + i386/asm-64.h i386/core-64.h diff --git a/lightning/i386/asm-32.h b/lightning/i386/asm-32.h index ac1e55bce..649ef7544 100644 --- a/lightning/i386/asm-32.h +++ b/lightning/i386/asm-32.h @@ -43,8 +43,6 @@ * + sr/sm = a star preceding a register or memory */ -#include "asm-i386.h" - #if defined(_ASM_SAFETY) #define _r1(R) ( ((R) & ~3) == _AL || ((R) & ~3) == _AH ? _rN(R) : JITFAIL( "8-bit register required")) #endif diff --git a/lightning/i386/asm-64.h b/lightning/i386/asm-64.h index c6a8fc62b..a92db0dfc 100644 --- a/lightning/i386/asm-64.h +++ b/lightning/i386/asm-64.h @@ -37,8 +37,6 @@ #ifndef LIGHTNING_DEBUG -#include "asm-i386.h" - /* OPCODE + i = immediate operand * + r = register operand * + m = memory operand (disp,base,index,scale) diff --git a/lightning/i386/asm-i386.h b/lightning/i386/asm.h similarity index 99% rename from lightning/i386/asm-i386.h rename to lightning/i386/asm.h index 62f9ba098..48615116f 100644 --- a/lightning/i386/asm-i386.h +++ b/lightning/i386/asm.h @@ -1590,6 +1590,14 @@ enum { /* [2] "Intel Architecture Software Developer's Manual Volume 2: Instruction Set Reference", */ /* Intel Corporation 1997. */ +#if LIGHTNING_CROSS \ + ? LIGHTNING_TARGET == LIGHTNING_X86_64 \ + : defined (__x86_64__) +#include "asm-64.h" +#else +#include "asm-32.h" +#endif + #endif #endif /* __lightning_asm_i386_h */ diff --git a/lightning/i386/core-32.h b/lightning/i386/core-32.h index 701431534..d93967f5e 100644 --- a/lightning/i386/core-32.h +++ b/lightning/i386/core-32.h @@ -37,8 +37,6 @@ #define JIT_CAN_16 1 #define JIT_AP _EBP -#include "core-i386.h" - struct jit_local_state { int framesize; int argssize; @@ -48,7 +46,7 @@ struct jit_local_state { #define jit_base_prolog() (_jitl.framesize = 20, _jitl.alloca_offset = 0, \ PUSHLr(_EBX), PUSHLr(_ESI), PUSHLr(_EDI), PUSHLr(_EBP), MOVLrr(_ESP, _EBP)) -#define jit_ret(ofs) \ +#define jit_base_ret(ofs) \ (((ofs) < 0 ? LEAVE_() : POPLr(_EBP)), \ POPLr(_EDI), POPLr(_ESI), POPLr(_EBX), RET_()) diff --git a/lightning/i386/core-64.h b/lightning/i386/core-64.h index 0c8808c26..d2ab96a7e 100644 --- a/lightning/i386/core-64.h +++ b/lightning/i386/core-64.h @@ -39,8 +39,6 @@ #define JIT_CALLTMPSTART 0x48 #define JIT_REXTMP 0x4B -#include "core-i386.h" - struct jit_local_state { int long_jumps; int nextarg_getfp; diff --git a/lightning/i386/core-i386.h b/lightning/i386/core.h similarity index 99% rename from lightning/i386/core-i386.h rename to lightning/i386/core.h index b57f9a539..3ed67309d 100644 --- a/lightning/i386/core-i386.h +++ b/lightning/i386/core.h @@ -350,5 +350,14 @@ #define _jit_alignment(pc, n) (((pc ^ _MASK(4)) + 1) & _MASK(n)) #define jit_align(n) NOPi(_jit_alignment(_jit_UL(_jit.x.pc), (n))) + +#if LIGHTNING_CROSS \ + ? LIGHTNING_TARGET == LIGHTNING_X86_64 \ + : defined (__x86_64__) +#include "core-64.h" +#else +#include "core-32.h" +#endif + #endif /* __lightning_core_i386_h */ diff --git a/lightning/i386/fp-32.h b/lightning/i386/fp-32.h index b6cd9fd77..ff596310c 100644 --- a/lightning/i386/fp-32.h +++ b/lightning/i386/fp-32.h @@ -30,8 +30,8 @@ ***********************************************************************/ -#ifndef __lightning_asm_fp_h -#define __lightning_asm_fp_h +#ifndef __lightning_fp_h +#define __lightning_fp_h /* We really must map the x87 stack onto a flat register file. In practice, we can provide something sensible and make it work on the x86 using the @@ -353,4 +353,4 @@ union jit_double_imm { #define jit_arg_f() ((_jitl.framesize += sizeof(float)) - sizeof(float)) #define jit_arg_d() ((_jitl.framesize += sizeof(double)) - sizeof(double)) -#endif /* __lightning_asm_h */ +#endif /* __lightning_fp_h */ diff --git a/lightning/i386/fp.h b/lightning/i386/fp.h new file mode 100644 index 000000000..f0b75f59b --- /dev/null +++ b/lightning/i386/fp.h @@ -0,0 +1,45 @@ +/******************************** -*- C -*- **************************** + * + * Floating-point support (i386) + * + ***********************************************************************/ + + +/*********************************************************************** + * + * Copyright 2008 Free Software Foundation, Inc. + * Written by Paolo Bonzini. + * + * This file is part of GNU lightning. + * + * GNU lightning is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU lightning is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with GNU lightning; see the file COPYING.LESSER; if not, write to the + * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + ***********************************************************************/ + + + +#ifndef __lightning_fp_i386_h +#define __lightning_fp_i386_h + +#if LIGHTNING_CROSS \ + ? LIGHTNING_TARGET == LIGHTNING_X86_64 \ + : defined (__x86_64__) +#include "fp-64.h" +#else +#include "fp-32.h" +#endif + +#endif /* __lightning_fp_i386_h */ diff --git a/lightningize.in b/lightningize.in index 8abff21bd..9c87760ea 100644 --- a/lightningize.in +++ b/lightningize.in @@ -195,7 +195,8 @@ for j in $BACKENDS; do suffix=`echo $j | sed -ne 's,.*:,,p' ` dirs="$dirs lightning/$dir" for i in $file_base_names; do - files="$files lightning/$dir:$pkgincludedir/$dir/$i$suffix.h" + test -f "$pkgincludedir/$dir/$i$suffix.h" && \ + files="$files lightning/$dir:$pkgincludedir/$dir/$i$suffix.h" done done diff --git a/opcode/disass.c b/opcode/disass.c index 8e3b962aa..c2a7e25da 100644 --- a/opcode/disass.c +++ b/opcode/disass.c @@ -34,10 +34,10 @@ #include "config.h" #include "dis-asm.h" -#define LIGHTNING_I386_32 0 -#define LIGHTNING_I386_64 1 -#define LIGHTNING_PPC 2 -#define LIGHTNING_SPARC 3 +#define LIGHTNING_I386 0 +#define LIGHTNING_X86_64 1 +#define LIGHTNING_PPC 2 +#define LIGHTNING_SPARC 3 void disassemble(stream, from, to) FILE *stream;