1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205 |
- {
- Copyright (c) 1998-2006 by Florian Klaempfl
- This unit implements an abstract asmoutput class for all processor types
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- ****************************************************************************
- }
- { @abstract(This unit implements an abstract asm output class for all processor types)
- This unit implements an abstract assembler output class for all processors, these
- are then overridden for each assembler writer to actually write the data in these
- classes to an assembler file.
- }
- unit aasmtai;
- {$i fpcdefs.inc}
- interface
- uses
- cutils,cclasses,
- globtype,systems,
- cpuinfo,cpubase,
- cgbase,cgutils,
- symtype,
- aasmbase,aasmdata,ogbase
- {$ifdef jvm}
- ,widestr
- {$endif jvm}
- ;
- type
- { keep the number of elements in this enumeration less or equal than 32 as long
- as FPC knows only 4 byte and 32 byte sets (FK) }
- taitype = (
- ait_none,
- ait_align,
- ait_section,
- ait_comment,
- ait_string,
- ait_instruction,
- ait_datablock,
- ait_symbol,
- { needed to calc the size of a symbol }
- ait_symbol_end,
- ait_directive,
- ait_label,
- ait_const,
- ait_real_32bit,
- ait_real_64bit,
- ait_real_80bit,
- ait_comp_64bit,
- ait_real_128bit,
- ait_stab,
- ait_force_line,
- ait_function_name,
- {$ifdef alpha}
- { the follow is for the DEC Alpha }
- ait_frame,
- {$endif alpha}
- {$ifdef ia64}
- ait_bundle,
- ait_stop,
- {$endif ia64}
- {$ifdef m68k}
- ait_labeled_instruction,
- {$endif m68k}
- {$ifdef arm}
- ait_thumb_set,
- {$endif arm}
- ait_set,
- ait_weak,
- { used to split into tiny assembler files }
- ait_cutobject,
- ait_regalloc,
- ait_tempalloc,
- { used to mark assembler blocks and inlined functions }
- ait_marker,
- { used to describe a new location of a variable }
- ait_varloc,
- {$ifdef JVM}
- { JVM only }
- ait_jvar, { debug information for a local variable }
- ait_jcatch, { exception catch clause }
- {$endif JVM}
- { SEH directives used in ARM,MIPS and x86_64 COFF targets }
- ait_seh_directive
- );
- taiconst_type = (
- aitconst_128bit,
- aitconst_64bit,
- aitconst_32bit,
- aitconst_16bit,
- aitconst_8bit,
- aitconst_sleb128bit,
- aitconst_uleb128bit,
- { win32 only }
- aitconst_rva_symbol,
- aitconst_secrel32_symbol,
- { darwin only }
- { From gcc/config/darwin.c (darwin_asm_output_dwarf_delta):
- ***
- Output a difference of two labels that will be an assembly time
- constant if the two labels are local. (.long lab1-lab2 will be
- very different if lab1 is at the boundary between two sections; it
- will be relocated according to the second section, not the first,
- so one ends up with a difference between labels in different
- sections, which is bad in the dwarf2 eh context for instance.)
- ***
- We cannot use this everywhere, because older versions of the
- darwin assembler don't support the construct used for these
- relsyms (nor do they support dwarf, for that matter)
- }
- aitconst_darwin_dwarf_delta64,
- aitconst_darwin_dwarf_delta32,
- { ARM Thumb-2 only }
- aitconst_half16bit, { used for table jumps. The actual value is the 16bit value shifted left once }
- { for use by dwarf debugger information }
- aitconst_16bit_unaligned,
- aitconst_32bit_unaligned,
- aitconst_64bit_unaligned,
- { i8086 far pointer; emits: 'DW symbol, SEG symbol' }
- aitconst_farptr,
- { offset of symbol's GOT slot in GOT }
- aitconst_got,
- { offset of symbol itself from GOT }
- aitconst_gotoff_symbol
- );
- const
- {$if defined(cpu64bitaddr)}
- aitconst_ptr = aitconst_64bit;
- aitconst_ptr_unaligned = aitconst_64bit_unaligned;
- {$elseif defined(cpu32bitaddr)}
- aitconst_ptr = aitconst_32bit;
- aitconst_ptr_unaligned = aitconst_32bit_unaligned;
- {$elseif defined(cpu16bitaddr)}
- aitconst_ptr = aitconst_16bit;
- aitconst_ptr_unaligned = aitconst_16bit_unaligned;
- {$endif}
- {$if defined(cpu64bitalu)}
- aitconst_aint = aitconst_64bit;
- {$elseif defined(cpu32bitalu)}
- aitconst_aint = aitconst_32bit;
- {$elseif defined(cpu16bitalu)}
- aitconst_aint = aitconst_16bit;
- {$elseif defined(cpu8bitalu)}
- aitconst_aint = aitconst_8bit;
- {$endif}
- taitypestr : array[taitype] of string[24] = (
- '<none>',
- 'align',
- 'section',
- 'comment',
- 'string',
- 'instruction',
- 'datablock',
- 'symbol',
- 'symbol_end',
- 'symbol_directive',
- 'label',
- 'const',
- 'real_32bit',
- 'real_64bit',
- 'real_80bit',
- 'comp_64bit',
- 'real_128bit',
- 'stab',
- 'force_line',
- 'function_name',
- {$ifdef alpha}
- { the follow is for the DEC Alpha }
- 'frame',
- {$endif alpha}
- {$ifdef ia64}
- 'bundle',
- 'stop',
- {$endif ia64}
- {$ifdef m68k}
- 'labeled_instr',
- {$endif m68k}
- {$ifdef arm}
- 'thumb_set',
- {$endif arm}
- 'set',
- 'weak',
- 'cut',
- 'regalloc',
- 'tempalloc',
- 'marker',
- 'varloc',
- {$ifdef JVM}
- 'jvar',
- 'jcatch',
- {$endif JVM}
- 'seh_directive'
- );
- type
- { Types of operand }
- toptype=(top_none,top_reg,top_ref,top_const,top_bool,top_local
- {$ifdef arm}
- { ARM only }
- ,top_regset
- ,top_modeflags
- ,top_specialreg
- {$endif arm}
- {$if defined(arm) or defined(aarch64)}
- ,top_conditioncode
- ,top_shifterop
- {$endif defined(arm) or defined(aarch64)}
- {$ifdef m68k}
- { m68k only }
- ,top_regset
- {$endif m68k}
- {$ifdef jvm}
- { jvm only}
- ,top_single
- ,top_double
- ,top_string
- ,top_wstring
- {$endif jvm}
- );
- { kinds of operations that an instruction can perform on an operand }
- topertype = (operand_read,operand_write,operand_readwrite);
- tlocaloper = record
- localsym : pointer;
- localsymderef : tderef;
- localsymofs : longint;
- localindexreg : tregister;
- localscale : byte;
- localgetoffset,
- localforceref : boolean
- end;
- plocaloper = ^tlocaloper;
- { please keep the size of this record <=12 bytes and keep it properly aligned }
- toper = record
- ot : longint;
- case typ : toptype of
- top_none : ();
- top_reg : (reg:tregister);
- top_ref : (ref:preference);
- top_const : (val:tcgint);
- top_bool : (b:boolean);
- { local varsym that will be inserted in pass_generate_code }
- top_local : (localoper:plocaloper);
- {$ifdef arm}
- top_regset : (regset:^tcpuregisterset; regtyp: tregistertype; subreg: tsubregister; usermode: boolean);
- top_modeflags : (modeflags : tcpumodeflags);
- top_specialreg : (specialreg:tregister; specialflags:tspecialregflags);
- {$endif arm}
- {$if defined(arm) or defined(aarch64)}
- top_shifterop : (shifterop : pshifterop);
- top_conditioncode : (cc : TAsmCond);
- {$endif defined(arm) or defined(aarch64)}
- {$ifdef m68k}
- top_regset : (dataregset,addrregset,fpuregset:^tcpuregisterset);
- {$endif m68k}
- {$ifdef jvm}
- top_single : (sval:single);
- top_double : (dval:double);
- top_string : (pcvallen: aint; pcval: pchar);
- top_wstring : (pwstrval: pcompilerwidestring);
- {$endif jvm}
- end;
- poper=^toper;
- const
- { ait_* types which don't result in executable code or which don't influence
- the way the program runs/behaves, but which may be encountered by the
- optimizer (= if it's sometimes added to the exprasm list). Update if you add
- a new ait type! }
- SkipInstr = [ait_comment, ait_symbol,ait_section
- ,ait_stab, ait_function_name, ait_force_line
- ,ait_regalloc, ait_tempalloc, ait_symbol_end
- ,ait_directive
- ,ait_varloc,
- {$ifdef JVM}
- ait_jvar, ait_jcatch,
- {$endif JVM}
- ait_seh_directive];
- { ait_* types which do not have line information (and hence which are of type
- tai, otherwise, they are of type tailineinfo }
- SkipLineInfo =[ait_label,
- ait_regalloc,ait_tempalloc,
- ait_stab,ait_function_name,
- ait_cutobject,ait_marker,ait_varloc,ait_align,ait_section,ait_comment,
- ait_const,ait_directive,
- {$ifdef arm}
- 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_symbol,
- {$ifdef JVM}
- ait_jvar, ait_jcatch,
- {$endif JVM}
- ait_seh_directive
- ];
- type
- { cut type, required for alphanumeric ordering of the assembler filenames }
- TCutPlace=(cut_normal,cut_begin,cut_end);
- TAsmMarker = (
- mark_NoPropInfoStart,mark_NoPropInfoEnd,
- mark_AsmBlockStart,mark_AsmBlockEnd,
- mark_NoLineInfoStart,mark_NoLineInfoEnd,mark_BlockStart,
- mark_Position
- );
- TRegAllocType = (ra_alloc,ra_dealloc,ra_sync,ra_resize,ra_markused);
- TStabType = (stab_stabs,stab_stabn,stab_stabd,
- { AIX/XCOFF stab types }
- stab_stabx,
- { begin/end include file }
- stabx_bi,stabx_ei,
- { begin/end function }
- stabx_bf, stabx_ef,
- { begin/end static data block }
- stabx_bs, stabx_es,
- { line spec, function start/end label }
- stabx_line, stabx_function);
- TAsmDirective=(
- asd_indirect_symbol,
- asd_extern,asd_nasm_import, asd_toc_entry,
- asd_reference,asd_no_dead_strip,asd_weak_reference,asd_lazy_reference,
- asd_weak_definition,
- { for Jasmin }
- asd_jclass,asd_jinterface,asd_jsuper,asd_jfield,asd_jlimit,asd_jline,
- { .ent/.end for MIPS and Alpha }
- asd_ent,asd_ent_end,
- { supported by recent clang-based assemblers for data-in-code }
- asd_data_region, asd_end_data_region,
- { .thumb_func for ARM }
- asd_thumb_func
- );
- TAsmSehDirective=(
- ash_proc,ash_endproc,
- ash_endprologue,ash_handler,ash_handlerdata,
- ash_eh,ash_32,ash_no32,
- ash_setframe,ash_stackalloc,ash_pushreg,
- ash_savereg,ash_savexmm,ash_pushframe
- );
- const
- regallocstr : array[tregalloctype] of string[10]=('allocated','released','sync','resized','used');
- tempallocstr : array[boolean] of string[10]=('released','allocated');
- stabtypestr : array[TStabType] of string[8]=(
- 'stabs','stabn','stabd',
- 'stabx',
- 'bi','ei',
- 'bf','ef',
- 'bs','es',
- 'line','function');
- directivestr : array[TAsmDirective] of string[23]=(
- 'indirect_symbol',
- 'extern','nasm_import', 'tc', 'reference',
- 'no_dead_strip','weak_reference','lazy_reference','weak_definition',
- { for Jasmin }
- 'class','interface','super','field','limit','line',
- { .ent/.end for MIPS and Alpha }
- 'ent','end',
- { supported by recent clang-based assemblers for data-in-code }
- 'data_region','end_data_region',
- { .thumb_func for ARM }
- 'thumb_func'
- );
- sehdirectivestr : array[TAsmSehDirective] of string[16]=(
- '.seh_proc','.seh_endproc',
- '.seh_endprologue','.seh_handler','.seh_handlerdata',
- '.seh_eh','.seh_32','seh_no32',
- '.seh_setframe','.seh_stackalloc','.seh_pushreg',
- '.seh_savereg','.seh_savexmm','.seh_pushframe'
- );
- type
- { abstract assembler item }
- tai = class(TLinkedListItem)
- {$ifndef NOOPT}
- { pointer to record with optimizer info about this tai object }
- optinfo : pointer;
- {$endif NOOPT}
- typ : taitype;
- constructor Create;
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);virtual;
- procedure ppuwrite(ppufile:tcompilerppufile);virtual;
- procedure buildderefimpl;virtual;
- procedure derefimpl;virtual;
- end;
- { abstract assembler item with line information }
- tailineinfo = class(tai)
- fileinfo : tfileposinfo;
- constructor Create;
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- end;
- tai_simple = class(tai)
- constructor create(_typ : taitype);
- end;
- taiclass = class of tai;
- taiclassarray = array[taitype] of taiclass;
- { Generates an assembler string }
- tai_string = class(tailineinfo)
- str : pchar;
- { extra len so the string can contain an \0 }
- len : longint;
- constructor Create(const _str : string);
- constructor Create_pchar(_str : pchar;length : longint);
- destructor Destroy;override;
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- function getcopy:tlinkedlistitem;override;
- end;
- { Generates a common label }
- tai_symbol = class(tai)
- sym : tasmsymbol;
- value : puint;
- size : longint;
- is_global,
- has_value : boolean;
- constructor Create(_sym:tasmsymbol;siz:longint);
- constructor Create_Global(_sym:tasmsymbol;siz:longint);
- constructor Createname(const _name : string;_symtyp:Tasmsymtype;siz:longint);
- constructor Createname_global(const _name : string;_symtyp:Tasmsymtype;siz:longint);
- constructor Createname_global_value(const _name : string;_symtyp:Tasmsymtype;siz:longint;val:ptruint);
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- procedure derefimpl;override;
- end;
- tai_symbol_end = class(tailineinfo)
- sym : tasmsymbol;
- constructor Create(_sym:tasmsymbol);
- constructor Createname(const _name : string);
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- procedure derefimpl;override;
- end;
- tai_directive = class(tailineinfo)
- name : ansistring;
- directive : TAsmDirective;
- constructor Create(_directive:TAsmDirective;const _name:ansistring);
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- end;
- { Generates an assembler label }
- tai_label = class(tai)
- labsym : tasmlabel;
- {$ifdef arm}
- { set to true when the label has been moved by insertpcrelativedata to the correct location
- so one label can be used multiple times }
- moved : boolean;
- { true, if a label has been already inserted, this is important for arm thumb where no negative
- pc relative offsets are allowed }
- inserted : boolean;
- {$endif arm}
- constructor Create(_labsym : tasmlabel);
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- procedure derefimpl;override;
- end;
- { Generates an assembler comment }
- tai_comment = class(tai)
- str : pchar;
- constructor Create(_str : pchar);
- destructor Destroy; override;
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- function getcopy:tlinkedlistitem;override;
- end;
- { Generates a section / segment directive }
- tai_section = class(tai)
- sectype : TAsmSectiontype;
- secorder : TasmSectionorder;
- secalign : byte;
- name : pshortstring;
- sec : TObjSection; { used in binary writer }
- destructor Destroy;override;
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- {$push}{$warnings off}
- private
- { this constructor is made private on purpose }
- { because sections should be created via new_section() }
- constructor Create(Asectype:TAsmSectiontype;const Aname:string;Aalign:byte;Asecorder:TasmSectionorder=secorder_default);
- {$pop}
- end;
- { Generates an uninitializised data block }
- tai_datablock = class(tailineinfo)
- is_global : boolean;
- sym : tasmsymbol;
- size : asizeint;
- constructor Create(const _name : string;_size : aint);
- constructor Create_global(const _name : string;_size : asizeint);
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- procedure derefimpl;override;
- end;
- { Generates an integer const }
- { tai_const }
- tai_const = class(tai)
- sym,
- endsym : tasmsymbol;
- { if symbols and offset are provided the symofs is used,
- the value is calculated during assembling }
- symofs,
- value : int64;
- consttype : taiconst_type;
- { we use for the 128bit int64/qword for now because I can't imagine a
- case where we need 128 bit now (FK) }
- constructor Create(_typ:taiconst_type;_value : int64);
- constructor Create_128bit(_value : int64);
- constructor Create_64bit(_value : int64);
- constructor Create_32bit(_value : longint);
- constructor Create_16bit(_value : word);
- constructor Create_64bit_unaligned(_value : int64);
- constructor Create_32bit_unaligned(_value : longint);
- constructor Create_16bit_unaligned(_value : word);
- constructor Create_8bit(_value : byte);
- constructor Create_char(size: integer; _value: dword);
- constructor Create_sleb128bit(_value : int64);
- constructor Create_uleb128bit(_value : qword);
- constructor Create_aint(_value : aint);
- constructor Create_pint(_value : pint);
- constructor Create_pint_unaligned(_value : pint);
- constructor Create_sym(_sym:tasmsymbol);
- {$ifdef i8086}
- constructor Create_sym_near(_sym:tasmsymbol);
- constructor Create_sym_far(_sym:tasmsymbol);
- {$endif i8086}
- constructor Create_type_sym(_typ:taiconst_type;_sym:tasmsymbol);
- constructor Create_sym_offset(_sym:tasmsymbol;ofs:aint);
- constructor Create_type_sym_offset(_typ:taiconst_type;_sym:tasmsymbol;ofs:aint);
- constructor Create_rel_sym(_typ:taiconst_type;_sym,_endsym:tasmsymbol);
- constructor Create_rel_sym_offset(_typ : taiconst_type; _sym,_endsym : tasmsymbol; _ofs : int64);
- constructor Create_rva_sym(_sym:tasmsymbol);
- constructor Createname(const name:string;ofs:aint);
- constructor Createname(const name:string;_symtyp:Tasmsymtype;ofs:aint);
- constructor Create_type_name(_typ:taiconst_type;const name:string;ofs:aint);
- constructor Create_type_name(_typ:taiconst_type;const name:string;_symtyp:Tasmsymtype;ofs:aint);
- constructor Create_nil_codeptr;
- constructor Create_nil_dataptr;
- constructor Create_int_codeptr(_value: int64);
- constructor Create_int_dataptr(_value: int64);
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- procedure derefimpl;override;
- function getcopy:tlinkedlistitem;override;
- 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;
- tformatoptions = (fo_none,fo_hiloswapped);
- { Generates a double float (64 bit real) }
- tai_real_64bit = class(tai)
- value : ts64real;
- {$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;
- end;
- { tai_stab }
- tai_stab = class(tai)
- str : pchar;
- stabtype : TStabType;
- constructor Create(_stabtype:TStabType;_str : pchar);
- constructor Create_str(_stabtype:TStabType;const s:string);
- constructor create_ansistr(_stabtype: TStabType; const s: ansistring);
- destructor Destroy;override;
- end;
- tai_force_line = class(tailineinfo)
- constructor Create;
- end;
- tai_function_name = class(tai)
- funcname : pshortstring;
- constructor create(const s:string);
- destructor destroy;override;
- end;
- { Insert a cut to split assembler into several smaller files }
- tai_cutobject = class(tai)
- place : tcutplace;
- constructor Create;
- constructor Create_begin;
- constructor Create_end;
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- end;
- { Insert a marker for assembler and inline blocks }
- tai_marker = class(tai)
- Kind: TAsmMarker;
- Constructor Create(_Kind: TAsmMarker);
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- end;
- tai_tempalloc = class(tai)
- allocation : boolean;
- {$ifdef EXTDEBUG}
- problem : pshortstring;
- {$endif EXTDEBUG}
- temppos,
- tempsize : longint;
- constructor alloc(pos,size:longint);
- constructor dealloc(pos,size:longint);
- {$ifdef EXTDEBUG}
- constructor allocinfo(pos,size:longint;const st:string);
- {$endif EXTDEBUG}
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- destructor destroy;override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- end;
- tai_regalloc = class(tai)
- reg : tregister;
- ratype : TRegAllocType;
- { tells BuildLabelTableAndFixRegAlloc that the deallocation should be kept }
- keep : boolean;
- { reg(de)alloc belongs to this instruction, this
- is only used for automatic inserted (de)alloc for
- imaginary register and required for spilling code }
- instr : tai;
- constructor alloc(r : tregister;ainstr:tai);
- constructor dealloc(r : tregister;ainstr:tai);
- constructor sync(r : tregister);
- constructor resize(r : tregister);
- constructor markused(r : tregister);
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- end;
- tadd_reg_instruction_proc=procedure(instr:Tai;r:tregister) of object;
- { Class template for assembler instructions
- }
- tai_cpu_abstract = class(tailineinfo)
- protected
- procedure ppuloadoper(ppufile:tcompilerppufile;var o:toper);virtual;
- procedure ppuwriteoper(ppufile:tcompilerppufile;const o:toper);virtual;
- procedure ppubuildderefimploper(var o:toper);virtual;abstract;
- procedure ppuderefoper(var o:toper);virtual;abstract;
- public
- { Condition flags for instruction }
- condition : TAsmCond;
- { Number of operands to instruction }
- ops : byte;
- { Number of allocate oper structures }
- opercnt : byte;
- { Operands of instruction }
- oper : array[0..max_operands-1] of poper;
- { Actual opcode of instruction }
- opcode : tasmop;
- {$ifdef x86}
- segprefix : tregister;
- {$endif x86}
- { true if instruction is a jmp }
- is_jmp : boolean; { is this instruction a jump? (needed for optimizer) }
- Constructor Create(op : tasmop);virtual;
- Destructor Destroy;override;
- function getcopy:TLinkedListItem;override;
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- procedure buildderefimpl;override;
- procedure derefimpl;override;
- procedure SetCondition(const c:TAsmCond);
- procedure allocate_oper(opers:longint);
- procedure loadconst(opidx:longint;l:aint);
- procedure loadsymbol(opidx:longint;s:tasmsymbol;sofs:longint);
- procedure loadlocal(opidx:longint;s:pointer;sofs:longint;indexreg:tregister;scale:byte;getoffset,forceref:boolean);
- procedure loadref(opidx:longint;const r:treference);
- procedure loadreg(opidx:longint;r:tregister);
- procedure loadoper(opidx:longint;o:toper);
- procedure clearop(opidx:longint);
- procedure freeop(opidx:longint);
- { register allocator }
- function is_same_reg_move(regtype: Tregistertype):boolean;virtual;
- function spilling_get_operation_type(opnr: longint): topertype;virtual;
- function spilling_get_operation_type_ref(opnr: longint; reg: tregister): topertype;virtual;
- function Pass1(objdata:TObjData):longint;virtual;
- procedure Pass2(objdata:TObjData);virtual;
- procedure resetpass1; virtual;
- procedure resetpass2; virtual;
- end;
- tai_cpu_class = class of tai_cpu_abstract;
- { Buffer type used for alignment }
- tfillbuffer = array[0..63] of char;
- { alignment for operator }
- tai_align_abstract = class(tai)
- aligntype : byte; { 1 = no align, 2 = word align, 4 = dword align }
- fillsize : byte; { real size to fill }
- fillop : byte; { value to fill with - optional }
- use_op : boolean;
- constructor Create(b:byte);virtual;
- constructor Create_op(b: byte; _op: byte);virtual;
- constructor Create_zeros(b:byte);
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- function calculatefillbuf(var buf : tfillbuffer;executable : boolean):pchar;virtual;
- end;
- tai_align_class = class of tai_align_abstract;
- tai_varloc = class(tai)
- oldlocation,
- oldlocationhi,
- newlocation,
- newlocationhi : tregister;
- varsym : tsym;
- constructor create(sym : tsym;loc : tregister);
- constructor create64(sym : tsym;loc,lochi : tregister);
- {$ifdef cpu64bitalu}
- constructor create128(sym : tsym;loc,lochi : tregister);
- {$endif cpu64bitalu}
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- procedure buildderefimpl;override;
- procedure derefimpl;override;
- end;
- TSehDirectiveDatatype=(sd_none,sd_string,sd_reg,sd_offset,sd_regoffset);
- TSehDirectiveData=record
- case typ: TSehDirectiveDatatype of
- sd_none: ();
- sd_string: (name:pshortstring;flags:byte);
- sd_reg,sd_offset,sd_regoffset: (reg:TRegister;offset:dword);
- end;
- tai_seh_directive = class(tai)
- kind: TAsmSehDirective;
- data: TSehDirectiveData;
- constructor create(_kind:TAsmSehDirective);
- constructor create_name(_kind:TAsmSehDirective;const _name: string);
- constructor create_reg(_kind:TAsmSehDirective;r:TRegister);
- constructor create_offset(_kind:TAsmSehDirective;ofs:dword);
- constructor create_reg_offset(_kind:TAsmSehDirective;r:TRegister;ofs:dword);
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- destructor destroy;override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- procedure generate_code(objdata:TObjData);virtual;
- property datatype: TSehDirectiveDatatype read data.typ;
- end;
- tai_seh_directive_class=class of tai_seh_directive;
- {$ifdef JVM}
- { JVM variable live range description }
- tai_jvar = class(tai)
- stackslot: longint;
- desc: pshortstring;
- startlab,stoplab: tasmsymbol;
- constructor Create(_stackslot: longint; const _desc: shortstring; _startlab, _stoplab: TAsmSymbol);
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- destructor destroy;override;
- end;
- tai_jvar_class = class of tai_jvar;
- { JVM exception catch description }
- tai_jcatch = class(tai)
- name: pshortstring;
- startlab,stoplab,handlerlab: tasmsymbol;
- constructor Create(const _name: shortstring; _startlab, _stoplab, _handlerlab: TAsmSymbol);
- destructor destroy;override;
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- end;
- tai_jcatch_class = class of tai_jcatch;
- {$endif JVM}
- tai_set = class(tai)
- sym,
- value: pshortstring;
- constructor create(const asym, avalue: string);
- destructor destroy;override;
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- end;
- {$ifdef arm}
- tai_thumb_set = class(tai_set)
- constructor create(const asym, avalue: string);
- end;
- {$endif arm}
- tai_weak = class(tai)
- sym: pshortstring;
- constructor create(const asym: string);
- destructor destroy;override;
- constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
- procedure ppuwrite(ppufile:tcompilerppufile);override;
- end;
- var
- { array with all class types for tais }
- aiclass : taiclassarray;
- { target specific tais, possibly overwritten in target specific aasmcpu }
- cai_align : tai_align_class = tai_align_abstract;
- cai_cpu : tai_cpu_class = tai_cpu_abstract;
- cai_seh_directive: tai_seh_directive_class = tai_seh_directive;
- { hook to notify uses of registers }
- add_reg_instruction_hook : tadd_reg_instruction_proc;
- procedure maybe_new_object_file(list:TAsmList);
- procedure new_section(list:TAsmList;Asectype:TAsmSectiontype;const Aname:string;Aalign:byte;Asecorder:TasmSectionorder=secorder_default);
- procedure section_symbol_start(list:TAsmList;const Aname:string;Asymtyp:Tasmsymtype;
- Aglobal:boolean;Asectype:TAsmSectiontype;Aalign:byte);
- procedure section_symbol_end(list:TAsmList;const Aname:string);
- function ppuloadai(ppufile:tcompilerppufile):tai;
- procedure ppuwriteai(ppufile:tcompilerppufile;n:tai);
- implementation
- uses
- SysUtils,
- verbose,
- globals;
- const
- pputaimarker = 254;
- {****************************************************************************
- Helpers
- ****************************************************************************}
- procedure maybe_new_object_file(list:TAsmList);
- begin
- if create_smartlink_library then
- list.concat(tai_cutobject.create);
- end;
- procedure new_section(list:TAsmList;Asectype:TAsmSectiontype;const Aname:string;Aalign:byte;Asecorder:TasmSectionorder=secorder_default);
- begin
- list.concat(tai_section.create(Asectype,Aname,Aalign,Asecorder));
- list.concat(cai_align.create(Aalign));
- end;
- procedure section_symbol_start(list:TAsmList;const Aname:string;Asymtyp:Tasmsymtype;
- Aglobal:boolean;Asectype:TAsmSectiontype;Aalign:byte);
- begin
- maybe_new_object_file(list);
- new_section(list,Asectype,Aname,Aalign);
- if Aglobal or
- create_smartlink then
- list.concat(tai_symbol.createname_global(Aname,Asymtyp,0))
- else
- list.concat(tai_symbol.createname(Aname,Asymtyp,0));
- end;
- procedure section_symbol_end(list:TAsmList;const Aname:string);
- begin
- list.concat(tai_symbol_end.createname(Aname));
- end;
- function ppuloadai(ppufile:tcompilerppufile):tai;
- var
- b : byte;
- t : taitype;
- begin
- { marker }
- b:=ppufile.getbyte;
- if b<>pputaimarker then
- internalerror(200208181);
- { load nodetype }
- t:=taitype(ppufile.getbyte);
- if t<>ait_none then
- begin
- if t>high(taitype) then
- internalerror(200208182);
- if not assigned(aiclass[t]) then
- internalerror(200208183);
- {writeln('taiload: ',taitypestr[t]);}
- { generate tai of the correct class }
- ppuloadai:=aiclass[t].ppuload(t,ppufile);
- end
- else
- ppuloadai:=nil;
- end;
- procedure ppuwriteai(ppufile:tcompilerppufile;n:tai);
- begin
- { marker, read by ppuloadnode }
- ppufile.putbyte(pputaimarker);
- if assigned(n) then
- begin
- { type, read by ppuloadnode }
- ppufile.putbyte(byte(n.typ));
- {writeln('taiwrite: ',taitypestr[n.typ]);}
- n.ppuwrite(ppufile);
- end
- else
- ppufile.putbyte(byte(ait_none));
- end;
- constructor tai_weak.create(const asym: string);
- begin
- inherited create;
- typ:=ait_weak;
- sym:=stringdup(asym);
- end;
- destructor tai_weak.destroy;
- begin
- stringdispose(sym);
- inherited destroy;
- end;
- constructor tai_weak.ppuload(t: taitype; ppufile: tcompilerppufile);
- begin
- inherited ppuload(t,ppufile);
- sym:=stringdup(ppufile.getstring);
- end;
- procedure tai_weak.ppuwrite(ppufile: tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- ppufile.putstring(sym^);
- end;
- {$ifdef arm}
- constructor tai_thumb_set.create(const asym, avalue: string);
- begin
- inherited create(asym, avalue);
- typ:=ait_thumb_set;
- end;
- {$endif arm}
- constructor tai_set.create(const asym, avalue: string);
- begin
- inherited create;
- typ:=ait_set;
- sym:=stringdup(asym);
- value:=stringdup(avalue);
- end;
- destructor tai_set.destroy;
- begin
- stringdispose(sym);
- stringdispose(value);
- inherited destroy;
- end;
- constructor tai_set.ppuload(t: taitype; ppufile: tcompilerppufile);
- begin
- inherited ppuload(t,ppufile);
- sym:=stringdup(ppufile.getstring);
- value:=stringdup(ppufile.getstring);
- end;
- procedure tai_set.ppuwrite(ppufile: tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- ppufile.putstring(sym^);
- ppufile.putstring(value^);
- end;
- constructor tai_varloc.create(sym: tsym; loc: tregister);
- begin
- inherited Create;
- typ:=ait_varloc;
- newlocation:=loc;
- newlocationhi:=NR_NO;
- varsym:=sym;
- oldlocationhi:=NR_NO;
- end;
- constructor tai_varloc.create64(sym: tsym; loc, lochi: tregister);
- begin
- inherited Create;
- typ:=ait_varloc;
- newlocation:=loc;
- newlocationhi:=lochi;
- varsym:=sym;
- end;
- {$ifdef cpu64bitalu}
- constructor tai_varloc.create128(sym: tsym; loc, lochi: tregister);
- begin
- inherited Create;
- typ:=ait_varloc;
- newlocation:=loc;
- newlocationhi:=lochi;
- varsym:=sym;
- end;
- {$endif cpu64bitalu}
- constructor tai_varloc.ppuload(t: taitype; ppufile: tcompilerppufile);
- begin
- inherited ppuload(t, ppufile);
- end;
- procedure tai_varloc.ppuwrite(ppufile: tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- end;
- procedure tai_varloc.buildderefimpl;
- begin
- inherited buildderefimpl;
- end;
- procedure tai_varloc.derefimpl;
- begin
- inherited derefimpl;
- end;
- {****************************************************************************
- TAI
- ****************************************************************************}
- constructor tai.Create;
- begin
- {$ifndef NOOPT}
- optinfo:=nil;
- {$endif NOOPT}
- end;
- constructor tai.ppuload(t:taitype;ppufile:tcompilerppufile);
- begin
- typ:=t;
- {$ifndef NOOPT}
- optinfo:=nil;
- {$endif}
- end;
- procedure tai.ppuwrite(ppufile:tcompilerppufile);
- begin
- end;
- procedure tai.buildderefimpl;
- begin
- end;
- procedure tai.derefimpl;
- begin
- end;
- {****************************************************************************
- TAILINEINFO
- ****************************************************************************}
- constructor tailineinfo.create;
- begin
- inherited create;
- fileinfo:=current_filepos;
- end;
- constructor tailineinfo.ppuload(t:taitype;ppufile:tcompilerppufile);
- begin
- inherited ppuload(t,ppufile);
- ppufile.getposinfo(fileinfo);
- end;
- procedure tailineinfo.ppuwrite(ppufile:tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- ppufile.putposinfo(fileinfo);
- end;
- {****************************************************************************
- TAI_SIMPLE
- ****************************************************************************}
- constructor tai_simple.create(_typ : taitype);
- begin
- inherited create;
- typ:=_typ;
- end;
- {****************************************************************************
- TAI_SECTION
- ****************************************************************************}
- constructor tai_section.Create(Asectype:TAsmSectiontype;const Aname:string;Aalign:byte;Asecorder:TasmSectionorder=secorder_default);
- begin
- inherited Create;
- typ:=ait_section;
- sectype:=asectype;
- secalign:=Aalign;
- secorder:=Asecorder;
- name:=stringdup(Aname);
- sec:=nil;
- end;
- constructor tai_section.ppuload(t:taitype;ppufile:tcompilerppufile);
- begin
- inherited ppuload(t,ppufile);
- sectype:=TAsmSectiontype(ppufile.getbyte);
- secalign:=ppufile.getbyte;
- name:=stringdup(ppufile.getstring);
- sec:=nil;
- end;
- destructor tai_section.Destroy;
- begin
- stringdispose(name);
- end;
- procedure tai_section.ppuwrite(ppufile:tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- ppufile.putbyte(byte(sectype));
- ppufile.putbyte(secalign);
- ppufile.putstring(name^);
- end;
- {****************************************************************************
- TAI_DATABLOCK
- ****************************************************************************}
- constructor tai_datablock.Create(const _name : string;_size : aint);
- begin
- inherited Create;
- typ:=ait_datablock;
- sym:=current_asmdata.DefineAsmSymbol(_name,AB_LOCAL,AT_DATA);
- { keep things aligned }
- if _size<=0 then
- _size:=sizeof(aint);
- size:=_size;
- is_global:=false;
- end;
- constructor tai_datablock.Create_global(const _name : string;_size : asizeint);
- begin
- inherited Create;
- typ:=ait_datablock;
- sym:=current_asmdata.DefineAsmSymbol(_name,AB_GLOBAL,AT_DATA);
- { keep things aligned }
- if _size<=0 then
- _size:=sizeof(aint);
- size:=_size;
- is_global:=true;
- end;
- constructor tai_datablock.ppuload(t:taitype;ppufile:tcompilerppufile);
- begin
- inherited Create;
- sym:=ppufile.getasmsymbol;
- size:=ppufile.getaint;
- is_global:=boolean(ppufile.getbyte);
- end;
- procedure tai_datablock.ppuwrite(ppufile:tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- ppufile.putasmsymbol(sym);
- ppufile.putaint(size);
- ppufile.putbyte(byte(is_global));
- end;
- procedure tai_datablock.derefimpl;
- begin
- end;
- {****************************************************************************
- TAI_SYMBOL
- ****************************************************************************}
- constructor tai_symbol.Create(_sym:tasmsymbol;siz:longint);
- begin
- inherited Create;
- typ:=ait_symbol;
- sym:=_sym;
- size:=siz;
- { don't redefine global/external symbols as local, as code to access
- such symbols is different on some platforms }
- if not(sym.bind in [AB_NONE,AB_LOCAL]) then
- internalerror(2013081601);
- sym.bind:=AB_LOCAL;
- is_global:=false;
- end;
- constructor tai_symbol.Create_global(_sym:tasmsymbol;siz:longint);
- begin
- inherited Create;
- typ:=ait_symbol;
- sym:=_sym;
- size:=siz;
- { don't override PRIVATE_EXTERN with GLOBAL }
- if not(sym.bind in [AB_GLOBAL,AB_PRIVATE_EXTERN]) then
- sym.bind:=AB_GLOBAL;
- is_global:=true;
- end;
- constructor tai_symbol.Createname(const _name : string;_symtyp:Tasmsymtype;siz:longint);
- begin
- inherited Create;
- typ:=ait_symbol;
- sym:=current_asmdata.DefineAsmSymbol(_name,AB_LOCAL,_symtyp);
- size:=siz;
- is_global:=false;
- end;
- constructor tai_symbol.Createname_global(const _name : string;_symtyp:Tasmsymtype;siz:longint);
- begin
- inherited Create;
- typ:=ait_symbol;
- sym:=current_asmdata.DefineAsmSymbol(_name,AB_GLOBAL,_symtyp);
- size:=siz;
- is_global:=true;
- end;
- constructor tai_symbol.createname_global_value(const _name: string;_symtyp: tasmsymtype; siz: longint; val: ptruint);
- begin
- Createname_global(_name,_symtyp,siz);
- value:=val;
- has_value:=true;
- end;
- constructor tai_symbol.ppuload(t:taitype;ppufile:tcompilerppufile);
- begin
- inherited ppuload(t,ppufile);
- sym:=ppufile.getasmsymbol;
- size:=ppufile.getlongint;
- is_global:=boolean(ppufile.getbyte);
- end;
- procedure tai_symbol.ppuwrite(ppufile:tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- ppufile.putasmsymbol(sym);
- ppufile.putlongint(size);
- ppufile.putbyte(byte(is_global));
- end;
- procedure tai_symbol.derefimpl;
- begin
- end;
- {****************************************************************************
- TAI_SYMBOL_END
- ****************************************************************************}
- constructor tai_symbol_end.Create(_sym:tasmsymbol);
- begin
- inherited Create;
- typ:=ait_symbol_end;
- sym:=_sym;
- end;
- constructor tai_symbol_end.Createname(const _name : string);
- begin
- inherited Create;
- typ:=ait_symbol_end;
- sym:=current_asmdata.GetAsmSymbol(_name);
- if not assigned(sym) then
- internalerror(2013080301);
- end;
- constructor tai_symbol_end.ppuload(t:taitype;ppufile:tcompilerppufile);
- begin
- inherited ppuload(t,ppufile);
- sym:=ppufile.getasmsymbol;
- end;
- procedure tai_symbol_end.ppuwrite(ppufile:tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- ppufile.putasmsymbol(sym);
- end;
- procedure tai_symbol_end.derefimpl;
- begin
- end;
- {****************************************************************************
- TAI_SYMBOL_END
- ****************************************************************************}
- constructor tai_directive.Create(_directive:TAsmDirective;const _name:ansistring);
- begin
- inherited Create;
- typ:=ait_directive;
- name:=_name;
- directive:=_directive;
- end;
- constructor tai_directive.ppuload(t:taitype;ppufile:tcompilerppufile);
- begin
- inherited ppuload(t,ppufile);
- name:=ppufile.getansistring;
- directive:=TAsmDirective(ppufile.getbyte);
- end;
- procedure tai_directive.ppuwrite(ppufile:tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- ppufile.putansistring(name);
- ppufile.putbyte(byte(directive));
- end;
- {****************************************************************************
- TAI_CONST
- ****************************************************************************}
- constructor tai_const.Create(_typ:taiconst_type;_value : int64);
- begin
- inherited Create;
- typ:=ait_const;
- consttype:=_typ;
- value:=_value;
- sym:=nil;
- endsym:=nil;
- end;
- constructor tai_const.Create_128bit(_value : int64);
- begin
- inherited Create;
- typ:=ait_const;
- consttype:=aitconst_128bit;
- value:=_value;
- sym:=nil;
- endsym:=nil;
- end;
- constructor tai_const.Create_64bit(_value : int64);
- begin
- inherited Create;
- typ:=ait_const;
- consttype:=aitconst_64bit;
- value:=_value;
- sym:=nil;
- endsym:=nil;
- end;
- constructor tai_const.Create_32bit(_value : longint);
- begin
- inherited Create;
- typ:=ait_const;
- consttype:=aitconst_32bit;
- value:=_value;
- sym:=nil;
- endsym:=nil;
- end;
- constructor tai_const.Create_16bit(_value : word);
- begin
- inherited Create;
- typ:=ait_const;
- consttype:=aitconst_16bit;
- value:=_value;
- sym:=nil;
- endsym:=nil;
- end;
- constructor tai_const.Create_64bit_unaligned(_value : int64);
- begin
- inherited Create;
- typ:=ait_const;
- consttype:=aitconst_64bit_unaligned;
- value:=_value;
- sym:=nil;
- endsym:=nil;
- end;
- constructor tai_const.Create_32bit_unaligned(_value : longint);
- begin
- inherited Create;
- typ:=ait_const;
- consttype:=aitconst_32bit_unaligned;
- value:=_value;
- sym:=nil;
- endsym:=nil;
- end;
- constructor tai_const.Create_16bit_unaligned(_value : word);
- begin
- inherited Create;
- typ:=ait_const;
- consttype:=aitconst_16bit_unaligned;
- value:=_value;
- sym:=nil;
- endsym:=nil;
- end;
- constructor tai_const.Create_8bit(_value : byte);
- begin
- inherited Create;
- typ:=ait_const;
- consttype:=aitconst_8bit;
- value:=_value;
- sym:=nil;
- endsym:=nil;
- end;
- constructor tai_const.Create_char(size: integer; _value: dword);
- begin
- inherited Create;
- typ:=ait_const;
- case size of
- 1:
- begin
- consttype:=aitconst_8bit;
- value:=byte(_value)
- end;
- 2:
- begin
- consttype:=aitconst_16bit;
- value:=word(_value)
- end
- else
- InternalError(2010030701)
- end
- end;
- constructor tai_const.Create_sleb128bit(_value : int64);
- begin
- inherited Create;
- typ:=ait_const;
- consttype:=aitconst_sleb128bit;
- value:=_value;
- sym:=nil;
- endsym:=nil;
- end;
- constructor tai_const.Create_uleb128bit(_value : qword);
- begin
- inherited Create;
- typ:=ait_const;
- consttype:=aitconst_uleb128bit;
- value:=int64(_value);
- sym:=nil;
- endsym:=nil;
- end;
- constructor tai_const.Create_aint(_value : aint);
- begin
- inherited Create;
- typ:=ait_const;
- consttype:=aitconst_aint;
- value:=_value;
- sym:=nil;
- endsym:=nil;
- end;
- constructor tai_const.Create_pint(_value : pint);
- begin
- inherited Create;
- typ:=ait_const;
- consttype:=aitconst_ptr;
- value:=_value;
- sym:=nil;
- endsym:=nil;
- end;
- constructor tai_const.Create_pint_unaligned(_value: pint);
- begin
- inherited Create;
- typ:=ait_const;
- consttype:=aitconst_ptr_unaligned;
- value:=_value;
- sym:=nil;
- endsym:=nil;
- end;
- constructor tai_const.Create_type_sym(_typ:taiconst_type;_sym:tasmsymbol);
- begin
- inherited Create;
- typ:=ait_const;
- consttype:=_typ;
- sym:=_sym;
- endsym:=nil;
- value:=0;
- { update sym info }
- if assigned(sym) then
- sym.increfs;
- end;
- constructor tai_const.Create_sym(_sym:tasmsymbol);
- begin
- self.create_sym_offset(_sym,0);
- end;
- {$ifdef i8086}
- constructor tai_const.Create_sym_near(_sym: tasmsymbol);
- begin
- self.create_sym(_sym);
- consttype:=aitconst_ptr;
- end;
- constructor tai_const.Create_sym_far(_sym: tasmsymbol);
- begin
- self.create_sym(_sym);
- consttype:=aitconst_farptr;
- end;
- {$endif i8086}
- constructor tai_const.Create_sym_offset(_sym:tasmsymbol;ofs:aint);
- begin
- inherited Create;
- typ:=ait_const;
- {$ifdef i8086}
- if assigned(_sym) and (_sym.typ=AT_DATA) then
- begin
- if current_settings.x86memorymodel in x86_far_data_models then
- consttype:=aitconst_farptr
- else
- consttype:=aitconst_ptr;
- end
- else
- begin
- if current_settings.x86memorymodel in x86_far_code_models then
- consttype:=aitconst_farptr
- else
- consttype:=aitconst_ptr;
- end;
- {$else i8086}
- consttype:=aitconst_ptr;
- {$endif i8086}
- { sym is allowed to be nil, this is used to write nil pointers }
- sym:=_sym;
- endsym:=nil;
- { store the original offset in symofs so that we can recalculate the
- value field in the assembler }
- symofs:=ofs;
- value:=ofs;
- { update sym info }
- if assigned(sym) then
- sym.increfs;
- end;
- constructor tai_const.Create_type_sym_offset(_typ : taiconst_type;_sym : tasmsymbol; ofs : aint);
- begin
- inherited Create;
- typ:=ait_const;
- consttype:=_typ;
- { sym is allowed to be nil, this is used to write nil pointers }
- sym:=_sym;
- endsym:=nil;
- { store the original offset in symofs so that we can recalculate the
- value field in the assembler }
- symofs:=ofs;
- value:=ofs;
- { update sym info }
- if assigned(sym) then
- sym.increfs;
- end;
- constructor tai_const.Create_rel_sym(_typ:taiconst_type;_sym,_endsym:tasmsymbol);
- begin
- self.create_sym_offset(_sym,0);
- consttype:=_typ;
- endsym:=_endsym;
- endsym.increfs;
- end;
- constructor tai_const.Create_rel_sym_offset(_typ: taiconst_type; _sym,_endsym: tasmsymbol; _ofs: int64);
- begin
- self.create_sym_offset(_sym,_ofs);
- consttype:=_typ;
- endsym:=_endsym;
- endsym.increfs;
- end;
- constructor tai_const.Create_rva_sym(_sym:tasmsymbol);
- begin
- self.create_sym_offset(_sym,0);
- consttype:=aitconst_rva_symbol;
- end;
- constructor tai_const.Createname(const name:string;ofs:aint);
- begin
- self.Createname(name,AT_NONE,ofs);
- end;
- constructor tai_const.Createname(const name:string;_symtyp:Tasmsymtype;ofs:aint);
- begin
- self.create_sym_offset(current_asmdata.RefAsmSymbol(name,_symtyp),ofs);
- end;
- constructor tai_const.Create_type_name(_typ:taiconst_type;const name:string;ofs:aint);
- begin
- self.Create_type_name(_typ,name,AT_NONE,ofs);
- end;
- constructor tai_const.Create_type_name(_typ:taiconst_type;const name:string;_symtyp:Tasmsymtype;ofs:aint);
- begin
- self.create_sym_offset(current_asmdata.RefAsmSymbol(name,_symtyp),ofs);
- consttype:=_typ;
- end;
- constructor tai_const.Create_nil_codeptr;
- begin
- self.Create_int_codeptr(0);
- end;
- constructor tai_const.Create_nil_dataptr;
- begin
- self.Create_int_dataptr(0);
- end;
- constructor tai_const.Create_int_codeptr(_value: int64);
- begin
- inherited Create;
- typ:=ait_const;
- {$ifdef i8086}
- if current_settings.x86memorymodel in x86_far_code_models then
- consttype:=aitconst_farptr
- else
- {$endif i8086}
- consttype:=aitconst_ptr;
- sym:=nil;
- endsym:=nil;
- symofs:=0;
- value:=_value;
- end;
- constructor tai_const.Create_int_dataptr(_value: int64);
- begin
- inherited Create;
- typ:=ait_const;
- {$ifdef i8086}
- if current_settings.x86memorymodel in x86_far_data_models then
- consttype:=aitconst_farptr
- else
- {$endif i8086}
- consttype:=aitconst_ptr;
- sym:=nil;
- endsym:=nil;
- symofs:=0;
- value:=_value;
- end;
- constructor tai_const.ppuload(t:taitype;ppufile:tcompilerppufile);
- begin
- inherited ppuload(t,ppufile);
- consttype:=taiconst_type(ppufile.getbyte);
- sym:=ppufile.getasmsymbol;
- endsym:=ppufile.getasmsymbol;
- value:=ppufile.getint64;
- end;
- procedure tai_const.ppuwrite(ppufile:tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- ppufile.putbyte(byte(consttype));
- ppufile.putasmsymbol(sym);
- ppufile.putasmsymbol(endsym);
- ppufile.putint64(value);
- end;
- procedure tai_const.derefimpl;
- begin
- end;
- function tai_const.getcopy:tlinkedlistitem;
- begin
- getcopy:=inherited getcopy;
- { we need to increase the reference number }
- if assigned(sym) then
- sym.increfs;
- if assigned(endsym) then
- endsym.increfs;
- end;
- function tai_const.size:longint;
- begin
- case consttype of
- aitconst_8bit :
- result:=1;
- aitconst_16bit,aitconst_16bit_unaligned :
- result:=2;
- aitconst_32bit,aitconst_darwin_dwarf_delta32,
- aitconst_32bit_unaligned:
- result:=4;
- aitconst_64bit,aitconst_darwin_dwarf_delta64,
- aitconst_64bit_unaligned:
- result:=8;
- aitconst_secrel32_symbol,
- aitconst_rva_symbol :
- if target_info.system=system_x86_64_win64 then
- result:=sizeof(longint)
- else
- result:=sizeof(pint);
- aitconst_uleb128bit :
- result:=LengthUleb128(qword(value));
- aitconst_sleb128bit :
- result:=LengthSleb128(value);
- aitconst_half16bit:
- result:=2;
- aitconst_gotoff_symbol:
- result:=4;
- else
- internalerror(200603253);
- end;
- end;
- {****************************************************************************
- TAI_real_32bit
- ****************************************************************************}
- 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);
- begin
- inherited ppuload(t,ppufile);
- value:=ppufile.getreal;
- end;
- procedure tai_real_32bit.ppuwrite(ppufile:tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- ppufile.putreal(value);
- end;
- {****************************************************************************
- TAI_real_64bit
- ****************************************************************************}
- constructor tai_real_64bit.Create(_value : ts64real);
- begin
- inherited Create;
- typ:=ait_real_64bit;
- value:=_value;
- end;
- {$ifdef ARM}
- constructor tai_real_64bit.Create_hiloswapped(_value : 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}
- 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);
- begin
- inherited ppuload(t,ppufile);
- value:=ppufile.getreal;
- savesize:=ppufile.getbyte;
- end;
- procedure tai_real_80bit.ppuwrite(ppufile:tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- ppufile.putreal(value);
- ppufile.putbyte(savesize);
- end;
- {****************************************************************************
- TAI_real_80bit
- ****************************************************************************}
- constructor tai_real_128bit.Create(_value : ts128real);
- begin
- inherited Create;
- typ:=ait_real_128bit;
- value:=_value;
- end;
- constructor tai_real_128bit.ppuload(t:taitype;ppufile:tcompilerppufile);
- begin
- inherited ppuload(t,ppufile);
- value:=ppufile.getreal;
- end;
- procedure tai_real_128bit.ppuwrite(ppufile:tcompilerppufile);
- 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;
- end;
- constructor tai_comp_64bit.ppuload(t:taitype;ppufile:tcompilerppufile);
- begin
- inherited ppuload(t,ppufile);
- ppufile.putdata(value,sizeof(value));
- end;
- procedure tai_comp_64bit.ppuwrite(ppufile:tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- ppufile.getdata(value,sizeof(value));
- end;
- {****************************************************************************
- TAI_STRING
- ****************************************************************************}
- constructor tai_string.Create(const _str : string);
- begin
- inherited Create;
- typ:=ait_string;
- len:=length(_str);
- getmem(str,len+1);
- move(_str[1],str^,len);
- str[len]:=#0;
- end;
- constructor tai_string.Create_pchar(_str : pchar;length : longint);
- begin
- inherited Create;
- typ:=ait_string;
- str:=_str;
- len:=length;
- end;
- destructor tai_string.destroy;
- begin
- if str<>nil then
- freemem(str);
- inherited Destroy;
- end;
- constructor tai_string.ppuload(t:taitype;ppufile:tcompilerppufile);
- begin
- inherited ppuload(t,ppufile);
- len:=ppufile.getlongint;
- getmem(str,len);
- ppufile.getdata(str^,len);
- end;
- procedure tai_string.ppuwrite(ppufile:tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- ppufile.putlongint(len);
- ppufile.putdata(str^,len);
- end;
- function tai_string.getcopy : tlinkedlistitem;
- var
- p : tlinkedlistitem;
- begin
- p:=inherited getcopy;
- getmem(tai_string(p).str,len);
- move(str^,tai_string(p).str^,len);
- getcopy:=p;
- end;
- {****************************************************************************
- TAI_LABEL
- ****************************************************************************}
- constructor tai_label.Create(_labsym : tasmlabel);
- begin
- inherited Create;
- typ:=ait_label;
- labsym:=_labsym;
- labsym.is_set:=true;
- end;
- constructor tai_label.ppuload(t:taitype;ppufile:tcompilerppufile);
- begin
- inherited ppuload(t,ppufile);
- labsym:=tasmlabel(ppufile.getasmsymbol);
- ppufile.getbyte; { was is_global flag, now unused }
- end;
- procedure tai_label.ppuwrite(ppufile:tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- ppufile.putasmsymbol(labsym);
- ppufile.putbyte(0); { was is_global flag, now unused }
- end;
- procedure tai_label.derefimpl;
- begin
- labsym.is_set:=true;
- end;
- {****************************************************************************
- tai_comment comment to be inserted in the assembler file
- ****************************************************************************}
- constructor tai_comment.Create(_str : pchar);
- begin
- inherited Create;
- typ:=ait_comment;
- str:=_str;
- end;
- destructor tai_comment.destroy;
- begin
- freemem(str);
- inherited Destroy;
- end;
- constructor tai_comment.ppuload(t:taitype;ppufile:tcompilerppufile);
- var
- len : longint;
- begin
- inherited ppuload(t,ppufile);
- len:=ppufile.getlongint;
- getmem(str,len+1);
- ppufile.getdata(str^,len);
- str[len]:=#0;
- end;
- procedure tai_comment.ppuwrite(ppufile:tcompilerppufile);
- var
- len : longint;
- begin
- inherited ppuwrite(ppufile);
- len:=strlen(str);
- ppufile.putlongint(len);
- ppufile.putdata(str^,len);
- end;
- function tai_comment.getcopy : tlinkedlistitem;
- var
- p : tlinkedlistitem;
- begin
- p:=inherited getcopy;
- getmem(tai_comment(p).str,strlen(str)+1);
- move(str^,tai_comment(p).str^,strlen(str)+1);
- getcopy:=p;
- end;
- {****************************************************************************
- TAI_STABS
- ****************************************************************************}
- constructor tai_stab.create(_stabtype:TStabType;_str : pchar);
- begin
- inherited create;
- typ:=ait_stab;
- str:=_str;
- stabtype:=_stabtype;
- end;
- constructor tai_stab.create_str(_stabtype:TStabType;const s:string);
- begin
- self.create(_stabtype,strpnew(s));
- end;
- constructor tai_stab.create_ansistr(_stabtype:TStabType;const s:ansistring);
- begin
- inherited create;
- typ:=ait_stab;
- stabtype:=_stabtype;
- getmem(str,length(s)+1);
- if length(s)>0 then
- move(s[1],str^,length(s)+1)
- else
- str^:=#0;
- end;
- destructor tai_stab.destroy;
- begin
- freemem(str);
- inherited destroy;
- end;
- {****************************************************************************
- TAI_FORCE_LINE
- ****************************************************************************}
- constructor tai_force_line.create;
- begin
- inherited create;
- typ:=ait_force_line;
- end;
- {****************************************************************************
- TAI_FUNCTION_NAME
- ****************************************************************************}
- constructor tai_function_name.create(const s:string);
- begin
- inherited create;
- typ:=ait_function_name;
- funcname:=stringdup(s);
- end;
- destructor tai_function_name.destroy;
- begin
- stringdispose(funcname);
- inherited destroy;
- end;
- {****************************************************************************
- TAI_CUTOBJECT
- ****************************************************************************}
- constructor tai_cutobject.Create;
- begin
- inherited Create;
- typ:=ait_cutobject;
- place:=cut_normal;
- end;
- constructor tai_cutobject.Create_begin;
- begin
- inherited Create;
- typ:=ait_cutobject;
- place:=cut_begin;
- end;
- constructor tai_cutobject.Create_end;
- begin
- inherited Create;
- typ:=ait_cutobject;
- place:=cut_end;
- end;
- constructor tai_cutobject.ppuload(t:taitype;ppufile:tcompilerppufile);
- begin
- inherited ppuload(t,ppufile);
- place:=TCutPlace(ppufile.getbyte);
- end;
- procedure tai_cutobject.ppuwrite(ppufile:tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- ppufile.putbyte(byte(place));
- end;
- {****************************************************************************
- Tai_Marker
- ****************************************************************************}
- constructor Tai_Marker.Create(_Kind: TAsmMarker);
- begin
- Inherited Create;
- typ := ait_marker;
- Kind := _Kind;
- end;
- constructor Tai_Marker.ppuload(t:taitype;ppufile:tcompilerppufile);
- begin
- inherited ppuload(t,ppufile);
- kind:=TAsmMarker(ppufile.getbyte);
- end;
- procedure Tai_Marker.ppuwrite(ppufile:tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- ppufile.putbyte(byte(kind));
- end;
- {*****************************************************************************
- tai_tempalloc
- *****************************************************************************}
- constructor tai_tempalloc.alloc(pos,size:longint);
- begin
- inherited Create;
- typ:=ait_tempalloc;
- allocation:=true;
- temppos:=pos;
- tempsize:=size;
- {$ifdef EXTDEBUG}
- problem:=nil;
- {$endif EXTDEBUG}
- end;
- destructor tai_tempalloc.destroy;
- begin
- {$ifdef EXTDEBUG}
- stringdispose(problem);
- {$endif EXTDEBUG}
- inherited destroy;
- end;
- constructor tai_tempalloc.dealloc(pos,size:longint);
- begin
- inherited Create;
- typ:=ait_tempalloc;
- allocation:=false;
- temppos:=pos;
- tempsize:=size;
- {$ifdef EXTDEBUG}
- problem:=nil;
- {$endif EXTDEBUG}
- end;
- {$ifdef EXTDEBUG}
- constructor tai_tempalloc.allocinfo(pos,size:longint;const st:string);
- begin
- inherited Create;
- typ:=ait_tempalloc;
- allocation:=false;
- temppos:=pos;
- tempsize:=size;
- problem:=stringdup(st);
- end;
- {$endif EXTDEBUG}
- constructor tai_tempalloc.ppuload(t:taitype;ppufile:tcompilerppufile);
- begin
- inherited ppuload(t,ppufile);
- temppos:=ppufile.getlongint;
- tempsize:=ppufile.getlongint;
- allocation:=boolean(ppufile.getbyte);
- {$ifdef EXTDEBUG}
- problem:=nil;
- {$endif EXTDEBUG}
- end;
- procedure tai_tempalloc.ppuwrite(ppufile:tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- ppufile.putlongint(temppos);
- ppufile.putlongint(tempsize);
- ppufile.putbyte(byte(allocation));
- end;
- {*****************************************************************************
- tai_regalloc
- *****************************************************************************}
- constructor tai_regalloc.alloc(r : tregister;ainstr:tai);
- begin
- inherited create;
- typ:=ait_regalloc;
- ratype:=ra_alloc;
- reg:=r;
- { ainstr must be an instruction }
- if assigned(ainstr) and
- (ainstr.typ<>ait_instruction) then
- internalerror(200411011);
- instr:=ainstr;
- end;
- constructor tai_regalloc.dealloc(r : tregister;ainstr:tai);
- begin
- inherited create;
- typ:=ait_regalloc;
- ratype:=ra_dealloc;
- reg:=r;
- { ainstr must be an instruction }
- if assigned(ainstr) and
- (ainstr.typ<>ait_instruction) then
- internalerror(200411012);
- instr:=ainstr;
- end;
- constructor tai_regalloc.sync(r : tregister);
- begin
- inherited create;
- typ:=ait_regalloc;
- ratype:=ra_sync;
- reg:=r;
- end;
- constructor tai_regalloc.resize(r : tregister);
- begin
- inherited create;
- typ:=ait_regalloc;
- ratype:=ra_resize;
- reg:=r;
- end;
- constructor tai_regalloc.markused(r : tregister);
- begin
- inherited create;
- typ:=ait_regalloc;
- ratype:=ra_markused;
- reg:=r;
- end;
- constructor tai_regalloc.ppuload(t:taitype;ppufile:tcompilerppufile);
- begin
- inherited ppuload(t,ppufile);
- ppufile.getdata(reg,sizeof(Tregister));
- ratype:=tregalloctype(ppufile.getbyte);
- keep:=boolean(ppufile.getbyte);
- end;
- procedure tai_regalloc.ppuwrite(ppufile:tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- ppufile.putdata(reg,sizeof(Tregister));
- ppufile.putbyte(byte(ratype));
- ppufile.putbyte(byte(keep));
- end;
- {*****************************************************************************
- TaiInstruction
- *****************************************************************************}
- constructor tai_cpu_abstract.Create(op : tasmop);
- begin
- inherited create;
- typ:=ait_instruction;
- is_jmp:=false;
- opcode:=op;
- ops:=0;
- end;
- destructor tai_cpu_abstract.Destroy;
- var
- i : integer;
- begin
- for i:=0 to opercnt-1 do
- freeop(i);
- inherited destroy;
- end;
- { ---------------------------------------------------------------------
- Loading of operands.
- ---------------------------------------------------------------------}
- procedure tai_cpu_abstract.allocate_oper(opers:longint);
- begin
- while (opers>opercnt) do
- begin
- new(oper[opercnt]);
- fillchar(oper[opercnt]^,sizeof(toper),0);
- inc(opercnt);
- end;
- end;
- procedure tai_cpu_abstract.loadconst(opidx:longint;l:aint);
- begin
- allocate_oper(opidx+1);
- with oper[opidx]^ do
- begin
- if typ<>top_const then
- clearop(opidx);
- val:=l;
- typ:=top_const;
- end;
- end;
- procedure tai_cpu_abstract.loadsymbol(opidx:longint;s:tasmsymbol;sofs:longint);
- var
- r : treference;
- begin
- reference_reset_symbol(r,s,sofs,1);
- r.refaddr:=addr_full;
- loadref(opidx,r);
- end;
- procedure tai_cpu_abstract.loadlocal(opidx:longint;s:pointer;sofs:longint;indexreg:tregister;scale:byte;getoffset,forceref:boolean);
- begin
- if not assigned(s) then
- internalerror(200204251);
- allocate_oper(opidx+1);
- with oper[opidx]^ do
- begin
- if typ<>top_local then
- begin
- clearop(opidx);
- new(localoper);
- end;
- with oper[opidx]^.localoper^ do
- begin
- localsym:=s;
- localsymofs:=sofs;
- localindexreg:=indexreg;
- localscale:=scale;
- localgetoffset:=getoffset;
- localforceref:=forceref;
- end;
- typ:=top_local;
- end;
- end;
- procedure tai_cpu_abstract.loadref(opidx:longint;const r:treference);
- begin
- allocate_oper(opidx+1);
- with oper[opidx]^ do
- begin
- if typ<>top_ref then
- begin
- clearop(opidx);
- new(ref);
- end;
- ref^:=r;
- {$ifdef x86}
- { We allow this exception for x86, since overloading this would be
- too much of a a speed penalty}
- if (ref^.segment<>NR_NO) and (ref^.segment<>NR_DS) then
- segprefix:=ref^.segment;
- {$endif}
- if (cs_create_pic in current_settings.moduleswitches) and
- assigned(r.symbol) and
- not assigned(r.relsymbol) and
- (r.refaddr=addr_no)
- {$ifdef ARM}
- and not(r.base=NR_R15)
- {$endif ARM}
- {$ifdef aarch64}
- and not(r.refaddr in [addr_full,addr_gotpageoffset,addr_gotpage])
- {$endif aarch64}
- then
- internalerror(200502052);
- typ:=top_ref;
- if assigned(add_reg_instruction_hook) then
- begin
- add_reg_instruction_hook(self,ref^.base);
- add_reg_instruction_hook(self,ref^.index);
- end;
- { mark symbol as used }
- if assigned(ref^.symbol) then
- ref^.symbol.increfs;
- if assigned(ref^.relsymbol) then
- ref^.relsymbol.increfs;
- end;
- end;
- procedure tai_cpu_abstract.loadreg(opidx:longint;r:tregister);
- begin
- allocate_oper(opidx+1);
- with oper[opidx]^ do
- begin
- if typ<>top_reg then
- clearop(opidx);
- reg:=r;
- typ:=top_reg;
- end;
- if assigned(add_reg_instruction_hook) then
- add_reg_instruction_hook(self,r);
- {$ifdef ARM}
- { R15 is the PC on the ARM thus moves to R15 are jumps.
- Due to speed considerations we don't use a virtual overridden method here.
- Because the pc/r15 isn't handled by the reg. allocator this should never cause
- problems with iregs getting r15.
- }
- is_jmp:=(opcode=A_MOV) and (opidx=0) and (r=NR_R15);
- {$endif ARM}
- end;
- procedure tai_cpu_abstract.loadoper(opidx:longint;o:toper);
- begin
- allocate_oper(opidx+1);
- clearop(opidx);
- oper[opidx]^:=o;
- { copy also the reference }
- with oper[opidx]^ do
- begin
- case typ of
- top_reg:
- begin
- if assigned(add_reg_instruction_hook) then
- add_reg_instruction_hook(self,reg);
- end;
- top_ref:
- begin
- new(ref);
- ref^:=o.ref^;
- {$ifdef x86}
- if (ref^.segment<>NR_NO) and (ref^.segment<>NR_DS) then
- segprefix:=ref^.segment;
- {$endif x86}
- if assigned(add_reg_instruction_hook) then
- begin
- add_reg_instruction_hook(self,ref^.base);
- add_reg_instruction_hook(self,ref^.index);
- end;
- end;
- {$ifdef ARM}
- top_shifterop:
- begin
- new(shifterop);
- shifterop^:=o.shifterop^;
- if assigned(add_reg_instruction_hook) then
- add_reg_instruction_hook(self,shifterop^.rs);
- end;
- {$endif ARM}
- end;
- end;
- end;
- procedure tai_cpu_abstract.clearop(opidx:longint);
- begin
- with oper[opidx]^ do
- begin
- case typ of
- top_ref:
- dispose(ref);
- top_local:
- dispose(localoper);
- {$ifdef ARM}
- top_shifterop:
- dispose(shifterop);
- top_regset:
- dispose(regset);
- {$endif ARM}
- {$ifdef m68k}
- top_regset:
- begin
- dispose(dataregset);
- dispose(addrregset);
- dispose(fpuregset);
- end;
- {$endif m68k}
- {$ifdef jvm}
- top_string:
- freemem(pcval);
- top_wstring:
- donewidestring(pwstrval);
- {$endif jvm}
- end;
- typ:=top_none;
- end;
- end;
- procedure tai_cpu_abstract.freeop(opidx:longint);
- begin
- clearop(opidx);
- dispose(oper[opidx]);
- end;
- { ---------------------------------------------------------------------
- Miscellaneous methods.
- ---------------------------------------------------------------------}
- procedure tai_cpu_abstract.SetCondition(const c:TAsmCond);
- begin
- condition:=c;
- end;
- Function tai_cpu_abstract.getcopy:TLinkedListItem;
- var
- i : longint;
- p : tai_cpu_abstract;
- begin
- p:=tai_cpu_abstract(inherited getcopy);
- { make a copy of the references }
- p.opercnt:=0;
- p.allocate_oper(ops);
- for i:=0 to ops-1 do
- begin
- p.oper[i]^:=oper[i]^;
- case oper[i]^.typ of
- top_local :
- begin
- new(p.oper[i]^.localoper);
- p.oper[i]^.localoper^:=oper[i]^.localoper^;
- end;
- top_ref :
- begin
- new(p.oper[i]^.ref);
- p.oper[i]^.ref^:=oper[i]^.ref^;
- end;
- {$ifdef ARM}
- top_shifterop:
- begin
- new(p.oper[i]^.shifterop);
- p.oper[i]^.shifterop^:=oper[i]^.shifterop^;
- end;
- {$endif ARM}
- end;
- end;
- getcopy:=p;
- end;
- function tai_cpu_abstract.is_same_reg_move(regtype: Tregistertype):boolean;
- begin
- { When the generic RA is used this needs to be overridden, we don't use
- virtual;abstract; to prevent a lot of warnings of unimplemented abstract methods
- when tai_cpu is created (PFV) }
- internalerror(2004040901);
- result:=false;
- end;
- function tai_cpu_abstract.spilling_get_operation_type(opnr: longint): topertype;
- begin
- internalerror(2004040902);
- result:=operand_readwrite;
- end;
- function tai_cpu_abstract.spilling_get_operation_type_ref(opnr: longint; reg: tregister): topertype;
- begin
- result := operand_read;
- end;
- constructor tai_cpu_abstract.ppuload(t:taitype;ppufile:tcompilerppufile);
- var
- i : integer;
- begin
- inherited ppuload(t,ppufile);
- { hopefully, we don't get problems with big/litte endian here when cross compiling :/ }
- ppufile.getdata(condition,sizeof(tasmcond));
- allocate_oper(ppufile.getbyte);
- for i:=0 to ops-1 do
- ppuloadoper(ppufile,oper[i]^);
- opcode:=tasmop(ppufile.getword);
- {$ifdef x86}
- ppufile.getdata(segprefix,sizeof(Tregister));
- {$endif x86}
- is_jmp:=boolean(ppufile.getbyte);
- end;
- procedure tai_cpu_abstract.ppuwrite(ppufile:tcompilerppufile);
- var
- i : integer;
- begin
- inherited ppuwrite(ppufile);
- ppufile.putdata(condition,sizeof(tasmcond));
- ppufile.putbyte(ops);
- for i:=0 to ops-1 do
- ppuwriteoper(ppufile,oper[i]^);
- ppufile.putword(word(opcode));
- {$ifdef x86}
- ppufile.putdata(segprefix,sizeof(Tregister));
- {$endif x86}
- ppufile.putbyte(byte(is_jmp));
- end;
- procedure tai_cpu_abstract.buildderefimpl;
- var
- i : integer;
- begin
- for i:=0 to ops-1 do
- ppubuildderefimploper(oper[i]^);
- end;
- procedure tai_cpu_abstract.derefimpl;
- var
- i : integer;
- begin
- for i:=0 to ops-1 do
- ppuderefoper(oper[i]^);
- end;
- procedure tai_cpu_abstract.resetpass1;
- begin
- end;
- procedure tai_cpu_abstract.resetpass2;
- begin
- end;
- function tai_cpu_abstract.Pass1(objdata:TObjData):longint;
- begin
- result:=0;
- end;
- procedure tai_cpu_abstract.Pass2(objdata:TObjData);
- begin
- end;
- procedure tai_cpu_abstract.ppuloadoper(ppufile:tcompilerppufile;var o:toper);
- begin
- o.typ:=toptype(ppufile.getbyte);
- o.ot:=ppufile.getlongint;
- case o.typ of
- top_reg :
- ppufile.getdata(o.reg,sizeof(Tregister));
- top_ref :
- begin
- new(o.ref);
- {$ifdef x86}
- ppufile.getdata(o.ref^.segment,sizeof(Tregister));
- {$endif x86}
- ppufile.getdata(o.ref^.base,sizeof(Tregister));
- ppufile.getdata(o.ref^.index,sizeof(Tregister));
- ppufile.getdata(o.ref^.refaddr,sizeof(o.ref^.refaddr));
- o.ref^.scalefactor:=ppufile.getbyte;
- o.ref^.offset:=ppufile.getaint;
- o.ref^.symbol:=ppufile.getasmsymbol;
- o.ref^.relsymbol:=ppufile.getasmsymbol;
- end;
- top_const :
- o.val:=ppufile.getaint;
- top_local :
- begin
- new(o.localoper);
- with o.localoper^ do
- begin
- ppufile.getderef(localsymderef);
- localsymofs:=ppufile.getaint;
- localindexreg:=tregister(ppufile.getlongint);
- localscale:=ppufile.getbyte;
- localgetoffset:=(ppufile.getbyte<>0);
- end;
- end;
- else
- internalerror(2007010210);
- end;
- end;
- procedure tai_cpu_abstract.ppuwriteoper(ppufile:tcompilerppufile;const o:toper);
- begin
- ppufile.putbyte(byte(o.typ));
- ppufile.putlongint(o.ot);
- case o.typ of
- top_reg :
- ppufile.putdata(o.reg,sizeof(Tregister));
- top_ref :
- begin
- {$ifdef x86}
- ppufile.putdata(o.ref^.segment,sizeof(Tregister));
- {$endif x86}
- ppufile.putdata(o.ref^.base,sizeof(Tregister));
- ppufile.putdata(o.ref^.index,sizeof(Tregister));
- ppufile.putdata(o.ref^.refaddr,sizeof(o.ref^.refaddr));
- ppufile.putbyte(o.ref^.scalefactor);
- ppufile.putaint(o.ref^.offset);
- ppufile.putasmsymbol(o.ref^.symbol);
- ppufile.putasmsymbol(o.ref^.relsymbol);
- end;
- top_const :
- ppufile.putaint(o.val);
- top_local :
- begin
- with o.localoper^ do
- begin
- ppufile.putderef(localsymderef);
- ppufile.putaint(localsymofs);
- ppufile.putlongint(longint(localindexreg));
- ppufile.putbyte(localscale);
- ppufile.putbyte(byte(localgetoffset));
- end;
- end;
- else
- internalerror(2007010211);
- end;
- end;
- {****************************************************************************
- tai_align_abstract
- ****************************************************************************}
- constructor tai_align_abstract.Create(b: byte);
- begin
- inherited Create;
- typ:=ait_align;
- {$ifdef EXTDEBUG}
- if upper(classname)='TAI_ALIGN_ABSTRACT' then
- internalerror(200709191);
- {$endif EXTDEBUG}
- if b in [1,2,4,8,16,32] then
- aligntype := b
- else
- aligntype := 1;
- fillsize:=0;
- fillop:=0;
- use_op:=false;
- end;
- constructor tai_align_abstract.Create_op(b: byte; _op: byte);
- begin
- inherited Create;
- typ:=ait_align;
- if b in [1,2,4,8,16,32] then
- aligntype := b
- else
- aligntype := 1;
- fillsize:=0;
- fillop:=_op;
- use_op:=true;
- end;
- constructor tai_align_abstract.Create_zeros(b: byte);
- begin
- inherited Create;
- typ:=ait_align;
- if b in [1,2,4,8,16,32] then
- aligntype := b
- else
- aligntype := 1;
- use_op:=true;
- fillsize:=0;
- fillop:=0;
- end;
- function tai_align_abstract.calculatefillbuf(var buf : tfillbuffer;executable : boolean):pchar;
- begin
- if fillsize>sizeof(buf) then
- internalerror(200404293);
- fillchar(buf,high(buf),fillop);
- calculatefillbuf:=pchar(@buf);
- end;
- constructor tai_align_abstract.ppuload(t:taitype;ppufile:tcompilerppufile);
- begin
- inherited ppuload(t,ppufile);
- aligntype:=ppufile.getbyte;
- fillsize:=0;
- fillop:=ppufile.getbyte;
- use_op:=boolean(ppufile.getbyte);
- end;
- procedure tai_align_abstract.ppuwrite(ppufile:tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- ppufile.putbyte(aligntype);
- ppufile.putbyte(fillop);
- ppufile.putbyte(byte(use_op));
- end;
- {****************************************************************************
- tai_seh_directive
- ****************************************************************************}
- const
- datatypemap: array[TAsmSehDirective] of TSehDirectiveDatatype=(
- sd_string, { proc }
- sd_none, { endproc }
- sd_none, { endprologue }
- sd_string, { handler }
- sd_none, { handlerdata }
- sd_none,sd_none,sd_none, { eh, 32, no32 }
- sd_regoffset, { setframe }
- sd_offset, { stackalloc }
- sd_reg, { pushreg }
- sd_regoffset, { savereg }
- sd_regoffset, { savexmm }
- sd_none { pushframe }
- );
- constructor tai_seh_directive.create(_kind:TAsmSehDirective);
- begin
- inherited Create;
- typ:=ait_seh_directive;
- kind:=_kind;
- data.typ:=datatypemap[_kind];
- end;
- constructor tai_seh_directive.create_name(_kind:TAsmSehDirective;const _name:string);
- begin
- create(_kind);
- data.name:=stringdup(_name);
- end;
- constructor tai_seh_directive.create_reg(_kind:TAsmSehDirective;r:TRegister);
- begin
- create(_kind);
- data.reg:=r;
- end;
- constructor tai_seh_directive.create_offset(_kind:TAsmSehDirective;ofs:dword);
- begin
- create(_kind);
- data.offset:=ofs;
- end;
- constructor tai_seh_directive.create_reg_offset(_kind:TAsmSehDirective;
- r:TRegister;ofs:dword);
- begin
- create(_kind);
- data.offset:=ofs;
- data.reg:=r;
- end;
- constructor tai_seh_directive.ppuload(t:taitype;ppufile:tcompilerppufile);
- begin
- inherited ppuload(t, ppufile);
- kind:=TAsmSehDirective(ppufile.getbyte);
- data.typ:=datatypemap[kind];
- case data.typ of
- sd_none: ;
- sd_string:
- begin
- data.name:=stringdup(ppufile.getstring);
- data.flags:=ppufile.getbyte;
- end;
- sd_reg,sd_offset,sd_regoffset:
- begin
- ppufile.getdata(data.reg,sizeof(TRegister));
- data.offset:=ppufile.getdword;
- end;
- else
- InternalError(2011091201);
- end;
- end;
- destructor tai_seh_directive.destroy;
- begin
- if data.typ=sd_string then
- stringdispose(data.name);
- inherited destroy;
- end;
- procedure tai_seh_directive.ppuwrite(ppufile:tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- ppufile.putbyte(ord(kind));
- case data.typ of
- sd_none: ;
- sd_string:
- begin
- ppufile.putstring(data.name^);
- ppufile.putbyte(data.flags);
- end;
- sd_reg,sd_offset,sd_regoffset:
- begin
- ppufile.putdata(data.reg,sizeof(TRegister));
- ppufile.putdword(data.offset);
- end;
- else
- InternalError(2011091202);
- end;
- end;
- procedure tai_seh_directive.generate_code(objdata:TObjData);
- begin
- end;
- {$ifdef JVM}
- {****************************************************************************
- tai_jvar
- ****************************************************************************}
- constructor tai_jvar.Create(_stackslot: longint; const _desc: shortstring; _startlab, _stoplab: TAsmSymbol);
- begin
- Inherited create;
- typ:=ait_jvar;
- stackslot:=_stackslot;
- desc:=stringdup(_desc);
- startlab:=_startlab;
- stoplab:=_stoplab;
- end;
- constructor tai_jvar.ppuload(t: taitype; ppufile: tcompilerppufile);
- begin
- inherited ppuload(t, ppufile);
- stackslot:=ppufile.getlongint;
- desc:=stringdup(ppufile.getstring);
- startlab:=ppufile.getasmsymbol;
- stoplab:=ppufile.getasmsymbol;
- end;
- procedure tai_jvar.ppuwrite(ppufile: tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- ppufile.putlongint(stackslot);
- ppufile.putstring(desc^);
- ppufile.putasmsymbol(startlab);
- ppufile.putasmsymbol(stoplab);
- end;
- destructor tai_jvar.destroy;
- begin
- stringdispose(desc);
- inherited destroy;
- end;
- {****************************************************************************
- tai_jcatch
- ****************************************************************************}
- constructor tai_jcatch.Create(const _name: shortstring; _startlab, _stoplab, _handlerlab: TAsmSymbol);
- begin
- Inherited create;
- typ:=ait_jcatch;
- name:=stringdup(_name);
- startlab:=_startlab;
- startlab.increfs;
- stoplab:=_stoplab;
- stoplab.increfs;
- handlerlab:=_handlerlab;
- handlerlab.increfs;
- end;
- destructor tai_jcatch.destroy;
- begin
- stringdispose(name);
- inherited destroy;
- end;
- constructor tai_jcatch.ppuload(t: taitype; ppufile: tcompilerppufile);
- begin
- inherited ppuload(t, ppufile);
- name:=stringdup(ppufile.getstring);
- startlab:=ppufile.getasmsymbol;
- startlab.increfs;
- stoplab:=ppufile.getasmsymbol;
- stoplab.increfs;
- handlerlab:=ppufile.getasmsymbol;
- handlerlab.increfs;
- end;
- procedure tai_jcatch.ppuwrite(ppufile: tcompilerppufile);
- begin
- inherited ppuwrite(ppufile);
- ppufile.putstring(name^);
- ppufile.putasmsymbol(startlab);
- ppufile.putasmsymbol(stoplab);
- ppufile.putasmsymbol(handlerlab);
- end;
- {$endif JVM}
- begin
- {$push}{$warnings off}
- { taitype should fit into a 4 byte set for speed reasons }
- if ord(high(taitype))>31 then
- internalerror(201108181);
- {$pop}
- end.
|