summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/aarch64/aasmcpu.pas22
-rw-r--r--compiler/aasmtai.pas306
-rw-r--r--compiler/aggas.pas178
-rw-r--r--compiler/agjasmin.pas12
-rw-r--r--compiler/arm/aasmcpu.pas22
-rw-r--r--compiler/arm/narmcon.pas36
-rw-r--r--compiler/assemble.pas178
-rw-r--r--compiler/dbgdwarf.pas6
-rw-r--r--compiler/llvm/agllvm.pas60
-rw-r--r--compiler/mips/ncpucnv.pas2
-rw-r--r--compiler/ncgcon.pas36
-rw-r--r--compiler/ngtcon.pas16
-rw-r--r--compiler/powerpc/agppcmpw.pas9
-rw-r--r--compiler/psystem.pas5
-rw-r--r--compiler/rautils.pas14
-rw-r--r--compiler/x86/agx86int.pas29
-rw-r--r--compiler/x86/agx86nsm.pas173
17 files changed, 423 insertions, 681 deletions
diff --git a/compiler/aarch64/aasmcpu.pas b/compiler/aarch64/aasmcpu.pas
index 8624744df8..54251eb8ce 100644
--- a/compiler/aarch64/aasmcpu.pas
+++ b/compiler/aarch64/aasmcpu.pas
@@ -673,14 +673,9 @@ implementation
if (tai_const(hp).consttype=aitconst_64bit) then
inc(extradataoffset);
end;
- ait_comp_64bit,
- ait_real_64bit:
+ ait_realconst:
begin
- inc(extradataoffset);
- end;
- ait_real_80bit:
- begin
- inc(extradataoffset,2);
+ inc(extradataoffset,((tai_realconst(hp).savesize-4+3) div 4));
end;
end;
if (hp.typ=ait_const) then
@@ -734,18 +729,9 @@ implementation
if (tai_const(curtai).consttype=aitconst_64bit) then
inc(curinspos);
end;
- ait_real_32bit:
- begin
- inc(curinspos);
- end;
- ait_comp_64bit,
- ait_real_64bit:
- begin
- inc(curinspos,2);
- end;
- ait_real_80bit:
+ ait_realconst:
begin
- inc(curinspos,3);
+ inc(curinspos,(tai_realconst(hp).savesize+3) div 4);
end;
end;
{ special case for case jump tables }
diff --git a/compiler/aasmtai.pas b/compiler/aasmtai.pas
index 4b17815662..b8ebcc2481 100644
--- a/compiler/aasmtai.pas
+++ b/compiler/aasmtai.pas
@@ -64,11 +64,7 @@ interface
ait_directive,
ait_label,
ait_const,
- ait_real_32bit,
- ait_real_64bit,
- ait_real_80bit,
- ait_comp_64bit,
- ait_real_128bit,
+ ait_realconst,
ait_stab,
ait_force_line,
ait_function_name,
@@ -152,6 +148,14 @@ interface
aitconst_gotoff_symbol
);
+ tairealconsttype = (
+ aitrealconst_s32bit,
+ aitrealconst_s64bit,
+ aitrealconst_s80bit,
+ aitrealconst_s128bit,
+ aitrealconst_s64comp
+ );
+
const
{$if defined(cpu64bitaddr)}
aitconst_ptr = aitconst_64bit;
@@ -187,11 +191,7 @@ interface
'symbol_directive',
'label',
'const',
- 'real_32bit',
- 'real_64bit',
- 'real_80bit',
- 'comp_64bit',
- 'real_128bit',
+ 'realconst',
'stab',
'force_line',
'function_name',
@@ -351,7 +351,7 @@ interface
ait_thumb_set,
{$endif arm}
ait_set,ait_weak,
- ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit,ait_real_128bit,
+ ait_realconst,
ait_symbol,
{$ifdef JVM}
ait_jvar, ait_jcatch,
@@ -626,57 +626,34 @@ interface
function size:longint;
end;
- { Generates a single float (32 bit real) }
- tai_real_32bit = class(tai)
- value : ts32real;
- constructor Create(_value : ts32real);
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- end;
-
+ { floating point const }
tformatoptions = (fo_none,fo_hiloswapped);
-
- { Generates a double float (64 bit real) }
- tai_real_64bit = class(tai)
- value : ts64real;
+ tai_realconst = class(tai)
+ realtyp: tairealconsttype;
+ savesize: byte;
+ value: record
+ case tairealconsttype of
+ aitrealconst_s32bit: (s32val: ts32real);
+ aitrealconst_s64bit: (s64val: ts64real);
+ aitrealconst_s80bit: (s80val: ts80real);
+ aitrealconst_s128bit: (s128val: ts128real);
+ aitrealconst_s64comp: (s64compval: ts64comp);
+ end;
{$ifdef ARM}
formatoptions : tformatoptions;
- constructor Create_hiloswapped(_value : ts64real);
{$endif ARM}
- constructor Create(_value : ts64real);
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- end;
-
-
- { Generates an extended float (80 bit real) }
- tai_real_80bit = class(tai)
- value : ts80real;
- savesize : byte;
- constructor Create(_value : ts80real; _savesize: byte);
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- end;
-
-
- { Generates an float128 (128 bit real) }
- tai_real_128bit = class(tai)
- value : ts128real;
- constructor Create(_value : ts128real);
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- end;
-
- { Generates a comp int (integer over 64 bits)
-
- This is Intel 80x86 specific, and is not
- really supported on other processors.
- }
- tai_comp_64bit = class(tai)
- value : ts64comp;
- constructor Create(_value : ts64comp);
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
+ constructor create_s32real(val: ts32real);
+ constructor create_s64real(val: ts64real);
+{$ifdef ARM}
+ constructor create_s64real_hiloswapped(val : ts64real);
+{$endif ARM}
+ constructor create_s80real(val: ts80real; _savesize: byte);
+ constructor create_s128real(val: ts128real);
+ constructor create_s64compreal(val: ts64comp);
+ constructor ppuload(t: taitype;ppufile: tcompilerppufile); override;
+ procedure ppuwrite(ppufile: tcompilerppufile); override;
+ function getcopy:tlinkedlistitem;override;
+ function datasize: word;
end;
{ tai_stab }
@@ -1890,156 +1867,151 @@ implementation
{****************************************************************************
- TAI_real_32bit
+ TAI_realconst
****************************************************************************}
- constructor tai_real_32bit.Create(_value : ts32real);
-
- begin
- inherited Create;
- typ:=ait_real_32bit;
- value:=_value;
- end;
-
- constructor tai_real_32bit.ppuload(t:taitype;ppufile:tcompilerppufile);
+ constructor tai_realconst.create_s32real(val: ts32real);
begin
- inherited ppuload(t,ppufile);
- value:=ppufile.getreal;
- end;
-
-
- procedure tai_real_32bit.ppuwrite(ppufile:tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- ppufile.putreal(value);
+ inherited create;
+ typ:=ait_realconst;
+ realtyp:=aitrealconst_s32bit;
+ savesize:=4;
+ value.s32val:=val;
end;
-{****************************************************************************
- TAI_real_64bit
- ****************************************************************************}
-
- constructor tai_real_64bit.Create(_value : ts64real);
-
+ constructor tai_realconst.create_s64real(val: ts64real);
begin
- inherited Create;
- typ:=ait_real_64bit;
- value:=_value;
+ inherited create;
+ typ:=ait_realconst;
+ realtyp:=aitrealconst_s64bit;
+ savesize:=8;
+ value.s64val:=val;
end;
-
{$ifdef ARM}
- constructor tai_real_64bit.Create_hiloswapped(_value : ts64real);
-
+ constructor tai_realconst.create_s64real_hiloswapped(val : ts64real);
begin
- inherited Create;
- typ:=ait_real_64bit;
- value:=_value;
- formatoptions:=fo_hiloswapped;
- end;
-{$endif ARM}
-
- constructor tai_real_64bit.ppuload(t:taitype;ppufile:tcompilerppufile);
- begin
- inherited ppuload(t,ppufile);
- value:=ppufile.getreal;
-{$ifdef ARM}
- formatoptions:=tformatoptions(ppufile.getbyte);
-{$endif ARM}
+ inherited create;
+ typ:=ait_realconst;
+ realtyp:=aitrealconst_s64bit;
+ value.s64val:=val;
+ savesize:=8;
+ formatoptions:=fo_hiloswapped;
end;
-
- procedure tai_real_64bit.ppuwrite(ppufile:tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- ppufile.putreal(value);
-{$ifdef ARM}
- ppufile.putbyte(byte(formatoptions));
{$endif ARM}
- end;
-
-
-{****************************************************************************
- TAI_real_80bit
- ****************************************************************************}
-
- constructor tai_real_80bit.Create(_value : ts80real; _savesize: byte);
-
- begin
- inherited Create;
- typ:=ait_real_80bit;
- value:=_value;
- savesize:=_savesize;
- end;
-
- constructor tai_real_80bit.ppuload(t:taitype;ppufile:tcompilerppufile);
+ constructor tai_realconst.create_s80real(val: ts80real; _savesize: byte);
begin
- inherited ppuload(t,ppufile);
- value:=ppufile.getreal;
- savesize:=ppufile.getbyte;
+ inherited create;
+ typ:=ait_realconst;
+ realtyp:=aitrealconst_s80bit;
+ savesize:=_savesize;
+ value.s80val:=val;
end;
- procedure tai_real_80bit.ppuwrite(ppufile:tcompilerppufile);
+ constructor tai_realconst.create_s128real(val: ts128real);
begin
- inherited ppuwrite(ppufile);
- ppufile.putreal(value);
- ppufile.putbyte(savesize);
+ inherited create;
+ typ:=ait_realconst;
+ realtyp:=aitrealconst_s128bit;
+ savesize:=16;
+ value.s128val:=val;
end;
-{****************************************************************************
- TAI_real_80bit
- ****************************************************************************}
-
- constructor tai_real_128bit.Create(_value : ts128real);
-
+ constructor tai_realconst.create_s64compreal(val: ts64comp);
begin
- inherited Create;
- typ:=ait_real_128bit;
- value:=_value;
+ inherited create;
+ typ:=ait_realconst;
+ realtyp:=aitrealconst_s64comp;
+ savesize:=8;
+ value.s64compval:=val;
end;
- constructor tai_real_128bit.ppuload(t:taitype;ppufile:tcompilerppufile);
+ constructor tai_realconst.ppuload(t: taitype; ppufile: tcompilerppufile);
begin
- inherited ppuload(t,ppufile);
- value:=ppufile.getreal;
+ inherited;
+ realtyp:=tairealconsttype(ppufile.getbyte);
+{$ifdef ARM}
+ formatoptions:=tformatoptions(ppufile.getbyte);
+{$endif ARM}
+ case realtyp of
+ aitrealconst_s32bit:
+ value.s32val:=ppufile.getreal;
+ aitrealconst_s64bit:
+ value.s64val:=ppufile.getreal;
+ aitrealconst_s80bit:
+ value.s80val:=ppufile.getreal;
+ aitrealconst_s128bit:
+ value.s128val:=ppufile.getreal;
+ aitrealconst_s64comp:
+ value.s64compval:=comp(ppufile.getint64);
+ else
+ internalerror(2014050602);
+ end;
end;
- procedure tai_real_128bit.ppuwrite(ppufile:tcompilerppufile);
+ procedure tai_realconst.ppuwrite(ppufile: tcompilerppufile);
+ var
+ c: comp;
begin
inherited ppuwrite(ppufile);
- ppufile.putreal(value);
- end;
-
-
-{****************************************************************************
- Tai_comp_64bit
- ****************************************************************************}
-
- constructor tai_comp_64bit.Create(_value : ts64comp);
-
- begin
- inherited Create;
- typ:=ait_comp_64bit;
- value:=_value;
+ ppufile.putbyte(byte(realtyp));
+{$ifdef ARM}
+ ppufile.putbyte(byte(formatoptions));
+{$endif ARM}
+ case realtyp of
+ aitrealconst_s32bit:
+ ppufile.putreal(value.s32val);
+ aitrealconst_s64bit:
+ ppufile.putreal(value.s64val);
+ aitrealconst_s80bit:
+ ppufile.putreal(value.s80val);
+ aitrealconst_s128bit:
+ ppufile.putreal(value.s128val);
+ aitrealconst_s64comp:
+ begin
+ c:=comp(value.s64compval);
+ ppufile.putint64(int64(c));
+ end
+ else
+ internalerror(2014050601);
+ end;
end;
- constructor tai_comp_64bit.ppuload(t:taitype;ppufile:tcompilerppufile);
+ function tai_realconst.getcopy: tlinkedlistitem;
begin
- inherited ppuload(t,ppufile);
- ppufile.putdata(value,sizeof(value));
+ result:=inherited getcopy;
+ tai_realconst(result).value:=value;
+ tai_realconst(result).realtyp:=realtyp;
+ tai_realconst(result).savesize:=savesize;
+{$ifdef ARM}
+ tai_realconst(result).formatoptions:=formatoptions;
+{$endif ARM}
end;
- procedure tai_comp_64bit.ppuwrite(ppufile:tcompilerppufile);
+ function tai_realconst.datasize: word;
begin
- inherited ppuwrite(ppufile);
- ppufile.getdata(value,sizeof(value));
+ case realtyp of
+ aitrealconst_s32bit:
+ result:=4;
+ aitrealconst_s64bit,
+ aitrealconst_s64comp:
+ result:=8;
+ aitrealconst_s80bit:
+ result:=10;
+ aitrealconst_s128bit:
+ result:=16;
+ else
+ internalerror(2014050603);
+ end;
end;
diff --git a/compiler/aggas.pas b/compiler/aggas.pas
index de41d75c24..7bd1d45b99 100644
--- a/compiler/aggas.pas
+++ b/compiler/aggas.pas
@@ -119,89 +119,10 @@ implementation
var
symendcount : longint;
- type
-{$ifdef cpuextended}
- t80bitarray = array[0..9] of byte;
-{$endif cpuextended}
- t64bitarray = array[0..7] of byte;
- t32bitarray = array[0..3] of byte;
-
{****************************************************************************}
{ Support routines }
{****************************************************************************}
- function single2str(d : single) : string;
- var
- hs : string;
- begin
- str(d,hs);
- { replace space with + }
- if hs[1]=' ' then
- hs[1]:='+';
- single2str:='0d'+hs
- end;
-
- function double2str(d : double) : string;
- var
- hs : string;
- begin
- str(d,hs);
- { replace space with + }
- if hs[1]=' ' then
- hs[1]:='+';
- double2str:='0d'+hs
- end;
-
- function extended2str(e : extended) : string;
- var
- hs : string;
- begin
- str(e,hs);
- { replace space with + }
- if hs[1]=' ' then
- hs[1]:='+';
- extended2str:='0d'+hs
- end;
-
-
- { convert floating point values }
- { to correct endian }
- procedure swap64bitarray(var t: t64bitarray);
- var
- b: byte;
- begin
- b:= t[7];
- t[7] := t[0];
- t[0] := b;
-
- b := t[6];
- t[6] := t[1];
- t[1] := b;
-
- b:= t[5];
- t[5] := t[2];
- t[2] := b;
-
- b:= t[4];
- t[4] := t[3];
- t[3] := b;
- end;
-
-
- procedure swap32bitarray(var t: t32bitarray);
- var
- b: byte;
- begin
- b:= t[1];
- t[1]:= t[2];
- t[2]:= b;
-
- b:= t[0];
- t[0]:= t[3];
- t[3]:= b;
- end;
-
-
const
ait_const2str : array[aitconst_128bit..aitconst_64bit_unaligned] of string[20]=(
#9'.fixme128'#9,#9'.quad'#9,#9'.long'#9,#9'.short'#9,#9'.byte'#9,
@@ -631,8 +552,7 @@ implementation
needsObject :=
(
assigned(hp.next) and
- (tai(hp.next).typ in [ait_const,ait_datablock,
- ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit])
+ (tai(hp.next).typ in [ait_const,ait_datablock,ait_realconst])
) or
(hp.sym.typ=AT_DATA);
@@ -1096,101 +1016,9 @@ implementation
end;
end;
- { the "and defined(FPC_HAS_TYPE_EXTENDED)" isn't optimal but currently the only solution
- it prevents proper cross compilation to i386 though
- }
-{$if defined(cpuextended) and defined(FPC_HAS_TYPE_EXTENDED)}
- ait_real_80bit :
+ ait_realconst :
begin
- if do_line then
- AsmWriteLn(target_asm.comment+'value: '+extended2str(tai_real_80bit(hp).value));
- { Make sure e is a extended type, bestreal could be
- a different type (bestreal) !! (PFV) }
- e:=tai_real_80bit(hp).value;
- AsmWrite(#9'.byte'#9);
- for i:=0 to 9 do
- begin
- if i<>0 then
- AsmWrite(',');
- AsmWrite(tostr(t80bitarray(e)[i]));
- end;
- for i:=11 to tai_real_80bit(hp).savesize do
- AsmWrite(',0');
- AsmLn;
- end;
-{$endif cpuextended}
-
- ait_real_64bit :
- begin
- if do_line then
- AsmWriteLn(target_asm.comment+'value: '+double2str(tai_real_64bit(hp).value));
- d:=tai_real_64bit(hp).value;
- { swap the values to correct endian if required }
- if source_info.endian <> target_info.endian then
- swap64bitarray(t64bitarray(d));
- AsmWrite(#9'.byte'#9);
-{$ifdef arm}
- if tai_real_64bit(hp).formatoptions=fo_hiloswapped then
- begin
- for i:=4 to 7 do
- begin
- if i<>4 then
- AsmWrite(',');
- AsmWrite(tostr(t64bitarray(d)[i]));
- end;
- for i:=0 to 3 do
- begin
- AsmWrite(',');
- AsmWrite(tostr(t64bitarray(d)[i]));
- end;
- end
- else
-{$endif arm}
- begin
- for i:=0 to 7 do
- begin
- if i<>0 then
- AsmWrite(',');
- AsmWrite(tostr(t64bitarray(d)[i]));
- end;
- end;
- AsmLn;
- end;
-
- ait_real_32bit :
- begin
- if do_line then
- AsmWriteLn(target_asm.comment+'value: '+single2str(tai_real_32bit(hp).value));
- sin:=tai_real_32bit(hp).value;
- { swap the values to correct endian if required }
- if source_info.endian <> target_info.endian then
- swap32bitarray(t32bitarray(sin));
- AsmWrite(#9'.byte'#9);
- for i:=0 to 3 do
- begin
- if i<>0 then
- AsmWrite(',');
- AsmWrite(tostr(t32bitarray(sin)[i]));
- end;
- AsmLn;
- end;
-
- ait_comp_64bit :
- begin
- if do_line then
- AsmWriteLn(target_asm.comment+'value: '+extended2str(tai_comp_64bit(hp).value));
- AsmWrite(#9'.byte'#9);
- co:=comp(tai_comp_64bit(hp).value);
- { swap the values to correct endian if required }
- if source_info.endian <> target_info.endian then
- swap64bitarray(t64bitarray(co));
- for i:=0 to 7 do
- begin
- if i<>0 then
- AsmWrite(',');
- AsmWrite(tostr(t64bitarray(co)[i]));
- end;
- AsmLn;
+ WriteRealConstAsBytes(tai_realconst(hp),#9'.byte'#9,do_line);
end;
ait_string :
diff --git a/compiler/agjasmin.pas b/compiler/agjasmin.pas
index c33747f422..61ea134a6a 100644
--- a/compiler/agjasmin.pas
+++ b/compiler/agjasmin.pas
@@ -391,21 +391,11 @@ implementation
// internalerror(2010122702);
end;
- ait_real_64bit :
+ ait_realconst :
begin
internalerror(2010122703);
end;
- ait_real_32bit :
- begin
- internalerror(2010122703);
- end;
-
- ait_comp_64bit :
- begin
- internalerror(2010122704);
- end;
-
ait_string :
begin
pos:=0;
diff --git a/compiler/arm/aasmcpu.pas b/compiler/arm/aasmcpu.pas
index 58b8010226..7dc97a600f 100644
--- a/compiler/arm/aasmcpu.pas
+++ b/compiler/arm/aasmcpu.pas
@@ -972,14 +972,9 @@ implementation
if (tai_const(hp).consttype=aitconst_64bit) then
inc(extradataoffset,multiplier);
end;
- ait_comp_64bit,
- ait_real_64bit:
+ ait_realconst:
begin
- inc(extradataoffset,multiplier);
- end;
- ait_real_80bit:
- begin
- inc(extradataoffset,2*multiplier);
+ inc(extradataoffset,multiplier*(((tai_realconst(hp).savesize-4)+3) div 4));
end;
end;
{ check if the same constant has been already inserted into the currently handled list,
@@ -1035,18 +1030,9 @@ implementation
if (tai_const(curtai).consttype=aitconst_64bit) then
inc(curinspos,multiplier);
end;
- ait_real_32bit:
- begin
- inc(curinspos,multiplier);
- end;
- ait_comp_64bit,
- ait_real_64bit:
- begin
- inc(curinspos,2*multiplier);
- end;
- ait_real_80bit:
+ ait_realconst:
begin
- inc(curinspos,3*multiplier);
+ inc(curinspos,multiplier*((tai_realconst(hp).savesize+3) div 4));
end;
end;
{ special case for case jump tables }
diff --git a/compiler/arm/narmcon.pas b/compiler/arm/narmcon.pas
index a9dc04cef7..94abed8f42 100644
--- a/compiler/arm/narmcon.pas
+++ b/compiler/arm/narmcon.pas
@@ -53,11 +53,11 @@ interface
{ I suppose the parser/pass_1 must make sure the generated real }
{ constants are actually supported by the target processor? (JM) }
const
- floattype2ait:array[tfloattype] of taitype=
- (ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_real_80bit,ait_comp_64bit,ait_comp_64bit,ait_real_128bit);
+ floattype2ait:array[tfloattype] of tairealconsttype=
+ (aitrealconst_s32bit,aitrealconst_s64bit,aitrealconst_s80bit,aitrealconst_s80bit,aitrealconst_s64comp,aitrealconst_s64comp,aitrealconst_s128bit);
var
lastlabel : tasmlabel;
- realait : taitype;
+ realait : tairealconsttype;
hiloswapped : boolean;
begin
@@ -73,55 +73,55 @@ interface
current_procinfo.aktlocaldata.concat(Tai_label.Create(lastlabel));
location.reference.symboldata:=current_procinfo.aktlocaldata.last;
case realait of
- ait_real_32bit :
+ aitrealconst_s32bit :
begin
- current_procinfo.aktlocaldata.concat(Tai_real_32bit.Create(ts32real(value_real)));
+ current_procinfo.aktlocaldata.concat(tai_realconst.create_s32real(ts32real(value_real)));
{ range checking? }
if floating_point_range_check_error and
- (tai_real_32bit(current_procinfo.aktlocaldata.last).value=MathInf.Value) then
+ (tai_realconst(current_procinfo.aktlocaldata.last).value.s32val=MathInf.Value) then
Message(parser_e_range_check_error);
end;
- ait_real_64bit :
+ aitrealconst_s64bit :
begin
if hiloswapped then
- current_procinfo.aktlocaldata.concat(Tai_real_64bit.Create_hiloswapped(ts64real(value_real)))
+ current_procinfo.aktlocaldata.concat(tai_realconst.create_s64real_hiloswapped(ts64real(value_real)))
else
- current_procinfo.aktlocaldata.concat(Tai_real_64bit.Create(ts64real(value_real)));
+ current_procinfo.aktlocaldata.concat(tai_realconst.create_s64real(ts64real(value_real)));
{ range checking? }
if floating_point_range_check_error and
- (tai_real_64bit(current_procinfo.aktlocaldata.last).value=MathInf.Value) then
+ (tai_realconst(current_procinfo.aktlocaldata.last).value.s64val=MathInf.Value) then
Message(parser_e_range_check_error);
end;
- ait_real_80bit :
+ aitrealconst_s80bit :
begin
- current_procinfo.aktlocaldata.concat(Tai_real_80bit.Create(value_real,tfloatdef(resultdef).size));
+ current_procinfo.aktlocaldata.concat(tai_realconst.create_s80real(value_real,tfloatdef(resultdef).size));
{ range checking? }
if floating_point_range_check_error and
- (tai_real_80bit(current_procinfo.aktlocaldata.last).value=MathInf.Value) then
+ (tai_realconst(current_procinfo.aktlocaldata.last).value.s80val=MathInf.Value) then
Message(parser_e_range_check_error);
end;
{$ifdef cpufloat128}
- ait_real_128bit :
+ aitrealconst_s128bit :
begin
- current_procinfo.aktlocaldata.concat(Tai_real_128bit.Create(value_real));
+ current_procinfo.aktlocaldata.concat(tai_realconst.create_s128real(value_real));
{ range checking? }
if floating_point_range_check_error and
- (tai_real_128bit(current_procinfo.aktlocaldata.last).value=MathInf.Value) then
+ (tai_realconst(current_procinfo.aktlocaldata.last).value.s128val=MathInf.Value) then
Message(parser_e_range_check_error);
end;
{$endif cpufloat128}
{ the round is necessary for native compilers where comp isn't a float }
- ait_comp_64bit :
+ aitrealconst_s64comp :
if (value_real>9223372036854775807.0) or (value_real<-9223372036854775808.0) then
message(parser_e_range_check_error)
else
- current_procinfo.aktlocaldata.concat(Tai_comp_64bit.Create(round(value_real)));
+ current_procinfo.aktlocaldata.concat(tai_realconst.create_s64compreal(round(value_real)));
else
internalerror(2005092401);
end;
diff --git a/compiler/assemble.pas b/compiler/assemble.pas
index 609877e342..b7a5efac1a 100644
--- a/compiler/assemble.pas
+++ b/compiler/assemble.pas
@@ -83,6 +83,10 @@ interface
lastsectype : TAsmSectionType;
procedure WriteSourceLine(hp: tailineinfo);
procedure WriteTempalloc(hp: tai_tempalloc);
+ procedure WriteRealConstAsBytes(hp: tai_realconst; const dbdir: string; do_line: boolean);
+ function single2str(d : single) : string; virtual;
+ function double2str(d : double) : string; virtual;
+ function extended2str(e : extended) : string; virtual;
public
{# Returns the complete path and executable name of the assembler
program.
@@ -271,6 +275,40 @@ Implementation
TExternalAssembler
*****************************************************************************}
+ function TExternalAssembler.single2str(d : single) : string;
+ var
+ hs : string;
+ begin
+ str(d,hs);
+ { replace space with + }
+ if hs[1]=' ' then
+ hs[1]:='+';
+ single2str:='0d'+hs
+ end;
+
+ function TExternalAssembler.double2str(d : double) : string;
+ var
+ hs : string;
+ begin
+ str(d,hs);
+ { replace space with + }
+ if hs[1]=' ' then
+ hs[1]:='+';
+ double2str:='0d'+hs
+ end;
+
+ function TExternalAssembler.extended2str(e : extended) : string;
+ var
+ hs : string;
+ begin
+ str(e,hs);
+ { replace space with + }
+ if hs[1]=' ' then
+ hs[1]:='+';
+ extended2str:='0d'+hs
+ end;
+
+
Function DoPipe:boolean;
begin
DoPipe:=(cs_asm_pipe in current_settings.globalswitches) and
@@ -774,6 +812,109 @@ Implementation
tostr(hp.tempsize)+' '+tempallocstr[hp.allocation]);
end;
+
+ procedure TExternalAssembler.WriteRealConstAsBytes(hp: tai_realconst; const dbdir: string; do_line: boolean);
+ var
+ pdata: pbyte;
+ index, step, swapmask, count: longint;
+ ssingle: single;
+ ddouble: double;
+ ccomp: comp;
+{$if defined(cpuextended) and defined(FPC_HAS_TYPE_EXTENDED)}
+ eextended: extended;
+{$endif cpuextended}
+ begin
+ if do_line then
+ begin
+ case tai_realconst(hp).realtyp of
+ aitrealconst_s32bit:
+ AsmWriteLn(target_asm.comment+'value: '+single2str(tai_realconst(hp).value.s32val));
+ aitrealconst_s64bit:
+ AsmWriteLn(target_asm.comment+'value: '+double2str(tai_realconst(hp).value.s64val));
+{$if defined(cpuextended) and defined(FPC_HAS_TYPE_EXTENDED)}
+ { can't write full 80 bit floating point constants yet on non-x86 }
+ aitrealconst_s80bit:
+ AsmWriteLn(target_asm.comment+'value: '+extended2str(tai_realconst(hp).value.s80val));
+{$endif cpuextended}
+ aitrealconst_s64comp:
+ AsmWriteLn(target_asm.comment+'value: '+extended2str(tai_realconst(hp).value.s64compval));
+ else
+ internalerror(2014050604);
+ end;
+ end;
+ AsmWrite(dbdir);
+ { generic float writing code: get start address of value, then write
+ byte by byte. Can't use fields directly, because e.g ts64comp is
+ defined as extended on x86 }
+ case tai_realconst(hp).realtyp of
+ aitrealconst_s32bit:
+ begin
+ ssingle:=single(tai_realconst(hp).value.s32val);
+ pdata:=@ssingle;
+ end;
+ aitrealconst_s64bit:
+ begin
+ ddouble:=double(tai_realconst(hp).value.s64val);
+ pdata:=@ddouble;
+ end;
+{$if defined(cpuextended) and defined(FPC_HAS_TYPE_EXTENDED)}
+ { can't write full 80 bit floating point constants yet on non-x86 }
+ aitrealconst_s80bit:
+ begin
+ eextended:=extended(tai_realconst(hp).value.s80val);
+ pdata:=@eextended;
+ end;
+{$endif cpuextended}
+ aitrealconst_s64comp:
+ begin
+ ccomp:=comp(tai_realconst(hp).value.s64compval);
+ pdata:=@ccomp;
+ end;
+ else
+ internalerror(2014051001);
+ end;
+ count:=tai_realconst(hp).datasize;
+ { write bytes in inverse order if source and target endianess don't
+ match }
+ if source_info.endian<>target_info.endian then
+ begin
+ { go from back to front }
+ index:=count-1;
+ step:=-1;
+ end
+ else
+ begin
+ index:=0;
+ step:=1;
+ end;
+{$ifdef ARM}
+ { ARM-specific: low and high dwords of a double may be swapped }
+ if tai_realconst(hp).formatoptions=fo_hiloswapped then
+ begin
+ { only supported for double }
+ if tai_realconst(hp).datasize<>8 then
+ internalerror(2014050605);
+ { switch bit of the index so that the words are written in
+ the opposite order }
+ swapmask:=4;
+ end
+ else
+{$endif ARM}
+ swapmask:=0;
+ repeat
+ AsmWrite(tostr(pdata[index xor swapmask]));
+ inc(index,step);
+ dec(count);
+ if count<>0 then
+ AsmWrite(',');
+ until count=0;
+ { padding }
+ for count:=tai_realconst(hp).datasize+1 to tai_realconst(hp).savesize do
+ AsmWrite(',0');
+ AsmLn;
+ end;
+
+
procedure TExternalAssembler.WriteTree(p:TAsmList);
begin
end;
@@ -1161,14 +1302,8 @@ Implementation
ObjData.alloc(Tai_datablock(hp).size);
end;
end;
- ait_real_80bit :
- ObjData.alloc(tai_real_80bit(hp).savesize);
- ait_real_64bit :
- ObjData.alloc(8);
- ait_real_32bit :
- ObjData.alloc(4);
- ait_comp_64bit :
- ObjData.alloc(8);
+ ait_realconst:
+ ObjData.alloc(tai_realconst(hp).savesize);
ait_const:
begin
{ if symbols are provided we can calculate the value for relative symbols.
@@ -1291,14 +1426,8 @@ Implementation
ObjData.alloc(Tai_datablock(hp).size);
end;
end;
- ait_real_80bit :
- ObjData.alloc(tai_real_80bit(hp).savesize);
- ait_real_64bit :
- ObjData.alloc(8);
- ait_real_32bit :
- ObjData.alloc(4);
- ait_comp_64bit :
- ObjData.alloc(8);
+ ait_realconst:
+ ObjData.alloc(tai_realconst(hp).savesize);
ait_const:
begin
{ Recalculate relative symbols }
@@ -1427,21 +1556,10 @@ Implementation
ObjData.alloc(Tai_datablock(hp).size);
end;
end;
- ait_real_80bit :
- begin
- ObjData.writebytes(Tai_real_80bit(hp).value,10);
- ObjData.writebytes(zerobuf,Tai_real_80bit(hp).savesize-10);
- end;
- ait_real_64bit :
- ObjData.writebytes(Tai_real_64bit(hp).value,8);
- ait_real_32bit :
- ObjData.writebytes(Tai_real_32bit(hp).value,4);
- ait_comp_64bit :
+ ait_realconst:
begin
-{$ifdef x86}
- co:=comp(Tai_comp_64bit(hp).value);
- ObjData.writebytes(co,8);
-{$endif x86}
+ ObjData.writebytes(tai_realconst(hp).value,tai_realconst(hp).datasize);
+ ObjData.writebytes(zerobuf,tai_realconst(hp).savesize-tai_realconst(hp).datasize);
end;
ait_string :
ObjData.writebytes(Tai_string(hp).str^,Tai_string(hp).len);
diff --git a/compiler/dbgdwarf.pas b/compiler/dbgdwarf.pas
index 4592094753..5b20b587c8 100644
--- a/compiler/dbgdwarf.pas
+++ b/compiler/dbgdwarf.pas
@@ -2763,12 +2763,12 @@ implementation
s32real:
begin
current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(4));
- current_asmdata.asmlists[al_dwarf_info].concat(tai_real_32bit.create(pbestreal(sym.value.valueptr)^));
+ current_asmdata.asmlists[al_dwarf_info].concat(tai_realconst.create_s32real(pbestreal(sym.value.valueptr)^));
end;
s64real:
begin
current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(8));
- current_asmdata.asmlists[al_dwarf_info].concat(tai_real_64bit.create(pbestreal(sym.value.valueptr)^));
+ current_asmdata.asmlists[al_dwarf_info].concat(tai_realconst.create_s64real(pbestreal(sym.value.valueptr)^));
end;
s64comp,
s64currency:
@@ -2780,7 +2780,7 @@ implementation
sc80real:
begin
current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(sym.constdef.size));
- current_asmdata.asmlists[al_dwarf_info].concat(tai_real_80bit.create(pextended(sym.value.valueptr)^,sym.constdef.size));
+ current_asmdata.asmlists[al_dwarf_info].concat(tai_realconst.create_s80real(pextended(sym.value.valueptr)^,sym.constdef.size));
end;
else
internalerror(200601291);
diff --git a/compiler/llvm/agllvm.pas b/compiler/llvm/agllvm.pas
index dfff223dc7..74f8a3bd4e 100644
--- a/compiler/llvm/agllvm.pas
+++ b/compiler/llvm/agllvm.pas
@@ -43,6 +43,7 @@ interface
// procedure WriteWeakSymbolDef(s: tasmsymbol); virtual;
procedure WriteDirectiveName(dir: TAsmDirective); virtual;
procedure WriteWeakSymbolDef(s: tasmsymbol);
+ procedure WriteRealConst(hp: tai_realconst; do_line: boolean);
public
constructor create(smart: boolean); override;
function MakeCmdLine: TCmdStr; override;
@@ -532,38 +533,9 @@ implementation
AsmWriteln('const');
end;
- { the "and defined(FPC_HAS_TYPE_EXTENDED)" isn't optimal but currently the only solution
- it prevents proper cross compilation to i386 though
- }
-{$if defined(cpuextended) and defined(FPC_HAS_TYPE_EXTENDED)}
- ait_real_80bit :
- begin
-// if do_line then
- AsmWriteLn(target_asm.comment+'value: '+extended2str(tai_real_80bit(hp).value));
- end;
-{$endif cpuextended}
-
- ait_real_32bit,
- ait_real_64bit:
+ ait_realconst :
begin
- if hp.typ=ait_real_32bit then
- begin
-// if do_line then
- AsmWriteLn(target_asm.comment+'value: '+single2str(tai_real_32bit(hp).value));
-// d:=tai_real_32bit(hp).value
- end
- else
- begin
-// if do_line then
- AsmWriteLn(target_asm.comment+'value: '+double2str(tai_real_64bit(hp).value));
-// d:=tai_real_64bit(hp).value;
- end;
- end;
-
- ait_comp_64bit :
- begin
-// if do_line then
- AsmWriteLn(target_asm.comment+'value: '+extended2str(tai_comp_64bit(hp).value));
+ WriteRealConst(tai_realconst(hp),do_line);
end;
ait_string :
@@ -793,6 +765,32 @@ implementation
end;
+ procedure TLLVMAssember.WriteRealConst(hp: tai_realconst; do_line: boolean);
+ var
+ pdata: pbyte;
+ index, step, swapmask, count: longint;
+ begin
+// if do_line then
+ begin
+ case tai_realconst(hp).realtyp of
+ aitrealconst_s32bit:
+ AsmWriteLn(target_asm.comment+'value: '+single2str(tai_realconst(hp).value.s32val));
+ aitrealconst_s64bit:
+ AsmWriteLn(target_asm.comment+'value: '+double2str(tai_realconst(hp).value.s64val));
+{$if defined(cpuextended) and defined(FPC_HAS_TYPE_EXTENDED)}
+ { can't write full 80 bit floating point constants yet on non-x86 }
+ aitrealconst_s80bit:
+ AsmWriteLn(target_asm.comment+'value: '+extended2str(tai_realconst(hp).value.s80val));
+{$endif cpuextended}
+ aitrealconst_s64comp:
+ AsmWriteLn(target_asm.comment+'value: '+extended2str(tai_realconst(hp).value.s64compval));
+ else
+ internalerror(2014050604);
+ end;
+ end;
+ end;
+
+
constructor TLLVMAssember.create(smart: boolean);
begin
inherited create(smart);
diff --git a/compiler/mips/ncpucnv.pas b/compiler/mips/ncpucnv.pas
index de219edec9..6195ffef24 100644
--- a/compiler/mips/ncpucnv.pas
+++ b/compiler/mips/ncpucnv.pas
@@ -171,7 +171,7 @@ begin
hregister := cg.getfpuregister(current_asmdata.CurrAsmList, OS_F64);
new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata_norel,l1.name,const_align(8));
current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(l1));
- current_asmdata.asmlists[al_typedconsts].concat(Tai_real_64bit.Create(4294967296.0));
+ current_asmdata.asmlists[al_typedconsts].concat(tai_realconst.create_s64real(4294967296.0));
cg.a_loadfpu_ref_reg(current_asmdata.CurrAsmList, OS_F64, OS_F64, href, hregister);
current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_ADD_D, location.Register, hregister, location.Register));
diff --git a/compiler/ncgcon.pas b/compiler/ncgcon.pas
index 0cd1da2ffc..9b92b285e2 100644
--- a/compiler/ncgcon.pas
+++ b/compiler/ncgcon.pas
@@ -112,8 +112,8 @@ implementation
{ I suppose the parser/pass_1 must make sure the generated real }
{ constants are actually supported by the target processor? (JM) }
const
- floattype2ait:array[tfloattype] of taitype=
- (ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_real_80bit,ait_comp_64bit,ait_comp_64bit,ait_real_128bit);
+ floattype2ait:array[tfloattype] of tairealconsttype=
+ (aitrealconst_s32bit,aitrealconst_s64bit,aitrealconst_s80bit,aitrealconst_s80bit,aitrealconst_s64comp,aitrealconst_s64comp,aitrealconst_s128bit);
{ Since the value is stored always as bestreal, we share a single pool
between all float types. This requires type and hiloswapped flag to
@@ -127,7 +127,7 @@ implementation
var
lastlabel : tasmlabel;
- realait : taitype;
+ realait : tairealconsttype;
entry : PHashSetItem;
key: tfloatkey;
{$ifdef ARM}
@@ -165,57 +165,57 @@ implementation
new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata_norel,lastlabel.name,const_align(resultdef.alignment));
current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(lastlabel));
case realait of
- ait_real_32bit :
+ aitrealconst_s32bit :
begin
- current_asmdata.asmlists[al_typedconsts].concat(Tai_real_32bit.Create(ts32real(value_real)));
+ current_asmdata.asmlists[al_typedconsts].concat(tai_realconst.create_s32real(ts32real(value_real)));
{ range checking? }
if floating_point_range_check_error and
- (tai_real_32bit(current_asmdata.asmlists[al_typedconsts].last).value=MathInf.Value) then
+ (tai_realconst(current_asmdata.asmlists[al_typedconsts].last).value.s32val=MathInf.Value) then
Message(parser_e_range_check_error);
end;
- ait_real_64bit :
+ aitrealconst_s64bit :
begin
{$ifdef ARM}
if hiloswapped then
- current_asmdata.asmlists[al_typedconsts].concat(Tai_real_64bit.Create_hiloswapped(ts64real(value_real)))
+ current_asmdata.asmlists[al_typedconsts].concat(tai_realconst.create_s64real_hiloswapped(ts64real(value_real)))
else
{$endif ARM}
- current_asmdata.asmlists[al_typedconsts].concat(Tai_real_64bit.Create(ts64real(value_real)));
+ current_asmdata.asmlists[al_typedconsts].concat(tai_realconst.create_s64real(ts64real(value_real)));
{ range checking? }
if floating_point_range_check_error and
- (tai_real_64bit(current_asmdata.asmlists[al_typedconsts].last).value=MathInf.Value) then
+ (tai_realconst(current_asmdata.asmlists[al_typedconsts].last).value.s64val=MathInf.Value) then
Message(parser_e_range_check_error);
end;
- ait_real_80bit :
+ aitrealconst_s80bit :
begin
- current_asmdata.asmlists[al_typedconsts].concat(Tai_real_80bit.Create(value_real,resultdef.size));
+ current_asmdata.asmlists[al_typedconsts].concat(tai_realconst.create_s80real(value_real,tfloatdef(resultdef).size));
{ range checking? }
if floating_point_range_check_error and
- (tai_real_80bit(current_asmdata.asmlists[al_typedconsts].last).value=MathInf.Value) then
+ (tai_realconst(current_asmdata.asmlists[al_typedconsts].last).value.s80val=MathInf.Value) then
Message(parser_e_range_check_error);
end;
{$ifdef cpufloat128}
- ait_real_128bit :
+ aitrealconst_s128bit :
begin
- current_asmdata.asmlists[al_typedconsts].concat(Tai_real_128bit.Create(value_real));
+ current_asmdata.asmlists[al_typedconsts].concat(tai_realconst.create_s128real(value_real));
{ range checking? }
if floating_point_range_check_error and
- (tai_real_128bit(current_asmdata.asmlists[al_typedconsts].last).value=MathInf.Value) then
+ (tai_realconst(current_asmdata.asmlists[al_typedconsts].last).value.s128val=MathInf.Value) then
Message(parser_e_range_check_error);
end;
{$endif cpufloat128}
{ the round is necessary for native compilers where comp isn't a float }
- ait_comp_64bit :
+ aitrealconst_s64comp :
if (value_real>9223372036854775807.0) or (value_real<-9223372036854775808.0) then
message(parser_e_range_check_error)
else
- current_asmdata.asmlists[al_typedconsts].concat(Tai_comp_64bit.Create(round(value_real)));
+ current_asmdata.asmlists[al_typedconsts].concat(tai_realconst.create_s64compreal(round(value_real)));
else
internalerror(10120);
end;
diff --git a/compiler/ngtcon.pas b/compiler/ngtcon.pas
index 4a0a200451..9e791fbc49 100644
--- a/compiler/ngtcon.pas
+++ b/compiler/ngtcon.pas
@@ -734,25 +734,25 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
case def.floattype of
s32real :
- list.concat(Tai_real_32bit.Create(ts32real(value)));
+ list.concat(tai_realconst.create_s32real(ts32real(value)));
s64real :
{$ifdef ARM}
if is_double_hilo_swapped then
- list.concat(Tai_real_64bit.Create_hiloswapped(ts64real(value)))
+ list.concat(tai_realconst.create_s64real_hiloswapped(ts64real(value)))
else
{$endif ARM}
- list.concat(Tai_real_64bit.Create(ts64real(value)));
+ list.concat(tai_realconst.create_s64real(ts64real(value)));
s80real :
- list.concat(Tai_real_80bit.Create(value,s80floattype.size));
+ list.concat(tai_realconst.create_s80real(value,s80floattype.size));
sc80real :
- list.concat(Tai_real_80bit.Create(value,sc80floattype.size));
+ list.concat(tai_realconst.create_s80real(value,sc80floattype.size));
s64comp :
{ the round is necessary for native compilers where comp isn't a float }
- list.concat(Tai_comp_64bit.Create(round(value)));
+ list.concat(tai_realconst.create_s64compreal(round(value)));
s64currency:
- list.concat(Tai_comp_64bit.Create(round(value*10000)));
+ list.concat(tai_realconst.create_s64compreal(round(value*10000)));
s128real:
- list.concat(Tai_real_128bit.Create(value));
+ list.concat(tai_realconst.create_s128real(value));
else
internalerror(200611053);
end;
diff --git a/compiler/powerpc/agppcmpw.pas b/compiler/powerpc/agppcmpw.pas
index f5a93e404b..3010aa1a9d 100644
--- a/compiler/powerpc/agppcmpw.pas
+++ b/compiler/powerpc/agppcmpw.pas
@@ -900,6 +900,13 @@ interface
end;
end;
+ ait_realconst:
+ begin
+ { update for tai_realconst change, see aggas.pas and commented
+ old code below }
+ internalerror(2014050607);
+ end;
+(*
ait_real_64bit :
begin
AsmWriteLn(target_asm.comment+'value: '+double2str(tai_real_64bit(hp).value));
@@ -935,7 +942,7 @@ interface
end;
AsmLn;
end;
-
+*)
ait_string:
begin
{NOTE When a single quote char is encountered, it is
diff --git a/compiler/psystem.pas b/compiler/psystem.pas
index e1ca895805..5c20bfa351 100644
--- a/compiler/psystem.pas
+++ b/compiler/psystem.pas
@@ -700,10 +700,7 @@ implementation
aiclass[ait_directive]:=tai_directive;
aiclass[ait_label]:=tai_label;
aiclass[ait_const]:=tai_const;
- aiclass[ait_real_32bit]:=tai_real_32bit;
- aiclass[ait_real_64bit]:=tai_real_64bit;
- aiclass[ait_real_80bit]:=tai_real_80bit;
- aiclass[ait_comp_64bit]:=tai_comp_64bit;
+ aiclass[ait_realconst]:=tai_realconst;
aiclass[ait_stab]:=tai_stab;
aiclass[ait_force_line]:=tai_force_line;
aiclass[ait_function_name]:=tai_function_name;
diff --git a/compiler/rautils.pas b/compiler/rautils.pas
index 5d3c767fc5..dffe31456b 100644
--- a/compiler/rautils.pas
+++ b/compiler/rautils.pas
@@ -1523,17 +1523,19 @@ end;
{***********************************************************************}
Begin
case real_typ of
- s32real : p.concat(Tai_real_32bit.Create(value));
+ s32real : p.concat(tai_realconst.create_s32real(value));
s64real :
{$ifdef ARM}
if is_double_hilo_swapped then
- p.concat(Tai_real_64bit.Create_hiloswapped(value))
+ p.concat(tai_realconst.create_s64real_hiloswapped(value))
else
{$endif ARM}
- p.concat(Tai_real_64bit.Create(value));
- s80real : p.concat(Tai_real_80bit.Create(value,s80floattype.size));
- sc80real : p.concat(Tai_real_80bit.Create(value,sc80floattype.size));
- s64comp : p.concat(Tai_comp_64bit.Create(trunc(value)));
+ p.concat(tai_realconst.create_s64real(value));
+ s80real : p.concat(tai_realconst.create_s80real(value,s80floattype.size));
+ sc80real : p.concat(tai_realconst.create_s80real(value,sc80floattype.size));
+ s64comp : p.concat(tai_realconst.create_s64compreal(trunc(value)));
+ else
+ internalerror(2014050608);
end;
end;
diff --git a/compiler/x86/agx86int.pas b/compiler/x86/agx86int.pas
index 40c0f0378a..e254f81ea7 100644
--- a/compiler/x86/agx86int.pas
+++ b/compiler/x86/agx86int.pas
@@ -586,14 +586,21 @@ implementation
end;
end;
- ait_real_32bit :
- AsmWriteLn(#9#9'DD'#9+single2str(tai_real_32bit(hp).value));
- ait_real_64bit :
- AsmWriteLn(#9#9'DQ'#9+double2str(tai_real_64bit(hp).value));
- ait_real_80bit :
- AsmWriteLn(#9#9'DT'#9+extended2str(tai_real_80bit(hp).value));
- ait_comp_64bit :
- AsmWriteLn(#9#9'DQ'#9+extended2str(tai_comp_64bit(hp).value));
+ ait_realconst:
+ begin
+ case tai_realconst(hp).realtyp of
+ aitrealconst_s32bit:
+ AsmWriteLn(#9#9'DD'#9+single2str(tai_realconst(hp).value.s32val));
+ aitrealconst_s64bit:
+ AsmWriteLn(#9#9'DQ'#9+double2str(tai_realconst(hp).value.s64val));
+ aitrealconst_s80bit:
+ AsmWriteLn(#9#9'DT'#9+extended2str(tai_realconst(hp).value.s80val));
+ aitrealconst_s64comp:
+ AsmWriteLn(#9#9'DQ'#9+extended2str(tai_realconst(hp).value.s64compval));
+ else
+ internalerror(2014050604);
+ end;
+ end;
ait_string :
begin
counter := 0;
@@ -676,8 +683,7 @@ implementation
begin
AsmWrite(tai_label(hp).labsym.name);
if assigned(hp.next) and not(tai(hp.next).typ in
- [ait_const,
- ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit,ait_string]) then
+ [ait_const,ait_realconst,ait_string]) then
AsmWriteLn(':')
else
DoNotSplitLine:=true;
@@ -691,8 +697,7 @@ implementation
AsmWriteLn(#9'PUBLIC'#9+tai_symbol(hp).sym.name);
AsmWrite(tai_symbol(hp).sym.name);
if assigned(hp.next) and not(tai(hp.next).typ in
- [ait_const,
- ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit,ait_string]) then
+ [ait_const,ait_realconst,ait_string]) then
AsmWriteLn(':')
end;
ait_symbol_end :
diff --git a/compiler/x86/agx86nsm.pas b/compiler/x86/agx86nsm.pas
index dba802d224..55f47c2c40 100644
--- a/compiler/x86/agx86nsm.pas
+++ b/compiler/x86/agx86nsm.pas
@@ -42,6 +42,10 @@ interface
procedure WriteOper(const o:toper;s : topsize; opcode: tasmop;ops:longint;dest : boolean);
procedure WriteOper_jmp(const o:toper; ai : taicpu);
procedure WriteSection(atype:TAsmSectiontype;const aname:string);
+ protected
+ function single2str(d: single): string; override;
+ function double2str(d: double): string; override;
+ function extended2str(e: extended): string; override;
public
procedure WriteTree(p:TAsmList);override;
procedure WriteAsmList;override;
@@ -60,12 +64,6 @@ interface
fmodule,finput,verbose,cpuinfo,cgbase
;
- type
-{$ifdef cpuextended}
- t80bitarray = array[0..9] of byte;
-{$endif cpuextended}
- t64bitarray = array[0..7] of byte;
- t32bitarray = array[0..3] of byte;
const
line_length = 64;
@@ -91,7 +89,8 @@ interface
result:=generic_regname(r);
end;
- function single2str(d : single) : string;
+
+ function TX86NasmAssembler.single2str(d: single): string;
var
hs : string;
p : longint;
@@ -107,7 +106,8 @@ interface
single2str:=lower(hs);
end;
- function double2str(d : double) : string;
+
+ function TX86NasmAssembler.double2str(d: double): string;
var
hs : string;
p : longint;
@@ -123,7 +123,8 @@ interface
double2str:=lower(hs);
end;
- function extended2str(e : extended) : string;
+
+ function TX86NasmAssembler.extended2str(e: extended): string;
var
hs : string;
p : longint;
@@ -140,57 +141,6 @@ interface
end;
- { convert floating point values }
- { to correct endian }
- procedure swap64bitarray(var t: t64bitarray);
- var
- b: byte;
- begin
- b:= t[7];
- t[7] := t[0];
- t[0] := b;
-
- b := t[6];
- t[6] := t[1];
- t[1] := b;
-
- b:= t[5];
- t[5] := t[2];
- t[2] := b;
-
- b:= t[4];
- t[4] := t[3];
- t[3] := b;
- end;
-
-
- procedure swap32bitarray(var t: t32bitarray);
- var
- b: byte;
- begin
- b:= t[1];
- t[1]:= t[2];
- t[2]:= b;
-
- b:= t[0];
- t[0]:= t[3];
- t[3]:= b;
- end;
-
-
- function comp2str(d : bestreal) : string;
- type
- pdouble = ^double;
- var
- c : comp;
- dd : pdouble;
- begin
- c:=comp(d);
- dd:=pdouble(@c); { this makes a bitwise copy of c into a double }
- comp2str:=double2str(dd^);
- end;
-
-
function sizestr(s:topsize;dest:boolean):string;
begin
case s of
@@ -787,105 +737,9 @@ interface
end;
end;
-{$if defined(cpuextended) and defined(FPC_HAS_TYPE_EXTENDED)}
- ait_real_80bit :
+ ait_realconst:
begin
- if do_line then
- AsmWriteLn(target_asm.comment+'value: '+extended2str(tai_real_80bit(hp).value));
- { Make sure e is a extended type, bestreal could be
- a different type (bestreal) !! (PFV) }
- e:=tai_real_80bit(hp).value;
- AsmWrite(#9#9'DB'#9);
- for i:=0 to 9 do
- begin
- if i<>0 then
- AsmWrite(',');
- AsmWrite(tostr(t80bitarray(e)[i]));
- end;
- for i:=11 to tai_real_80bit(hp).savesize do
- AsmWrite(',0');
- AsmLn;
- end;
-{$else cpuextended}
- ait_real_80bit :
- AsmWriteLn(#9#9'DT'#9+extended2str(tai_real_80bit(hp).value));
-{$endif cpuextended}
-
- // ait_real_64bit :
- // AsmWriteLn(#9#9'DQ'#9+double2str(tai_real_64bit(hp).value));
- ait_real_64bit :
- begin
- if do_line then
- AsmWriteLn(target_asm.comment+'value: '+double2str(tai_real_64bit(hp).value));
- d:=tai_real_64bit(hp).value;
- { swap the values to correct endian if required }
- if source_info.endian <> target_info.endian then
- swap64bitarray(t64bitarray(d));
- AsmWrite(#9#9'DB'#9);
-{$ifdef arm}
- if tai_real_64bit(hp).formatoptions=fo_hiloswapped then
- begin
- for i:=4 to 7 do
- begin
- if i<>4 then
- AsmWrite(',');
- AsmWrite(tostr(t64bitarray(d)[i]));
- end;
- for i:=0 to 3 do
- begin
- AsmWrite(',');
- AsmWrite(tostr(t64bitarray(d)[i]));
- end;
- end
- else
-{$endif arm}
- begin
- for i:=0 to 7 do
- begin
- if i<>0 then
- AsmWrite(',');
- AsmWrite(tostr(t64bitarray(d)[i]));
- end;
- end;
- AsmLn;
- end;
- // ait_real_32bit :
- // AsmWriteLn(#9#9'DD'#9+single2str(tai_real_32bit(hp).value));
- ait_real_32bit :
- begin
- if do_line then
- AsmWriteLn(target_asm.comment+'value: '+single2str(tai_real_32bit(hp).value));
- sin:=tai_real_32bit(hp).value;
- { swap the values to correct endian if required }
- if source_info.endian <> target_info.endian then
- swap32bitarray(t32bitarray(sin));
- AsmWrite(#9#9'DB'#9);
- for i:=0 to 3 do
- begin
- if i<>0 then
- AsmWrite(',');
- AsmWrite(tostr(t32bitarray(sin)[i]));
- end;
- AsmLn;
- end;
- // ait_comp_64bit :
- // AsmWriteLn(#9#9'DQ'#9+comp2str(tai_real_80bit(hp).value));
- ait_comp_64bit :
- begin
- if do_line then
- AsmWriteLn(target_asm.comment+'value: '+extended2str(tai_comp_64bit(hp).value));
- AsmWrite(#9#9'DB'#9);
- co:=comp(tai_comp_64bit(hp).value);
- { swap the values to correct endian if required }
- if source_info.endian <> target_info.endian then
- swap64bitarray(t64bitarray(co));
- for i:=0 to 7 do
- begin
- if i<>0 then
- AsmWrite(',');
- AsmWrite(tostr(t64bitarray(co)[i]));
- end;
- AsmLn;
+ WriteRealConstAsBytes(tai_realconst(hp),#9#9'DB'#9,do_line);
end;
ait_string :
@@ -993,8 +847,7 @@ interface
if SmartAsm then
AddSymbol(tai_symbol(hp).sym.name,true);
if assigned(hp.next) and not(tai(hp.next).typ in
- [ait_const,
- ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit,ait_string]) then
+ [ait_const,ait_realconst,ait_string]) then
AsmWriteLn(':')
end;