From 991e1f49bd45aa595f7d880da7650c605430fc16 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sat, 12 Sep 2015 23:32:13 +0000 Subject: [PATCH] * store a pointer to the used tasminfo record in every assembler writer, so that we can use assembler writers with different conventions from the currently set target_asm (e.g. an x86 assembler writer for inline assembly in LLVM IR) git-svn-id: trunk@31628 - --- compiler/aarch64/agcpugas.pas | 27 ++++++++-------- compiler/aggas.pas | 16 +++++----- compiler/arm/agarmgas.pas | 15 +++++---- compiler/assemble.pas | 57 ++++++++++++++++++---------------- compiler/avr/agavrgas.pas | 9 +++--- compiler/jvm/agjasmin.pas | 28 ++++++++--------- compiler/llvm/agllvm.pas | 36 ++++++++++----------- compiler/m68k/ag68kgas.pas | 10 +++--- compiler/mips/cpugas.pas | 12 +++---- compiler/ogcoff.pas | 12 +++---- compiler/ogelf.pas | 6 ++-- compiler/ogmacho.pas | 6 ++-- compiler/ognlm.pas | 6 ++-- compiler/ogomf.pas | 6 ++-- compiler/powerpc/agppcmpw.pas | 12 +++---- compiler/powerpc/agppcvasm.pas | 12 +++---- compiler/ppcgen/agppcgas.pas | 45 +++++++++++++-------------- compiler/sparc/cpugas.pas | 10 +++--- compiler/x86/agx86att.pas | 22 ++++++------- compiler/x86/agx86int.pas | 36 ++++++++++----------- compiler/x86/agx86nsm.pas | 16 +++++----- 21 files changed, 198 insertions(+), 201 deletions(-) diff --git a/compiler/aarch64/agcpugas.pas b/compiler/aarch64/agcpugas.pas index e906163f97..fdc6d5ceaa 100644 --- a/compiler/aarch64/agcpugas.pas +++ b/compiler/aarch64/agcpugas.pas @@ -29,7 +29,7 @@ unit agcpugas; interface uses - globtype, + globtype,systems, aasmtai, aggas, cpubase,cpuinfo; @@ -40,11 +40,11 @@ unit agcpugas; end; TAArch64Assembler=class(TGNUassembler) - constructor create(smart: boolean); override; + constructor create(info: pasminfo; smart: boolean); override; end; TAArch64AppleAssembler=class(TAppleGNUassembler) - constructor create(smart: boolean); override; + constructor create(info: pasminfo; smart: boolean); override; function MakeCmdLine: TCmdStr; override; end; @@ -65,7 +65,6 @@ unit agcpugas; uses cutils,globals,verbose, - systems, assemble, aasmcpu, itcpugas, @@ -76,9 +75,9 @@ unit agcpugas; { AArch64 Assembler writer } {****************************************************************************} - constructor TAArch64Assembler.create(smart: boolean); + constructor TAArch64Assembler.create(info: pasminfo; smart: boolean); begin - inherited create(smart); + inherited; InstrWriter := TAArch64InstrWriter.create(self); end; @@ -86,9 +85,9 @@ unit agcpugas; { Apple AArch64 Assembler writer } {****************************************************************************} - constructor TAArch64AppleAssembler.create(smart: boolean); + constructor TAArch64AppleAssembler.create(info: pasminfo; smart: boolean); begin - inherited create(smart); + inherited; InstrWriter := TAArch64InstrWriter.create(self); end; @@ -109,7 +108,7 @@ unit agcpugas; { Helper routines for Instruction Writer } {****************************************************************************} - function getreferencestring(var ref : treference) : string; + function getreferencestring(asminfo: pasminfo; var ref : treference) : string; const darwin_addrpage2str: array[addr_page..addr_gotpageoffset] of string[11] = ('@PAGE','@PAGEOFF','@GOTPAGE','@GOTPAGEOFF'); @@ -130,7 +129,7 @@ unit agcpugas; (ref.shiftmode<>SM_None) or (ref.offset<>0) then internalerror(2014121501); - if target_asm.id=as_darwin then + if asminfo^.id=as_darwin then result:=ref.symbol.name+darwin_addrpage2str[ref.refaddr] else result:=linux_addrpage2str[ref.refaddr]+ref.symbol.name @@ -172,7 +171,7 @@ unit agcpugas; addr_gotpageoffset, addr_pageoffset: begin - if target_asm.id=as_darwin then + if asminfo^.id=as_darwin then result:=result+', '+ref.symbol.name+darwin_addrpage2str[ref.refaddr] else result:=result+', '+linux_addrpage2str[ref.refaddr]+ref.symbol.name @@ -200,7 +199,7 @@ unit agcpugas; end; - function getopstr(hp: taicpu; opnr: longint; const o: toper): string; + function getopstr(asminfo: pasminfo; hp: taicpu; opnr: longint; const o: toper): string; begin case o.typ of top_reg: @@ -248,7 +247,7 @@ unit agcpugas; getopstr:=o.ref^.symbol.name; end else - getopstr:=getreferencestring(o.ref^); + getopstr:=getreferencestring(asminfo,o.ref^); else internalerror(2014121507); end; @@ -274,7 +273,7 @@ unit agcpugas; // debug code // writeln(s); // writeln(taicpu(hp).fileinfo.line); - s:=s+sep+getopstr(taicpu(hp),i,taicpu(hp).oper[i]^); + s:=s+sep+getopstr(owner.asminfo,taicpu(hp),i,taicpu(hp).oper[i]^); sep:=','; end; end; diff --git a/compiler/aggas.pas b/compiler/aggas.pas index 3554338cdc..b651461524 100644 --- a/compiler/aggas.pas +++ b/compiler/aggas.pas @@ -175,7 +175,7 @@ implementation function TGNUAssembler.NextSetLabel: string; begin inc(setcount); - result := target_asm.labelprefix+'$set$'+tostr(setcount); + result := asminfo^.labelprefix+'$set$'+tostr(setcount); end; function is_smart_section(atype:TAsmSectiontype):boolean; @@ -636,7 +636,7 @@ implementation begin if not assigned(p) then exit; - replaceforbidden:=target_asm.dollarsign<>'$'; + replaceforbidden:=asminfo^.dollarsign<>'$'; last_align := 2; InlineLevel:=0; @@ -661,7 +661,7 @@ implementation ait_comment : Begin - writer.AsmWrite(target_asm.comment); + writer.AsmWrite(asminfo^.comment); writer.AsmWritePChar(tai_comment(hp).str); writer.AsmLn; End; @@ -670,7 +670,7 @@ implementation begin if (cs_asm_regalloc in current_settings.globalswitches) then begin - writer.AsmWrite(#9+target_asm.comment+'Register '); + writer.AsmWrite(#9+asminfo^.comment+'Register '); repeat writer.AsmWrite(std_regname(Tai_regalloc(hp).reg)); if (hp.next=nil) or @@ -706,7 +706,7 @@ implementation else begin {$ifdef EXTDEBUG} - writer.AsmWrite(target_asm.comment); + writer.AsmWrite(asminfo^.comment); writer.AsmWriteln(' sec_none'); {$endif EXTDEBUG} end; @@ -1212,7 +1212,7 @@ implementation begin if tf_needs_symbol_size in target_info.flags then begin - s:=target_asm.labelprefix+'e'+tostr(symendcount); + s:=asminfo^.labelprefix+'e'+tostr(symendcount); inc(symendcount); writer.AsmWriteLn(s+':'); writer.AsmWrite(#9'.size'#9); @@ -1558,9 +1558,9 @@ implementation begin if not (current_asmdata.asmlists[hal].empty) then begin - writer.AsmWriteLn(target_asm.comment+'Begin asmlist '+AsmlistTypeStr[hal]); + writer.AsmWriteLn(asminfo^.comment+'Begin asmlist '+AsmlistTypeStr[hal]); writetree(current_asmdata.asmlists[hal]); - writer.AsmWriteLn(target_asm.comment+'End asmlist '+AsmlistTypeStr[hal]); + writer.AsmWriteLn(asminfo^.comment+'End asmlist '+AsmlistTypeStr[hal]); end; end; diff --git a/compiler/arm/agarmgas.pas b/compiler/arm/agarmgas.pas index 21ef82618c..a94bb9eb43 100644 --- a/compiler/arm/agarmgas.pas +++ b/compiler/arm/agarmgas.pas @@ -29,14 +29,14 @@ unit agarmgas; interface uses - globtype, + globtype,systems, aasmtai, aggas, cpubase,cpuinfo; type TARMGNUAssembler=class(TGNUassembler) - constructor create(smart: boolean); override; + constructor create(info: pasminfo; smart: boolean); override; function MakeCmdLine: TCmdStr; override; procedure WriteExtraHeader; override; end; @@ -46,7 +46,7 @@ unit agarmgas; end; TArmAppleGNUAssembler=class(TAppleGNUassembler) - constructor create(smart: boolean); override; + constructor create(info: pasminfo; smart: boolean); override; end; @@ -79,7 +79,6 @@ unit agarmgas; uses cutils,globals,verbose, - systems, assemble, aasmcpu, itcpugas, @@ -89,9 +88,9 @@ unit agarmgas; { GNU Arm Assembler writer } {****************************************************************************} - constructor TArmGNUAssembler.create(smart: boolean); + constructor TArmGNUAssembler.create(info: pasminfo; smart: boolean); begin - inherited create(smart); + inherited; InstrWriter := TArmInstrWriter.create(self); end; @@ -135,9 +134,9 @@ unit agarmgas; { GNU/Apple ARM Assembler writer } {****************************************************************************} - constructor TArmAppleGNUAssembler.create(smart: boolean); + constructor TArmAppleGNUAssembler.create(info: pasminfo; smart: boolean); begin - inherited create(smart); + inherited; InstrWriter := TArmInstrWriter.create(self); end; diff --git a/compiler/assemble.pas b/compiler/assemble.pas index 1b949b1a6f..02a6d1d4d9 100644 --- a/compiler/assemble.pas +++ b/compiler/assemble.pas @@ -44,6 +44,8 @@ interface type TAssembler=class(TObject) public + {assembler info} + asminfo : pasminfo; {filenames} path : TPathStr; name : string; @@ -54,7 +56,7 @@ interface SmartAsm : boolean; SmartFilesCount, SmartHeaderCount : longint; - Constructor Create(smart:boolean);virtual; + Constructor Create(info: pasminfo; smart:boolean);virtual; Destructor Destroy;override; procedure NextSmartName(place:tcutplace); procedure MakeObject;virtual;abstract; @@ -183,8 +185,8 @@ interface {# Constructs the command line for calling the assembler } function MakeCmdLine: TCmdStr; virtual; public - Constructor Create(smart:boolean);override; - Constructor CreateWithWriter(wr: TExternalAssemblerOutputFile; freewriter, smart: boolean); + Constructor Create(info: pasminfo; smart: boolean);override; + Constructor CreateWithWriter(info: pasminfo; wr: TExternalAssemblerOutputFile; freewriter, smart: boolean); procedure MakeObject;override; destructor Destroy; override; @@ -218,7 +220,7 @@ interface property CObjOutput:TObjOutputclass read FCObjOutput write FCObjOutput; property CInternalAr : TObjectWriterClass read FCInternalAr write FCInternalAr; public - constructor create(smart:boolean);override; + constructor Create(info: pasminfo; smart: boolean);override; destructor destroy;override; procedure MakeObject;override; end; @@ -274,8 +276,9 @@ Implementation TAssembler *****************************************************************************} - Constructor TAssembler.Create(smart:boolean); + Constructor TAssembler.Create(info: pasminfo; smart: boolean); begin + asminfo:=info; { load start values } AsmFileName:=current_module.AsmFilename; ObjFileName:=current_module.ObjFileName; @@ -724,13 +727,13 @@ Implementation begin DoPipe:=(cs_asm_pipe in current_settings.globalswitches) and (([cs_asm_extern,cs_asm_leave,cs_link_on_target] * current_settings.globalswitches) = []) and - ((target_asm.id in [as_gas,as_ggas,as_darwin,as_powerpc_xcoff])); + ((asminfo^.id in [as_gas,as_ggas,as_darwin,as_powerpc_xcoff])); end; - Constructor TExternalAssembler.Create(smart:boolean); + Constructor TExternalAssembler.Create(info: pasminfo; smart: boolean); begin - inherited create(smart); + inherited; if not assigned(fwriter) then begin fwriter:=TExternalAssemblerOutputFile.Create(self); @@ -744,11 +747,11 @@ Implementation end; - constructor TExternalAssembler.CreateWithWriter(wr: TExternalAssemblerOutputFile; freewriter,smart: boolean); + constructor TExternalAssembler.CreateWithWriter(info: pasminfo; wr: TExternalAssemblerOutputFile; freewriter,smart: boolean); begin fwriter:=wr; ffreewriter:=freewriter; - Create(smart); + Create(info,smart); end; @@ -802,14 +805,14 @@ Implementation if cs_link_on_target in current_settings.globalswitches then begin { If linking on target, don't add any path PM } - FindAssembler:=utilsprefix+ChangeFileExt(target_asm.asmbin,target_info.exeext); + FindAssembler:=utilsprefix+ChangeFileExt(asminfo^.asmbin,target_info.exeext); exit; end else - UtilExe:=utilsprefix+ChangeFileExt(target_asm.asmbin,source_info.exeext); - if lastas<>ord(target_asm.id) then + UtilExe:=utilsprefix+ChangeFileExt(asminfo^.asmbin,source_info.exeext); + if lastas<>ord(asminfo^.id) then begin - lastas:=ord(target_asm.id); + lastas:=ord(asminfo^.id); { is an assembler passed ? } if utilsdirectory<>'' then asfound:=FindFile(UtilExe,utilsdirectory,false,LastASBin); @@ -886,7 +889,7 @@ Implementation function TExternalAssembler.MakeCmdLine: TCmdStr; begin - result:=target_asm.asmcmd; + result:=asminfo^.asmcmd; {$ifdef arm} if (target_info.system=system_arm_darwin) then Replace(result,'$ARCH',lower(cputypestr[current_settings.cputype])); @@ -955,7 +958,7 @@ Implementation begin if (infile<>lastinfile) then begin - writer.AsmWriteLn(target_asm.comment+'['+infile.name+']'); + writer.AsmWriteLn(asminfo^.comment+'['+infile.name+']'); if assigned(lastinfile) then lastinfile.close; end; @@ -964,7 +967,7 @@ Implementation begin if (hp.fileinfo.line<>0) and (infile.linebuf^[hp.fileinfo.line]>=0) then - writer.AsmWriteLn(target_asm.comment+'['+tostr(hp.fileinfo.line)+'] '+ + writer.AsmWriteLn(asminfo^.comment+'['+tostr(hp.fileinfo.line)+'] '+ fixline(infile.GetLineStr(hp.fileinfo.line))); { set it to a negative value ! to make that is has been read already !! PM } @@ -980,11 +983,11 @@ Implementation begin {$ifdef EXTDEBUG} if assigned(hp.problem) then - writer.AsmWriteLn(target_asm.comment+'Temp '+tostr(hp.temppos)+','+ + writer.AsmWriteLn(asminfo^.comment+'Temp '+tostr(hp.temppos)+','+ tostr(hp.tempsize)+' '+hp.problem^) else {$endif EXTDEBUG} - writer.AsmWriteLn(target_asm.comment+'Temp '+tostr(hp.temppos)+','+ + writer.AsmWriteLn(asminfo^.comment+'Temp '+tostr(hp.temppos)+','+ tostr(hp.tempsize)+' '+tempallocstr[hp.allocation]); end; @@ -1004,16 +1007,16 @@ Implementation begin case tai_realconst(hp).realtyp of aitrealconst_s32bit: - writer.AsmWriteLn(target_asm.comment+'value: '+single2str(tai_realconst(hp).value.s32val)); + writer.AsmWriteLn(asminfo^.comment+'value: '+single2str(tai_realconst(hp).value.s32val)); aitrealconst_s64bit: - writer.AsmWriteLn(target_asm.comment+'value: '+double2str(tai_realconst(hp).value.s64val)); + writer.AsmWriteLn(asminfo^.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: - writer.AsmWriteLn(target_asm.comment+'value: '+extended2str(tai_realconst(hp).value.s80val)); + writer.AsmWriteLn(asminfo^.comment+'value: '+extended2str(tai_realconst(hp).value.s80val)); {$endif cpuextended} aitrealconst_s64comp: - writer.AsmWriteLn(target_asm.comment+'value: '+extended2str(tai_realconst(hp).value.s64compval)); + writer.AsmWriteLn(asminfo^.comment+'value: '+extended2str(tai_realconst(hp).value.s64compval)); else internalerror(2014050604); end; @@ -1127,9 +1130,9 @@ Implementation TInternalAssembler *****************************************************************************} - constructor TInternalAssembler.create(smart:boolean); + constructor TInternalAssembler.Create(info: pasminfo; smart: boolean); begin - inherited create(smart); + inherited; ObjOutput:=nil; ObjData:=nil; SmartAsm:=smart; @@ -2007,7 +2010,7 @@ Implementation startsecorder: TAsmSectionOrder; begin if not(cs_asm_leave in current_settings.globalswitches) and - not(af_needar in target_asm.flags) then + not(af_needar in asminfo^.flags) then ObjWriter:=CInternalAr.CreateAr(current_module.staticlibfilename) else ObjWriter:=TObjectwriter.create; @@ -2151,7 +2154,7 @@ Implementation begin if not assigned(CAssembler[target_asm.id]) then Message(asmw_f_assembler_output_not_supported); - a:=CAssembler[target_asm.id].Create(smart); + a:=CAssembler[target_asm.id].Create(@target_asm,smart); a.MakeObject; a.Free; end; diff --git a/compiler/avr/agavrgas.pas b/compiler/avr/agavrgas.pas index 9aafe9804b..79ea88038e 100644 --- a/compiler/avr/agavrgas.pas +++ b/compiler/avr/agavrgas.pas @@ -29,7 +29,7 @@ unit agavrgas; interface uses - globtype, + globtype,systems, aasmtai,aasmdata, aggas, cpubase; @@ -39,7 +39,7 @@ unit agavrgas; { TAVRGNUAssembler } TAVRGNUAssembler=class(TGNUassembler) - constructor create(smart: boolean); override; + constructor create(info: pasminfo; smart: boolean); override; function MakeCmdLine: TCmdStr; override; end; @@ -52,7 +52,6 @@ unit agavrgas; uses cutils,globals,verbose, - systems, assemble, aasmbase,aasmcpu, itcpugas, @@ -63,9 +62,9 @@ unit agavrgas; { GNU Arm Assembler writer } {****************************************************************************} - constructor TAVRGNUAssembler.create(smart: boolean); + constructor TAVRGNUAssembler.create(info: pasminfo; smart: boolean); begin - inherited create(smart); + inherited; InstrWriter := TAVRInstrWriter.create(self); end; diff --git a/compiler/jvm/agjasmin.pas b/compiler/jvm/agjasmin.pas index faa69702fe..c639b3ba19 100644 --- a/compiler/jvm/agjasmin.pas +++ b/compiler/jvm/agjasmin.pas @@ -28,7 +28,7 @@ unit agjasmin; interface uses - cclasses, + cclasses,systems, globtype,globals, symconst,symbase,symdef,symsym, aasmbase,aasmtai,aasmdata,aasmcpu, @@ -70,7 +70,7 @@ interface procedure WriteSymtableProcdefs(st: TSymtable); procedure WriteSymtableStructDefs(st: TSymtable); public - constructor Create(smart: boolean); override; + constructor Create(info: pasminfo; smart: boolean); override; function MakeCmdLine: TCmdStr;override; procedure WriteTree(p:TAsmList);override; procedure WriteAsmList;override; @@ -101,7 +101,7 @@ implementation uses SysUtils, - cutils,cfileutl,systems,script, + cutils,cfileutl,script, fmodule,finput,verbose, symtype,symcpu,symtable,jvmdef, itcpujas,cpubase,cpuinfo,cgutils, @@ -336,7 +336,7 @@ implementation begin if (infile<>lastinfile) then begin - writer.AsmWriteLn(target_asm.comment+'['+infile.name+']'); + writer.AsmWriteLn(asminfo^.comment+'['+infile.name+']'); if assigned(lastinfile) then lastinfile.close; end; @@ -345,7 +345,7 @@ implementation begin if (hp1.fileinfo.line<>0) and ((infile.linebuf^[hp1.fileinfo.line]>=0) or (InlineLevel>0)) then - writer.AsmWriteLn(target_asm.comment+'['+tostr(hp1.fileinfo.line)+'] '+ + writer.AsmWriteLn(asminfo^.comment+'['+tostr(hp1.fileinfo.line)+'] '+ fixline(infile.GetLineStr(hp1.fileinfo.line))); { set it to a negative value ! to make that is has been read already !! PM } @@ -362,7 +362,7 @@ implementation ait_comment : Begin - writer.AsmWrite(target_asm.comment); + writer.AsmWrite(asminfo^.comment); writer.AsmWritePChar(tai_comment(hp).str); writer.AsmLn; End; @@ -371,7 +371,7 @@ implementation begin if (cs_asm_regalloc in current_settings.globalswitches) then begin - writer.AsmWrite(#9+target_asm.comment+'Register '); + writer.AsmWrite(#9+asminfo^.comment+'Register '); repeat writer.AsmWrite(std_regname(Tai_regalloc(hp).reg)); if (hp.next=nil) or @@ -392,11 +392,11 @@ implementation begin {$ifdef EXTDEBUG} if assigned(tai_tempalloc(hp).problem) then - writer.AsmWriteLn(target_asm.comment+'Temp '+tostr(tai_tempalloc(hp).temppos)+','+ + writer.AsmWriteLn(asminfo^.comment+'Temp '+tostr(tai_tempalloc(hp).temppos)+','+ tostr(tai_tempalloc(hp).tempsize)+' '+tai_tempalloc(hp).problem^) else {$endif EXTDEBUG} - writer.AsmWriteLn(target_asm.comment+'Temp '+tostr(tai_tempalloc(hp).temppos)+','+ + writer.AsmWriteLn(asminfo^.comment+'Temp '+tostr(tai_tempalloc(hp).temppos)+','+ tostr(tai_tempalloc(hp).tempsize)+' '+tempallocstr[tai_tempalloc(hp).allocation]); end; end; @@ -686,7 +686,7 @@ implementation if jasminjarfound then Message1(exec_t_using_assembler,jasminjar); end; - result:=target_asm.asmcmd; + result:=asminfo^.asmcmd; filenames:=ScriptFixFileName(AsmFileName); if cs_asm_extern in current_settings.globalswitches then filenames:=maybequoted(filenames); @@ -1078,9 +1078,9 @@ implementation nestedstructs.free; end; - constructor TJasminAssembler.Create(smart: boolean); + constructor TJasminAssembler.Create(info: pasminfo; smart: boolean); begin - inherited CreateWithWriter(TJasminAssemblerOutputFile.Create(self),true,smart); + inherited CreateWithWriter(info,TJasminAssemblerOutputFile.Create(self),true,smart); InstrWriter:=TJasminInstrWriter.Create(self); asmfiles:=TCmdStrList.Create; end; @@ -1098,9 +1098,9 @@ implementation (* for hal:=low(TasmlistType) to high(TasmlistType) do begin - writer.AsmWriteLn(target_asm.comment+'Begin asmlist '+AsmlistTypeStr[hal]); + writer.AsmWriteLn(asminfo^.comment+'Begin asmlist '+AsmlistTypeStr[hal]); writetree(current_asmdata.asmlists[hal]); - writer.AsmWriteLn(target_asm.comment+'End asmlist '+AsmlistTypeStr[hal]); + writer.AsmWriteLn(asminfo^.comment+'End asmlist '+AsmlistTypeStr[hal]); end; *) { print all global variables } diff --git a/compiler/llvm/agllvm.pas b/compiler/llvm/agllvm.pas index 0c7925daf6..233710ba83 100644 --- a/compiler/llvm/agllvm.pas +++ b/compiler/llvm/agllvm.pas @@ -26,7 +26,7 @@ unit agllvm; interface uses - globtype,globals, + globtype,globals,systems, aasmbase,aasmtai,aasmdata, assemble; @@ -46,7 +46,7 @@ interface procedure WriteOrdConst(hp: tai_const); procedure WriteTai(const replaceforbidden: boolean; const do_line: boolean; var InlineLevel: cardinal; var asmblock: boolean; var hp: tai); public - constructor create(smart: boolean); override; + constructor create(info: pasminfo; smart: boolean); override; function MakeCmdLine: TCmdStr; override; procedure WriteTree(p:TAsmList);override; procedure WriteAsmList;override; @@ -77,7 +77,7 @@ implementation uses SysUtils, - cutils,cfileutl,systems, + cutils,cfileutl, fmodule,verbose, aasmcnst,symconst,symdef,symtable, llvmbase,aasmllvm,itllvm,llvmdef, @@ -519,7 +519,7 @@ implementation begin if not assigned(p) then exit; - replaceforbidden:=target_asm.dollarsign<>'$'; + replaceforbidden:=asminfo^.dollarsign<>'$'; InlineLevel:=0; asmblock:=false; @@ -580,16 +580,16 @@ implementation begin case tai_realconst(hp).realtyp of aitrealconst_s32bit: - writer.AsmWriteLn(target_asm.comment+'value: '+single2str(tai_realconst(hp).value.s32val)); + writer.AsmWriteLn(asminfo^.comment+'value: '+single2str(tai_realconst(hp).value.s32val)); aitrealconst_s64bit: - writer.AsmWriteLn(target_asm.comment+'value: '+double2str(tai_realconst(hp).value.s64val)); + writer.AsmWriteLn(asminfo^.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: - writer.AsmWriteLn(target_asm.comment+'value: '+extended2str(tai_realconst(hp).value.s80val)); + writer.AsmWriteLn(asminfo^.comment+'value: '+extended2str(tai_realconst(hp).value.s80val)); {$endif cpuextended} aitrealconst_s64comp: - writer.AsmWriteLn(target_asm.comment+'value: '+extended2str(tai_realconst(hp).value.s64compval)); + writer.AsmWriteLn(asminfo^.comment+'value: '+extended2str(tai_realconst(hp).value.s64compval)); else internalerror(2014050604); end; @@ -617,7 +617,7 @@ implementation consttyp: taiconst_type; begin if fdecllevel=0 then - writer.AsmWrite(target_asm.comment+' const '); + writer.AsmWrite(asminfo^.comment+' const '); consttyp:=hp.consttype; case consttyp of aitconst_got, @@ -641,7 +641,7 @@ implementation aitconst_64bit_unaligned: begin if fdecllevel=0 then - writer.AsmWrite(target_asm.comment); + writer.AsmWrite(asminfo^.comment); { can't have compile-time differences between symbols; these are normally for PIC, but llvm takes care of that for us } if assigned(hp.endsym) then @@ -758,7 +758,7 @@ implementation case hp.typ of ait_comment : begin - writer.AsmWrite(target_asm.comment); + writer.AsmWrite(asminfo^.comment); writer.AsmWritePChar(tai_comment(hp).str); if fdecllevel<>0 then internalerror(2015090601); @@ -769,7 +769,7 @@ implementation begin if (cs_asm_regalloc in current_settings.globalswitches) then begin - writer.AsmWrite(#9+target_asm.comment+'Register '); + writer.AsmWrite(#9+asminfo^.comment+'Register '); repeat writer.AsmWrite(std_regname(Tai_regalloc(hp).reg)); if (hp.next=nil) or @@ -800,7 +800,7 @@ implementation ait_datablock : begin - writer.AsmWrite(target_asm.comment); + writer.AsmWrite(asminfo^.comment); writer.AsmWriteln('datablock'); end; @@ -817,7 +817,7 @@ implementation ait_string : begin if fdecllevel=0 then - writer.AsmWrite(target_asm.comment); + writer.AsmWrite(asminfo^.comment); writer.AsmWrite('c"'); for i:=1 to tai_string(hp).len do begin @@ -850,7 +850,7 @@ implementation begin { should be emitted as part of the variable/function def } //internalerror(2013010704); - writer.AsmWriteln(target_asm.comment+'global/privateextern label: '+tai_label(hp).labsym.name); + writer.AsmWriteln(asminfo^.comment+'global/privateextern label: '+tai_label(hp).labsym.name); end; if replaceforbidden then writer.AsmWrite(ReplaceForbiddenAsmSymbolChars(tai_label(hp).labsym.name)) @@ -863,7 +863,7 @@ implementation ait_symbol : begin if fdecllevel=0 then - writer.AsmWrite(target_asm.comment); + writer.AsmWrite(asminfo^.comment); writer.AsmWriteln(LlvmAsmSymName(tai_symbol(hp).sym)); { todo } if tai_symbol(hp).has_value then @@ -1056,9 +1056,9 @@ implementation end; - constructor TLLVMAssember.create(smart: boolean); + constructor TLLVMAssember.create(info: pasminfo; smart: boolean); begin - inherited create(smart); + inherited; InstrWriter:=TLLVMInstrWriter.create(self); end; diff --git a/compiler/m68k/ag68kgas.pas b/compiler/m68k/ag68kgas.pas index 2db0ca2db1..d652d41b29 100644 --- a/compiler/m68k/ag68kgas.pas +++ b/compiler/m68k/ag68kgas.pas @@ -26,13 +26,13 @@ unit ag68kgas; interface uses - cclasses,cpubase, + cclasses,cpubase,systems, globals,globtype, aasmbase,aasmtai,aasmdata,aasmcpu,assemble,aggas; type Tm68kGNUAssembler=class(TGNUassembler) - constructor create(smart: boolean); override; + constructor create(info: pasminfo; smart: boolean); override; function MakeCmdLine : TCmdStr; override; end; @@ -49,7 +49,7 @@ interface implementation uses - cutils,systems, + cutils, cgbase,cgutils,cpuinfo, verbose,itcpugas; @@ -58,9 +58,9 @@ interface { GNU m68k Assembler writer } {****************************************************************************} - constructor Tm68kGNUAssembler.create(smart: boolean); + constructor Tm68kGNUAssembler.create(info: pasminfo; smart: boolean); begin - inherited create(smart); + inherited; InstrWriter := Tm68kInstrWriter.create(self); end; diff --git a/compiler/mips/cpugas.pas b/compiler/mips/cpugas.pas index 3e3a595b02..afbda424f9 100644 --- a/compiler/mips/cpugas.pas +++ b/compiler/mips/cpugas.pas @@ -26,13 +26,13 @@ unit cpugas; interface uses - cpubase, aasmbase, globtype, + cpubase, aasmbase, globtype, systems, aasmtai, aasmcpu, assemble, aggas; type TMIPSGNUAssembler = class(TGNUassembler) nomacro, noreorder, noat : boolean; - constructor create(smart: boolean); override; + constructor create(info: pasminfo; smart: boolean); override; {# Constructs the command line for calling the assembler } function MakeCmdLine: TCmdStr; override; end; @@ -52,7 +52,7 @@ unit cpugas; implementation uses - cutils, systems, cpuinfo, + cutils, cpuinfo, globals, verbose, itcpugas, cgbase, cgutils; @@ -69,10 +69,10 @@ unit cpugas; { GNU MIPS Assembler writer } {****************************************************************************} - constructor TMIPSGNUAssembler.create(smart: boolean); + constructor TMIPSGNUAssembler.create(info: pasminfo; smart: boolean); begin - inherited create(smart); - InstrWriter := TMIPSInstrWriter.create(self); + inherited; + InstrWriter:=TMIPSInstrWriter.create(self); nomacro:=false; noreorder:=false; noat:=false; diff --git a/compiler/ogcoff.pas b/compiler/ogcoff.pas index 8cb6aa007d..d380047453 100644 --- a/compiler/ogcoff.pas +++ b/compiler/ogcoff.pas @@ -243,11 +243,11 @@ interface TObjSectionArray = array[0..high(smallint)] of TObjSection; TDJCoffAssembler = class(tinternalassembler) - constructor create(smart:boolean);override; + constructor create(info: pasminfo; smart:boolean);override; end; TPECoffassembler = class(tinternalassembler) - constructor create(smart:boolean);override; + constructor create(info: pasminfo; smart:boolean);override; end; @@ -2843,9 +2843,9 @@ const pemagic : array[0..3] of byte = ( TDJCoffAssembler ****************************************************************************} - constructor TDJCoffAssembler.Create(smart:boolean); + constructor TDJCoffAssembler.Create(info: pasminfo; smart:boolean); begin - inherited Create(smart); + inherited; CObjOutput:=TDJCoffObjOutput; CInternalAr:=tarobjectwriter; end; @@ -2855,9 +2855,9 @@ const pemagic : array[0..3] of byte = ( TPECoffAssembler ****************************************************************************} - constructor TPECoffAssembler.Create(smart:boolean); + constructor TPECoffAssembler.Create(info: pasminfo; smart:boolean); begin - inherited Create(smart); + inherited; CObjOutput:=TPECoffObjOutput; CInternalAr:=tarobjectwriter; end; diff --git a/compiler/ogelf.pas b/compiler/ogelf.pas index 99f6af9764..1d42396821 100644 --- a/compiler/ogelf.pas +++ b/compiler/ogelf.pas @@ -104,7 +104,7 @@ interface end; TElfAssembler = class(tinternalassembler) - constructor create(smart:boolean);override; + constructor create(info: pasminfo; smart:boolean);override; end; PSectionRec=^TSectionRec; @@ -1301,9 +1301,9 @@ implementation TELFAssembler ****************************************************************************} - constructor TElfAssembler.Create(smart:boolean); + constructor TElfAssembler.Create(info: pasminfo; smart:boolean); begin - inherited Create(smart); + inherited; CObjOutput:=TElfObjectOutput; CInternalAr:=tarobjectwriter; end; diff --git a/compiler/ogmacho.pas b/compiler/ogmacho.pas index 62d5c25706..2b54875efb 100644 --- a/compiler/ogmacho.pas +++ b/compiler/ogmacho.pas @@ -146,7 +146,7 @@ type TMachoAssembler=class(TInternalAssembler) public - constructor create(smart:boolean);override; + constructor create(info: pasminfo; smart:boolean);override; end; @@ -354,9 +354,9 @@ uses { TMachoAssembler } - constructor TMachoAssembler.create(smart: boolean); + constructor TMachoAssembler.create(info: pasminfo; smart: boolean); begin - inherited create(smart); + inherited; CObjOutput:=TMachoObjectOutput; CInternalAr:=tarobjectwriter; end; diff --git a/compiler/ognlm.pas b/compiler/ognlm.pas index 7e4db43175..2a7496e091 100644 --- a/compiler/ognlm.pas +++ b/compiler/ognlm.pas @@ -302,7 +302,7 @@ const NLM_MAX_DESCRIPTION_LENGTH = 127; end; TNLMCoffassembler = class(tinternalassembler) - constructor create(smart:boolean);override; + constructor create(info: pasminfo; smart:boolean);override; end; TNLMCoffObjData = class(TCoffObjData) @@ -1471,9 +1471,9 @@ function SecOpts(SecOptions:TObjSectionOptions):string; TDJCoffAssembler ****************************************************************************} - constructor TNLMCoffAssembler.Create(smart:boolean); + constructor TNLMCoffAssembler.Create(info: pasminfo; smart:boolean); begin - inherited Create(smart); + inherited; CObjOutput:=TNLMCoffObjOutput; CInternalAr:=tarobjectwriter; end; diff --git a/compiler/ogomf.pas b/compiler/ogomf.pas index 14e0560738..affaca05eb 100644 --- a/compiler/ogomf.pas +++ b/compiler/ogomf.pas @@ -304,7 +304,7 @@ interface end; TOmfAssembler = class(tinternalassembler) - constructor create(smart:boolean);override; + constructor create(info: pasminfo; smart:boolean);override; end; implementation @@ -2534,9 +2534,9 @@ implementation TOmfAssembler ****************************************************************************} - constructor TOmfAssembler.Create(smart:boolean); + constructor TOmfAssembler.Create(info: pasminfo; smart:boolean); begin - inherited Create(smart); + inherited; CObjOutput:=TOmfObjOutput; CInternalAr:=TOmfLibObjectWriter; end; diff --git a/compiler/powerpc/agppcmpw.pas b/compiler/powerpc/agppcmpw.pas index d41f76902e..e90f28fd1d 100644 --- a/compiler/powerpc/agppcmpw.pas +++ b/compiler/powerpc/agppcmpw.pas @@ -734,7 +734,7 @@ interface case hp.typ of ait_comment: begin - writer.AsmWrite(target_asm.comment); + writer.AsmWrite(asminfo^.comment); writer.AsmWritePChar(tai_comment(hp).str); writer.AsmLn; end; @@ -744,7 +744,7 @@ interface ait_section: begin {if LastSecType<>sec_none then - writer.AsmWriteLn('_'+target_asm.secnames[LastSecType]+#9#9'ENDS');} + writer.AsmWriteLn('_'+asminfo^.secnames[LastSecType]+#9#9'ENDS');} if tai_section(hp).sectype<>sec_none then begin @@ -911,7 +911,7 @@ interface (* ait_real_64bit : begin - writer.AsmWriteLn(target_asm.comment+'value: '+double2str(tai_real_64bit(hp).value)); + writer.AsmWriteLn(asminfo^.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 @@ -930,7 +930,7 @@ interface ait_real_32bit : begin - writer.AsmWriteLn(target_asm.comment+'value: '+single2str(tai_real_32bit(hp).value)); + writer.AsmWriteLn(asminfo^.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 @@ -1221,9 +1221,9 @@ interface for hal:=low(TasmlistType) to high(TasmlistType) do begin - writer.AsmWriteLn(target_asm.comment+'Begin asmlist '+AsmListTypeStr[hal]); + writer.AsmWriteLn(asminfo^.comment+'Begin asmlist '+AsmListTypeStr[hal]); writetree(current_asmdata.asmlists[hal]); - writer.AsmWriteLn(target_asm.comment+'End asmlist '+AsmListTypeStr[hal]); + writer.AsmWriteLn(asminfo^.comment+'End asmlist '+AsmListTypeStr[hal]); end; writer.AsmWriteLn(#9'end'); diff --git a/compiler/powerpc/agppcvasm.pas b/compiler/powerpc/agppcvasm.pas index 110e27cc42..57632171c9 100644 --- a/compiler/powerpc/agppcvasm.pas +++ b/compiler/powerpc/agppcvasm.pas @@ -31,7 +31,7 @@ unit agppcvasm; interface uses - aasmbase, + aasmbase,systems, aasmtai,aasmdata, aggas, cpubase,cgutils, @@ -43,7 +43,7 @@ unit agppcvasm; end; TPPCVASM=class(TGNUassembler) - constructor create(smart: boolean); override; + constructor create(info: pasminfo; smart: boolean); override; function MakeCmdLine: TCmdStr; override; end; @@ -59,7 +59,7 @@ unit agppcvasm; uses cutils,cfileutl,globals,verbose, - cgbase,systems, + cgbase, assemble,script, itcpugas,cpuinfo, aasmcpu; @@ -359,15 +359,15 @@ unit agppcvasm; {****************************************************************************} - constructor TPPCVASM.create(smart: boolean); + constructor TPPCVASM.create(info: pasminfo; smart: boolean); begin - inherited create(smart); + inherited; InstrWriter := TPPCInstrWriter.create(self); end; function TPPCVASM.MakeCmdLine: TCmdStr; begin - result:=target_asm.asmcmd; + result:=asminfo^.asmcmd; if (cs_link_on_target in current_settings.globalswitches) then begin diff --git a/compiler/ppcgen/agppcgas.pas b/compiler/ppcgen/agppcgas.pas index 21f5ef2bbf..67180a3147 100644 --- a/compiler/ppcgen/agppcgas.pas +++ b/compiler/ppcgen/agppcgas.pas @@ -31,7 +31,7 @@ unit agppcgas; interface uses - aasmbase, + systems,aasmbase, aasmtai,aasmdata, aggas, cpubase,cgutils, @@ -43,17 +43,17 @@ unit agppcgas; end; TPPCGNUAssembler=class(TGNUassembler) - constructor create(smart: boolean); override; + constructor create(info: pasminfo; smart: boolean); override; procedure WriteExtraHeader; override; end; TPPCAppleGNUAssembler=class(TAppleGNUassembler) - constructor create(smart: boolean); override; + constructor create(info: pasminfo; smart: boolean); override; function MakeCmdLine: TCmdStr; override; end; TPPCAIXAssembler=class(TPPCGNUAssembler) - constructor create(smart: boolean); override; + constructor create(info: pasminfo; smart: boolean); override; protected function sectionname(atype: TAsmSectiontype; const aname: string; aorder: TAsmSectionOrder): string; override; procedure WriteExtraHeader; override; @@ -63,9 +63,6 @@ unit agppcgas; topstr = string[4]; - function getreferencestring(var ref : treference) : string; - function getopstr_jmp(const o:toper) : string; - function getopstr(const o:toper) : string; function branchmode(o: tasmop): topstr; function cond2str(op: tasmop; c: tasmcond): string; @@ -73,7 +70,7 @@ unit agppcgas; uses cutils,globals,verbose, - cgbase,systems, + cgbase, assemble, itcpugas,cpuinfo, aasmcpu; @@ -91,7 +88,7 @@ unit agppcgas; {$endif cpu64bitaddr} - function getreferencestring(var ref : treference) : string; + function getreferencestring(asminfo: pasminfo; var ref : treference) : string; var s : string; begin @@ -111,7 +108,7 @@ unit agppcgas; (offset<>0) or not assigned(symbol) then internalerror(2011122701); - if target_asm.dollarsign<>'$' then + if asminfo^.dollarsign<>'$' then getreferencestring:=ReplaceForbiddenAsmSymbolChars(symbol.name)+'('+gas_regname(NR_RTOC)+')' else getreferencestring:=symbol.name+'('+gas_regname(NR_RTOC)+')'; @@ -126,7 +123,7 @@ unit agppcgas; s := s+'('; if assigned(symbol) then begin - if target_asm.dollarsign<>'$' then + if asminfo^.dollarsign<>'$' then begin s:=s+ReplaceForbiddenAsmSymbolChars(symbol.name); if assigned(relsymbol) then @@ -190,7 +187,7 @@ unit agppcgas; end; - function getopstr_jmp(const o:toper) : string; + function getopstr_jmp(asminfo: pasminfo; const o:toper) : string; var hs : string; begin @@ -205,7 +202,7 @@ unit agppcgas; if o.ref^.refaddr<>addr_full then internalerror(200402267); hs:=o.ref^.symbol.name; - if target_asm.dollarsign<>'$' then + if asminfo^.dollarsign<>'$' then hs:=ReplaceForbiddenAsmSymbolChars(hs); if o.ref^.offset>0 then hs:=hs+'+'+tostr(o.ref^.offset) @@ -222,7 +219,7 @@ unit agppcgas; end; - function getopstr(const o:toper) : string; + function getopstr(asminfo: pasminfo; const o:toper) : string; var hs : string; begin @@ -235,7 +232,7 @@ unit agppcgas; if o.ref^.refaddr=addr_full then begin hs:=o.ref^.symbol.name; - if target_asm.dollarsign<>'$' then + if asminfo^.dollarsign<>'$' then hs:=ReplaceForbiddenAsmSymbolChars(hs); if o.ref^.offset>0 then hs:=hs+'+'+tostr(o.ref^.offset) @@ -245,7 +242,7 @@ unit agppcgas; getopstr:=hs; end else - getopstr:=getreferencestring(o.ref^); + getopstr:=getreferencestring(asminfo,o.ref^); else internalerror(2002070604); end; @@ -367,7 +364,7 @@ unit agppcgas; { first write the current contents of s, because the symbol } { may be 255 characters } owner.writer.AsmWrite(s); - s:=getopstr_jmp(taicpu(hp).oper[0]^); + s:=getopstr_jmp(owner.asminfo,taicpu(hp).oper[0]^); end; end else @@ -387,7 +384,7 @@ unit agppcgas; // debug code // writeln(s); // writeln(taicpu(hp).fileinfo.line); - s:=s+sep+getopstr(taicpu(hp).oper[i]^); + s:=s+sep+getopstr(owner.asminfo,taicpu(hp).oper[i]^); sep:=','; end; end; @@ -400,9 +397,9 @@ unit agppcgas; { GNU PPC Assembler writer } {****************************************************************************} - constructor TPPCGNUAssembler.create(smart: boolean); + constructor TPPCGNUAssembler.create(info: pasminfo; smart: boolean); begin - inherited create(smart); + inherited; InstrWriter := TPPCInstrWriter.create(self); end; @@ -424,9 +421,9 @@ unit agppcgas; { GNU/Apple PPC Assembler writer } {****************************************************************************} - constructor TPPCAppleGNUAssembler.create(smart: boolean); + constructor TPPCAppleGNUAssembler.create(info: pasminfo; smart: boolean); begin - inherited create(smart); + inherited; InstrWriter := TPPCInstrWriter.create(self); end; @@ -453,9 +450,9 @@ unit agppcgas; { AIX PPC Assembler writer } {****************************************************************************} - constructor TPPCAIXAssembler.create(smart: boolean); + constructor TPPCAIXAssembler.create(info: pasminfo; smart: boolean); begin - inherited create(smart); + inherited; InstrWriter := TPPCInstrWriter.create(self); end; diff --git a/compiler/sparc/cpugas.pas b/compiler/sparc/cpugas.pas index 9e8813d292..1acdfe4a00 100644 --- a/compiler/sparc/cpugas.pas +++ b/compiler/sparc/cpugas.pas @@ -26,13 +26,13 @@ unit cpugas; interface uses - cpubase, + cpubase,systems, aasmtai,aasmdata,aasmcpu,assemble,aggas, cgutils,globtype; type TGasSPARC=class(TGnuAssembler) - constructor create(smart: boolean); override; + constructor create(info: pasminfo; smart: boolean); override; {# Constructs the command line for calling the assembler } function MakeCmdLine: TCmdStr; override; end; @@ -46,7 +46,7 @@ interface implementation uses - cutils,systems,globals,cpuinfo,procinfo, + cutils,globals,cpuinfo,procinfo, verbose,itcpugas,cgbase; @@ -54,9 +54,9 @@ implementation { GNU PPC Assembler writer } {****************************************************************************} - constructor TGasSPARC.create(smart: boolean); + constructor TGasSPARC.create(info: pasminfo; smart: boolean); begin - inherited create(smart); + inherited; InstrWriter := TSPARCInstrWriter.create(self); end; diff --git a/compiler/x86/agx86att.pas b/compiler/x86/agx86att.pas index 20f5dab772..35dcef0cd9 100644 --- a/compiler/x86/agx86att.pas +++ b/compiler/x86/agx86att.pas @@ -28,22 +28,22 @@ unit agx86att; interface uses - cclasses,cpubase, + cclasses,cpubase,systems, globals,globtype,cgutils, aasmbase,aasmtai,aasmdata,assemble,aggas; type Tx86ATTAssembler=class(TGNUassembler) - constructor create(smart: boolean); override; + constructor create(info: pasminfo; smart: boolean); override; function MakeCmdLine: TCmdStr; override; end; Tx86AppleGNUAssembler=class(TAppleGNUassembler) - constructor create(smart: boolean); override; + constructor create(info: pasminfo; smart: boolean); override; end; Tx86AoutGNUAssembler=class(TAoutGNUassembler) - constructor create(smart: boolean); override; + constructor create(info: pasminfo; smart: boolean); override; end; @@ -65,7 +65,7 @@ interface implementation uses - cutils,systems, + cutils, verbose, itcpugas, cgbase, @@ -76,9 +76,9 @@ interface Tx86ATTAssembler ****************************************************************************} - constructor Tx86ATTAssembler.create(smart: boolean); + constructor Tx86ATTAssembler.create(info: pasminfo; smart: boolean); begin - inherited create(smart); + inherited; InstrWriter := Tx86InstrWriter.create(self); end; @@ -124,9 +124,9 @@ interface Tx86AppleGNUAssembler ****************************************************************************} - constructor Tx86AppleGNUAssembler.create(smart: boolean); + constructor Tx86AppleGNUAssembler.create(info: pasminfo; smart: boolean); begin - inherited create(smart); + inherited; InstrWriter := Tx86InstrWriter.create(self); { Apple's assembler does not support a size suffix for popcount } Tx86InstrWriter(InstrWriter).fskipPopcountSuffix := true; @@ -138,9 +138,9 @@ interface Tx86AoutGNUAssembler ****************************************************************************} - constructor Tx86AoutGNUAssembler.create(smart: boolean); + constructor Tx86AoutGNUAssembler.create(info: pasminfo; smart: boolean); begin - inherited create(smart); + inherited; InstrWriter := Tx86InstrWriter.create(self); end; diff --git a/compiler/x86/agx86int.pas b/compiler/x86/agx86int.pas index 1b91c5d4fd..66c966dd3a 100644 --- a/compiler/x86/agx86int.pas +++ b/compiler/x86/agx86int.pas @@ -256,7 +256,7 @@ implementation writer.AsmWrite('['); if assigned(symbol) then begin - if (target_asm.id = as_i386_tasm) then + if (asminfo^.id = as_i386_tasm) then writer.AsmWrite('dword ptr '); writer.AsmWrite(symbol.name); first:=false; @@ -269,7 +269,7 @@ implementation first:=false; {$ifdef x86_64} { ml64 needs [$+foo] instead of [rip+foo] } - if (base=NR_RIP) and (target_asm.id=as_x86_64_masm) then + if (base=NR_RIP) and (asminfo^.id=as_x86_64_masm) then writer.AsmWrite('$') else {$endif x86_64} @@ -398,7 +398,7 @@ implementation begin if o.ref^.refaddr=addr_no then begin - if (target_asm.id <> as_i386_tasm) then + if (asminfo^.id <> as_i386_tasm) then begin if s=S_FAR then writer.AsmWrite('far ptr ') @@ -491,7 +491,7 @@ implementation case hp.typ of ait_comment : Begin - writer.AsmWrite(target_asm.comment); + writer.AsmWrite(asminfo^.comment); writer.AsmWritePChar(tai_comment(hp).str); writer.AsmLn; End; @@ -499,7 +499,7 @@ implementation ait_regalloc : begin if (cs_asm_regalloc in current_settings.globalswitches) then - writer.AsmWriteLn(target_asm.comment+'Register '+masm_regname(tai_regalloc(hp).reg)+ + writer.AsmWriteLn(asminfo^.comment+'Register '+masm_regname(tai_regalloc(hp).reg)+ regallocstr[tai_regalloc(hp).ratype]); end; @@ -513,7 +513,7 @@ implementation begin if tai_section(hp).sectype<>sec_none then begin - if target_asm.id=as_x86_64_masm then + if asminfo^.id=as_x86_64_masm then begin if LasTSecType<>sec_none then writer.AsmWriteLn(secnamesml64[LasTSecType]+#9#9'ENDS'); @@ -756,7 +756,7 @@ implementation { nasm prefers prefix on a line alone writer.AsmWriteln(#9#9+prefix); but not masm PM prefix:=''; } - if target_asm.id in [as_i386_nasmcoff,as_i386_nasmwin32,as_i386_nasmwdosx, + if asminfo^.id in [as_i386_nasmcoff,as_i386_nasmwin32,as_i386_nasmwdosx, as_i386_nasmelf,as_i386_nasmobj,as_i386_nasmbeos,as_i386_nasmhaiku] then begin writer.AsmWriteln(prefix); @@ -765,7 +765,7 @@ implementation end else prefix:= ''; - if (target_asm.id = as_i386_wasm) and + if (asminfo^.id = as_i386_wasm) and (taicpu(hp).opsize=S_W) and (fixed_opcode=A_PUSH) and (taicpu(hp).oper[0]^.typ=top_const) then @@ -773,7 +773,7 @@ implementation writer.AsmWriteln(#9#9'DB 66h,68h ; pushw imm16'); writer.AsmWrite(#9#9'DW'); end - else if (target_asm.id=as_x86_64_masm) and + else if (asminfo^.id=as_x86_64_masm) and (fixed_opcode=A_MOVQ) then writer.AsmWrite(#9#9'mov') else @@ -831,7 +831,7 @@ implementation {$endif i8086} { I was told that this isn't necesarry because } { the labels generated by FPC are unique (FK) } - { writer.AsmWriteLn(#9'LOCALS '+target_asm.labelprefix); } + { writer.AsmWriteLn(#9'LOCALS '+asminfo^.labelprefix); } { TODO: PARA is incorrect, must use actual section align } if lasTSectype<>sec_none then writer.AsmWriteLn('_'+secnames[lasTSectype]+#9#9+ @@ -880,7 +880,7 @@ implementation sym:=TAsmSymbol(current_asmdata.AsmSymbolDict[i]); if sym.bind=AB_EXTERNAL then begin - case target_asm.id of + case asminfo^.id of as_i386_masm, as_i386_wasm : writer.AsmWriteln(#9'EXTRN'#9+sym.name+': NEAR'); @@ -900,7 +900,7 @@ implementation begin DoAssemble:=Inherited DoAssemble; { masm does not seem to recognize specific extensions and uses .obj allways PM } - if (target_asm.id in [as_i386_masm,as_i386_wasm]) then + if (asminfo^.id in [as_i386_masm,as_i386_wasm]) then begin masmobjfn:=ChangeFileExt(objfilename,'.obj'); if not(cs_asm_extern in current_settings.globalswitches) then @@ -923,13 +923,13 @@ implementation if current_module.mainsource<>'' then comment(v_info,'Start writing intel-styled assembler output for '+current_module.mainsource); {$endif} - if target_asm.id<>as_x86_64_masm then + if asminfo^.id<>as_x86_64_masm then begin writer.AsmWriteLn(#9'.386p'); { masm 6.11 does not seem to like LOCALS PM } - if (target_asm.id = as_i386_tasm) then + if (asminfo^.id = as_i386_tasm) then begin - writer.AsmWriteLn(#9'LOCALS '+target_asm.labelprefix); + writer.AsmWriteLn(#9'LOCALS '+asminfo^.labelprefix); end; {$ifdef i8086} writer.AsmWriteLn('DGROUP'#9'GROUP'#9'_BSS,_DATA'); @@ -942,9 +942,9 @@ implementation for hal:=low(TasmlistType) to high(TasmlistType) do begin - writer.AsmWriteLn(target_asm.comment+'Begin asmlist '+AsmListTypeStr[hal]); + writer.AsmWriteLn(asminfo^.comment+'Begin asmlist '+AsmListTypeStr[hal]); writetree(current_asmdata.asmlists[hal]); - writer.AsmWriteLn(target_asm.comment+'End asmlist '+AsmListTypeStr[hal]); + writer.AsmWriteLn(asminfo^.comment+'End asmlist '+AsmListTypeStr[hal]); end; { better do this at end of WriteTree, but then there comes a trouble with @@ -952,7 +952,7 @@ implementation if LastSecType <> sec_none then begin - if target_asm.id=as_x86_64_masm then + if asminfo^.id=as_x86_64_masm then writer.AsmWriteLn(secnamesml64[LasTSecType]+#9#9'ENDS') else writer.AsmWriteLn('_'+secnames[LasTSecType]+#9#9'ENDS'); diff --git a/compiler/x86/agx86nsm.pas b/compiler/x86/agx86nsm.pas index 8ce0a0477e..f34676af3f 100644 --- a/compiler/x86/agx86nsm.pas +++ b/compiler/x86/agx86nsm.pas @@ -668,7 +668,7 @@ interface case hp.typ of ait_comment : Begin - writer.AsmWrite(target_asm.comment); + writer.AsmWrite(asminfo^.comment); writer.AsmWritePChar(tai_comment(hp).str); writer.AsmLn; End; @@ -676,7 +676,7 @@ interface ait_regalloc : begin if (cs_asm_regalloc in current_settings.globalswitches) then - writer.AsmWriteLn(#9#9+target_asm.comment+'Register '+nasm_regname(tai_regalloc(hp).reg)+' '+ + writer.AsmWriteLn(#9#9+asminfo^.comment+'Register '+nasm_regname(tai_regalloc(hp).reg)+' '+ regallocstr[tai_regalloc(hp).ratype]); end; @@ -743,7 +743,7 @@ interface aitconst_sleb128bit, aitconst_128bit: begin - writer.AsmWriteLn(target_asm.comment+'Unsupported const type '+ + writer.AsmWriteLn(asminfo^.comment+'Unsupported const type '+ ait_const2str[consttype]); end; {$ifdef i8086} @@ -963,7 +963,7 @@ interface assigned(taicpu(hp).oper[1]^.ref^.symbol) and (taicpu(hp).oper[1]^.ref^.base=NR_NO)) then begin - writer.AsmWrite(target_asm.comment); + writer.AsmWrite(asminfo^.comment); writer.AsmWriteln('Converting LEA to MOV instruction'); taicpu(hp).opcode:=A_MOV; end; @@ -1082,10 +1082,10 @@ interface ait_varloc: begin if tai_varloc(hp).newlocationhi<>NR_NO then - writer.AsmWriteLn(target_asm.comment+'Var '+tai_varloc(hp).varsym.realname+' located in register '+ + writer.AsmWriteLn(asminfo^.comment+'Var '+tai_varloc(hp).varsym.realname+' located in register '+ std_regname(tai_varloc(hp).newlocationhi)+':'+std_regname(tai_varloc(hp).newlocation)) else - writer.AsmWriteLn(target_asm.comment+'Var '+tai_varloc(hp).varsym.realname+' located in register '+ + writer.AsmWriteLn(asminfo^.comment+'Var '+tai_varloc(hp).varsym.realname+' located in register '+ std_regname(tai_varloc(hp).newlocation)); end; else @@ -1168,9 +1168,9 @@ interface begin if not (current_asmdata.asmlists[hal].empty) then begin - writer.AsmWriteLn(target_asm.comment+'Begin asmlist '+AsmListTypeStr[hal]); + writer.AsmWriteLn(asminfo^.comment+'Begin asmlist '+AsmListTypeStr[hal]); writetree(current_asmdata.asmlists[hal]); - writer.AsmWriteLn(target_asm.comment+'End asmlist '+AsmListTypeStr[hal]); + writer.AsmWriteLn(asminfo^.comment+'End asmlist '+AsmListTypeStr[hal]); end; end;