mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-05-07 15:12:33 +02:00
+ support for floating point constants
git-svn-id: branches/jvmbackend@18333 -
This commit is contained in:
parent
a1c50d0576
commit
dd2862e25a
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -220,6 +220,7 @@ compiler/jvm/itcpujas.pas svneol=native#text/plain
|
|||||||
compiler/jvm/jvmreg.dat svneol=native#text/plain
|
compiler/jvm/jvmreg.dat svneol=native#text/plain
|
||||||
compiler/jvm/njvmadd.pas svneol=native#text/plain
|
compiler/jvm/njvmadd.pas svneol=native#text/plain
|
||||||
compiler/jvm/njvmcal.pas svneol=native#text/plain
|
compiler/jvm/njvmcal.pas svneol=native#text/plain
|
||||||
|
compiler/jvm/njvmcon.pas svneol=native#text/plain
|
||||||
compiler/jvm/njvmmat.pas svneol=native#text/plain
|
compiler/jvm/njvmmat.pas svneol=native#text/plain
|
||||||
compiler/jvm/rgcpu.pas svneol=native#text/plain
|
compiler/jvm/rgcpu.pas svneol=native#text/plain
|
||||||
compiler/jvm/rjvmcon.inc svneol=native#text/plain
|
compiler/jvm/rjvmcon.inc svneol=native#text/plain
|
||||||
|
@ -32,7 +32,7 @@ implementation
|
|||||||
uses
|
uses
|
||||||
ncgbas,ncgflw,ncgcnv,ncgld,ncgmem,ncgcon,ncgset,
|
ncgbas,ncgflw,ncgcnv,ncgld,ncgmem,ncgcon,ncgset,
|
||||||
ncgadd, ncgcal,ncgmat,ncginl,
|
ncgadd, ncgcal,ncgmat,ncginl,
|
||||||
njvmadd,njvmcal,njvmmat
|
njvmadd,njvmcal,njvmmat,njvmcon
|
||||||
{ ncpuadd,ncpucall,ncpumat,ncpuinln,ncpucnv,ncpuset, }
|
{ ncpuadd,ncpucall,ncpumat,ncpuinln,ncpucnv,ncpuset, }
|
||||||
{ this not really a node }
|
{ this not really a node }
|
||||||
{ rgcpu},tgcpu;
|
{ rgcpu},tgcpu;
|
||||||
|
@ -98,6 +98,8 @@ uses
|
|||||||
|
|
||||||
procedure a_load_loc_stack(list : TAsmList;size: tdef;const loc: tlocation);
|
procedure a_load_loc_stack(list : TAsmList;size: tdef;const loc: tlocation);
|
||||||
|
|
||||||
|
procedure a_loadfpu_const_stack(list : TAsmList;size: tdef;a :double);
|
||||||
|
|
||||||
procedure a_op_stack(list : TAsmList;op: topcg; size: tdef; trunc32: boolean);
|
procedure a_op_stack(list : TAsmList;op: topcg; size: tdef; trunc32: boolean);
|
||||||
procedure a_op_const_stack(list : TAsmList;op: topcg; size: tdef;a : aint);
|
procedure a_op_const_stack(list : TAsmList;op: topcg; size: tdef;a : aint);
|
||||||
procedure a_op_reg_stack(list : TAsmList;op: topcg; size: tdef;reg: tregister);
|
procedure a_op_reg_stack(list : TAsmList;op: topcg; size: tdef;reg: tregister);
|
||||||
@ -151,7 +153,7 @@ uses
|
|||||||
|
|
||||||
const
|
const
|
||||||
opcmp2if: array[topcmp] of tasmop = (A_None,
|
opcmp2if: array[topcmp] of tasmop = (A_None,
|
||||||
a_ifeq,a_ifgt,a_if_icmplt,a_ifge,a_ifle,
|
a_ifeq,a_ifgt,a_iflt,a_ifge,a_ifle,
|
||||||
a_ifne,a_ifle,a_iflt,a_ifge,a_ifgt);
|
a_ifne,a_ifle,a_iflt,a_ifge,a_ifgt);
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -270,6 +272,36 @@ implementation
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure thlcgjvm.a_loadfpu_const_stack(list: TAsmList; size: tdef; a: double);
|
||||||
|
begin
|
||||||
|
case tfloatdef(size).floattype of
|
||||||
|
s32real:
|
||||||
|
begin
|
||||||
|
if a=0.0 then
|
||||||
|
list.concat(taicpu.op_none(a_fconst_0))
|
||||||
|
else if a=1.0 then
|
||||||
|
list.concat(taicpu.op_none(a_fconst_1))
|
||||||
|
else if a=2.0 then
|
||||||
|
list.concat(taicpu.op_none(a_fconst_2))
|
||||||
|
else
|
||||||
|
list.concat(taicpu.op_single(a_ldc,a));
|
||||||
|
incstack(1);
|
||||||
|
end;
|
||||||
|
s64real:
|
||||||
|
begin
|
||||||
|
if a=0.0 then
|
||||||
|
list.concat(taicpu.op_none(a_dconst_0))
|
||||||
|
else if a=1.0 then
|
||||||
|
list.concat(taicpu.op_none(a_dconst_1))
|
||||||
|
else
|
||||||
|
list.concat(taicpu.op_double(a_ldc2_w,a));
|
||||||
|
incstack(2);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
internalerror(2011010501);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure thlcgjvm.a_op_stack(list: TAsmList; op: topcg; size: tdef; trunc32: boolean);
|
procedure thlcgjvm.a_op_stack(list: TAsmList; op: topcg; size: tdef; trunc32: boolean);
|
||||||
var
|
var
|
||||||
cgsize: tcgsize;
|
cgsize: tcgsize;
|
||||||
|
60
compiler/jvm/njvmcon.pas
Normal file
60
compiler/jvm/njvmcon.pas
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
{
|
||||||
|
Copyright (c) 1998-2011 by Florian Klaempfl and Jonas Maebe
|
||||||
|
|
||||||
|
Generate assembler for constant nodes for the JVM
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
|
****************************************************************************
|
||||||
|
}
|
||||||
|
unit njvmcon;
|
||||||
|
|
||||||
|
{$i fpcdefs.inc}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
node,ncon,ncgcon;
|
||||||
|
|
||||||
|
type
|
||||||
|
tjvmrealconstnode = class(tcgrealconstnode)
|
||||||
|
procedure pass_generate_code;override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses
|
||||||
|
globtype,
|
||||||
|
aasmdata,defutil,
|
||||||
|
cgbase,hlcgobj,hlcgcpu,cgutils
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
{*****************************************************************************
|
||||||
|
TJVMREALCONSTNODE
|
||||||
|
*****************************************************************************}
|
||||||
|
|
||||||
|
procedure tjvmrealconstnode.pass_generate_code;
|
||||||
|
begin
|
||||||
|
location_reset(location,LOC_FPUREGISTER,def_cgsize(resultdef));
|
||||||
|
location.register:=hlcg.getfpuregister(current_asmdata.CurrAsmList,resultdef);
|
||||||
|
thlcgjvm(hlcg).a_loadfpu_const_stack(current_asmdata.CurrAsmList,resultdef,value_real);
|
||||||
|
thlcgjvm(hlcg).a_load_stack_reg(current_asmdata.CurrAsmList,resultdef,location.register);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
begin
|
||||||
|
crealconstnode:=tjvmrealconstnode;
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user