aasmtai.pas 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This unit implements an abstract asmoutput class for all processor types
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. { @abstract(This unit implements an abstract asm output class for all processor types)
  19. This unit implements an abstract assembler output class for all processors, these
  20. are then overriden for each assembler writer to actually write the data in these
  21. classes to an assembler file.
  22. }
  23. unit aasmtai;
  24. {$i fpcdefs.inc}
  25. interface
  26. uses
  27. cutils,cclasses,
  28. globtype,globals,systems,
  29. cpuinfo,cpubase,
  30. symppu,
  31. aasmbase;
  32. type
  33. taitype = (
  34. ait_none,
  35. ait_align,
  36. ait_section,
  37. ait_comment,
  38. ait_direct,
  39. ait_string,
  40. ait_instruction,
  41. ait_datablock,
  42. ait_symbol,
  43. ait_symbol_end, { needed to calc the size of a symbol }
  44. ait_label,
  45. ait_const_32bit,
  46. ait_const_16bit,
  47. ait_const_8bit,
  48. ait_const_symbol,
  49. { the following is only used by the win32 version of the compiler }
  50. { and only the GNU AS Win32 is able to write it }
  51. ait_const_rva,
  52. ait_real_32bit,
  53. ait_real_64bit,
  54. ait_real_80bit,
  55. ait_comp_64bit,
  56. {$ifdef GDB}
  57. ait_stabn,
  58. ait_stabs,
  59. ait_force_line,
  60. ait_stab_function_name,
  61. {$endif GDB}
  62. {$ifdef alpha}
  63. { the follow is for the DEC Alpha }
  64. ait_frame,
  65. ait_ent,
  66. {$endif alpha}
  67. {$ifdef ia64}
  68. ait_bundle,
  69. ait_stop,
  70. {$endif ia64}
  71. {$ifdef m68k}
  72. ait_labeled_instruction,
  73. {$endif m68k}
  74. {$ifdef SPARC}
  75. ait_labeled_instruction,
  76. {$endif SPARC}
  77. ait_cut, { used to split into tiny assembler files }
  78. ait_regalloc,
  79. ait_tempalloc,
  80. ait_marker { used to mark assembler blocks and inlined functions }
  81. );
  82. const
  83. taitypestr : array[taitype] of string[14] = (
  84. '<none>',
  85. 'align',
  86. 'section',
  87. 'comment',
  88. 'direct',
  89. 'string',
  90. 'instruction',
  91. 'datablock',
  92. 'symbol',
  93. 'symbol_end',
  94. 'label',
  95. 'const_32bit',
  96. 'const_16bit',
  97. 'const_8bit',
  98. 'const_symbol',
  99. 'const_rva',
  100. 'real_32bit',
  101. 'real_64bit',
  102. 'real_80bit',
  103. 'comp_64bit',
  104. {$ifdef GDB}
  105. 'stabn',
  106. 'stabs',
  107. 'force_line',
  108. 'stab_funcname',
  109. {$endif GDB}
  110. {$ifdef alpha}
  111. { the follow is for the DEC Alpha }
  112. 'frame',
  113. 'ent',
  114. {$endif alpha}
  115. {$ifdef ia64}
  116. 'bundle',
  117. 'stop',
  118. {$endif ia64}
  119. {$ifdef m68k}
  120. 'labeled_instr',
  121. {$endif m68k}
  122. {$ifdef SPARC}
  123. 'labeled_instr',
  124. {$endif SPARC}
  125. 'cut',
  126. 'regalloc',
  127. 'tempalloc',
  128. 'marker'
  129. );
  130. { ait_* types which don't result in executable code or which don't influence }
  131. { the way the program runs/behaves, but which may be encountered by the }
  132. { optimizer (= if it's sometimes added to the exprasm list). Update if you add }
  133. { a new ait type! }
  134. const
  135. SkipInstr = [ait_comment, ait_symbol,ait_section
  136. {$ifdef GDB}
  137. ,ait_stabs, ait_stabn, ait_stab_function_name, ait_force_line
  138. {$endif GDB}
  139. ,ait_regalloc, ait_tempalloc, ait_symbol_end];
  140. type
  141. { cut type, required for alphanumeric ordering of the assembler filenames }
  142. TCutPlace=(cut_normal,cut_begin,cut_end);
  143. TMarker = (NoPropInfoStart,NoPropInfoEnd,
  144. AsmBlockStart,AsmBlockEnd,
  145. InlineStart,InlineEnd);
  146. { the short name makes typing easier }
  147. tai = class(TLinkedListItem)
  148. { pointer to record with optimizer info about this tai object }
  149. optinfo : pointer;
  150. fileinfo : tfileposinfo;
  151. typ : taitype;
  152. constructor Create;
  153. constructor ppuload(t:taitype;ppufile:tcompilerppufile);virtual;
  154. procedure ppuwrite(ppufile:tcompilerppufile);virtual;
  155. procedure derefimpl;virtual;
  156. end;
  157. taiclass = class of tai;
  158. taiclassarray = array[taitype] of taiclass;
  159. { Generates an assembler string }
  160. tai_string = class(tai)
  161. str : pchar;
  162. { extra len so the string can contain an \0 }
  163. len : longint;
  164. constructor Create(const _str : string);
  165. constructor Create_pchar(_str : pchar);
  166. constructor Create_length_pchar(_str : pchar;length : longint);
  167. destructor Destroy;override;
  168. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  169. procedure ppuwrite(ppufile:tcompilerppufile);override;
  170. end;
  171. { Generates a common label }
  172. tai_symbol = class(tai)
  173. is_global : boolean;
  174. sym : tasmsymbol;
  175. size : longint;
  176. constructor Create(_sym:tasmsymbol;siz:longint);
  177. constructor Createname(const _name : string;siz:longint);
  178. constructor Createname_global(const _name : string;siz:longint);
  179. constructor Createdataname(const _name : string;siz:longint);
  180. constructor Createdataname_global(const _name : string;siz:longint);
  181. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  182. procedure ppuwrite(ppufile:tcompilerppufile);override;
  183. procedure derefimpl;override;
  184. end;
  185. tai_symbol_end = class(tai)
  186. sym : tasmsymbol;
  187. constructor Create(_sym:tasmsymbol);
  188. constructor Createname(const _name : string);
  189. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  190. procedure ppuwrite(ppufile:tcompilerppufile);override;
  191. procedure derefimpl;override;
  192. end;
  193. { Generates an assembler label }
  194. tai_label = class(tai)
  195. is_global : boolean;
  196. l : tasmlabel;
  197. constructor Create(_l : tasmlabel);
  198. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  199. procedure ppuwrite(ppufile:tcompilerppufile);override;
  200. procedure derefimpl;override;
  201. end;
  202. { Directly output data to final assembler file }
  203. tai_direct = class(tai)
  204. str : pchar;
  205. constructor Create(_str : pchar);
  206. destructor Destroy; override;
  207. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  208. procedure ppuwrite(ppufile:tcompilerppufile);override;
  209. end;
  210. { Generates an assembler comment }
  211. tai_comment = class(tai)
  212. str : pchar;
  213. constructor Create(_str : pchar);
  214. destructor Destroy; override;
  215. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  216. procedure ppuwrite(ppufile:tcompilerppufile);override;
  217. end;
  218. { Generates a section / segment directive }
  219. tai_section = class(tai)
  220. sec : TSection;
  221. constructor Create(s : TSection);
  222. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  223. procedure ppuwrite(ppufile:tcompilerppufile);override;
  224. end;
  225. { Generates an uninitializised data block }
  226. tai_datablock = class(tai)
  227. is_global : boolean;
  228. sym : tasmsymbol;
  229. size : longint;
  230. constructor Create(const _name : string;_size : longint);
  231. constructor Create_global(const _name : string;_size : longint);
  232. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  233. procedure ppuwrite(ppufile:tcompilerppufile);override;
  234. procedure derefimpl;override;
  235. end;
  236. { Generates a long integer (32 bit) }
  237. tai_const = class(tai)
  238. value : longint;
  239. constructor Create_32bit(_value : longint);
  240. constructor Create_16bit(_value : word);
  241. constructor Create_8bit(_value : byte);
  242. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  243. procedure ppuwrite(ppufile:tcompilerppufile);override;
  244. end;
  245. tai_const_symbol = class(tai)
  246. sym : tasmsymbol;
  247. offset : longint;
  248. constructor Create(_sym:tasmsymbol);
  249. constructor Create_offset(_sym:tasmsymbol;ofs:longint);
  250. constructor Create_rva(_sym:tasmsymbol);
  251. constructor Createname(const name:string);
  252. constructor Createname_offset(const name:string;ofs:longint);
  253. constructor Createname_rva(const name:string);
  254. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  255. procedure ppuwrite(ppufile:tcompilerppufile);override;
  256. procedure derefimpl;override;
  257. end;
  258. { Generates a single float (32 bit real) }
  259. tai_real_32bit = class(tai)
  260. value : ts32real;
  261. constructor Create(_value : ts32real);
  262. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  263. procedure ppuwrite(ppufile:tcompilerppufile);override;
  264. end;
  265. { Generates a double float (64 bit real) }
  266. tai_real_64bit = class(tai)
  267. value : ts64real;
  268. constructor Create(_value : ts64real);
  269. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  270. procedure ppuwrite(ppufile:tcompilerppufile);override;
  271. end;
  272. { Generates an extended float (80 bit real) }
  273. tai_real_80bit = class(tai)
  274. value : ts80real;
  275. constructor Create(_value : ts80real);
  276. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  277. procedure ppuwrite(ppufile:tcompilerppufile);override;
  278. end;
  279. { Generates a comp int (integer over 64 bits)
  280. This is Intel 80x86 specific, and is not
  281. really supported on other processors.
  282. }
  283. tai_comp_64bit = class(tai)
  284. value : ts64comp;
  285. constructor Create(_value : ts64comp);
  286. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  287. procedure ppuwrite(ppufile:tcompilerppufile);override;
  288. end;
  289. { Insert a cut to split assembler into several smaller files }
  290. tai_cut = class(tai)
  291. place : tcutplace;
  292. constructor Create;
  293. constructor Create_begin;
  294. constructor Create_end;
  295. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  296. procedure ppuwrite(ppufile:tcompilerppufile);override;
  297. end;
  298. { Insert a marker for assembler and inline blocks }
  299. tai_marker = class(tai)
  300. Kind: TMarker;
  301. Constructor Create(_Kind: TMarker);
  302. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  303. procedure ppuwrite(ppufile:tcompilerppufile);override;
  304. end;
  305. tai_tempalloc = class(tai)
  306. allocation : boolean;
  307. temppos,
  308. tempsize : longint;
  309. constructor alloc(pos,size:longint);
  310. constructor dealloc(pos,size:longint);
  311. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  312. procedure ppuwrite(ppufile:tcompilerppufile);override;
  313. end;
  314. tai_regalloc = class(tai)
  315. allocation : boolean;
  316. reg : tregister;
  317. constructor alloc(r : tregister);
  318. constructor dealloc(r : tregister);
  319. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  320. procedure ppuwrite(ppufile:tcompilerppufile);override;
  321. end;
  322. { Class template for assembler instructions
  323. }
  324. taicpu_abstract = class(tai)
  325. protected
  326. procedure ppuloadoper(ppufile:tcompilerppufile;var o:toper);virtual;abstract;
  327. procedure ppuwriteoper(ppufile:tcompilerppufile;const o:toper);virtual;abstract;
  328. procedure ppuderefoper(var o:toper);virtual;abstract;
  329. public
  330. { Condition flags for instruction }
  331. condition : TAsmCond;
  332. { Number of operands to instruction }
  333. ops : byte;
  334. { Operands of instruction }
  335. oper : array[0..max_operands-1] of toper;
  336. { Actual opcode of instruction }
  337. opcode : tasmop;
  338. {$ifdef i386}
  339. segprefix : tregister;
  340. {$endif i386}
  341. { true if instruction is a jmp }
  342. is_jmp : boolean; { is this instruction a jump? (needed for optimizer) }
  343. Constructor Create(op : tasmop);
  344. Destructor Destroy;override;
  345. function getcopy:TLinkedListItem;override;
  346. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  347. procedure ppuwrite(ppufile:tcompilerppufile);override;
  348. procedure derefimpl;override;
  349. procedure SetCondition(const c:TAsmCond);
  350. procedure loadconst(opidx:longint;l:aword);
  351. procedure loadsymbol(opidx:longint;s:tasmsymbol;sofs:longint);
  352. procedure loadref(opidx:longint;const r:treference);
  353. procedure loadreg(opidx:longint;r:tregister);
  354. procedure loadoper(opidx:longint;o:toper);
  355. end;
  356. { alignment for operator }
  357. tai_align_abstract = class(tai)
  358. buf : array[0..63] of char; { buf used for fill }
  359. aligntype : byte; { 1 = no align, 2 = word align, 4 = dword align }
  360. fillsize : byte; { real size to fill }
  361. fillop : byte; { value to fill with - optional }
  362. use_op : boolean;
  363. constructor Create(b:byte);
  364. constructor Create_op(b: byte; _op: byte);
  365. constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
  366. procedure ppuwrite(ppufile:tcompilerppufile);override;
  367. function getfillbuf:pchar;virtual;
  368. end;
  369. taasmoutput = class(tlinkedlist)
  370. function getlasttaifilepos : pfileposinfo;
  371. end;
  372. var
  373. { array with all class types for tais }
  374. aiclass : taiclassarray;
  375. { temporary lists }
  376. exprasmlist,
  377. { default lists }
  378. datasegment,codesegment,bsssegment,
  379. debuglist,withdebuglist,consts,
  380. importssection,exportssection,
  381. resourcesection,rttilist,
  382. resourcestringlist : taasmoutput;
  383. function ppuloadai(ppufile:tcompilerppufile):tai;
  384. procedure ppuwriteai(ppufile:tcompilerppufile;n:tai);
  385. implementation
  386. uses
  387. {$ifdef delphi}
  388. sysutils,
  389. {$else}
  390. strings,
  391. {$endif}
  392. verbose,
  393. ppu;
  394. const
  395. pputaimarker = 254;
  396. {****************************************************************************
  397. Helpers
  398. ****************************************************************************}
  399. function ppuloadai(ppufile:tcompilerppufile):tai;
  400. var
  401. b : byte;
  402. t : taitype;
  403. begin
  404. { marker }
  405. b:=ppufile.getbyte;
  406. if b<>pputaimarker then
  407. internalerror(200208181);
  408. { load nodetype }
  409. t:=taitype(ppufile.getbyte);
  410. if t<>ait_none then
  411. begin
  412. if t>high(taitype) then
  413. internalerror(200208182);
  414. if not assigned(aiclass[t]) then
  415. internalerror(200208183);
  416. //writeln('taiload: ',taitypestr[t]);
  417. { generate tai of the correct class }
  418. ppuloadai:=aiclass[t].ppuload(t,ppufile);
  419. end
  420. else
  421. ppuloadai:=nil;
  422. end;
  423. procedure ppuwriteai(ppufile:tcompilerppufile;n:tai);
  424. begin
  425. { marker, read by ppuloadnode }
  426. ppufile.putbyte(pputaimarker);
  427. if assigned(n) then
  428. begin
  429. { type, read by ppuloadnode }
  430. ppufile.putbyte(byte(n.typ));
  431. //writeln('taiwrite: ',taitypestr[n.typ]);
  432. n.ppuwrite(ppufile);
  433. end
  434. else
  435. ppufile.putbyte(byte(ait_none));
  436. end;
  437. {****************************************************************************
  438. TAI
  439. ****************************************************************************}
  440. constructor tai.Create;
  441. begin
  442. fileinfo:=aktfilepos;
  443. optinfo:=nil;
  444. end;
  445. constructor tai.ppuload(t:taitype;ppufile:tcompilerppufile);
  446. begin
  447. typ:=t;
  448. ppufile.getposinfo(fileinfo);
  449. optinfo:=nil;
  450. end;
  451. procedure tai.ppuwrite(ppufile:tcompilerppufile);
  452. begin
  453. ppufile.putposinfo(fileinfo);
  454. end;
  455. procedure tai.derefimpl;
  456. begin
  457. end;
  458. {****************************************************************************
  459. TAI_SECTION
  460. ****************************************************************************}
  461. constructor tai_section.Create(s : TSection);
  462. begin
  463. inherited Create;
  464. typ:=ait_section;
  465. sec:=s;
  466. end;
  467. constructor tai_section.ppuload(t:taitype;ppufile:tcompilerppufile);
  468. begin
  469. inherited ppuload(t,ppufile);
  470. sec:=tsection(ppufile.getbyte);
  471. end;
  472. procedure tai_section.ppuwrite(ppufile:tcompilerppufile);
  473. begin
  474. inherited ppuwrite(ppufile);
  475. ppufile.putbyte(byte(sec));
  476. end;
  477. {****************************************************************************
  478. TAI_DATABLOCK
  479. ****************************************************************************}
  480. constructor tai_datablock.Create(const _name : string;_size : longint);
  481. begin
  482. inherited Create;
  483. typ:=ait_datablock;
  484. sym:=objectlibrary.newasmsymboltype(_name,AB_LOCAL,AT_DATA);
  485. { keep things aligned }
  486. if _size<=0 then
  487. _size:=4;
  488. size:=_size;
  489. is_global:=false;
  490. end;
  491. constructor tai_datablock.Create_global(const _name : string;_size : longint);
  492. begin
  493. inherited Create;
  494. typ:=ait_datablock;
  495. sym:=objectlibrary.newasmsymboltype(_name,AB_GLOBAL,AT_DATA);
  496. { keep things aligned }
  497. if _size<=0 then
  498. _size:=4;
  499. size:=_size;
  500. is_global:=true;
  501. end;
  502. constructor tai_datablock.ppuload(t:taitype;ppufile:tcompilerppufile);
  503. begin
  504. inherited Create;
  505. sym:=ppufile.getasmsymbol;
  506. size:=ppufile.getlongint;
  507. is_global:=boolean(ppufile.getbyte);
  508. end;
  509. procedure tai_datablock.ppuwrite(ppufile:tcompilerppufile);
  510. begin
  511. inherited ppuwrite(ppufile);
  512. ppufile.putasmsymbol(sym);
  513. ppufile.putlongint(size);
  514. ppufile.putbyte(byte(is_global));
  515. end;
  516. procedure tai_datablock.derefimpl;
  517. begin
  518. objectlibrary.DerefAsmsymbol(sym);
  519. end;
  520. {****************************************************************************
  521. TAI_SYMBOL
  522. ****************************************************************************}
  523. constructor tai_symbol.Create(_sym:tasmsymbol;siz:longint);
  524. begin
  525. inherited Create;
  526. typ:=ait_symbol;
  527. sym:=_sym;
  528. size:=siz;
  529. is_global:=(sym.defbind=AB_GLOBAL);
  530. end;
  531. constructor tai_symbol.Createname(const _name : string;siz:longint);
  532. begin
  533. inherited Create;
  534. typ:=ait_symbol;
  535. sym:=objectlibrary.newasmsymboltype(_name,AB_LOCAL,AT_FUNCTION);
  536. size:=siz;
  537. is_global:=false;
  538. end;
  539. constructor tai_symbol.Createname_global(const _name : string;siz:longint);
  540. begin
  541. inherited Create;
  542. typ:=ait_symbol;
  543. sym:=objectlibrary.newasmsymboltype(_name,AB_GLOBAL,AT_FUNCTION);
  544. size:=siz;
  545. is_global:=true;
  546. end;
  547. constructor tai_symbol.Createdataname(const _name : string;siz:longint);
  548. begin
  549. inherited Create;
  550. typ:=ait_symbol;
  551. sym:=objectlibrary.newasmsymboltype(_name,AB_LOCAL,AT_DATA);
  552. size:=siz;
  553. is_global:=false;
  554. end;
  555. constructor tai_symbol.Createdataname_global(const _name : string;siz:longint);
  556. begin
  557. inherited Create;
  558. typ:=ait_symbol;
  559. sym:=objectlibrary.newasmsymboltype(_name,AB_GLOBAL,AT_DATA);
  560. size:=siz;
  561. is_global:=true;
  562. end;
  563. constructor tai_symbol.ppuload(t:taitype;ppufile:tcompilerppufile);
  564. begin
  565. inherited ppuload(t,ppufile);
  566. sym:=ppufile.getasmsymbol;
  567. size:=ppufile.getlongint;
  568. is_global:=boolean(ppufile.getbyte);
  569. end;
  570. procedure tai_symbol.ppuwrite(ppufile:tcompilerppufile);
  571. begin
  572. inherited ppuwrite(ppufile);
  573. ppufile.putasmsymbol(sym);
  574. ppufile.putlongint(size);
  575. ppufile.putbyte(byte(is_global));
  576. end;
  577. procedure tai_symbol.derefimpl;
  578. begin
  579. objectlibrary.DerefAsmsymbol(sym);
  580. end;
  581. {****************************************************************************
  582. TAI_SYMBOL
  583. ****************************************************************************}
  584. constructor tai_symbol_end.Create(_sym:tasmsymbol);
  585. begin
  586. inherited Create;
  587. typ:=ait_symbol_end;
  588. sym:=_sym;
  589. end;
  590. constructor tai_symbol_end.Createname(const _name : string);
  591. begin
  592. inherited Create;
  593. typ:=ait_symbol_end;
  594. sym:=objectlibrary.newasmsymboltype(_name,AB_GLOBAL,AT_NONE);
  595. end;
  596. constructor tai_symbol_end.ppuload(t:taitype;ppufile:tcompilerppufile);
  597. begin
  598. inherited ppuload(t,ppufile);
  599. sym:=ppufile.getasmsymbol;
  600. end;
  601. procedure tai_symbol_end.ppuwrite(ppufile:tcompilerppufile);
  602. begin
  603. inherited ppuwrite(ppufile);
  604. ppufile.putasmsymbol(sym);
  605. end;
  606. procedure tai_symbol_end.derefimpl;
  607. begin
  608. objectlibrary.DerefAsmsymbol(sym);
  609. end;
  610. {****************************************************************************
  611. TAI_CONST
  612. ****************************************************************************}
  613. constructor tai_const.Create_32bit(_value : longint);
  614. begin
  615. inherited Create;
  616. typ:=ait_const_32bit;
  617. value:=_value;
  618. end;
  619. constructor tai_const.Create_16bit(_value : word);
  620. begin
  621. inherited Create;
  622. typ:=ait_const_16bit;
  623. value:=_value;
  624. end;
  625. constructor tai_const.Create_8bit(_value : byte);
  626. begin
  627. inherited Create;
  628. typ:=ait_const_8bit;
  629. value:=_value;
  630. end;
  631. constructor tai_const.ppuload(t:taitype;ppufile:tcompilerppufile);
  632. begin
  633. inherited ppuload(t,ppufile);
  634. value:=ppufile.getlongint;
  635. end;
  636. procedure tai_const.ppuwrite(ppufile:tcompilerppufile);
  637. begin
  638. inherited ppuwrite(ppufile);
  639. ppufile.putlongint(value);
  640. end;
  641. {****************************************************************************
  642. TAI_CONST_SYMBOL_OFFSET
  643. ****************************************************************************}
  644. constructor tai_const_symbol.Create(_sym:tasmsymbol);
  645. begin
  646. inherited Create;
  647. typ:=ait_const_symbol;
  648. sym:=_sym;
  649. offset:=0;
  650. { update sym info }
  651. inc(sym.refs);
  652. end;
  653. constructor tai_const_symbol.Create_offset(_sym:tasmsymbol;ofs:longint);
  654. begin
  655. inherited Create;
  656. typ:=ait_const_symbol;
  657. sym:=_sym;
  658. offset:=ofs;
  659. { update sym info }
  660. inc(sym.refs);
  661. end;
  662. constructor tai_const_symbol.Create_rva(_sym:tasmsymbol);
  663. begin
  664. inherited Create;
  665. typ:=ait_const_rva;
  666. sym:=_sym;
  667. offset:=0;
  668. { update sym info }
  669. inc(sym.refs);
  670. end;
  671. constructor tai_const_symbol.Createname(const name:string);
  672. begin
  673. inherited Create;
  674. typ:=ait_const_symbol;
  675. sym:=objectlibrary.newasmsymbol(name);
  676. offset:=0;
  677. { update sym info }
  678. inc(sym.refs);
  679. end;
  680. constructor tai_const_symbol.Createname_offset(const name:string;ofs:longint);
  681. begin
  682. inherited Create;
  683. typ:=ait_const_symbol;
  684. sym:=objectlibrary.newasmsymbol(name);
  685. offset:=ofs;
  686. { update sym info }
  687. inc(sym.refs);
  688. end;
  689. constructor tai_const_symbol.Createname_rva(const name:string);
  690. begin
  691. inherited Create;
  692. typ:=ait_const_rva;
  693. sym:=objectlibrary.newasmsymbol(name);
  694. offset:=0;
  695. { update sym info }
  696. inc(sym.refs);
  697. end;
  698. constructor tai_const_symbol.ppuload(t:taitype;ppufile:tcompilerppufile);
  699. begin
  700. inherited ppuload(t,ppufile);
  701. sym:=ppufile.getasmsymbol;
  702. offset:=ppufile.getlongint;
  703. end;
  704. procedure tai_const_symbol.ppuwrite(ppufile:tcompilerppufile);
  705. begin
  706. inherited ppuwrite(ppufile);
  707. ppufile.putasmsymbol(sym);
  708. ppufile.putlongint(offset);
  709. end;
  710. procedure tai_const_symbol.derefimpl;
  711. begin
  712. objectlibrary.DerefAsmsymbol(sym);
  713. end;
  714. {****************************************************************************
  715. TAI_real_32bit
  716. ****************************************************************************}
  717. constructor tai_real_32bit.Create(_value : ts32real);
  718. begin
  719. inherited Create;
  720. typ:=ait_real_32bit;
  721. value:=_value;
  722. end;
  723. constructor tai_real_32bit.ppuload(t:taitype;ppufile:tcompilerppufile);
  724. begin
  725. inherited ppuload(t,ppufile);
  726. value:=ppufile.getreal;
  727. end;
  728. procedure tai_real_32bit.ppuwrite(ppufile:tcompilerppufile);
  729. begin
  730. inherited ppuwrite(ppufile);
  731. ppufile.putreal(value);
  732. end;
  733. {****************************************************************************
  734. TAI_real_64bit
  735. ****************************************************************************}
  736. constructor tai_real_64bit.Create(_value : ts64real);
  737. begin
  738. inherited Create;
  739. typ:=ait_real_64bit;
  740. value:=_value;
  741. end;
  742. constructor tai_real_64bit.ppuload(t:taitype;ppufile:tcompilerppufile);
  743. begin
  744. inherited ppuload(t,ppufile);
  745. value:=ppufile.getreal;
  746. end;
  747. procedure tai_real_64bit.ppuwrite(ppufile:tcompilerppufile);
  748. begin
  749. inherited ppuwrite(ppufile);
  750. ppufile.putreal(value);
  751. end;
  752. {****************************************************************************
  753. TAI_real_80bit
  754. ****************************************************************************}
  755. constructor tai_real_80bit.Create(_value : ts80real);
  756. begin
  757. inherited Create;
  758. typ:=ait_real_80bit;
  759. value:=_value;
  760. end;
  761. constructor tai_real_80bit.ppuload(t:taitype;ppufile:tcompilerppufile);
  762. begin
  763. inherited ppuload(t,ppufile);
  764. value:=ppufile.getreal;
  765. end;
  766. procedure tai_real_80bit.ppuwrite(ppufile:tcompilerppufile);
  767. begin
  768. inherited ppuwrite(ppufile);
  769. ppufile.putreal(value);
  770. end;
  771. {****************************************************************************
  772. Tai_comp_64bit
  773. ****************************************************************************}
  774. constructor tai_comp_64bit.Create(_value : ts64comp);
  775. begin
  776. inherited Create;
  777. typ:=ait_comp_64bit;
  778. value:=_value;
  779. end;
  780. constructor tai_comp_64bit.ppuload(t:taitype;ppufile:tcompilerppufile);
  781. begin
  782. inherited ppuload(t,ppufile);
  783. value:=ppufile.getreal;
  784. end;
  785. procedure tai_comp_64bit.ppuwrite(ppufile:tcompilerppufile);
  786. begin
  787. inherited ppuwrite(ppufile);
  788. ppufile.putreal(value);
  789. end;
  790. {****************************************************************************
  791. TAI_STRING
  792. ****************************************************************************}
  793. constructor tai_string.Create(const _str : string);
  794. begin
  795. inherited Create;
  796. typ:=ait_string;
  797. len:=length(_str);
  798. getmem(str,len+1);
  799. strpcopy(str,_str);
  800. end;
  801. constructor tai_string.Create_pchar(_str : pchar);
  802. begin
  803. inherited Create;
  804. typ:=ait_string;
  805. str:=_str;
  806. len:=strlen(_str);
  807. end;
  808. constructor tai_string.Create_length_pchar(_str : pchar;length : longint);
  809. begin
  810. inherited Create;
  811. typ:=ait_string;
  812. str:=_str;
  813. len:=length;
  814. end;
  815. destructor tai_string.destroy;
  816. begin
  817. { you can have #0 inside the strings so }
  818. if str<>nil then
  819. freemem(str,len+1);
  820. inherited Destroy;
  821. end;
  822. constructor tai_string.ppuload(t:taitype;ppufile:tcompilerppufile);
  823. begin
  824. inherited ppuload(t,ppufile);
  825. len:=ppufile.getlongint;
  826. getmem(str,len+1);
  827. ppufile.getdata(str^,len);
  828. str[len]:=#0;
  829. end;
  830. procedure tai_string.ppuwrite(ppufile:tcompilerppufile);
  831. begin
  832. inherited ppuwrite(ppufile);
  833. ppufile.putlongint(len);
  834. ppufile.putdata(str^,len);
  835. end;
  836. {****************************************************************************
  837. TAI_LABEL
  838. ****************************************************************************}
  839. constructor tai_label.create(_l : tasmlabel);
  840. begin
  841. inherited Create;
  842. typ:=ait_label;
  843. l:=_l;
  844. l.is_set:=true;
  845. is_global:=(l.defbind=AB_GLOBAL);
  846. end;
  847. constructor tai_label.ppuload(t:taitype;ppufile:tcompilerppufile);
  848. begin
  849. inherited ppuload(t,ppufile);
  850. l:=tasmlabel(ppufile.getasmsymbol);
  851. is_global:=boolean(ppufile.getbyte);
  852. end;
  853. procedure tai_label.ppuwrite(ppufile:tcompilerppufile);
  854. begin
  855. inherited ppuwrite(ppufile);
  856. ppufile.putasmsymbol(l);
  857. ppufile.putbyte(byte(is_global));
  858. end;
  859. procedure tai_label.derefimpl;
  860. begin
  861. objectlibrary.DerefAsmsymbol(tasmsymbol(l));
  862. l.is_set:=true;
  863. end;
  864. {****************************************************************************
  865. TAI_DIRECT
  866. ****************************************************************************}
  867. constructor tai_direct.Create(_str : pchar);
  868. begin
  869. inherited Create;
  870. typ:=ait_direct;
  871. str:=_str;
  872. end;
  873. destructor tai_direct.destroy;
  874. begin
  875. strdispose(str);
  876. inherited Destroy;
  877. end;
  878. constructor tai_direct.ppuload(t:taitype;ppufile:tcompilerppufile);
  879. var
  880. len : longint;
  881. begin
  882. inherited ppuload(t,ppufile);
  883. len:=ppufile.getlongint;
  884. getmem(str,len+1);
  885. ppufile.getdata(str^,len);
  886. str[len]:=#0;
  887. end;
  888. procedure tai_direct.ppuwrite(ppufile:tcompilerppufile);
  889. var
  890. len : longint;
  891. begin
  892. inherited ppuwrite(ppufile);
  893. len:=strlen(str);
  894. ppufile.putlongint(len);
  895. ppufile.putdata(str^,len);
  896. end;
  897. {****************************************************************************
  898. tai_comment comment to be inserted in the assembler file
  899. ****************************************************************************}
  900. constructor tai_comment.Create(_str : pchar);
  901. begin
  902. inherited Create;
  903. typ:=ait_comment;
  904. str:=_str;
  905. end;
  906. destructor tai_comment.destroy;
  907. begin
  908. strdispose(str);
  909. inherited Destroy;
  910. end;
  911. constructor tai_comment.ppuload(t:taitype;ppufile:tcompilerppufile);
  912. var
  913. len : longint;
  914. begin
  915. inherited ppuload(t,ppufile);
  916. len:=ppufile.getlongint;
  917. getmem(str,len+1);
  918. ppufile.getdata(str^,len);
  919. str[len]:=#0;
  920. end;
  921. procedure tai_comment.ppuwrite(ppufile:tcompilerppufile);
  922. var
  923. len : longint;
  924. begin
  925. inherited ppuwrite(ppufile);
  926. len:=strlen(str);
  927. ppufile.putlongint(len);
  928. ppufile.putdata(str^,len);
  929. end;
  930. {****************************************************************************
  931. TAI_CUT
  932. ****************************************************************************}
  933. constructor tai_cut.Create;
  934. begin
  935. inherited Create;
  936. typ:=ait_cut;
  937. place:=cut_normal;
  938. end;
  939. constructor tai_cut.Create_begin;
  940. begin
  941. inherited Create;
  942. typ:=ait_cut;
  943. place:=cut_begin;
  944. end;
  945. constructor tai_cut.Create_end;
  946. begin
  947. inherited Create;
  948. typ:=ait_cut;
  949. place:=cut_end;
  950. end;
  951. constructor tai_cut.ppuload(t:taitype;ppufile:tcompilerppufile);
  952. begin
  953. inherited ppuload(t,ppufile);
  954. place:=TCutPlace(ppufile.getbyte);
  955. end;
  956. procedure tai_cut.ppuwrite(ppufile:tcompilerppufile);
  957. begin
  958. inherited ppuwrite(ppufile);
  959. ppufile.putbyte(byte(place));
  960. end;
  961. {****************************************************************************
  962. Tai_Marker
  963. ****************************************************************************}
  964. Constructor Tai_Marker.Create(_Kind: TMarker);
  965. Begin
  966. Inherited Create;
  967. typ := ait_marker;
  968. Kind := _Kind;
  969. End;
  970. constructor Tai_Marker.ppuload(t:taitype;ppufile:tcompilerppufile);
  971. begin
  972. inherited ppuload(t,ppufile);
  973. kind:=TMarker(ppufile.getbyte);
  974. end;
  975. procedure Tai_Marker.ppuwrite(ppufile:tcompilerppufile);
  976. begin
  977. inherited ppuwrite(ppufile);
  978. ppufile.putbyte(byte(kind));
  979. end;
  980. {*****************************************************************************
  981. tai_tempalloc
  982. *****************************************************************************}
  983. constructor tai_tempalloc.alloc(pos,size:longint);
  984. begin
  985. inherited Create;
  986. typ:=ait_tempalloc;
  987. allocation:=true;
  988. temppos:=pos;
  989. tempsize:=size;
  990. end;
  991. constructor tai_tempalloc.dealloc(pos,size:longint);
  992. begin
  993. inherited Create;
  994. typ:=ait_tempalloc;
  995. allocation:=false;
  996. temppos:=pos;
  997. tempsize:=size;
  998. end;
  999. constructor tai_tempalloc.ppuload(t:taitype;ppufile:tcompilerppufile);
  1000. begin
  1001. inherited ppuload(t,ppufile);
  1002. temppos:=ppufile.getlongint;
  1003. tempsize:=ppufile.getlongint;
  1004. allocation:=boolean(ppufile.getbyte);
  1005. end;
  1006. procedure tai_tempalloc.ppuwrite(ppufile:tcompilerppufile);
  1007. begin
  1008. inherited ppuwrite(ppufile);
  1009. ppufile.putlongint(temppos);
  1010. ppufile.putlongint(tempsize);
  1011. ppufile.putbyte(byte(allocation));
  1012. end;
  1013. {*****************************************************************************
  1014. tai_regalloc
  1015. *****************************************************************************}
  1016. constructor tai_regalloc.alloc(r : tregister);
  1017. begin
  1018. inherited create;
  1019. typ:=ait_regalloc;
  1020. allocation:=true;
  1021. reg:=r;
  1022. end;
  1023. constructor tai_regalloc.dealloc(r : tregister);
  1024. begin
  1025. inherited create;
  1026. typ:=ait_regalloc;
  1027. allocation:=false;
  1028. reg:=r;
  1029. end;
  1030. constructor tai_regalloc.ppuload(t:taitype;ppufile:tcompilerppufile);
  1031. begin
  1032. inherited ppuload(t,ppufile);
  1033. reg:=tregister(ppufile.getbyte);
  1034. allocation:=boolean(ppufile.getbyte);
  1035. end;
  1036. procedure tai_regalloc.ppuwrite(ppufile:tcompilerppufile);
  1037. begin
  1038. inherited ppuwrite(ppufile);
  1039. ppufile.putbyte(byte(reg));
  1040. ppufile.putbyte(byte(allocation));
  1041. end;
  1042. {*****************************************************************************
  1043. TaiInstruction
  1044. *****************************************************************************}
  1045. constructor taicpu_abstract.Create(op : tasmop);
  1046. begin
  1047. inherited create;
  1048. typ:=ait_instruction;
  1049. is_jmp:=false;
  1050. opcode:=op;
  1051. ops:=0;
  1052. fillchar(condition,sizeof(condition),0);
  1053. fillchar(oper,sizeof(oper),0);
  1054. end;
  1055. destructor taicpu_abstract.Destroy;
  1056. var
  1057. i : longint;
  1058. begin
  1059. for i:=0 to ops-1 do
  1060. case oper[i].typ of
  1061. top_ref:
  1062. dispose(oper[i].ref);
  1063. top_symbol:
  1064. dec(tasmsymbol(oper[i].sym).refs);
  1065. end;
  1066. inherited destroy;
  1067. end;
  1068. { ---------------------------------------------------------------------
  1069. Loading of operands.
  1070. ---------------------------------------------------------------------}
  1071. procedure taicpu_abstract.loadconst(opidx:longint;l:aword);
  1072. begin
  1073. if opidx>=ops then
  1074. ops:=opidx+1;
  1075. with oper[opidx] do
  1076. begin
  1077. if typ=top_ref then
  1078. dispose(ref);
  1079. val:=l;
  1080. typ:=top_const;
  1081. end;
  1082. end;
  1083. procedure taicpu_abstract.loadsymbol(opidx:longint;s:tasmsymbol;sofs:longint);
  1084. begin
  1085. if not assigned(s) then
  1086. internalerror(200204251);
  1087. if opidx>=ops then
  1088. ops:=opidx+1;
  1089. with oper[opidx] do
  1090. begin
  1091. if typ=top_ref then
  1092. dispose(ref);
  1093. sym:=s;
  1094. symofs:=sofs;
  1095. typ:=top_symbol;
  1096. end;
  1097. inc(s.refs);
  1098. end;
  1099. procedure taicpu_abstract.loadref(opidx:longint;const r:treference);
  1100. begin
  1101. if opidx>=ops then
  1102. ops:=opidx+1;
  1103. with oper[opidx] do
  1104. begin
  1105. if typ<>top_ref then
  1106. new(ref);
  1107. ref^:=r;
  1108. {$ifdef i386}
  1109. { We allow this exception for i386, since overloading this would be
  1110. too much of a a speed penalty}
  1111. if not(ref^.segment in [R_DS,R_NO]) then
  1112. segprefix:=ref^.segment;
  1113. {$endif}
  1114. typ:=top_ref;
  1115. { mark symbol as used }
  1116. if assigned(ref^.symbol) then
  1117. inc(ref^.symbol.refs);
  1118. end;
  1119. end;
  1120. procedure taicpu_abstract.loadreg(opidx:longint;r:tregister);
  1121. begin
  1122. if opidx>=ops then
  1123. ops:=opidx+1;
  1124. with oper[opidx] do
  1125. begin
  1126. if typ=top_ref then
  1127. dispose(ref);
  1128. reg:=r;
  1129. typ:=top_reg;
  1130. end;
  1131. end;
  1132. procedure taicpu_abstract.loadoper(opidx:longint;o:toper);
  1133. begin
  1134. if opidx>=ops then
  1135. ops:=opidx+1;
  1136. if oper[opidx].typ=top_ref then
  1137. dispose(oper[opidx].ref);
  1138. oper[opidx]:=o;
  1139. { copy also the reference }
  1140. if oper[opidx].typ=top_ref then
  1141. begin
  1142. new(oper[opidx].ref);
  1143. oper[opidx].ref^:=o.ref^;
  1144. end;
  1145. end;
  1146. { ---------------------------------------------------------------------
  1147. Miscellaneous methods.
  1148. ---------------------------------------------------------------------}
  1149. procedure taicpu_abstract.SetCondition(const c:TAsmCond);
  1150. begin
  1151. condition:=c;
  1152. end;
  1153. Function taicpu_abstract.getcopy:TLinkedListItem;
  1154. var
  1155. i : longint;
  1156. p : TLinkedListItem;
  1157. begin
  1158. p:=inherited getcopy;
  1159. { make a copy of the references }
  1160. for i:=1 to ops do
  1161. if (taicpu_abstract(p).oper[i-1].typ=top_ref) then
  1162. begin
  1163. new(taicpu_abstract(p).oper[i-1].ref);
  1164. taicpu_abstract(p).oper[i-1].ref^:=oper[i-1].ref^;
  1165. end;
  1166. getcopy:=p;
  1167. end;
  1168. constructor taicpu_abstract.ppuload(t:taitype;ppufile:tcompilerppufile);
  1169. var
  1170. i : integer;
  1171. begin
  1172. inherited ppuload(t,ppufile);
  1173. { hopefully, we don't get problems with big/litte endian here when cross compiling :/ }
  1174. ppufile.getdata(condition,sizeof(tasmcond));
  1175. ops:=ppufile.getbyte;
  1176. for i:=1 to ops do
  1177. ppuloadoper(ppufile,oper[i-1]);
  1178. opcode:=tasmop(ppufile.getword);
  1179. {$ifdef i386}
  1180. segprefix:=tregister(ppufile.getbyte);
  1181. {$endif i386}
  1182. is_jmp:=boolean(ppufile.getbyte);
  1183. end;
  1184. procedure taicpu_abstract.ppuwrite(ppufile:tcompilerppufile);
  1185. var
  1186. i : integer;
  1187. begin
  1188. inherited ppuwrite(ppufile);
  1189. ppufile.putdata(condition,sizeof(tasmcond));
  1190. ppufile.putbyte(ops);
  1191. for i:=1 to ops do
  1192. ppuwriteoper(ppufile,oper[i-1]);
  1193. ppufile.putword(word(opcode));
  1194. {$ifdef i386}
  1195. ppufile.putbyte(byte(segprefix));
  1196. {$endif i386}
  1197. ppufile.putbyte(byte(is_jmp));
  1198. end;
  1199. procedure taicpu_abstract.derefimpl;
  1200. var
  1201. i : integer;
  1202. begin
  1203. for i:=1 to ops do
  1204. ppuderefoper(oper[i-1]);
  1205. end;
  1206. {****************************************************************************
  1207. tai_align_abstract
  1208. ****************************************************************************}
  1209. constructor tai_align_abstract.Create(b: byte);
  1210. begin
  1211. inherited Create;
  1212. typ:=ait_align;
  1213. if b in [1,2,4,8,16,32] then
  1214. aligntype := b
  1215. else
  1216. aligntype := 1;
  1217. fillsize:=0;
  1218. fillop:=0;
  1219. use_op:=false;
  1220. end;
  1221. constructor tai_align_abstract.Create_op(b: byte; _op: byte);
  1222. begin
  1223. inherited Create;
  1224. typ:=ait_align;
  1225. if b in [1,2,4,8,16,32] then
  1226. aligntype := b
  1227. else
  1228. aligntype := 1;
  1229. fillsize:=0;
  1230. fillop:=_op;
  1231. use_op:=true;
  1232. fillchar(buf,sizeof(buf),_op)
  1233. end;
  1234. function tai_align_abstract.getfillbuf:pchar;
  1235. begin
  1236. getfillbuf:=@buf;
  1237. end;
  1238. constructor tai_align_abstract.ppuload(t:taitype;ppufile:tcompilerppufile);
  1239. begin
  1240. inherited ppuload(t,ppufile);
  1241. aligntype:=ppufile.getbyte;
  1242. fillsize:=0;
  1243. fillop:=ppufile.getbyte;
  1244. use_op:=boolean(ppufile.getbyte);
  1245. end;
  1246. procedure tai_align_abstract.ppuwrite(ppufile:tcompilerppufile);
  1247. begin
  1248. inherited ppuwrite(ppufile);
  1249. ppufile.putbyte(aligntype);
  1250. ppufile.putbyte(fillop);
  1251. ppufile.putbyte(byte(use_op));
  1252. end;
  1253. {*****************************************************************************
  1254. TAAsmOutput
  1255. *****************************************************************************}
  1256. function taasmoutput.getlasttaifilepos : pfileposinfo;
  1257. begin
  1258. if assigned(last) then
  1259. getlasttaifilepos:=@tai(last).fileinfo
  1260. else
  1261. getlasttaifilepos:=nil;
  1262. end;
  1263. end.
  1264. {
  1265. $Log$
  1266. Revision 1.9 2002-10-05 12:43:23 carl
  1267. * fixes for Delphi 6 compilation
  1268. (warning : Some features do not work under Delphi)
  1269. Revision 1.8 2002/08/19 19:36:42 peter
  1270. * More fixes for cross unit inlining, all tnodes are now implemented
  1271. * Moved pocall_internconst to po_internconst because it is not a
  1272. calling type at all and it conflicted when inlining of these small
  1273. functions was requested
  1274. Revision 1.7 2002/08/18 20:06:23 peter
  1275. * inlining is now also allowed in interface
  1276. * renamed write/load to ppuwrite/ppuload
  1277. * tnode storing in ppu
  1278. * nld,ncon,nbas are already updated for storing in ppu
  1279. Revision 1.6 2002/08/16 05:21:09 florian
  1280. * powerpc compilation fix
  1281. Revision 1.5 2002/08/15 19:10:35 peter
  1282. * first things tai,tnode storing in ppu
  1283. Revision 1.4 2002/08/11 14:32:25 peter
  1284. * renamed current_library to objectlibrary
  1285. Revision 1.3 2002/08/11 13:24:10 peter
  1286. * saving of asmsymbols in ppu supported
  1287. * asmsymbollist global is removed and moved into a new class
  1288. tasmlibrarydata that will hold the info of a .a file which
  1289. corresponds with a single module. Added librarydata to tmodule
  1290. to keep the library info stored for the module. In the future the
  1291. objectfiles will also be stored to the tasmlibrarydata class
  1292. * all getlabel/newasmsymbol and friends are moved to the new class
  1293. Revision 1.2 2002/08/05 18:27:48 carl
  1294. + more more more documentation
  1295. + first version include/exclude (can't test though, not enough scratch for i386 :()...
  1296. Revision 1.1 2002/07/01 18:46:20 peter
  1297. * internal linker
  1298. * reorganized aasm layer
  1299. Revision 1.27 2002/05/18 13:34:04 peter
  1300. * readded missing revisions
  1301. Revision 1.25 2002/05/14 19:34:38 peter
  1302. * removed old logs and updated copyright year
  1303. Revision 1.24 2002/05/14 17:28:08 peter
  1304. * synchronized cpubase between powerpc and i386
  1305. * moved more tables from cpubase to cpuasm
  1306. * tai_align_abstract moved to tainst, cpuasm must define
  1307. the tai_align class now, which may be empty
  1308. Revision 1.23 2002/04/15 18:54:34 carl
  1309. - removed tcpuflags
  1310. Revision 1.22 2002/04/07 13:18:19 carl
  1311. + more documentation
  1312. Revision 1.21 2002/04/07 10:17:40 carl
  1313. - remove packenumfixed (requires version 1.0.2 or later to compile now!)
  1314. + changing some comments so its commented automatically
  1315. Revision 1.20 2002/03/24 19:04:31 carl
  1316. + patch for SPARC from Mazen NEIFER
  1317. }