summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2021-04-09 20:20:53 +0000
committerflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2021-04-09 20:20:53 +0000
commit538b38de31c30cdcdceb61dcb85724dceda472c8 (patch)
treeeb9b4566d5357d3e51a5bc4e9f83ce96c6a82f7a
parent064f0c686d01864790f071b56668a352ffc12484 (diff)
downloadfpc-538b38de31c30cdcdceb61dcb85724dceda472c8.tar.gz
* PowerPC: initial (and primitive) implemenation of TCpuAsmOptimizer.RegLoadedWithNewValue
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@49153 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r--compiler/powerpc/aoptcpu.pas48
1 files changed, 46 insertions, 2 deletions
diff --git a/compiler/powerpc/aoptcpu.pas b/compiler/powerpc/aoptcpu.pas
index 55ae8b671d..21caf65382 100644
--- a/compiler/powerpc/aoptcpu.pas
+++ b/compiler/powerpc/aoptcpu.pas
@@ -28,10 +28,12 @@ Interface
{$i fpcdefs.inc}
-uses cpubase, aoptobj, aoptcpub, aopt, aasmtai,aasmdata, aasmcpu;
+uses cpubase, cgbase, aoptobj, aoptcpub, aopt, aasmtai,aasmdata, aasmcpu;
Type
TCpuAsmOptimizer = class(TAsmOptimizer)
+ function RegLoadedWithNewValue(reg : tregister; hp : tai) : boolean; override;
+
{ uses the same constructor as TAopObj }
function PeepHoleOptPass1Cpu(var p: tai): boolean; override;
@@ -44,7 +46,49 @@ Type
Implementation
uses
- cutils, verbose, cgbase, cgcpu, cgobj;
+ cutils, verbose, cgcpu, cgobj;
+
+ function TCpuAsmOptimizer.RegLoadedWithNewValue(reg: tregister; hp: tai): boolean;
+ var
+ p: taicpu;
+ begin
+ p := taicpu(hp);
+ Result := false;
+ if not(assigned(hp) and (hp.typ = ait_instruction) and (p.ops > 0)) then
+ exit;
+
+ case p.opcode of
+ A_CMP,
+ A_CMPI,
+ A_CMPL,
+ A_CMPLI:
+ begin
+ result:=reg=NR_CR;
+ exit;
+ end;
+ A_STB,
+ { the register forming the address is modified so no new value is loaded }
+ A_STBU,
+ A_STBUX,
+ A_STBX,
+ A_STH,
+ A_STHBRX,
+ A_STHU,
+ A_STHUX,
+ A_STHX,
+ A_STMW:
+ exit;
+ else
+ ;
+ end;
+ case p.oper[0]^.typ of
+ top_reg:
+ Result := (p.oper[0]^.reg = reg) ;
+ else
+ ;
+ end;
+ end;
+
function TCpuAsmOptimizer.cmpi_mfcr_opt(p, next1, next2: taicpu): boolean;
var