Browse Source

Fix gcc-6.2 build

pull/1/head
Aleksey Demakov 8 years ago
parent
commit
0f176f54f5
  1. 7
      ChangeLog
  2. 13
      tools/Makefile.am
  3. 157
      tools/gen-apply-helper.c
  4. 130
      tools/gen-apply-helper.h
  5. 203
      tools/gen-apply.c

7
ChangeLog

@ -1,3 +1,10 @@
2016-10-22 Aleksey Demakov <ademakov@gmail.com>
* tools/gen-apply-helper.h
* tools/gen-apply-helper.c: move register detection functions to
separate files to avoid inter-procedural constant propagation in
modern compilers (e.g. gcc-6.*).
2016-04-08 Aleksey Demakov <ademakov@gmail.com>
* jit/jit-insn.c (jit_insn_label): revert the function to its old

13
tools/Makefile.am

@ -4,9 +4,10 @@ BUILT_SOURCES = jit-arch.h
noinst_PROGRAMS = gen-apply gen-rules gen-ops
noinst_HEADERS = gen-apply-macosx.h
dist_gen_apply_SOURCES = gen-apply.c
dist_gen_apply_SOURCES = \
gen-apply.c \
gen-apply-helper.c gen-apply-helper.h \
gen-apply-macosx.h
nodist_gen_apply_SOURCES = jit-arch.h
@ -16,6 +17,9 @@ gen_ops_SOURCES = gen-ops-scanner.l gen-ops-parser.y
AM_YFLAGS = -d
AM_CFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include \
-I$(top_srcdir)/jit -I$(top_builddir)/jit
jit-arch.h: $(top_srcdir)/include/jit/$(ARCH_HEADER)
rm -f $@
$(LN_S) $(top_srcdir)/include/jit/$(ARCH_HEADER) $@
@ -29,9 +33,6 @@ all-local: $(top_builddir)/jit/jit-apply-rules.h
$(top_builddir)/jit/jit-apply-rules.h: gen-apply$(EXEEXT)
./gen-apply >$@
AM_CFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include \
-I$(top_srcdir)/jit -I$(top_builddir)/jit
CLEANFILES = $(top_builddir)/jit/jit-apply-rules.h jit-arch.h \
gen-rules-parser.c gen-rules-parser.h gen-rules-scanner.c \
gen-ops-parser.c gen-ops-parser.h gen-ops-scanner.c

157
tools/gen-apply-helper.c

