|
@@ -30,38 +30,37 @@ interface
|
|
node,ninl,ncginl;
|
|
node,ninl,ncginl;
|
|
|
|
|
|
type
|
|
type
|
|
-
|
|
|
|
- { trvinlinenode }
|
|
|
|
-
|
|
|
|
- trvinlinenode = class(tcginlinenode)
|
|
|
|
- { first pass override
|
|
|
|
- so that the code generator will actually generate
|
|
|
|
- these nodes.
|
|
|
|
- }
|
|
|
|
- function first_sqrt_real: tnode; override;
|
|
|
|
- function first_abs_real: tnode; override;
|
|
|
|
- function first_sqr_real: tnode; override;
|
|
|
|
- function first_round_real: tnode; override;
|
|
|
|
- function first_trunc_real: tnode; override;
|
|
|
|
-
|
|
|
|
- function first_fma: tnode; override;
|
|
|
|
-
|
|
|
|
- procedure second_sqrt_real; override;
|
|
|
|
- procedure second_abs_real; override;
|
|
|
|
- procedure second_sqr_real; override;
|
|
|
|
- procedure second_round_real; override;
|
|
|
|
- procedure second_trunc_real; override;
|
|
|
|
-
|
|
|
|
- procedure second_fma; override;
|
|
|
|
- protected
|
|
|
|
- procedure load_fpu_location;
|
|
|
|
- end;
|
|
|
|
|
|
+ trvinlinenode = class(tcginlinenode)
|
|
|
|
+ { first pass override
|
|
|
|
+ so that the code generator will actually generate
|
|
|
|
+ these nodes.
|
|
|
|
+ }
|
|
|
|
+ function first_sqrt_real: tnode; override;
|
|
|
|
+ function first_abs_real: tnode; override;
|
|
|
|
+ function first_sqr_real: tnode; override;
|
|
|
|
+ function first_round_real: tnode; override;
|
|
|
|
+ function first_trunc_real: tnode; override;
|
|
|
|
+ function first_fma: tnode; override;
|
|
|
|
+ function first_minmax: tnode; override;
|
|
|
|
+
|
|
|
|
+ procedure second_sqrt_real; override;
|
|
|
|
+ procedure second_abs_real; override;
|
|
|
|
+ procedure second_sqr_real; override;
|
|
|
|
+ procedure second_round_real; override;
|
|
|
|
+ procedure second_trunc_real; override;
|
|
|
|
+
|
|
|
|
+ procedure second_fma; override;
|
|
|
|
+ procedure second_minmax; override;
|
|
|
|
+ protected
|
|
|
|
+ procedure load_fpu_location;
|
|
|
|
+ end;
|
|
|
|
|
|
implementation
|
|
implementation
|
|
|
|
|
|
uses
|
|
uses
|
|
ncal,
|
|
ncal,
|
|
cutils,globals,verbose,globtype,
|
|
cutils,globals,verbose,globtype,
|
|
|
|
+ compinnr,
|
|
aasmtai,aasmdata,aasmcpu,
|
|
aasmtai,aasmdata,aasmcpu,
|
|
symconst,symdef,
|
|
symconst,symdef,
|
|
defutil,
|
|
defutil,
|
|
@@ -159,6 +158,20 @@ implementation
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
+ function trvinlinenode.first_minmax : tnode;
|
|
|
|
+ begin
|
|
|
|
+ if is_single(resultdef) or is_double(resultdef) or is_quad(resultdef) then
|
|
|
|
+ begin
|
|
|
|
+ expectloc:=LOC_FPUREGISTER;
|
|
|
|
+ Result:=nil;
|
|
|
|
+ if needs_check_for_fpu_exceptions then
|
|
|
|
+ Include(current_procinfo.flags,pi_do_call);
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ Result:=inherited first_minmax;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
{ load the FPU into the an fpu register }
|
|
{ load the FPU into the an fpu register }
|
|
procedure trvinlinenode.load_fpu_location;
|
|
procedure trvinlinenode.load_fpu_location;
|
|
begin
|
|
begin
|
|
@@ -376,6 +389,58 @@ implementation
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
+ procedure trvinlinenode.second_minmax;
|
|
|
|
+ var
|
|
|
|
+ paraarray : array[1..2] of tnode;
|
|
|
|
+ i: Integer;
|
|
|
|
+ ai: taicpu;
|
|
|
|
+ opcode: TAsmOp;
|
|
|
|
+ cond: TAsmCond;
|
|
|
|
+ begin
|
|
|
|
+ paraarray[1]:=tcallparanode(tcallparanode(parameters).nextpara).paravalue;
|
|
|
|
+ paraarray[2]:=tcallparanode(parameters).paravalue;
|
|
|
|
+
|
|
|
|
+ for i:=low(paraarray) to high(paraarray) do
|
|
|
|
+ secondpass(paraarray[i]);
|
|
|
|
+
|
|
|
|
+ if is_single(resultdef) or is_double(resultdef) then
|
|
|
|
+ begin
|
|
|
|
+ { no memory operand is allowed }
|
|
|
|
+ for i:=low(paraarray) to high(paraarray) do
|
|
|
|
+ begin
|
|
|
|
+ if not(paraarray[i].location.loc in [LOC_FPUREGISTER,LOC_CFPUREGISTER]) then
|
|
|
|
+ hlcg.location_force_fpureg(current_asmdata.CurrAsmList,paraarray[i].location,
|
|
|
|
+ paraarray[i].resultdef,true);
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ location_reset(location,LOC_FPUREGISTER,paraarray[1].location.size);
|
|
|
|
+ location.register:=cg.getfpuregister(current_asmdata.CurrAsmList,location.size);
|
|
|
|
+
|
|
|
|
+ case inlinenumber of
|
|
|
|
+ in_min_single:
|
|
|
|
+ opcode:=A_FMIN_S;
|
|
|
|
+ in_min_double:
|
|
|
|
+ opcode:=A_FMIN_D;
|
|
|
|
+ in_min_quad:
|
|
|
|
+ opcode:=A_FMAX_Q;
|
|
|
|
+ in_max_single:
|
|
|
|
+ opcode:=A_FMAX_S;
|
|
|
|
+ in_max_double:
|
|
|
|
+ opcode:=A_FMAX_D;
|
|
|
|
+ in_max_quad:
|
|
|
|
+ opcode:=A_FMAX_Q;
|
|
|
|
+ else
|
|
|
|
+ Internalerror(2025010502);
|
|
|
|
+ end;
|
|
|
|
+ current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(opcode,
|
|
|
|
+ location.register,paraarray[1].location.register,paraarray[2].location.register));
|
|
|
|
+
|
|
|
|
+ cg.maybe_check_for_fpu_exception(current_asmdata.CurrAsmList);
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ internalerror(2025010501);
|
|
|
|
+ end;
|
|
|
|
+
|
|
begin
|
|
begin
|
|
cinlinenode:=trvinlinenode;
|
|
cinlinenode:=trvinlinenode;
|
|
end.
|
|
end.
|