From bada9f077cb488c7013d09f59d2af4f28523af75 Mon Sep 17 00:00:00 2001 From: coderJeff Date: Sun, 26 Nov 2023 10:46:42 -0500 Subject: [PATCH] Revert "gas64 change : use of IR_OPT_ADDRCISC for enabling optim [reg1+reg2*N] as in gas32" This reverts commit 22ff0bb01f1e796537ac052a4997f40157756968. --- src/compiler/ir-gas64.bas | 85 ++++++++++++++++++++++----------------- src/compiler/ir.bas | 1 - 2 files changed, 47 insertions(+), 39 deletions(-) diff --git a/src/compiler/ir-gas64.bas b/src/compiler/ir-gas64.bas index 052de72885..ac08109cc4 100644 --- a/src/compiler/ir-gas64.bas +++ b/src/compiler/ir-gas64.bas @@ -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) @@ -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= /// vidx=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= /// vidx=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 @@ -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)+"]" diff --git a/src/compiler/ir.bas b/src/compiler/ir.bas index 4426d2227a..d084f74332 100644 --- a/src/compiler/ir.bas +++ b/src/compiler/ir.bas @@ -183,7 +183,6 @@ function irhlAllocVrIdx _ vr->sym = symbol vr->ofs = ofs - vr->mult = mult vr->vidx = vidx function = vr