@ -0,0 +1,157 @@
/*
* gen-apply-helper.c - Helper routines to generate apply rules.
*
* Copyright (C) 2004 Southern Storm Software, Pty Ltd.
*
* This file is part of the libjit library.
*
* The libjit library 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 2.1 of
* the License, or (at your option) any later version.
*
* The libjit library 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 the libjit library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include "gen-apply-helper.h"
/*
* Detect the number of word registers that are used in function calls.
* We assume that the platform uses less than 32 registers in outgoing calls.
*/
void
detect_word_regs(jit_nint arg1, jit_nint arg2, jit_nint arg3,
jit_nint arg4, jit_nint arg5, jit_nint arg6,
jit_nint arg7, jit_nint arg8, jit_nint arg9,
jit_nint arg10, jit_nint arg11, jit_nint arg12,
jit_nint arg13, jit_nint arg14, jit_nint arg15,
jit_nint arg16, jit_nint arg17, jit_nint arg18,
jit_nint arg19, jit_nint arg20, jit_nint arg21,
jit_nint arg22, jit_nint arg23, jit_nint arg24,
jit_nint arg25, jit_nint arg26, jit_nint arg27,
jit_nint arg28, jit_nint arg29, jit_nint arg30,
jit_nint arg31, jit_nint arg32)
{
/* We fetch the number in the first stack argument, which will
correspond to the number of word registers that are present */
jit_nint *args, *stack_args;
jit_builtin_apply_args(jit_nint *, args);
stack_args = (jit_nint *)(args[0]);
num_word_regs = (int)(stack_args[0]);
/* Detect the presence of a structure return register by checking
to see if "arg1" is in the second word position after "stack_args" */
if(num_word_regs > 1 && args[2] == 0)
{
struct_return_special_reg = 1;
}
}
/*
* Detect the number of floating-point registers.
*/
void
detect_float_regs(float arg1, float arg2, float arg3,
float arg4, float arg5, float arg6,
float arg7, float arg8, float arg9,
float arg10, float arg11, float arg12,
float arg13, float arg14, float arg15,
float arg16, float arg17, float arg18,
float arg19, float arg20, float arg21,
float arg22, float arg23, float arg24,
float arg25, float arg26, float arg27,
float arg28, float arg29, float arg30,
float arg31, float arg32)
{
jit_nint *args;
float *stack_args;
jit_builtin_apply_args(jit_nint *, args);
stack_args = (float *)(args[0]);
/* The first stack argument indicates the number of floating-point
registers. At the moment we don't know if they overlap with
the word registers or not */
num_float_regs = (int)(stack_args[0]);
}
/*
* Detect the number of floating-point registers.
*/
void
detect_double_regs(double arg1, double arg2, double arg3,
double arg4, double arg5, double arg6,
double arg7, double arg8, double arg9,
double arg10, double arg11, double arg12,
double arg13, double arg14, double arg15,
double arg16, double arg17, double arg18,
double arg19, double arg20, double arg21,
double arg22, double arg23, double arg24,
double arg25, double arg26, double arg27,
double arg28, double arg29, double arg30,
double arg31, double arg32)
{
jit_nint *args;
double *stack_args;
jit_builtin_apply_args(jit_nint *, args);
stack_args = (double *)(args[0]);
/* The first stack argument indicates the number of floating-point
registers. At the moment we don't know if they overlap with
the word registers or not */
num_double_regs = (int)(stack_args[0]);
}
/*
* Detect the number of native floating-point registers.
*/
void
detect_nfloat_regs(jit_nfloat arg1, jit_nfloat arg2, jit_nfloat arg3,
jit_nfloat arg4, jit_nfloat arg5, jit_nfloat arg6,
jit_nfloat arg7, jit_nfloat arg8, jit_nfloat arg9,
jit_nfloat arg10, jit_nfloat arg11, jit_nfloat arg12,
jit_nfloat arg13, jit_nfloat arg14, jit_nfloat arg15,
jit_nfloat arg16, jit_nfloat arg17, jit_nfloat arg18,
jit_nfloat arg19, jit_nfloat arg20, jit_nfloat arg21,
jit_nfloat arg22, jit_nfloat arg23, jit_nfloat arg24,
jit_nfloat arg25, jit_nfloat arg26, jit_nfloat arg27,
jit_nfloat arg28, jit_nfloat arg29, jit_nfloat arg30,
jit_nfloat arg31, jit_nfloat arg32)
{
jit_nint *args;
jit_nfloat *stack_args;
jit_builtin_apply_args(jit_nint *, args);
stack_args = (jit_nfloat *)(args[0]);
/* The first stack argument indicates the number of floating-point
registers. At the moment we don't know if they overlap with
the word registers or not */
num_nfloat_regs = (int)(stack_args[0]);
}
/*
* Dummy functions for helping detect the size and position of "float",
* "double", and "long double" return values.
*/
float
return_float(void)
{
return (float)123.0;
}
double
return_double(void)
{
return (double)456.7;
}
jit_nfloat
return_nfloat(void)
{
return (jit_nfloat)8901.2;
}

130
tools/gen-apply-helper.h

