public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* [help] Is this a frv-elf-gcc bug?
@ 2004-10-09 17:57 zhan rongkai
  0 siblings, 0 replies; only message in thread
From: zhan rongkai @ 2004-10-09 17:57 UTC (permalink / raw)
  To: gcc

Hi, all:

Recently it seems that i have encountered a bug of the toolchains for
the frv-elf target.

In one header file, i define some macroes:

#define get_user(x, ptr)   \
        __get_user_check((x), (ptr), sizeof(*(ptr)))

#define __get_user_check(x, ptr, size)		\
	({					\
		long __gu_err = -EFAULT, __gu_val = 0; 		\
		const __typeof__(*(ptr)) *__gu_addr = (ptr); 	\
		if (access_ok(VERIFY_READ, __gu_addr, (size))) 	\
			__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
		(x) = (__typeof__(*(ptr)))__gu_val;		\
		__gu_err;			\
	})

#define __get_user_size(x, ptr, size, retval)	\
	do {					\
		retval = 0;			\
		switch (size) {			\
		case 1:				\
			__get_user_1(x, ptr, retval); \
			break;			\
		case 2:				\
			__get_user_2(x, ptr, retval); \
			break;			\
		case 4:				\
			__get_user_8(x, ptr, retval); \
			break;			\
		case 8:				\
			__get_user_8(x, ptr, retval); \
			break;			\
		default:			\
			retval = -EFAULT;	\
			x = __get_user_bad();	\
		}				\
	} while (0)

/*
 * The constraints "=e" to the operand %1 specifies that we only
 * use even registers which are required by the 'ldd' & 'std' instructions.
 */
#define __get_user_asm(x, ptr, retval, op) 	\
	__asm__ __volatile__(			\
		"1:  "op" @(%2, gr0), %1\n"	\
		"2:\n"				\
		".section .fixup,\"ax\"\n"	\
		"    .align 4\n"		\
		"3:  sethi #hi(%3), %0\n"	\
		"    setlo #lo(%3), %0\n"	\
		"    sethi #hi(2b), gr4\n"	\
		"    setlo #lo(2b), gr4\n"	\
		"    jmpl @(gr4, gr0)\n"	\
		".previous\n"			\
		".section __ex_table,\"a\"\n"	\
		"    .align 4\n"		\
		"    .long 1b, 3b\n"		\
		".previous\n"			\
		: "=r" (retval), "=e" (x)	\
		: "r" (ptr), "i" (-EFAULT), "0" (0) \
		: "memory", "gr4")

#define __get_user_1(x, ptr, retval)   __get_user_asm((x), (ptr),
(retval), "ldub")
#define __get_user_2(x, ptr, retval)   __get_user_asm((x), (ptr),
(retval), "lduh")
#define __get_user_4(x, ptr, retval)   __get_user_asm((x), (ptr),
(retval), "ld")
#define __get_user_8(x, ptr, retval)   __get_user_asm((x), (ptr),
(retval), "ldd")

In the above definition of the macro __get_user_asm, because the 'ldd'
(load double) instruction of frv core must use the registers with even
number, i specify the constraints "=e" for the output operand %1,
which is a machine-specific constraint, and tells gcc to only allocate
even number registers (such as, gr2, gr4 ...).

But when i compile the programs, gcc allocates the odd register 'GR7'
for the operand %1, therefore, gas exits with errors.

The following is the output information:

frv-elf-gcc -Wp,-MD,kernel/.time.o.d -nostdinc -iwithprefix include
-D__KERNEL__ -Iinclude  -D__KERNEL__ -Iinclude  -Wall
-Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common
-pipe
-fno-builtin -gstabs -fno-omit-frame-pointer -G0 -mcpu=fr400 -mno-pack
-mno-dword -O2 -g -Wdeclaration-after-statement   
-DKBUILD_BASENAME=time -DKBUILD_MODNAME=time -c -o kernel/.tmp_time.o
kernel/time.c
{standard input}: Assembler messages:
{standard input}:871: Error: register number must be even `ldd @(gr8,gr0),gr7'

The source file 'kernel/time.c' refers the macro 'get_user'.

Here is my toolchains version list:

   - binutils-2.15
   - gcc-core-3.4.2

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-10-09  8:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-09 17:57 [help] Is this a frv-elf-gcc bug? zhan rongkai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).