Irix6 long doubles implemented wrong? (27_io/ostream_inserter_arith)

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Tue Jan 28 17:10:00 GMT 2003


 > From: Alexandre Oliva <aoliva@redhat.com>
 > 
 > On Jan 28, 2003, "Kaveh R. Ghazi" <ghazi@caip.rutgers.edu> wrote:
 > 
 > > PS: over here:
 > > http://gcc.gnu.org/ml/gcc/2002-12/msg01310.html
 > > you mentioned something about using the native irix library for some
 > > of the math to speed it up.  What needs to be done there?  Can you
 > > explain it to me (somewhat verbosely? :-)
 > 
 > Have a look at the macro GOFAST_RENAME_LIBCALLS in
 > gcc/config/gofast.h.  gofast is a FP emulation library that uses entry
 > points different from those used by GCC, so GOFAST_RENAME_LIBCALLS
 > arranges for GCC to issue calls using these entry points instead of
 > those it traditionally does.
 > 
 > You assignment :-) is to: (i) find out the name of the functions that
 > IRIX uses for long double floating-point operations


Well I tried man pages, sgi's website and search engines without any
luck.  So instead I tried reverse engineering by compiling a small
program with cc -n32 -S and seeing what I got.  I used this code:

	extern TYPE foo(double a, TYPE b)
	{
	  TYPE x = a OP b;
	  return x;
	}

My knowledge of assembly is limited and I'm certainly no floating
point expert.  But it seems to me that the routines for * / + and -
are named __q_mul, __q_div, __q_add and __q_sub.  There are widening
routines named __q_ext and __q_extd for widening a float and a double
respectively.  Is there any other operation we need to figure out?

Also I'm sure the calling convention needs to be understood to see if
these are drop in replacements for our own, but I'd like some help on
that.  I've included the assembly for TYPE='long double' and OP='*'.
It's pretty easy to follow especially given the helpful comments
inserted by the irix cc compiler.  Is this enough info to proceed?

		Thanks,
		--Kaveh


	.set	noreorder
	.set	noat
	#  /usr/lib32/cmplrs/be::7.30
	#ism	1275524910

	#-----------------------------------------------------------
	# Compiling f2.c (/tmp/ctmB.BAAa5-Hr-)
	#-----------------------------------------------------------

	#-----------------------------------------------------------
	# Options:
	#-----------------------------------------------------------
	#  Target:R10000, ISA:mips4, Pointer Size:32
	#  -O0	(Optimization level)
	#  -g0	(Debug level)
	#  -m1	(Report warnings)
	#-----------------------------------------------------------

	.file	1	"/a/teal/caip5/ghazi/f2.c"

	.section .text, 1, 0x00000006, 4, 16
.text:
	.section .text

	# Program Unit: foo
	.ent	foo
	.globl	foo
foo:	# 0x0
	.dynsym	foo	sto_default
	.frame	$sp, 64, $31
	.mask	0x80000000, -48
	# x = 0
	# lcl_spill_temp_0 = 16
	# lcl_spill_temp_1 = 24
	.loc	1 2 1
 #   1  extern TYPE foo(double a, TYPE b)
 #   2  {
.BB1.foo:	# 0x0
	addiu $sp,$sp,-64             	#  
	sd $gp,24($sp)                	#  lcl_spill_temp_1
	sd $31,16($sp)                	#  lcl_spill_temp_0
	lui $1,%hi(%neg(%gp_rel(foo)))	#  foo
	addiu $1,$1,%lo(%neg(%gp_rel(foo)))	#  foo
	addu $gp,$25,$1               	#  
	sdc1 $f12,32($sp)             	#  a
	sdc1 $f14,48($sp)             	#  b
	sdc1 $f15,56($sp)             	#  b+8
	.loc	1 3 8
 #   3    TYPE x = a OP b;
	ldc1 $f12,32($sp)             	#  a
	lw $25,%call16(__q_extd)($gp) 	#  __q_extd
	jalr $25                      	#  __q_extd
	nop                           	#  
.BB2.foo:	# 0x34
	mov.d $f12,$f0                	#  
	mov.d $f13,$f2                	#  
	ldc1 $f14,48($sp)             	#  b
	ldc1 $f15,56($sp)             	#  b+8
	lw $25,%call16(__q_mul)($gp)  	#  __q_mul
	jalr $25                      	#  __q_mul
	nop                           	#  
.BB3.foo:	# 0x50
	sdc1 $f0,0($sp)               	#  x
	sdc1 $f2,8($sp)               	#  x+8
	.loc	1 4 3
 #   4    return x;
	ldc1 $f0,0($sp)               	#  x
	ldc1 $f2,8($sp)               	#  x+8
	ld $gp,24($sp)                	#  lcl_spill_temp_1
	ld $31,16($sp)                	#  lcl_spill_temp_0
	addiu $sp,$sp,64              	#  
	jr $31                        	#  
	nop                           	#  
	.end	foo
	.section .text
	.align 4
	.gpvalue 30720



More information about the Gcc-patches mailing list