@ -0,0 +1,130 @@
/*
* gen-apply-helper.h - Helper routines to generate apply rules.
*
* Copyright (C) 2004 Southern Storm Software, Pty Ltd.
*
* This file is part of the libjit library.
*
* The libjit library 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 2.1 of
* the License, or (at your option) any later version.
*
* The libjit library 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 the libjit library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef _GEN_APPLY_HELPER_H
#define _GEN_APPLY_HELPER_H
#include <jit/jit-defs.h>
#if defined(__GNUC__)
# define PLATFORM_IS_GCC 1
#endif
#if defined(__i386) || defined(__i386__) || defined(_M_IX86)
# define PLATFORM_IS_X86 1
# if defined(__CYGWIN__) || defined(__CYGWIN32__) \
|| defined(_WIN32) || defined(WIN32)
# define PLATFORM_IS_WIN32 1
# include <malloc.h>
# ifndef alloca
# define alloca _alloca
# endif
# endif
#endif
#if defined(__APPLE__) && defined(__MACH__)
# define PLATFORM_IS_MACOSX 1
#endif
#if defined(__x86_64__) || defined(__x86_64)
# define PLATFORM_IS_X86_64 1
#endif
#if defined(__arm__) || defined(__arm)
# define PLATFORM_IS_ARM 1
#endif
#include <config.h>
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#if HAVE_ALLOCA_H
# include <alloca.h>
#endif
/* Override default JIT_MEMCPY used in jit-apply-func.h */
#if defined(__APPLE__) && defined(__MACH__)
# define JIT_MEMCPY "_mem_copy"
#else
# define JIT_MEMCPY "mem_copy"
#endif
#include "jit-apply-func.h"
extern int num_word_regs;
extern int num_float_regs;
extern int num_double_regs;
extern int num_nfloat_regs;
extern int struct_return_special_reg;
void detect_word_regs(jit_nint arg1, jit_nint arg2, jit_nint arg3,
jit_nint arg4, jit_nint arg5, jit_nint arg6,
jit_nint arg7, jit_nint arg8, jit_nint arg9,
jit_nint arg10, jit_nint arg11, jit_nint arg12,
jit_nint arg13, jit_nint arg14, jit_nint arg15,
jit_nint arg16, jit_nint arg17, jit_nint arg18,
jit_nint arg19, jit_nint arg20, jit_nint arg21,
jit_nint arg22, jit_nint arg23, jit_nint arg24,
jit_nint arg25, jit_nint arg26, jit_nint arg27,
jit_nint arg28, jit_nint arg29, jit_nint arg30,
jit_nint arg31, jit_nint arg32);
void detect_float_regs(float arg1, float arg2, float arg3,
float arg4, float arg5, float arg6,
float arg7, float arg8, float arg9,
float arg10, float arg11, float arg12,
float arg13, float arg14, float arg15,
float arg16, float arg17, float arg18,
float arg19, float arg20, float arg21,
float arg22, float arg23, float arg24,
float arg25, float arg26, float arg27,
float arg28, float arg29, float arg30,
float arg31, float arg32);
void detect_double_regs(double arg1, double arg2, double arg3,
double arg4, double arg5, double arg6,
double arg7, double arg8, double arg9,
double arg10, double arg11, double arg12,
double arg13, double arg14, double arg15,
double arg16, double arg17, double arg18,
double arg19, double arg20, double arg21,
double arg22, double arg23, double arg24,
double arg25, double arg26, double arg27,
double arg28, double arg29, double arg30,
double arg31, double arg32);
void detect_nfloat_regs(jit_nfloat arg1, jit_nfloat arg2, jit_nfloat arg3,
jit_nfloat arg4, jit_nfloat arg5, jit_nfloat arg6,
jit_nfloat arg7, jit_nfloat arg8, jit_nfloat arg9,
jit_nfloat arg10, jit_nfloat arg11, jit_nfloat arg12,
jit_nfloat arg13, jit_nfloat arg14, jit_nfloat arg15,
jit_nfloat arg16, jit_nfloat arg17, jit_nfloat arg18,
jit_nfloat arg19, jit_nfloat arg20, jit_nfloat arg21,
jit_nfloat arg22, jit_nfloat arg23, jit_nfloat arg24,
jit_nfloat arg25, jit_nfloat arg26, jit_nfloat arg27,
jit_nfloat arg28, jit_nfloat arg29, jit_nfloat arg30,
jit_nfloat arg31, jit_nfloat arg32);
float return_float(void);
double return_double(void);
jit_nfloat return_nfloat(void);
#endif /* _GEN_APPLY_HELPER_H */

203
tools/gen-apply.c

