mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 20:09:27 +02:00
* support taking the address of labels defined in assembler blocks in the
LLVM code genrator (for the rtti unit's thunk hacking) git-svn-id: trunk@42969 -
This commit is contained in:
parent
cbe47848c2
commit
dcf4e4cb2c
@ -224,6 +224,7 @@ interface
|
|||||||
labeltype : TAsmLabelType;
|
labeltype : TAsmLabelType;
|
||||||
is_set : boolean;
|
is_set : boolean;
|
||||||
is_public : boolean;
|
is_public : boolean;
|
||||||
|
defined_in_asmstatement : boolean;
|
||||||
constructor Createlocal(AList: TFPHashObjectList; nr: longint; ltyp: TAsmLabelType);
|
constructor Createlocal(AList: TFPHashObjectList; nr: longint; ltyp: TAsmLabelType);
|
||||||
constructor Createstatic(AList: TFPHashObjectList; nr: longint; ltyp: TAsmLabelType);
|
constructor Createstatic(AList: TFPHashObjectList; nr: longint; ltyp: TAsmLabelType);
|
||||||
constructor Createglobal(AList: TFPHashObjectList; const modulename: TSymStr; nr: longint; ltyp: TAsmLabelType);
|
constructor Createglobal(AList: TFPHashObjectList; const modulename: TSymStr; nr: longint; ltyp: TAsmLabelType);
|
||||||
|
@ -973,8 +973,15 @@ implementation
|
|||||||
|
|
||||||
procedure TLLVMAssember.WriteTai(const replaceforbidden: boolean; const do_line, inmetadata: boolean; var InlineLevel: cardinal; var asmblock: boolean; var hp: tai);
|
procedure TLLVMAssember.WriteTai(const replaceforbidden: boolean; const do_line, inmetadata: boolean; var InlineLevel: cardinal; var asmblock: boolean; var hp: tai);
|
||||||
|
|
||||||
procedure WriteLinkageVibilityFlags(bind: TAsmSymBind);
|
procedure WriteLinkageVibilityFlags(bind: TAsmSymBind; is_definition: boolean);
|
||||||
begin
|
begin
|
||||||
|
{ re-declaration of a symbol defined in the current module (in an
|
||||||
|
assembler block) }
|
||||||
|
if not is_definition then
|
||||||
|
begin
|
||||||
|
writer.AsmWrite(' external');
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
case bind of
|
case bind of
|
||||||
AB_EXTERNAL,
|
AB_EXTERNAL,
|
||||||
AB_EXTERNAL_INDIRECT:
|
AB_EXTERNAL_INDIRECT:
|
||||||
@ -1297,7 +1304,7 @@ implementation
|
|||||||
writer.AsmWrite('define');
|
writer.AsmWrite('define');
|
||||||
if ldf_weak in taillvmdecl(hp).flags then
|
if ldf_weak in taillvmdecl(hp).flags then
|
||||||
writer.AsmWrite(' weak');
|
writer.AsmWrite(' weak');
|
||||||
WriteLinkageVibilityFlags(taillvmdecl(hp).namesym.bind);
|
WriteLinkageVibilityFlags(taillvmdecl(hp).namesym.bind, true);
|
||||||
writer.AsmWrite(llvmencodeproctype(tprocdef(taillvmdecl(hp).def), '', lpd_def));
|
writer.AsmWrite(llvmencodeproctype(tprocdef(taillvmdecl(hp).def), '', lpd_def));
|
||||||
WriteFunctionFlags(tprocdef(taillvmdecl(hp).def));
|
WriteFunctionFlags(tprocdef(taillvmdecl(hp).def));
|
||||||
if assigned(tprocdef(taillvmdecl(hp).def).personality) then
|
if assigned(tprocdef(taillvmdecl(hp).def).personality) then
|
||||||
@ -1319,7 +1326,7 @@ implementation
|
|||||||
writer.AsmWrite(' weak');
|
writer.AsmWrite(' weak');
|
||||||
if ldf_appending in taillvmdecl(hp).flags then
|
if ldf_appending in taillvmdecl(hp).flags then
|
||||||
writer.AsmWrite(' appending');
|
writer.AsmWrite(' appending');
|
||||||
WriteLinkageVibilityFlags(taillvmdecl(hp).namesym.bind);
|
WriteLinkageVibilityFlags(taillvmdecl(hp).namesym.bind, ldf_definition in taillvmdecl(hp).flags);
|
||||||
writer.AsmWrite(' ');
|
writer.AsmWrite(' ');
|
||||||
if (ldf_tls in taillvmdecl(hp).flags) then
|
if (ldf_tls in taillvmdecl(hp).flags) then
|
||||||
writer.AsmWrite('thread_local ');
|
writer.AsmWrite('thread_local ');
|
||||||
@ -1332,7 +1339,7 @@ implementation
|
|||||||
if not assigned(taillvmdecl(hp).initdata) then
|
if not assigned(taillvmdecl(hp).initdata) then
|
||||||
begin
|
begin
|
||||||
writer.AsmWrite(llvmencodetypename(taillvmdecl(hp).def));
|
writer.AsmWrite(llvmencodetypename(taillvmdecl(hp).def));
|
||||||
if not(taillvmdecl(hp).namesym.bind in [AB_EXTERNAL, AB_WEAK_EXTERNAL,AB_EXTERNAL_INDIRECT]) then
|
if ldf_definition in taillvmdecl(hp).flags then
|
||||||
writer.AsmWrite(' zeroinitializer');
|
writer.AsmWrite(' zeroinitializer');
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -1384,7 +1391,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
writer.AsmWrite(LlvmAsmSymName(taillvmalias(hp).newsym));
|
writer.AsmWrite(LlvmAsmSymName(taillvmalias(hp).newsym));
|
||||||
writer.AsmWrite(' = alias ');
|
writer.AsmWrite(' = alias ');
|
||||||
WriteLinkageVibilityFlags(taillvmalias(hp).bind);
|
WriteLinkageVibilityFlags(taillvmalias(hp).bind, true);
|
||||||
if taillvmalias(hp).def.typ=procdef then
|
if taillvmalias(hp).def.typ=procdef then
|
||||||
sstr:=llvmencodeproctype(tabstractprocdef(taillvmalias(hp).def), '', lpd_alias)
|
sstr:=llvmencodeproctype(tabstractprocdef(taillvmalias(hp).def), '', lpd_alias)
|
||||||
else
|
else
|
||||||
|
@ -794,12 +794,24 @@ implementation
|
|||||||
firstop,
|
firstop,
|
||||||
secondop: tllvmop;
|
secondop: tllvmop;
|
||||||
begin
|
begin
|
||||||
ai:=taillvm.blockaddress(voidcodepointertype,
|
if not assigned(l.asmblocklabel) or
|
||||||
current_asmdata.RefAsmSymbol(current_procinfo.procdef.mangledname,AT_FUNCTION),
|
not l.asmblocklabel.defined_in_asmstatement then
|
||||||
current_asmdata.RefAsmSymbol(l.mangledname,AT_LABEL)
|
begin
|
||||||
);
|
ai:=taillvm.blockaddress(voidcodepointertype,
|
||||||
emit_tai(ai,voidcodepointertype);
|
current_asmdata.RefAsmSymbol(current_procinfo.procdef.mangledname,AT_FUNCTION),
|
||||||
fqueue_offset:=low(fqueue_offset);
|
current_asmdata.RefAsmSymbol(l.mangledname,AT_LABEL)
|
||||||
|
);
|
||||||
|
emit_tai(ai,voidcodepointertype);
|
||||||
|
fqueue_offset:=low(fqueue_offset);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
{ we've already incorporated the offset via the inserted operations above,
|
||||||
|
make sure it doesn't get emitted again as part of the tai_const for
|
||||||
|
the tasmsymbol }
|
||||||
|
fqueue_offset:=0;
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1754,7 +1754,8 @@ Begin
|
|||||||
begin
|
begin
|
||||||
if tlabelsym(sym).defined then
|
if tlabelsym(sym).defined then
|
||||||
Message(sym_e_label_already_defined);
|
Message(sym_e_label_already_defined);
|
||||||
tlabelsym(sym).defined:=true
|
tlabelsym(sym).defined:=true;
|
||||||
|
hl.defined_in_asmstatement:=true
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
tlabelsym(sym).used:=true;
|
tlabelsym(sym).used:=true;
|
||||||
|
Loading…
Reference in New Issue
Block a user