Skip to content

Commit ccd5476

Browse files
committed
travis: disable some tests for faster build testing
(cherry picked from commit 5267093) gas64: fix check (cherry picked from commit 350fd28) gas64: fix internal check - returning structure values in registers true only if type is non-pointer struct (cherry picked from commit 4d177a8) Merge pull request #260 from jayrm/fbc-gas64 change gas64 internal checks for structs returned in registers on linux (cherry picked from commit fbedc0a) Revert "travis: disable some tests for faster build testing" This reverts commit 5267093. (cherry picked from commit 24d25c6) Revert "gas64: fix internal check" This reverts commit 4d177a8. Revert "gas64: fix check" This reverts commit 350fd28. (cherry picked from commit 83217e8) gas64: check if structure is returned in 2 registers - add hIsStructIn2Regs() internal function - add comments in hGetReturnTypeGas64Linux() (cherry picked from commit e973a9f) gas64: invert test for SSE 41 feature flag (cherry picked from commit c15753f) Merge pull request #261 from jayrm/fbc-gas64 gas64: check if structure is returned in 2 registers for linux (cherry picked from commit 91ff104)
1 parent c9c6041 commit ccd5476

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

src/compiler/ir-gas64.bas

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4418,7 +4418,7 @@ private sub _emitconvert( byval v1 as IRVREG ptr, byval v2 as IRVREG ptr )
44184418
ctx.roundfloat=true
44194419
asm_code("test DWORD PTR $sse41[rip], 0")
44204420
lname1 = *symbUniqueLabel( )
4421-
asm_code("jne "+lname1)
4421+
asm_code("je "+lname1)
44224422
asm_code("roundsd xmm0,xmm0,4") ''nearbyintf double
44234423
lname2 = *symbUniqueLabel( )
44244424
asm_code("jmp "+lname2)
@@ -4461,7 +4461,7 @@ private sub _emitconvert( byval v1 as IRVREG ptr, byval v2 as IRVREG ptr )
44614461
ctx.roundfloat=true
44624462
asm_code("test DWORD PTR $sse41[rip], 0")
44634463
lname1 = *symbUniqueLabel( )
4464-
asm_code("jne "+lname1)
4464+
asm_code("je "+lname1)
44654465
asm_code("roundsd xmm0,xmm0,4") ''nearbyintf double
44664466
asm_code("cvttsd2si rax, xmm0")
44674467
lname2 = *symbUniqueLabel( )
@@ -4499,7 +4499,7 @@ private sub _emitconvert( byval v1 as IRVREG ptr, byval v2 as IRVREG ptr )
44994499
ctx.roundfloat=true
45004500
asm_code("test DWORD PTR $sse41[rip], 0")
45014501
lname1 = *symbUniqueLabel( )
4502-
asm_code("jne "+lname1)
4502+
asm_code("je "+lname1)
45034503
asm_code("roundss xmm0,xmm0,4")
45044504
lname2 = *symbUniqueLabel( )
45054505
asm_code("jmp "+lname2)
@@ -4542,7 +4542,7 @@ private sub _emitconvert( byval v1 as IRVREG ptr, byval v2 as IRVREG ptr )
45424542
ctx.roundfloat=true
45434543
asm_code("test DWORD PTR $sse41[rip], 0")
45444544
lname1 = *symbUniqueLabel( )
4545-
asm_code("jne "+lname1)
4545+
asm_code("je "+lname1)
45464546
asm_code("roundss xmm0,xmm0,4") ''nearbyintf single
45474547
asm_code("cvttss2si rax, xmm0")
45484548
lname2 = *symbUniqueLabel( )
@@ -4742,6 +4742,21 @@ private sub emitStoreStruct(byval v1 as IRVREG ptr, byval v2 as IRVREG ptr,byref
47424742
asm_code("mov [rax], rdx")
47434743
end select
47444744
end sub
4745+
4746+
private function hIsStructIn2Regs( byval v1 as IRVREG ptr ) as integer
4747+
'' test if the VREG is for a struct that would be returned in 2 registers
4748+
'' sym->udt.retin2regs is set by symbStructEnd() and the udt should become
4749+
'' the subtype of the vreg.
4750+
4751+
'' only if the type is a UDT
4752+
if( typeGetDtAndPtrOnly( v1->dtype ) = FB_DATATYPE_STRUCT ) then
4753+
4754+
'' only if the UDT was analyzed to return in 2 registers
4755+
return ( v1->subtype->udt.retin2regs <> FB_STRUCT_NONE )
4756+
end if
4757+
return FALSE
4758+
end function
4759+
47454760
private sub _emitstore( byval v1 as IRVREG ptr, byval v2 as IRVREG ptr )
47464761

47474762
dim as string op1,op2,op3,op4,prefix,code1,code2,regtempo
@@ -4821,10 +4836,10 @@ private sub _emitstore( byval v1 as IRVREG ptr, byval v2 as IRVREG ptr )
48214836
asm_error("store 01")
48224837
end select
48234838

4824-
if v2->subtype<>0 andalso typeIsPtr( v2->dtype )=false andalso v2->subtype->udt.retin2regs<>FB_STRUCT_NONE then
4825-
'' for Linux structures can be returned in 2 registers so needs a special handling
4839+
if( hIsStructIn2Regs( v2 ) ) then
4840+
'' for Linux structures can be returned in 2 registers so needs a special handling
48264841
emitStoreStruct(v1,v2,op1,op3)
4827-
exit sub
4842+
exit sub
48284843
end if
48294844

48304845
''SOURCE
@@ -5090,7 +5105,7 @@ private sub _emitloadres(byval v1 as IRVREG ptr,byval vr as IRVREG Ptr)
50905105
asm_error("in loadres typ not handled")
50915106
end select
50925107

5093-
if v1->sym<>0 andalso typeIsPtr( v1->dtype )=false andalso v1->sym->subtype<>0 andalso v1->sym->subtype->udt.retin2regs<>FB_STRUCT_NONE then
5108+
if( hIsStructIn2Regs( v1 ) ) then
50945109
''Structure returned in 2 registers, linux only
50955110
''assuming in this case fb$result is always defined like xxx[rbp]
50965111
if v1->typ<>IR_VREGTYPE_VAR orelse ( symbIsStatic(v1->sym) Or symbisshared(v1->sym) )then
@@ -5852,7 +5867,8 @@ private sub hdocall(byval proc as FBSYMBOL ptr,byref pname as string,byref first
58525867
ctx.proccalling=false
58535868

58545869
if( vr ) then ''return value
5855-
if vr->subtype<>0 andalso typeIsPtr( vr->dtype )=false andalso vr->subtype->udt.retin2regs<>FB_STRUCT_NONE then
5870+
5871+
if( hIsStructIn2Regs( vr ) ) then
58565872
''Structure returned in 2 registers
58575873
vr->typ=IR_VREGTYPE_VAR ''for use when argument
58585874
ctx.stk+=typeGetSize( FB_DATATYPE_LONGINT )*2 ''reserving 16 bytes

src/compiler/symb-struct.bas

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ sub struct_analyze(byval fld as FBSYMBOL ptr,byref part1 as integer,byref part2
670670

671671
end sub
672672

673-
private function hGetReturnTypeGas64Linux( byval sym as FBSYMBOL ptr ) as FB_STRUCT_INREG
673+
private function hGetReturnTypeGas64Linux( byval sym as FBSYMBOL ptr ) as integer
674674

675675
assert( env.clopt.backend = FB_BACKEND_GAS64 )
676676
assert( env.clopt.target = FB_COMPTARGET_LINUX )
@@ -688,10 +688,12 @@ private function hGetReturnTypeGas64Linux( byval sym as FBSYMBOL ptr ) as FB_STR
688688

689689
select case as const part1+part2
690690
case 1 ''only integers in RAX
691-
'' return FB_STRUCT_R
691+
'' don't set retin2regs, it's handled by datatype only
692+
'' sym->udt.retin2regs = FB_STRUCT_R
692693
return FB_DATATYPE_LONGINT
693694
case 2 ''only floats in XMM0
694-
'' return FB_STRUCT_X
695+
'' don't set retin2regs, it's handled by datatype only
696+
'' sym->udt.retin2regs = FB_STRUCT_X
695697
return FB_DATATYPE_DOUBLE
696698
case 5 ''only integers in RAX/RDX
697699
sym->udt.retin2regs = FB_STRUCT_RR

0 commit comments

Comments
 (0)