@ -21,23 +21,9 @@
*/
#include "jit-arch.h"
#include <jit/jit-defs.h>
#include "gen-apply-helper.h"
#if defined(__APPLE__) && defined(__MACH__)
# define JIT_MEMCPY "_mem_copy"
#else
# define JIT_MEMCPY "mem_copy"
#endif
#include "jit-apply-func.h"
#include <stdio.h>
#include <config.h>
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#if HAVE_ALLOCA_H
#include <alloca.h>
#endif
/*
@ -47,31 +33,6 @@ the "jit-apply-rules.h" file.
*/
#if defined(__GNUC__)
#define PLATFORM_IS_GCC 1
#endif
#if defined(__i386) || defined(__i386__) || defined(_M_IX86)
#define PLATFORM_IS_X86 1
#if defined(__CYGWIN__) || defined(__CYGWIN32__) || \
defined(_WIN32) || defined(WIN32)
#define PLATFORM_IS_WIN32 1
#include <malloc.h>
#ifndef alloca
#define alloca _alloca
#endif
#endif
#endif
#if defined(__APPLE__) && defined(__MACH__)
#define PLATFORM_IS_MACOSX 1
#endif
#if defined(__x86_64__) || defined(__x86_64)
#define PLATFORM_IS_X86_64 1
#endif
#if defined(__arm__) || defined(__arm)
#define PLATFORM_IS_ARM 1
#endif
#if PLATFORM_IS_X86
/*
* On x86 the extended precision numbers are 10 bytes long. However certain
@ -92,6 +53,12 @@ the "jit-apply-rules.h" file.
#if defined(PLATFORM_IS_GCC) || defined(PLATFORM_IS_WIN32)
#if defined(PLATFORM_IS_GCC)
# define __UNUSED __attribute__((unused))
#else
# define __UNUSED
#endif
/*
* Pick up pre-defined values on platforms where auto-detection doesn't work.
*/
@ -219,37 +186,6 @@ int mem_cmp(const void *s1, const void *s2, unsigned int len)
return 0;
}
/*
* Detect the number of word registers that are used in function calls.
* We assume that the platform uses less than 32 registers in outgoing calls.
*/
void detect_word_regs(jit_nint arg1, jit_nint arg2, jit_nint arg3,
jit_nint arg4, jit_nint arg5, jit_nint arg6,
jit_nint arg7, jit_nint arg8, jit_nint arg9,
jit_nint arg10, jit_nint arg11, jit_nint arg12,
jit_nint arg13, jit_nint arg14, jit_nint arg15,
jit_nint arg16, jit_nint arg17, jit_nint arg18,
jit_nint arg19, jit_nint arg20, jit_nint arg21,
jit_nint arg22, jit_nint arg23, jit_nint arg24,
jit_nint arg25, jit_nint arg26, jit_nint arg27,
jit_nint arg28, jit_nint arg29, jit_nint arg30,
jit_nint arg31, jit_nint arg32)
{
/* We fetch the number in the first stack argument, which will
correspond to the number of word registers that are present */
jit_nint *args, *stack_args;
jit_builtin_apply_args(jit_nint *, args);
stack_args = (jit_nint *)(args[0]);
num_word_regs = (int)(stack_args[0]);
/* Detect the presence of a structure return register by checking
to see if "arg1" is in the second word position after "stack_args" */
if(num_word_regs > 1 && args[2] == 0)
{
struct_return_special_reg = 1;
}
}
/*
* Detect the presence of a structure return register if there are 0 or 1
* word registers as detected by "detect_word_regs". The structure
@ -349,84 +285,6 @@ struct detect_struct_reg detect_struct_overlap(jit_nint arg1, jit_nint arg2)
return ret;
}
/*
* Detect the number of floating-point registers.
*/
void detect_float_regs(float arg1, float arg2, float arg3,
float arg4, float arg5, float arg6,
float arg7, float arg8, float arg9,
float arg10, float arg11, float arg12,
float arg13, float arg14, float arg15,
float arg16, float arg17, float arg18,
float arg19, float arg20, float arg21,
float arg22, float arg23, float arg24,
float arg25, float arg26, float arg27,
float arg28, float arg29, float arg30,
float arg31, float arg32)
{
jit_nint *args;
float *stack_args;
jit_builtin_apply_args(jit_nint *, args);
stack_args = (float *)(args[0]);
/* The first stack argument indicates the number of floating-point
registers. At the moment we don't know if they overlap with
the word registers or not */
num_float_regs = (int)(stack_args[0]);
}
/*
* Detect the number of floating-point registers.
*/
void detect_double_regs(double arg1, double arg2, double arg3,
double arg4, double arg5, double arg6,
double arg7, double arg8, double arg9,
double arg10, double arg11, double arg12,
double arg13, double arg14, double arg15,
double arg16, double arg17, double arg18,
double arg19, double arg20, double arg21,
double arg22, double arg23, double arg24,
double arg25, double arg26, double arg27,
double arg28, double arg29, double arg30,
double arg31, double arg32)
{
jit_nint *args;
double *stack_args;
jit_builtin_apply_args(jit_nint *, args);
stack_args = (double *)(args[0]);
/* The first stack argument indicates the number of floating-point
registers. At the moment we don't know if they overlap with
the word registers or not */
num_double_regs = (int)(stack_args[0]);
}
/*
* Detect the number of native floating-point registers.
*/
void detect_nfloat_regs(jit_nfloat arg1, jit_nfloat arg2, jit_nfloat arg3,
jit_nfloat arg4, jit_nfloat arg5, jit_nfloat arg6,
jit_nfloat arg7, jit_nfloat arg8, jit_nfloat arg9,
jit_nfloat arg10, jit_nfloat arg11, jit_nfloat arg12,
jit_nfloat arg13, jit_nfloat arg14, jit_nfloat arg15,
jit_nfloat arg16, jit_nfloat arg17, jit_nfloat arg18,
jit_nfloat arg19, jit_nfloat arg20, jit_nfloat arg21,
jit_nfloat arg22, jit_nfloat arg23, jit_nfloat arg24,
jit_nfloat arg25, jit_nfloat arg26, jit_nfloat arg27,
jit_nfloat arg28, jit_nfloat arg29, jit_nfloat arg30,
jit_nfloat arg31, jit_nfloat arg32)
{
jit_nint *args;
jit_nfloat *stack_args;
jit_builtin_apply_args(jit_nint *, args);
stack_args = (jit_nfloat *)(args[0]);
/* The first stack argument indicates the number of floating-point
registers. At the moment we don't know if they overlap with
the word registers or not */
num_nfloat_regs = (int)(stack_args[0]);
}
#ifdef JIT_NATIVE_INT32
/*
@ -785,23 +643,6 @@ void detect_varargs_on_stack(jit_nint start, ...)
}
}
/*
* Dummy functions for helping detect the size and position of "float",
* "double", and "long double" return values.
*/
float return_float(void)
{
return (float)123.0;
}
double return_double(void)
{
return (double)456.7;
}
jit_nfloat return_nfloat(void)
{
return (jit_nfloat)8901.2;
}
/*
* Detect the behaviour of floating-point values in return blocks.
*/
@ -970,7 +811,7 @@ void detect_float_return(void)
jit_nint *args; \
volatile jit_nint stack[1]; \
union detect_un_##n buffer; \
void *apply_return; \
void *apply_return __UNUSED; \
jit_builtin_apply_args(jit_nint *, args); \
args[0] = (jit_nint)stack; \
stack[0] = (jit_nint)&buffer; \
@ -2511,9 +2352,9 @@ int main(int argc, char *argv[])
#ifndef JIT_APPLY_NUM_WORD_REGS
/* Detect the number of word registers */
detect_word_regs(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31);
detect_word_regs(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22, 23, 24, 25, 26, 27, 28, 29, 30, 31);
/* Detect the presence of a structure return register if
"detect_word_regs" was unable to do so */
@ -2527,32 +2368,32 @@ int main(int argc, char *argv[])
/* Detect the number of float registers */
detect_float_regs(0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0,
9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0,
25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0);
9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0,
25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0);
/* Detect the number of double registers */
detect_double_regs(0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0,
9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0,
25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0);
9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0,
25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0);
/* Detect the number of native floating-point registers */
detect_nfloat_regs(0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0,
9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0,
25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0);
9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0,
25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0);
/* Determine if floating-point values are passed in word registers */
if(num_float_regs > 0 && num_word_regs > 0)
{
#ifdef JIT_NATIVE_INT32
#ifdef JIT_NATIVE_INT32
if(num_word_regs == 1)
{
detect_float_overlap((float)(123.78), 1);
}
else
#endif
#endif
{
detect_double_overlap(123.78, 1, 2);
}

Loading…
Cancel
Save