mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-02 19:22:05 +01:00
* Flags specific to TAsmNode have been moved to their own field
This commit is contained in:
parent
c21a0f0654
commit
0e5da37533
@ -71,11 +71,19 @@ interface
|
||||
end;
|
||||
tfinalizetempsnodeclass = class of tfinalizetempsnode;
|
||||
|
||||
TAsmNodeFlag =
|
||||
(
|
||||
asmnf_get_asm_position,
|
||||
{ Used registers in assembler block }
|
||||
asmnf_has_registerlist
|
||||
);
|
||||
|
||||
TAsmNodeFlags = set of TAsmNodeFlag;
|
||||
|
||||
tasmnode = class(tnode)
|
||||
asmnodeflags: TAsmNodeFlags;
|
||||
p_asm : TAsmList;
|
||||
currenttai : tai;
|
||||
{ Used registers in assembler block }
|
||||
has_registerlist : boolean;
|
||||
constructor create(p : TAsmList);virtual;
|
||||
constructor create_get_position;
|
||||
destructor destroy;override;
|
||||
@ -88,6 +96,7 @@ interface
|
||||
function pass_typecheck:tnode;override;
|
||||
function docompare(p: tnode): boolean; override;
|
||||
{$ifdef DEBUG_NODE_XML}
|
||||
procedure XMLPrintNodeInfo(var T: Text); override;
|
||||
procedure XMLPrintNodeData(var T: Text); override;
|
||||
{$endif DEBUG_NODE_XML}
|
||||
end;
|
||||
@ -864,6 +873,7 @@ implementation
|
||||
begin
|
||||
inherited create(asmn);
|
||||
p_asm:=p;
|
||||
asmnodeflags := [];
|
||||
currenttai:=nil;
|
||||
end;
|
||||
|
||||
@ -872,7 +882,7 @@ implementation
|
||||
begin
|
||||
inherited create(asmn);
|
||||
p_asm:=nil;
|
||||
include(flags,nf_get_asm_position);
|
||||
asmnodeflags := [asmnf_get_asm_position];
|
||||
currenttai:=nil;
|
||||
end;
|
||||
|
||||
@ -890,7 +900,8 @@ implementation
|
||||
hp : tai;
|
||||
begin
|
||||
inherited ppuload(t,ppufile);
|
||||
if not(nf_get_asm_position in flags) then
|
||||
ppufile.getset(tppuset1(asmnodeflags));
|
||||
if not(asmnf_get_asm_position in asmnodeflags) then
|
||||
begin
|
||||
p_asm:=TAsmList.create;
|
||||
repeat
|
||||
@ -913,8 +924,9 @@ implementation
|
||||
hp : tai;
|
||||
begin
|
||||
inherited ppuwrite(ppufile);
|
||||
ppufile.putset(tppuset1(asmnodeflags));
|
||||
{ TODO: FIXME Add saving of register sets}
|
||||
if not(nf_get_asm_position in flags) then
|
||||
if not(asmnf_get_asm_position in asmnodeflags) then
|
||||
begin
|
||||
hp:=tai(p_asm.first);
|
||||
while assigned(hp) do
|
||||
@ -933,7 +945,7 @@ implementation
|
||||
hp : tai;
|
||||
begin
|
||||
inherited buildderefimpl;
|
||||
if not(nf_get_asm_position in flags) then
|
||||
if not(asmnf_get_asm_position in asmnodeflags) then
|
||||
begin
|
||||
hp:=tai(p_asm.first);
|
||||
while assigned(hp) do
|
||||
@ -950,7 +962,7 @@ implementation
|
||||
hp : tai;
|
||||
begin
|
||||
inherited derefimpl;
|
||||
if not(nf_get_asm_position in flags) then
|
||||
if not(asmnf_get_asm_position in asmnodeflags) then
|
||||
begin
|
||||
hp:=tai(p_asm.first);
|
||||
while assigned(hp) do
|
||||
@ -967,6 +979,7 @@ implementation
|
||||
n: tasmnode;
|
||||
begin
|
||||
n := tasmnode(inherited dogetcopy);
|
||||
n.asmnodeflags := asmnodeflags;
|
||||
if assigned(p_asm) then
|
||||
begin
|
||||
n.p_asm:=TAsmList.create;
|
||||
@ -974,7 +987,6 @@ implementation
|
||||
end
|
||||
else n.p_asm := nil;
|
||||
n.currenttai:=currenttai;
|
||||
n.has_registerlist:=has_registerlist;
|
||||
result:=n;
|
||||
end;
|
||||
|
||||
@ -983,7 +995,7 @@ implementation
|
||||
begin
|
||||
result:=nil;
|
||||
resultdef:=voidtype;
|
||||
if not(nf_get_asm_position in flags) then
|
||||
if not(asmnf_get_asm_position in asmnodeflags) then
|
||||
include(current_procinfo.flags,pi_has_assembler_block);
|
||||
end;
|
||||
|
||||
@ -1002,6 +1014,28 @@ implementation
|
||||
end;
|
||||
|
||||
{$ifdef DEBUG_NODE_XML}
|
||||
procedure TAsmNode.XMLPrintNodeInfo(var T: Text);
|
||||
var
|
||||
i: TAsmNodeFlag;
|
||||
First: Boolean;
|
||||
begin
|
||||
inherited XMLPrintNodeInfo(T);
|
||||
First := True;
|
||||
for i in asmnodeflags do
|
||||
begin
|
||||
if First then
|
||||
begin
|
||||
Write(T, ' asmnodeflags="', i);
|
||||
First := False;
|
||||
end
|
||||
else
|
||||
Write(T, ',', i)
|
||||
end;
|
||||
if not First then
|
||||
Write(T, '"');
|
||||
end;
|
||||
|
||||
|
||||
procedure TAsmNode.XMLPrintNodeData(var T: Text);
|
||||
|
||||
procedure PadString(var S: string; Len: Integer);
|
||||
|
||||
@ -288,7 +288,7 @@ interface
|
||||
begin
|
||||
location_reset(location,LOC_VOID,OS_NO);
|
||||
|
||||
if (nf_get_asm_position in flags) then
|
||||
if (asmnf_get_asm_position in asmnodeflags) then
|
||||
begin
|
||||
{ Add a marker, to be sure the list is not empty }
|
||||
current_asmdata.CurrAsmList.concat(tai_marker.create(mark_Position));
|
||||
@ -299,8 +299,8 @@ interface
|
||||
current_asmdata.CurrAsmList.Concat(tai_directive.create(asd_cpu,cputypestr[current_settings.asmcputype]));
|
||||
|
||||
{ Allocate registers used in the assembler block }
|
||||
{ has_registerlist=true means that registers are specified and already allocated }
|
||||
if (not has_registerlist) then
|
||||
{ asmnf_has_registerlist means that registers are specified and already allocated }
|
||||
if not (asmnf_has_registerlist in asmnodeflags) then
|
||||
cg.allocallcpuregisters(current_asmdata.CurrAsmList);
|
||||
|
||||
if (po_inline in current_procinfo.procdef.procoptions) then
|
||||
@ -431,7 +431,7 @@ interface
|
||||
end;
|
||||
|
||||
{ Release register used in the assembler block }
|
||||
if (not has_registerlist) then
|
||||
if not (asmnf_has_registerlist in asmnodeflags) then
|
||||
cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
|
||||
|
||||
{ Switch back to the CPU instruction set of the target CPU }
|
||||
|
||||
@ -260,9 +260,6 @@ interface
|
||||
{ tinlinenode }
|
||||
nf_inlineconst,
|
||||
|
||||
{ tasmnode }
|
||||
nf_get_asm_position,
|
||||
|
||||
{ tblocknode / this is not node-specific because it can also appear on
|
||||
implicit try/finally nodes }
|
||||
nf_block_with_exit,
|
||||
|
||||
@ -1099,7 +1099,8 @@ implementation
|
||||
|
||||
{ Force an empty register list for pure assembler routines,
|
||||
so that pass2 won't allocate volatile registers for them. }
|
||||
asmstat.has_registerlist:=(po_assembler in current_procinfo.procdef.procoptions);
|
||||
if Assigned(asmstat) and (po_assembler in current_procinfo.procdef.procoptions) then
|
||||
Include(asmstat.asmnodeflags, asmnf_has_registerlist);
|
||||
|
||||
{ END is read, got a list of changed registers? }
|
||||
if try_to_consume(_LECKKLAMMER) then
|
||||
@ -1139,7 +1140,8 @@ implementation
|
||||
if not try_to_consume(_COMMA) then
|
||||
break;
|
||||
until false;
|
||||
asmstat.has_registerlist:=true;
|
||||
if Assigned(asmstat) then
|
||||
Include(asmstat.asmnodeflags, asmnf_has_registerlist);
|
||||
end;
|
||||
consume(_RECKKLAMMER);
|
||||
end;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user