@@ -639,49 +639,54 @@ sub symbInsertInnerUDT _
639639end sub
640640
641641''================================================
642- '' for Linux structure parameters size<=16
642+ '' for Linux structure parameters size<=16 bytes
643643''================================================
644-
645- sub struct_analyze( byval fld as FBSYMBOL ptr, byref part1 as integer , byref part2 as integer , byref limit as integer )
644+ '' if the structure size is less or equal to 16 bytes it could be passed directly in registers according the datatype fields
645+ '' integers and floats could even be mixed using Rxx and Xmm
646+ '' analyzing the 8 low bytes then the 8 high bytes to know if each block contains integer or/and float
647+ '' if at least one integer field all the range is considered as integer
648+ '' if the size is greater than 8 and the result is only KPART1FLOAT or KPART1INTEGER then the structure is totally float or totally integer
649+ '' (the structure contains only an array of simple datatype) and the result is forced to KSTRUCT_XX or KSTRUCT_RR
650+ ''================================================
651+ private sub struct_analyze( byval fld as FBSYMBOL ptr, byref part1 as integer , byref part2 as integer , byref range as integer )
646652
647653 dim as integer lgt=fld->lgt
648654 fld = symbUdtGetFirstField(fld)
649655 while fld
650- if limit= 7 and fld->ofs> 7 then
651- limit+= 8
652- part2= 8
656+ if range=KLOW8BYTES and fld->ofs> 7 then
657+ range = KHIGH8BYTES
658+ part2 = KPART2FLOAT ''default
653659 end if
654660
655661 if typegetclass(fld->typ)=FB_DATACLASS_UDT then
656- struct_analyze(fld->subtype,part1,part2,limit )
662+ struct_analyze(fld->subtype,part1,part2,range )
657663 elseif typegetclass(fld->typ)=FB_DATACLASS_INTEGER then
658- if limit= 7 then
659- part1= 1
664+ if range=KLOW8BYTES then
665+ part1=KPART1INTEGER
660666 else
661- part2= 4
667+ part2=KPART2INTEGER
662668 end if
663669 end if
664670 fld=symbUdtGetNextField(fld)
665671 wend
666672
667673 if lgt> 8 then
668674 ''case array in type eg type udt / array(0 to 1) as integer /end type
669- if part1+part2= 1 then
670- part1= 5
671- elseif part1+part2= 2 then
672- part1= 10
675+ if part1+part2=KPART1INTEGER then
676+ part1=KSTRUCT_RR
677+ elseif part1+part2=KPART1FLOAT then
678+ part1=KSTRUCT_XX
673679 end if
674680 end if
675681
676682end sub
677-
678- private function hGetMagicStructNumber( byval sym as FBSYMBOL ptr ) as integer
683+ function hGetMagicStructNumber( byval sym as FBSYMBOL ptr ) as integer
679684 '' by default floating point for first register
680- dim as integer part1 = 2
681- dim as integer part2 = 0
682- dim as integer limit = 7
685+ dim as integer part1 = KPART1FLOAT
686+ dim as integer part2 = KPARTNOTDEF
687+ dim as integer range = KLOW8BYTES
683688
684- struct_analyze( sym, part1, part2, limit )
689+ struct_analyze( sym, part1, part2, range )
685690
686691 return part1 + part2
687692end function
@@ -695,24 +700,24 @@ private function hGetReturnTypeGas64Linux( byval sym as FBSYMBOL ptr ) as intege
695700
696701 if ( sym->lgt <= typeGetSize( FB_DATATYPE_LONGINT ) * 2 ) then
697702 select case as const hGetMagicStructNumber( sym )
698- case 1 ''only integers in RAX
703+ case KSTRUCT_R ''only integers in RAX
699704 '' don't set retin2regs, it's handled by datatype only
700705 '' sym->udt.retin2regs = FB_STRUCT_R
701706 return FB_DATATYPE_LONGINT
702- case 2 ''only floats in XMM0
707+ case KSTRUCT_X ''only floats in XMM0
703708 '' don't set retin2regs, it's handled by datatype only
704709 '' sym->udt.retin2regs = FB_STRUCT_X
705710 return FB_DATATYPE_DOUBLE
706- case 5 ''only integers in RAX/RDX
711+ case KSTRUCT_RR ''only integers in RAX/RDX
707712 sym->udt.retin2regs = FB_STRUCT_RR
708713 return FB_DATATYPE_STRUCT
709- case 9 ''first part in RAX then in XMMO
714+ case KSTRUCT_RX ''first part in RAX then in XMMO
710715 sym->udt.retin2regs = FB_STRUCT_RX
711716 return FB_DATATYPE_STRUCT
712- case 6 ''first part in XMMO then in RAX
717+ case KSTRUCT_XR ''first part in XMMO then in RAX
713718 sym->udt.retin2regs = FB_STRUCT_XR
714719 return typeAddrOf( FB_DATATYPE_STRUCT )
715- case 10 ''only floats in XMM0/XMM1
720+ case KSTRUCT_XX ''only floats in XMM0/XMM1
716721 sym->udt.retin2regs = FB_STRUCT_XX
717722 return FB_DATATYPE_STRUCT
718723 case else
0 commit comments