help on soft-float
Liu Hongming
liuhm@fudan.edu.cn
Mon Dec 22 09:50:00 GMT 2003
Hi,
my problem is the cross compiler could not support
soft float.Since my cpu doesnt have fp,so I need the
soft-float emulation.I have written a test program:
/*
* mygcc.c
* Test Program
*/
double x,y,z;
int
main(int argc, char *argv[])
{
x=128;
y=234;
z=x+y;
return 0;
}
then:
gcc -msoft-float -fomit-frame-pointer -G 0 -g -drx -o mygcc mygcc.c
the RTL insn list are:
/**********************************************/
;; Function main
(note 1 0 2 ("mygcc.c") 12)
(note 2 1 4 "" NOTE_INSN_DELETED)
(insn 4 2 6 (set (mem/f:SI (reg:SI 76) 0)
(reg:SI 4 a0)) -1 (nil)
(nil))
(insn 6 4 7 (set (mem/f:SI (plus:SI (reg:SI 76)
(const_int 4 [0x4])) 0)
(reg:SI 5 a1)) -1 (nil)
(nil))
(note 7 6 8 "" NOTE_INSN_FUNCTION_BEG)
(note 8 7 9 "" NOTE_INSN_DELETED)
(note 9 8 10 ("mygcc.c") 13)
(note 10 9 12 "" NOTE_INSN_DELETED)
(insn 12 10 14 (set (reg:DF 81)
(const_double:DF (const_int 0 [0x0]) 0 [0x0] 1080033280 [0x40600000] [128])) -1 (nil)
(expr_list:REG_EQUAL (const_double:DF (const_int 0 [0x0]) 0 [0x0] 1080033280 [0x40600000] [128])
(nil)))
(insn 14 12 15 (set (mem/f:DF (symbol_ref:SI ("x")) 0)
(reg:DF 81)) -1 (nil)
(nil))
(note 15 14 17 ("mygcc.c") 14)
(insn 17 15 19 (set (reg:DF 82)
(const_double:DF (const_int 0 [0x0]) 0 [0x0] 1080901632 [0x406d4000] [234])) -1 (nil)
(expr_list:REG_EQUAL (const_double:DF (const_int 0 [0x0]) 0 [0x0] 1080901632 [0x406d4000] [234])
(nil)))
(insn 19 17 20 (set (mem/f:DF (symbol_ref:SI ("y")) 0)
(reg:DF 82)) -1 (nil)
(nil))
(note 20 19 22 ("mygcc.c") 15)
(insn 22 20 24 (set (reg:DF 4 a0)
(mem/f:DF (symbol_ref:SI ("x")) 0)) -1 (nil)
(insn_list:REG_LIBCALL 28 (nil)))
(insn 24 22 26 (set (reg:DF 6 a2)
(mem/f:DF (symbol_ref:SI ("y")) 0)) -1 (nil)
(nil))
(call_insn/u 26 24 28 (parallel[
(set (reg:DF 2 v0)
(call (mem:SI (symbol_ref:SI ("dpadd")) 0)
(const_int 16 [0x10])))
(clobber (reg:SI 31 ra))
] ) -1 (nil)
(expr_list:REG_EH_REGION (const_int -1 [0xffffffff])
(nil))
(expr_list (use (reg:DF 6 a2))
(expr_list (use (reg:DF 4 a0))
(nil))))
(insn 28 26 30 (set (reg:DF 83)
(reg:DF 2 v0)) -1 (nil)
(insn_list:REG_RETVAL 22 (expr_list:REG_EQUAL (plus:DF (mem/f:DF (symbol_ref:SI ("x")) 0)
(mem/f:DF (symbol_ref:SI ("y")) 0))
(nil))))
(insn 30 28 31 (set (mem/f:DF (symbol_ref:SI ("z")) 0)
(reg:DF 83)) -1 (nil)
(nil))
(note 31 30 33 ("mygcc.c") 16)
(insn 33 31 34 (set (reg/i:SI 2 v0)
(const_int 0 [0x0])) -1 (nil)
(nil))
(insn 34 33 35 (use (reg/i:SI 2 v0)) -1 (nil)
(nil))
(jump_insn 35 34 36 (set (pc)
(label_ref 40)) -1 (nil)
(nil))
(barrier 36 35 37)
(note 37 36 38 ("mygcc.c") 17)
(note 38 37 39 "" NOTE_INSN_FUNCTION_END)
(note 39 38 40 ("mygcc.c") 17)
(code_label 40 39 0 2 "" [num uses: 0])
/************************************************/
then:
gcc -msoft-float -fomit-frame-pointer -G 0 -g -o mygcc mygcc.c
I use gdb to debug mygcc,I found that z didnt be assigned the
correct value.so I disassembled mygcc,the assembly code is:
int
main(int argc, char *argv[])
{
40080c: afa40020 sw $a0,32($sp)
400810: afa50024 sw $a1,36($sp)
x=128;
400814: 3c024060 lui $v0,0x4060
400818: 00001821 move $v1,$zero
40081c: 8f81805c lw $at,-32676($gp)
400820: 00000000 nop
400824: ac220000 sw $v0,0($at)
400828: 8f81805c lw $at,-32676($gp)
40082c: 00000000 nop
400830: ac230004 sw $v1,4($at)
y=234;
400834: 8f818018 lw $at,-32744($gp)
400838: 00000000 nop
40083c: 8c2230d0 lw $v0,12496($at)
400840: 8c2330d4 lw $v1,12500($at)
400844: 8f818034 lw $at,-32716($gp)
400848: 00000000 nop
40084c: ac220000 sw $v0,0($at)
400850: 8f818034 lw $at,-32716($gp)
400854: 00000000 nop
400858: ac230004 sw $v1,4($at)
z=x+y;
40085c: 8f84805c lw $a0,-32676($gp)
400860: 00000000 nop
400864: 8c840000 lw $a0,0($a0)
400868: 8f85805c lw $a1,-32676($gp)
40086c: 00000000 nop
400870: 8ca50004 lw $a1,4($a1)
400874: 8f868034 lw $a2,-32716($gp)
400878: 00000000 nop
40087c: 8cc60000 lw $a2,0($a2)
400880: 8f878034 lw $a3,-32716($gp)
400884: 00000000 nop
400888: 8ce70004 lw $a3,4($a3)
40088c: 8f998040 lw $t9,-32704($gp)
400890: 00000000 nop
400894: 0320f809 jalr $t9
400898: 00000000 nop
40089c: 8fbc0010 lw $gp,16($sp)
4008a0: 00000000 nop
4008a4: 8f818044 lw $at,-32700($gp)
4008a8: 00000000 nop
4008ac: ac220000 sw $v0,0($at)
4008b0: 8f818044 lw $at,-32700($gp)
4008b4: 00000000 nop
4008b8: ac230004 sw $v1,4($at)
return 0;
4008bc: 00001021 move $v0,$zero
4008c0: 10000001 b 4008c8 <main+0xd8>
4008c4: 00000000 nop
}
My question is: 1) Is the RTL insn list correct?
if it is,then what makes the assembly wrong?
if it is not,how could I fix it?
Since I am a newbie on GCC,I only know a little about gcc's
behavior.
Best Regards,
Alan
>Liu Hongming wrote:
>> I am using gcc cross-compiler for mips bought from some vendors,
>> and it doesnt support -msoft-float option(I dont know why it is a difficulty).
>
>It isn't clear what your problem is. What kind of error do you get when
>you try to use the -msoft-float option? Is this a missing multilib problem?
>
>If you have sources for your cross-compiler, it shouldn't be too hard to
>enable soft-float multilibs and rebuild it. You need to define the
>MULTILIB_* Makefile variables in the target t-* file. See for instance
>the example in the gcc/config/mips/t-elf file.
>--
>Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com
More information about the Gcc
mailing list