|
@@ -34,11 +34,10 @@ interface
|
|
function pass_typecheck:tnode;override;
|
|
function pass_typecheck:tnode;override;
|
|
function simplify(forinline : boolean) : tnode;override;
|
|
function simplify(forinline : boolean) : tnode;override;
|
|
protected
|
|
protected
|
|
-{$ifndef cpu64bitalu}
|
|
|
|
{ override the following if you want to implement }
|
|
{ override the following if you want to implement }
|
|
{ parts explicitely in the code generator (JM) }
|
|
{ parts explicitely in the code generator (JM) }
|
|
|
|
+ function use_moddiv64bitint_helper: boolean; virtual;
|
|
function first_moddiv64bitint: tnode; virtual;
|
|
function first_moddiv64bitint: tnode; virtual;
|
|
-{$endif not cpu64bitalu}
|
|
|
|
function firstoptimize: tnode; virtual;
|
|
function firstoptimize: tnode; virtual;
|
|
function first_moddivint: tnode; virtual;
|
|
function first_moddivint: tnode; virtual;
|
|
end;
|
|
end;
|
|
@@ -150,6 +149,22 @@ implementation
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
+ function tmoddivnode.use_moddiv64bitint_helper: boolean;
|
|
|
|
+ begin
|
|
|
|
+ { not with an ifdef around the call to this routine, because e.g. the
|
|
|
|
+ Java VM has a signed 64 bit division opcode, but not an unsigned
|
|
|
|
+ one }
|
|
|
|
+{$ifdef cpu64bitalu}
|
|
|
|
+ result:=false;
|
|
|
|
+{$else cpu64bitalu}
|
|
|
|
+ result:=
|
|
|
|
+ (left.resultdef.typ=orddef) and
|
|
|
|
+ (right.resultdef.typ=orddef) and
|
|
|
|
+ (is_64bitint(left.resultdef) or is_64bitint(right.resultdef));
|
|
|
|
+{$endif cpu64bitaly}
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
function tmoddivnode.pass_typecheck:tnode;
|
|
function tmoddivnode.pass_typecheck:tnode;
|
|
var
|
|
var
|
|
hp,t : tnode;
|
|
hp,t : tnode;
|
|
@@ -322,7 +337,6 @@ implementation
|
|
{$endif cpuneedsdiv32helper}
|
|
{$endif cpuneedsdiv32helper}
|
|
|
|
|
|
|
|
|
|
-{$ifndef cpu64bitalu}
|
|
|
|
function tmoddivnode.first_moddiv64bitint: tnode;
|
|
function tmoddivnode.first_moddiv64bitint: tnode;
|
|
var
|
|
var
|
|
procname: string[31];
|
|
procname: string[31];
|
|
@@ -355,7 +369,6 @@ implementation
|
|
right := nil;
|
|
right := nil;
|
|
firstpass(result);
|
|
firstpass(result);
|
|
end;
|
|
end;
|
|
-{$endif not cpu64bitalu}
|
|
|
|
|
|
|
|
|
|
|
|
function tmoddivnode.firstoptimize: tnode;
|
|
function tmoddivnode.firstoptimize: tnode;
|
|
@@ -429,11 +442,8 @@ implementation
|
|
if assigned(result) then
|
|
if assigned(result) then
|
|
exit;
|
|
exit;
|
|
|
|
|
|
-{$ifndef cpu64bitalu}
|
|
|
|
{ 64bit }
|
|
{ 64bit }
|
|
- if (left.resultdef.typ=orddef) and
|
|
|
|
- (right.resultdef.typ=orddef) and
|
|
|
|
- (is_64bitint(left.resultdef) or is_64bitint(right.resultdef)) then
|
|
|
|
|
|
+ if use_moddiv64bitint_helper then
|
|
begin
|
|
begin
|
|
result := first_moddiv64bitint;
|
|
result := first_moddiv64bitint;
|
|
if assigned(result) then
|
|
if assigned(result) then
|
|
@@ -441,7 +451,6 @@ implementation
|
|
expectloc:=LOC_REGISTER;
|
|
expectloc:=LOC_REGISTER;
|
|
end
|
|
end
|
|
else
|
|
else
|
|
-{$endif not cpu64bitalu}
|
|
|
|
begin
|
|
begin
|
|
result := first_moddivint;
|
|
result := first_moddivint;
|
|
if assigned(result) then
|
|
if assigned(result) then
|