Skip to content

Commit

Permalink
Revert "gas64 change : use of IR_OPT_ADDRCISC for enabling optim [reg…
Browse files Browse the repository at this point in the history
…1+reg2*N] as in gas32"

This reverts commit 22ff0bb.
  • Loading branch information
jayrm committed Nov 26, 2023
1 parent e4515f9 commit bada9f0
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 39 deletions.
85 changes: 47 additions & 38 deletions src/compiler/ir-gas64.bas
Expand Up @@ -2048,7 +2048,7 @@ private sub _init( )

irhlInit( )
'' IR_OPT_CPUSELFBOPS disabled, to prevent AST from producing self-ops.
irSetOption(IR_OPT_CPUBOPFLAGS or IR_OPT_MISSINGOPS or IR_OPT_CPUSELFBOPS or IR_OPT_ADDRCISC)
irSetOption(IR_OPT_CPUBOPFLAGS or IR_OPT_MISSINGOPS or IR_OPT_CPUSELFBOPS)' or IR_OPT_ADDRCISC)'

' dtypeName(FB_DATATYPE_INTEGER) = dtypeName(FB_DATATYPE_LONGINT)
'dtypeName(FB_DATATYPE_UINT ) = dtypeName(FB_DATATYPE_ULONGINT)
Expand Down Expand Up @@ -3102,42 +3102,6 @@ end sub
private sub prepare_idx(byval v1 as IRVREG ptr, byref op1 as string, byref op3 as string)

dim as string regtempo

if v1->mult<>0 then
if v1->vidx->sym=0 then
if v1->vidx->reg<>-1 then
regtempo=*regstrq(reg_findreal(v1->vidx->reg))
else
regtempo=*regstrq(reg_findreal(v1->vidx->vidx->reg))
op3="mov "+regtempo+", "+"["+regtempo+"]"
end if
else
regtempo=*reg_tempo()
if symbIsStatic(v1->vidx->sym) Or symbisshared(v1->vidx->sym) then
op3="mov "+regtempo+", "+*symbGetMangledName(v1->vidx->sym)+"[rip]"
else
op3="mov "+regtempo+", "+Str(v1->vidx->ofs)+"[rbp]"
end if
end if

select case as const v1->mult
Case 2,4,8
regtempo=regtempo+"*"+str(v1->mult)
case 3,5,9
regtempo=regtempo+"*"+str(v1->mult-1)+"+"+regtempo
End Select

if v1->sym=0 then
op1=str(v1->ofs)+"["+regtempo+"]"
elseif symbIsStatic(v1->sym) Or symbisshared(v1->sym) then
op1=*symbGetMangledName(v1->sym)+"["+Str(v1->ofs)+"+"+regtempo+"]"
else
op1=Str(v1->ofs)+"[rbp+"+regtempo+"]"
end if

return
end if

'asm_info("prepare_op v1->sym="+str(v1->sym)+" "+str(v1->vidx->sym))
if v1->sym=0 then
''format (ofs= )[datatype] vidx=<reg> /// vidx=<var varname ofs
Expand Down Expand Up @@ -5785,7 +5749,51 @@ private sub hdocall(byval proc as FBSYMBOL ptr,byref pname as string,byref first
''SOURCE
select case v2->typ ''source
case IR_VREGTYPE_IDX
prepare_idx(v2,op1,op3)
if v2->sym=0 then
if v2->vidx->sym=0 then
if v2->vidx->reg<>-1 then
reg2=reg_findreal(v2->vidx->reg)
op1=Str(v2->ofs)+"["+*regstrq(reg2)+"]"
else
''2 levels
reg2=reg_findreal(v2->vidx->vidx->reg)
op3="mov "+*regstrq(reg2)+", "+"["+*regstrq(reg2)+"]"
op1=Str(v2->ofs)+"["+*regstrq(reg2)+"]"
end if
else
regtempo=*reg_tempo()
if symbIsStatic(v2->vidx->sym) Or symbisshared(v2->vidx->sym) then
op3="lea "+regtempo+", "+*symbGetMangledName(v2->vidx->sym)+"[rip+"+Str(v2->vidx->ofs)+"]"
op3+=newline2+"mov "+regtempo+", "+"["+regtempo+"]"+" #NO"
op1=Str(v2->ofs)+"["+regtempo+"]"
else
op3="mov "+regtempo+", "+Str(v2->vidx->ofs)+"[rbp]"
op1=Str(v2->ofs)+"["+regtempo+"]"
end if
end if
else ''format varname ofs= [dt] vidx=<reg> /// vidx=<var varname
regtempo=*reg_tempo()
if symbIsStatic(v2->sym) Or symbisshared(v2->sym) then
op3="lea "+regtempo+", "+*symbGetMangledName(v2->sym)+"[rip+"+Str(v2->ofs)+"]"
else
op3="lea "+regtempo+", "+Str(v2->ofs)+"[rbp]"

end if

if v2->vidx->typ=IR_VREGTYPE_REG then
reg2=reg_findreal(v2->vidx->reg)
op1="["+regtempo+"+"+*regstrq(reg2)+"]"
elseif v2->vidx->typ=IR_VREGTYPE_VAR then
if symbIsStatic(v2->vidx->sym) Or symbisshared(v2->vidx->sym) then
op3+=newline2+"add "+regtempo+", "+*symbGetMangledName(v2->vidx->sym)+"[rip+"+Str(v2->vidx->ofs)+"]"
else
op3+=newline2+"add "+regtempo+","+Str(v2->vidx->ofs)+"[rbp]"
end if
op1="["+regtempo+"]"
else
asm_error("hdocall error with idx")
end if
end if

case IR_VREGTYPE_REG
if typeget(dtype)=FB_DATATYPE_POINTER then dtype=FB_DATATYPE_INTEGER
Expand All @@ -5803,6 +5811,7 @@ private sub hdocall(byval proc as FBSYMBOL ptr,byref pname as string,byref first
asm_error("in hdocall datatype not handled 01 ="+typedumpToStr(dtype,0))
end select


case IR_VREGTYPE_VAR ''format varname ofs1 local/static ofs1 could be zero
if v2->sym<>0 andalso (symbIsStatic(v2->sym) Or symbisshared(v2->sym) ) then ''for gas64
op1=*symbGetMangledName(v2->sym)+"[rip+"+Str(v2->ofs)+"]"
Expand Down
1 change: 0 additions & 1 deletion src/compiler/ir.bas
Expand Up @@ -183,7 +183,6 @@ function irhlAllocVrIdx _

vr->sym = symbol
vr->ofs = ofs
vr->mult = mult
vr->vidx = vidx

function = vr
Expand Down

0 comments on commit bada9f0

Please sign in to comment.