cgobj.pas 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Florian Klaempfl
  4. Member of the Free Pascal development team
  5. This unit implements the basic code generator object
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. unit cgobj;
  20. interface
  21. uses
  22. cclasses,aasm,cpuasm,cpubase,cpuinfo,
  23. cgconst,cgbase,
  24. tainst,
  25. symtable,symconst,symbase,symtype,symsym;
  26. type
  27. talignment = (AM_NATURAL,AM_NONE,AM_2BYTE,AM_4BYTE,AM_8BYTE);
  28. pcg = ^tcg;
  29. tcg = object
  30. scratch_register_array_pointer : aword;
  31. unusedscratchregisters : tregisterset;
  32. alignment : talignment;
  33. {************************************************}
  34. { basic routines }
  35. constructor init;
  36. destructor done;virtual;
  37. procedure a_label(list : taasmoutput;l : tasmlabel);virtual;
  38. { allocates register r by inserting a pai_realloc record }
  39. procedure a_reg_alloc(list : taasmoutput;r : tregister);
  40. { deallocates register r by inserting a pa_regdealloc record}
  41. procedure a_reg_dealloc(list : taasmoutput;r : tregister);
  42. { returns a register for use as scratch register }
  43. function get_scratch_reg(list : taasmoutput) : tregister;
  44. { releases a scratch register }
  45. procedure free_scratch_reg(list : taasmoutput;r : tregister);
  46. {************************************************}
  47. { code generation for subroutine entry/exit code }
  48. { initilizes data of type t }
  49. { if is_already_ref is true then the routines assumes }
  50. { that r points to the data to initialize }
  51. procedure g_initialize(list : taasmoutput;t : tdef;const ref : treference;is_already_ref : boolean);
  52. { finalizes data of type t }
  53. { if is_already_ref is true then the routines assumes }
  54. { that r points to the data to finalizes }
  55. procedure g_finalize(list : taasmoutput;t : tdef;const ref : treference;is_already_ref : boolean);
  56. { helper routines }
  57. procedure g_initialize_data(list : taasmoutput;p : tsym);
  58. procedure g_incr_data(list : taasmoutput;p : tsym);
  59. procedure g_finalize_data(list : taasmoutput;p : tindexarray);
  60. procedure g_copyvalueparas(list : taasmoutput;p : tindexarray);
  61. procedure g_finalizetempansistrings(list : taasmoutput);
  62. procedure g_entrycode(list : taasmoutput;
  63. const proc_names : tstringlist;make_global : boolean;
  64. stackframe : longint;var parasize : longint;
  65. var nostackframe : boolean;inlined : boolean);
  66. procedure g_exitcode(list : taasmoutput;parasize : longint;
  67. nostackframe,inlined : boolean);
  68. { string helper routines }
  69. procedure g_decrstrref(list : taasmoutput;const ref : treference;t : tdef);
  70. procedure g_removetemps(list : taasmoutput;p : tlinkedlist);
  71. { passing parameters, per default the parameter is pushed }
  72. { nr gives the number of the parameter (enumerated from }
  73. { left to right), this allows to move the parameter to }
  74. { register, if the cpu supports register calling }
  75. { conventions }
  76. procedure a_param_reg(list : taasmoutput;size : tcgsize;r : tregister;nr : longint);virtual;
  77. procedure a_param_const(list : taasmoutput;size : tcgsize;a : aword;nr : longint);virtual;
  78. procedure a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;nr : longint);virtual;
  79. procedure a_paramaddr_ref(list : taasmoutput;const r : treference;nr : longint);virtual;
  80. {**********************************}
  81. { these methods must be overriden: }
  82. { Remarks:
  83. * If a method specifies a size you have only to take care
  84. of that number of bits, i.e. load_const_reg with OP_8 must
  85. only load the lower 8 bit of the specified register
  86. the rest of the register can be undefined
  87. if necessary the compiler will call a method
  88. to zero or sign extend the register
  89. * The a_load_XX_XX with OP_64 needn't to be
  90. implemented for 32 bit
  91. processors, the code generator takes care of that
  92. * the addr size is for work with the natural pointer
  93. size
  94. * the procedures without fpu/mm are only for integer usage
  95. * normally the first location is the source and the
  96. second the destination
  97. }
  98. procedure a_call_name(list : taasmoutput;const s : string;
  99. offset : longint);virtual;
  100. { move instructions }
  101. procedure a_load_const_reg(list : taasmoutput;size : tcgsize;a : aword;register : tregister);virtual;
  102. procedure a_load_const_ref(list : taasmoutput;size : tcgsize;a : aword;const ref : treference);virtual;
  103. procedure a_load_reg_ref(list : taasmoutput;size : tcgsize;register : tregister;const ref : treference);virtual;
  104. procedure a_load_ref_reg(list : taasmoutput;size : tcgsize;const ref : treference;register : tregister);virtual;
  105. procedure a_load_reg_reg(list : taasmoutput;size : tcgsize;reg1,reg2 : tregister);virtual;
  106. { comparison operations }
  107. procedure a_cmp_reg_const_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;reg : tregister;
  108. l : tasmlabel);virtual;
  109. procedure a_cmp_reg_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg1,reg2 : tregister;l : tasmlabel);
  110. procedure a_cmp_reg_ref_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg : tregister;l : tasmlabel);
  111. procedure a_cmp_ref_const_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;reg : tregister;
  112. l : tasmlabel);
  113. procedure a_jmp_cond(list : taasmoutput;cond : TOpCmp;l: tasmlabel);
  114. procedure a_loadaddress_ref_reg(list : taasmoutput;const ref : treference;r : tregister);virtual;
  115. procedure g_stackframe_entry(list : taasmoutput;localsize : longint);virtual;
  116. { restores the frame pointer at procedure exit, for the }
  117. { i386 it generates a simple leave }
  118. procedure g_restore_frame_pointer(list : taasmoutput);virtual;
  119. { some processors like the PPC doesn't allow to change the stack in }
  120. { a procedure, so we need to maintain an extra stack for the }
  121. { result values of setjmp in exception code }
  122. { this two procedures are for pushing an exception value, }
  123. { they can use the scratch registers }
  124. procedure g_push_exception_value_reg(list : taasmoutput;reg : tregister);virtual;
  125. procedure g_push_exception_value_const(list : taasmoutput;reg : tregister);virtual;
  126. { that procedure pops a exception value }
  127. procedure g_pop_exception_value_reg(list : taasmoutput;reg : tregister);virtual;
  128. procedure g_return_from_proc(list : taasmoutput;parasize : aword);virtual;
  129. {********************************************************}
  130. { these methods can be overriden for extra functionality }
  131. { the following methods do nothing: }
  132. procedure g_interrupt_stackframe_entry(list : taasmoutput);virtual;
  133. procedure g_interrupt_stackframe_exit(list : taasmoutput);virtual;
  134. procedure g_profilecode(list : taasmoutput);virtual;
  135. procedure g_stackcheck(list : taasmoutput;stackframesize : longint);virtual;
  136. procedure g_maybe_loadself(list : taasmoutput);virtual;
  137. { copies len bytes from the source to destination, if }
  138. { loadref is true, it assumes that it first must load }
  139. { the source address from the memory location where }
  140. { source points to }
  141. procedure g_concatcopy(list : taasmoutput;const source,dest : treference;len : aword;loadref : boolean);virtual;
  142. { uses the addr of ref as param, was emitpushreferenceaddr }
  143. procedure a_param_ref_addr(list : taasmoutput;r : treference;nr : longint);virtual;
  144. end;
  145. var
  146. cg : pcg; { this is the main code generator class }
  147. implementation
  148. uses
  149. strings,globals,globtype,options,gdb,systems,
  150. ppu,verbose,types,temp_gen,tgcpu;
  151. {*****************************************************************************
  152. basic functionallity
  153. ******************************************************************************}
  154. constructor tcg.init;
  155. var
  156. i : longint;
  157. begin
  158. scratch_register_array_pointer:=1;
  159. for i:=1 to max_scratch_regs do
  160. include(unusedscratchregisters,scratch_regs[i]);
  161. end;
  162. destructor tcg.done;
  163. begin
  164. end;
  165. procedure tcg.a_reg_alloc(list : taasmoutput;r : tregister);
  166. begin
  167. list.concat(tairegalloc.alloc(r));
  168. end;
  169. procedure tcg.a_reg_dealloc(list : taasmoutput;r : tregister);
  170. begin
  171. list.concat(tairegalloc.dealloc(r));
  172. end;
  173. procedure tcg.a_label(list : taasmoutput;l : tasmlabel);
  174. begin
  175. list.concat(tai_label.create(l));
  176. end;
  177. function tcg.get_scratch_reg(list : taasmoutput) : tregister;
  178. var
  179. r : tregister;
  180. i : longint;
  181. begin
  182. if unusedscratchregisters=[] then
  183. internalerror(68996);
  184. for i:=scratch_register_array_pointer to
  185. (scratch_register_array_pointer+max_scratch_regs) do
  186. if scratch_regs[(i mod max_scratch_regs)+1] in unusedscratchregisters then
  187. begin
  188. r:=scratch_regs[(i mod max_scratch_regs)+1];
  189. break;
  190. end;
  191. exclude(unusedscratchregisters,r);
  192. inc(scratch_register_array_pointer);
  193. if scratch_register_array_pointer>max_scratch_regs then
  194. scratch_register_array_pointer:=1;
  195. a_reg_alloc(list,r);
  196. get_scratch_reg:=r;
  197. end;
  198. procedure tcg.free_scratch_reg(list : taasmoutput;r : tregister);
  199. begin
  200. include(unusedscratchregisters,r);
  201. a_reg_dealloc(list,r);
  202. end;
  203. {*****************************************************************************
  204. this methods must be overridden for extra functionality
  205. ******************************************************************************}
  206. procedure tcg.g_interrupt_stackframe_entry(list : taasmoutput);
  207. begin
  208. end;
  209. procedure tcg.g_interrupt_stackframe_exit(list : taasmoutput);
  210. begin
  211. end;
  212. procedure tcg.g_profilecode(list : taasmoutput);
  213. begin
  214. end;
  215. {*****************************************************************************
  216. for better code generation these methods should be overridden
  217. ******************************************************************************}
  218. procedure tcg.a_param_const(list : taasmoutput;size : tcgsize;a : aword;nr : longint);
  219. var
  220. hr : tregister;
  221. begin
  222. hr:=get_scratch_reg(list);
  223. a_load_const_reg(list,size,a,hr);
  224. a_param_reg(list,size,hr,nr);
  225. free_scratch_reg(list,hr);
  226. end;
  227. procedure tcg.a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;nr : longint);
  228. var
  229. hr : tregister;
  230. begin
  231. hr:=get_scratch_reg(list);
  232. a_load_ref_reg(list,size,r,hr);
  233. a_param_reg(list,size,hr,nr);
  234. free_scratch_reg(list,hr);
  235. end;
  236. procedure tcg.a_param_ref_addr(list : taasmoutput;r : treference;nr : longint);
  237. var
  238. hr : tregister;
  239. begin
  240. hr:=get_scratch_reg(list);
  241. a_loadaddress_ref_reg(list,r,hr);
  242. a_param_reg(list,OS_ADDR,hr,nr);
  243. free_scratch_reg(list,hr);
  244. end;
  245. procedure tcg.g_stackcheck(list : taasmoutput;stackframesize : longint);
  246. begin
  247. a_param_const(list,OS_32,stackframesize,1);
  248. a_call_name(list,'FPC_STACKCHECK',0);
  249. end;
  250. procedure tcg.a_load_const_ref(list : taasmoutput;size : tcgsize;a : aword;const ref : treference);
  251. var
  252. hr : tregister;
  253. begin
  254. hr:=get_scratch_reg(list);
  255. a_load_const_reg(list,size,a,hr);
  256. a_load_reg_ref(list,size,hr,ref);
  257. free_scratch_reg(list,hr);
  258. end;
  259. procedure tcg.g_concatcopy(list : taasmoutput;const source,dest : treference;len : aword;loadref : boolean);
  260. begin
  261. abstract;
  262. end;
  263. {*****************************************************************************
  264. String helper routines
  265. *****************************************************************************}
  266. procedure tcg.g_removetemps(list : taasmoutput;p : tlinkedlist);
  267. var
  268. hp : ptemptodestroy;
  269. pushedregs : tpushed;
  270. begin
  271. hp:=ttemptodestroy(p.first);
  272. if not(assigned(hp)) then
  273. exit;
  274. pushusedregisters(pushedregs,$ff);
  275. while assigned(hp) do
  276. begin
  277. if is_ansistring(hp^.typ) then
  278. begin
  279. g_decrstrref(list,hp.address,hp^.typ);
  280. ungetiftemp(hp^.address);
  281. end;
  282. hp:=ptemptodestroy(hp^.next);
  283. end;
  284. popusedregisters(pushedregs);
  285. end;
  286. procedure tcg.g_decrstrref(list : taasmoutput;const ref : treference;t : tdef);
  287. var
  288. pushedregs : tpushed;
  289. begin
  290. pushusedregisters(pushedregs,$ff);
  291. a_param_ref_addr(list,ref,1);
  292. if is_ansistring(t) then
  293. a_call_name(list,'FPC_ANSISTR_DECR_REF',0)
  294. else if is_widestring(t) then
  295. a_call_name(list,'FPC_WIDESTR_DECR_REF',0)
  296. else internalerror(58993);
  297. popusedregisters(pushedregs);
  298. end;
  299. {*****************************************************************************
  300. Code generation for subroutine entry- and exit code
  301. *****************************************************************************}
  302. { initilizes data of type t }
  303. { if is_already_ref is true then the routines assumes }
  304. { that r points to the data to initialize }
  305. procedure tcg.g_initialize(list : taasmoutput;t : tdef;const ref : treference;is_already_ref : boolean);
  306. var
  307. hr : treference;
  308. begin
  309. if is_ansistring(t) or
  310. is_widestring(t) then
  311. a_load_const_ref(list,OS_8,0,ref)
  312. else
  313. begin
  314. reset_reference(hr);
  315. hr.symbol:=t^.get_inittable_label;
  316. a_param_ref_addr(list,hr,2);
  317. if is_already_ref then
  318. a_param_ref(list,OS_ADDR,ref,1)
  319. else
  320. a_param_ref_addr(list,ref,1);
  321. a_call_name(list,'FPC_INITIALIZE',0);
  322. end;
  323. end;
  324. procedure tcg.g_finalize(list : taasmoutput;t : tdef;const ref : treference;is_already_ref : boolean);
  325. var
  326. r : treference;
  327. begin
  328. if is_ansistring(t) or
  329. is_widestring(t) then
  330. begin
  331. g_decrstrref(list,ref,t);
  332. end
  333. else
  334. begin
  335. reset_reference(r);
  336. r.symbol:=t^.get_inittable_label;
  337. a_param_ref_addr(list,r,2);
  338. if is_already_ref then
  339. a_paramaddr_ref(list,ref,1)
  340. else
  341. a_param_ref_addr(list,ref,1);
  342. a_call_name(list,'FPC_FINALIZE',0);
  343. end;
  344. end;
  345. { generates the code for initialisation of local data }
  346. procedure tcg.g_initialize_data(list : taasmoutput;p : tsym);
  347. var
  348. hr : treference;
  349. begin
  350. if (tsym(p).typ=varsym) and
  351. assigned(tvarsym(p).vartype.def) and
  352. not((tvarsym(p).vartype.def^.deftype=objectdef) and
  353. tobjectdef(tvarsym(p).vartype.def)^.is_class) and
  354. tvarsym(p).vartype.def.needs_inittable then
  355. begin
  356. procinfo^.flags:=procinfo^.flags or pi_needs_implicit_finally;
  357. reset_reference(hr);
  358. if tsym(p)^.owner^.symtabletype=localsymtable then
  359. begin
  360. hr.base:=procinfo^.framepointer;
  361. hr.offset:=-tvarsym(p)^.address;
  362. end
  363. else
  364. begin
  365. hr.symbol:=newasmsymbol(tvarsym(p)^.mangledname);
  366. end;
  367. g_initialize(list,tvarsym(p)^.vartype.def,hr,false);
  368. end;
  369. end;
  370. { generates the code for incrementing the reference count of parameters }
  371. procedure tcg.g_incr_data(list : taasmoutput;p : tsym);
  372. var
  373. hr : treference;
  374. begin
  375. if (tsym(p).typ=varsym) and
  376. not((tvarsym(p).vartype.def.deftype=objectdef) and
  377. tobjectdef(tvarsym(p).vartype.def).is_class) and
  378. tvarsym(p).vartype.def.needs_inittable and
  379. ((tvarsym(p).varspez=vs_value)) then
  380. begin
  381. procinfo^.flags:=procinfo^.flags or pi_needs_implicit_finally;
  382. reset_reference(hr);
  383. hr.symbol:=tvarsym(p)^.vartype.def^.get_inittable_label;
  384. a_param_ref_addr(list,hr,2);
  385. reset_reference(hr);
  386. hr.base:=procinfo^.framepointer;
  387. hr.offset:=tvarsym(p)^.address+procinfo^.para_offset;
  388. a_param_ref_addr(list,hr,1);
  389. reset_reference(hr);
  390. a_call_name(list,'FPC_ADDREF',0);
  391. end;
  392. end;
  393. { generates the code for finalisation of local data }
  394. procedure tcg.g_finalize_data(list : taasmoutput;p : tnamedindex);
  395. var
  396. hr : treference;
  397. begin
  398. if (tsym(p).typ=varsym) and
  399. assigned(tvarsym(p).vartype.def) and
  400. not((tvarsym(p).vartype.def.deftype=objectdef) and
  401. tobjectdef(tvarsym(p).vartype.def).is_class) and
  402. tvarsym(p).vartype.def.needs_inittable then
  403. begin
  404. { not all kind of parameters need to be finalized }
  405. if (tsym(p).owner.symtabletype=parasymtable) and
  406. ((tvarsym(p).varspez=vs_var) or
  407. (tvarsym(p).varspez=vs_const) { and
  408. (dont_copy_const_param(tvarsym(p)^.definition)) } ) then
  409. exit;
  410. procinfo^.flags:=procinfo^.flags or pi_needs_implicit_finally;
  411. reset_reference(hr);
  412. case tsym(p).owner^.symtabletype of
  413. localsymtable:
  414. begin
  415. hr.base:=procinfo^.framepointer;
  416. hr.offset:=-tvarsym(p).address;
  417. end;
  418. parasymtable:
  419. begin
  420. hr.base:=procinfo^.framepointer;
  421. hr.offset:=tvarsym(p).address+procinfo^.para_offset;
  422. end;
  423. else
  424. hr.symbol:=newasmsymbol(tvarsym(p).mangledname);
  425. end;
  426. g_finalize(list,tvarsym(p).vartype.def,hr,false);
  427. end;
  428. end;
  429. { generates the code to make local copies of the value parameters }
  430. procedure tcg.g_copyvalueparas(list : taasmoutput;p : pnamedindexobject);
  431. begin
  432. runerror(255);
  433. end;
  434. var
  435. _list : taasmoutput;
  436. { wrappers for the methods, because TP doesn't know procedures }
  437. { of objects }
  438. {$IFNDEF NEWST}
  439. procedure _copyvalueparas(s : pnamedindexobject);{$ifndef FPC}far;{$endif}
  440. begin
  441. cg^.g_copyvalueparas(_list,s);
  442. end;
  443. {$ENDIF NEWST}
  444. procedure tcg.g_finalizetempansistrings(list : taasmoutput);
  445. var
  446. hp : ptemprecord;
  447. hr : treference;
  448. begin
  449. hp:=templist;
  450. while assigned(hp) do
  451. begin
  452. if hp^.temptype in [tt_ansistring,tt_freeansistring] then
  453. begin
  454. procinfo^.flags:=procinfo^.flags or pi_needs_implicit_finally;
  455. reset_reference(hr);
  456. hr.base:=procinfo^.framepointer;
  457. hr.offset:=hp^.pos;
  458. a_param_ref_addr(list,hr,1);
  459. a_call_name(list,'FPC_ANSISTR_DECR_REF',0);
  460. end;
  461. hp:=hp^.next;
  462. end;
  463. end;
  464. procedure _finalize_data(s : pnamedindexobject);{$ifndef FPC}far;{$endif}
  465. begin
  466. cg^.g_finalize_data(_list,s);
  467. end;
  468. procedure _incr_data(s : pnamedindexobject);{$ifndef FPC}far;{$endif}
  469. begin
  470. cg^.g_incr_data(_list,tsym(s));
  471. end;
  472. procedure _initialize_data(s : pnamedindexobject);{$ifndef FPC}far;{$endif}
  473. begin
  474. cg^.g_initialize_data(_list,tsym(s));
  475. end;
  476. { generates the entry code for a procedure }
  477. procedure tcg.g_entrycode(list : taasmoutput;const proc_names:Tstringcontainer;make_global:boolean;
  478. stackframe:longint;var parasize:longint;var nostackframe:boolean;
  479. inlined : boolean);
  480. var
  481. hs : string;
  482. hp : pused_unit;
  483. initcode : taasmoutput;
  484. {$ifdef GDB}
  485. stab_function_name : Pai_stab_function_name;
  486. {$endif GDB}
  487. hr : treference;
  488. r : tregister;
  489. begin
  490. { Align }
  491. if (not inlined) then
  492. begin
  493. { gprof uses 16 byte granularity !! }
  494. if (cs_profile in aktmoduleswitches) then
  495. list^.insert(new(pai_align,init(16)))
  496. else
  497. if not(cs_littlesize in aktglobalswitches) then
  498. list^.insert(new(pai_align,init(4)));
  499. end;
  500. { save registers on cdecl }
  501. {$IFDEF NEWST}
  502. if (posavestdregs in aktprocdef^.options) then
  503. {$ELSE}
  504. if (po_savestdregs in aktprocsym^.definition^.procoptions) then
  505. {$ENDIF NEWST}
  506. begin
  507. for r:=firstreg to lastreg do
  508. begin
  509. if (r in registers_saved_on_cdecl) then
  510. if (r in (tg.availabletempregsint+
  511. tg.availabletempregsfpu+
  512. tg.availabletempregsmm)) then
  513. begin
  514. if not(r in tg.usedinproc) then
  515. {!!!!!!!!!!!! a_push_reg(list,r) }
  516. end
  517. else
  518. {!!!!!!!! a_push_reg(list,r) };
  519. end;
  520. end;
  521. { omit stack frame ? }
  522. if not inlined then
  523. if procinfo^.framepointer=stack_pointer then
  524. begin
  525. CGMessage(cg_d_stackframe_omited);
  526. nostackframe:=true;
  527. {$IFDEF NEWST}
  528. if (aktprocdef^.proctype in [potype_unitinit,potype_proginit,potype_unitfinalize]) then
  529. parasize:=0
  530. else
  531. parasize:=aktprocdef^.localst^.paramdatasize+procinfo^.para_offset-pointersize;
  532. {$ELSE}
  533. if (aktprocsym^.definition^.proctypeoption in [potype_unitinit,potype_proginit,potype_unitfinalize]) then
  534. parasize:=0
  535. else
  536. parasize:=aktprocsym^.definition^.parast^.datasize+procinfo^.para_offset-pointersize;
  537. {$ENDIF NEWST}
  538. end
  539. else
  540. begin
  541. {$IFDEF NEWST}
  542. if (aktprocdef^.proctype in [potype_unitinit,potype_proginit,potype_unitfinalize]) then
  543. parasize:=0
  544. else
  545. parasize:=aktprocdef^.localst^.paramdatasize+procinfo^.para_offset-pointersize*2;
  546. {$ELSE}
  547. if (aktprocsym^.definition^.proctypeoption in [potype_unitinit,potype_proginit,potype_unitfinalize]) then
  548. parasize:=0
  549. else
  550. parasize:=aktprocsym^.definition^.parast^.datasize+procinfo^.para_offset-pointersize*2;
  551. {$ENDIF}
  552. nostackframe:=false;
  553. {$IFDEF NEWST}
  554. if (pointerrupt in aktprocdef^.options) then
  555. g_interrupt_stackframe_entry(list);
  556. {$ELSE}
  557. if (po_interrupt in aktprocsym^.definition^.procoptions) then
  558. g_interrupt_stackframe_entry(list);
  559. {$ENDIF NEWST}
  560. g_stackframe_entry(list,stackframe);
  561. if (cs_check_stack in aktlocalswitches) and
  562. (tf_supports_stack_checking in target_info.flags) then
  563. g_stackcheck(@initcode,stackframe);
  564. end;
  565. if cs_profile in aktmoduleswitches then
  566. g_profilecode(@initcode);
  567. {$IFDEF NEWST}
  568. if (not inlined) and (aktprocdef^.proctype in [potype_unitinit]) then
  569. {$ELSE}
  570. if (not inlined) and (aktprocsym^.definition^.proctypeoption in [potype_unitinit]) then
  571. {$ENDIF NEWST}
  572. begin
  573. { needs the target a console flags ? }
  574. if tf_needs_isconsole in target_info.flags then
  575. begin
  576. hr.symbol:=newasmsymbol('U_'+target_info.system_unit+'_ISCONSOLE');
  577. if apptype=at_cui then
  578. a_load_const_ref(list,OS_8,1,hr)
  579. else
  580. a_load_const_ref(list,OS_8,0,hr);
  581. dispose(hr.symbol,done);
  582. end;
  583. hp:=pused_unit(usedunits.first);
  584. while assigned(hp) do
  585. begin
  586. { call the unit init code and make it external }
  587. if (hp^.u^.flags and uf_init)<>0 then
  588. a_call_name(list,
  589. 'INIT$$'+hp^.u^.modulename^,0);
  590. hp:=Pused_unit(hp^.next);
  591. end;
  592. end;
  593. {$ifdef dummy}
  594. { a constructor needs a help procedure }
  595. if (aktprocsym^.definition^.options and poconstructor)<>0 then
  596. begin
  597. if procinfo^._class^.isclass then
  598. begin
  599. list^.concat(new(paicpu,op_sym(A_CALL,S_NO,newasmsymbol('FPC_NEW_CLASS'))));
  600. list^.concat(new(paicpu,op_cond_sym(A_Jcc,C_Z,S_NO,quickexitlabel)));
  601. end
  602. else
  603. begin
  604. {
  605. list^.insert(new(pai_labeled,init(A_JZ,quickexitlabel)));
  606. list^.insert(new(paicpu,op_csymbol(A_CALL,S_NO,
  607. newcsymbol('FPC_HELP_CONSTRUCTOR',0))));
  608. list^.insert(new(paicpu,op_const_reg(A_MOV,S_L,procinfo^._class^.vmt_offset,R_EDI)));
  609. concat_external('FPC_HELP_CONSTRUCTOR',EXT_NEAR);
  610. }
  611. end;
  612. end;
  613. {$endif dummy}
  614. {$ifdef GDB}
  615. if (cs_debuginfo in aktmoduleswitches) then
  616. list^.insert(new(pai_force_line,init));
  617. {$endif GDB}
  618. {$IFDEF NEWST}
  619. { initialize return value }
  620. if assigned(procinfo^.retdef) and
  621. is_ansistring(procinfo^.retdef) or
  622. is_widestring(procinfo^.retdef) then
  623. begin
  624. reset_reference(hr);
  625. hr.offset:=procinfo^.return_offset;
  626. hr.base:=procinfo^.framepointer;
  627. a_load_const_ref(list,OS_32,0,hr);
  628. end;
  629. {$ELSE}
  630. { initialize return value }
  631. if assigned(procinfo^.returntype.def) and
  632. is_ansistring(procinfo^.returntype.def) or
  633. is_widestring(procinfo^.returntype.def) then
  634. begin
  635. reset_reference(hr);
  636. hr.offset:=procinfo^.return_offset;
  637. hr.base:=procinfo^.framepointer;
  638. a_load_const_ref(list,OS_32,0,hr);
  639. end;
  640. {$ENDIF}
  641. _list:=list;
  642. { generate copies of call by value parameters }
  643. {$IFDEF NEWST}
  644. if (poassembler in aktprocdef^.options) then
  645. aktprocdef^.parameters^.foreach(@_copyvalueparas);
  646. {$ELSE}
  647. if (po_assembler in aktprocsym^.definition^.procoptions) then
  648. aktprocsym^.definition^.parast^.foreach({$ifdef FPC}@{$endif FPC}_copyvalueparas);
  649. {$ENDIF NEWST}
  650. {$IFDEF NEWST}
  651. { initialisizes local data }
  652. aktprocdef^.localst^.foreach({$ifdef FPC}@{$endif FPC}_initialize_local);
  653. {$ELSE}
  654. { initialisizes local data }
  655. aktprocsym^.definition^.localst^.foreach({$ifdef FPC}@{$endif FPC}_initialize_data);
  656. { add a reference to all call by value/const parameters }
  657. aktprocsym^.definition^.parast^.foreach({$ifdef FPC}@{$endif FPC}_incr_data);
  658. {$ENDIF NEWST}
  659. {$IFDEF NEWST}
  660. if (cs_profile in aktmoduleswitches) or
  661. (typeof(aktprocdef^.owner^)=typeof(Tglobalsymtable)) or
  662. (typeof(aktprocdef^.owner^)=typeof(Timplsymtable)) or
  663. (assigned(procinfo^._class) and
  664. (typeof(procinfo^._class^.owner^)=typeof(Tglobalsymtable)) or
  665. (typeof(procinfo^._class^.owner^)=typeof(Timplsymtable))) then
  666. make_global:=true;
  667. {$ELSE}
  668. if (cs_profile in aktmoduleswitches) or
  669. (aktprocsym^.definition^.owner^.symtabletype=globalsymtable) or
  670. (assigned(procinfo^._class) and (procinfo^._class^.owner^.symtabletype=globalsymtable)) then
  671. make_global:=true;
  672. {$ENDIF NEWST}
  673. if not inlined then
  674. begin
  675. hs:=proc_names.get;
  676. {$ifdef GDB}
  677. if (cs_debuginfo in aktmoduleswitches) and target_os.use_function_relative_addresses then
  678. stab_function_name := new(pai_stab_function_name,init(strpnew(hs)));
  679. {$endif GDB}
  680. { insert the names for the procedure }
  681. while hs<>'' do
  682. begin
  683. if make_global then
  684. exprasmlist^.insert(new(pai_symbol,initname_global(hs,0)))
  685. else
  686. exprasmlist^.insert(new(pai_symbol,initname(hs,0)));
  687. {$ifdef GDB}
  688. if (cs_debuginfo in aktmoduleswitches) then
  689. begin
  690. if target_os.use_function_relative_addresses then
  691. list^.insert(new(pai_stab_function_name,init(strpnew(hs))));
  692. end;
  693. {$endif GDB}
  694. hs:=proc_names.get;
  695. end;
  696. end;
  697. {$ifdef GDB}
  698. if (not inlined) and (cs_debuginfo in aktmoduleswitches) then
  699. begin
  700. if target_os.use_function_relative_addresses then
  701. list^.insert(stab_function_name);
  702. if make_global or ((procinfo^.flags and pi_is_global) <> 0) then
  703. aktprocsym^.is_global := True;
  704. list^.insert(new(pai_stabs,init(aktprocsym^.stabstring)));
  705. aktprocsym^.isstabwritten:=true;
  706. end;
  707. {$endif GDB}
  708. end;
  709. procedure tcg.g_exitcode(list : taasmoutput;parasize:longint;nostackframe,inlined:boolean);
  710. var
  711. {$ifdef GDB}
  712. mangled_length : longint;
  713. p : pchar;
  714. {$endif GDB}
  715. nofinal,noreraiselabel : tasmlabel;
  716. hr : treference;
  717. r : tregister;
  718. begin
  719. if aktexitlabel^.is_used then
  720. list^.insert(new(pai_label,init(aktexitlabel)));
  721. { call the destructor help procedure }
  722. {$IFDEF NEWST}
  723. if (aktprocdef^.proctype=potype_destructor) then
  724. {$ELSE}
  725. if (aktprocsym^.definition^.proctypeoption=potype_destructor) then
  726. {$ENDIF}
  727. begin
  728. {$IFDEF NEWST}
  729. if oo_is_class in procinfo^._class^.options then
  730. {$ELSE NEWST}
  731. if procinfo^._class^.is_class then
  732. {$ENDIF}
  733. a_call_name(list,'FPC_DISPOSE_CLASS',0)
  734. else
  735. begin
  736. if procinfo^._class^.needs_inittable then
  737. begin
  738. getlabel(nofinal);
  739. {!!!!!!!!!!
  740. reset_reference(hr);
  741. hr.base:=R_EBP;
  742. hr.offset:=8;
  743. a_cmp_reg_const_label(list,OS_ADDR,OZ_EQ,
  744. }
  745. reset_reference(hr);
  746. hr.symbol:=procinfo^._class^.get_inittable_label;
  747. a_paramaddr_ref(list,hr,2);
  748. a_param_reg(list,OS_ADDR,self_pointer,1);
  749. a_call_name(list,'FPC_FINALIZE',0);
  750. a_label(list,nofinal);
  751. end;
  752. { vmt_offset_reg can be a scratch register, }
  753. { but it must be always the same }
  754. a_reg_alloc(list,vmt_offset_reg);
  755. a_load_const_reg(list,OS_32,procinfo^._class^.vmt_offset,vmt_offset_reg);
  756. a_call_name(list,'FPC_HELP_DESTRUCTOR',0);
  757. a_reg_dealloc(list,vmt_offset_reg);
  758. end;
  759. end;
  760. { finalize temporary data }
  761. g_finalizetempansistrings(list);
  762. _list:=list;
  763. { finalize local data }
  764. {$IFDEF NEWST}
  765. aktprocdef^.localst^.foreach({$ifndef TP}@{$endif}_finalize_data);
  766. {$ELSE}
  767. aktprocsym^.definition^.localst^.foreach({$ifndef TP}@{$endif}_finalize_data);
  768. {$ENDIF}
  769. {$IFNDEF NEWST}
  770. { finalize paras data }
  771. if assigned(aktprocsym^.definition^.parast) then
  772. aktprocsym^.definition^.parast^.foreach({$ifndef TP}@{$endif}_finalize_data);
  773. {$ENDIF NEWST}
  774. { do we need to handle exceptions because of ansi/widestrings ? }
  775. if (procinfo^.flags and pi_needs_implicit_finally)<>0 then
  776. begin
  777. getlabel(noreraiselabel);
  778. a_call_name(list,'FPC_POPADDRSTACK',0);
  779. a_reg_alloc(list,accumulator);
  780. g_pop_exception_value_reg(list,accumulator);
  781. a_cmp_reg_const_label(list,OS_32,OC_EQ,0,accumulator,noreraiselabel);
  782. a_reg_dealloc(list,accumulator);
  783. {$IFDEF NEWST}
  784. { must be the return value finalized before reraising the exception? }
  785. if (procinfo^.retdef<>tdef(voiddef)) and
  786. (procinfo^.retdef^.needs_inittable) and
  787. ((typeof(procinfo^.retdef^)<>typeof(Tobjectdef)) or
  788. not(oo_is_class in pobjectdef(procinfo^.retdef)^.options)) then
  789. begin
  790. reset_reference(hr);
  791. hr.offset:=procinfo^.return_offset;
  792. hr.base:=procinfo^.framepointer;
  793. g_finalize(list,procinfo^.retdef,hr,not (dp_ret_in_acc in procinfo^.retdef^.properties));
  794. end;
  795. {$ELSE}
  796. { must be the return value finalized before reraising the exception? }
  797. if (procinfo^.returntype.def<>tdef(voiddef)) and
  798. (procinfo^.returntype.def^.needs_inittable) and
  799. ((procinfo^.returntype.def^.deftype<>objectdef) or
  800. not(pobjectdef(procinfo^.returntype.def)^.is_class)) then
  801. begin
  802. reset_reference(hr);
  803. hr.offset:=procinfo^.return_offset;
  804. hr.base:=procinfo^.framepointer;
  805. g_finalize(list,procinfo^.returntype.def,hr,ret_in_param(procinfo^.returntype.def));
  806. end;
  807. {$ENDIF}
  808. a_call_name(list,'FPC_RERAISE',0);
  809. a_label(list,noreraiselabel);
  810. end;
  811. { call __EXIT for main program }
  812. {$IFDEF NEWST}
  813. if (not DLLsource) and (not inlined) and (aktprocdef^.proctype=potype_proginit) then
  814. a_call_name(list,'FPC_DO_EXIT',0);
  815. {$ELSE}
  816. if (not DLLsource) and (not inlined) and (aktprocsym^.definition^.proctypeoption=potype_proginit) then
  817. a_call_name(list,'FPC_DO_EXIT',0);
  818. {$ENDIF NEWST}
  819. { handle return value }
  820. {$IFDEF NEWST}
  821. if not(poassembler in aktprocdef^.options) then
  822. if (aktprocdef^.proctype<>potype_constructor) then
  823. {$ELSE}
  824. if not(po_assembler in aktprocsym^.definition^.procoptions) then
  825. if (aktprocsym^.definition^.proctypeoption<>potype_constructor) then
  826. {$ENDIF NEWST}
  827. { handle_return_value(inlined) }
  828. else
  829. begin
  830. { return self in EAX }
  831. a_label(list,quickexitlabel);
  832. a_reg_alloc(list,accumulator);
  833. a_load_reg_reg(list,OS_ADDR,self_pointer,accumulator);
  834. a_reg_dealloc(list,self_pointer);
  835. a_label(list,quickexitlabel);
  836. { we can't clear the zero flag because the Alpha }
  837. { for example doesn't have flags, we have to compare }
  838. { the accu. in the caller }
  839. end;
  840. { stabs uses the label also ! }
  841. if aktexit2label^.is_used or
  842. ((cs_debuginfo in aktmoduleswitches) and not inlined) then
  843. a_label(list,aktexit2label);
  844. {$ifdef dummy}
  845. { should we restore edi ? }
  846. { for all i386 gcc implementations }
  847. {!!!!!!!!!!! I don't know how to handle register saving yet }
  848. if (po_savestdregs in aktprocsym^.definition^.procoptions) then
  849. begin
  850. if (aktprocsym^.definition^.usedregisters and ($80 shr byte(R_EBX)))<>0 then
  851. exprasmlist^.concat(new(paicpu,op_reg(A_POP,S_L,R_EBX)));
  852. exprasmlist^.concat(new(paicpu,op_reg(A_POP,S_L,R_ESI)));
  853. exprasmlist^.concat(new(paicpu,op_reg(A_POP,S_L,R_EDI)));
  854. { here we could reset R_EBX
  855. but that is risky because it only works
  856. if genexitcode is called after genentrycode
  857. so lets skip this for the moment PM
  858. aktprocsym^.definition^.usedregisters:=
  859. aktprocsym^.definition^.usedregisters or not ($80 shr byte(R_EBX));
  860. }
  861. end;
  862. {$endif dummy}
  863. if not(nostackframe) and not inlined then
  864. g_restore_frame_pointer(list);
  865. { at last, the return is generated }
  866. if not inlined then
  867. {$IFDEF NEWST}
  868. if pointerrupt in aktprocdef^.options then
  869. {$ELSE}
  870. if po_interrupt in aktprocsym^.definition^.procoptions then
  871. {$ENDIF NEWST}
  872. g_interrupt_stackframe_exit(list)
  873. else
  874. g_return_from_proc(list,parasize);
  875. {$IFDEF NEWST}
  876. list^.concat(new(pai_symbol_end,initname(aktprocdef^.mangledname)));
  877. {$ELSE NEWST}
  878. list^.concat(new(pai_symbol_end,initname(aktprocsym^.definition^.mangledname)));
  879. {$ENDIF NEWST}
  880. {$ifdef GDB}
  881. if (cs_debuginfo in aktmoduleswitches) and not inlined then
  882. begin
  883. aktprocsym^.concatstabto(list);
  884. if assigned(procinfo^._class) then
  885. if (not assigned(procinfo^.parent) or
  886. not assigned(procinfo^.parent^._class)) then
  887. list^.concat(new(pai_stabs,init(strpnew(
  888. '"$t:v'+procinfo^._class^.numberstring+'",'+
  889. tostr(N_PSYM)+',0,0,'+tostr(procinfo^.selfpointer_offset)))));
  890. {!!!!!!!!!!!!
  891. else
  892. list^.concat(new(pai_stabs,init(strpnew(
  893. '"$t:r'+procinfo^._class^.numberstring+'",'+
  894. tostr(N_RSYM)+',0,0,'+tostr(GDB_i386index[R_ESI])))));
  895. }
  896. if (tdef(aktprocsym^.definition^.rettype.def) <> tdef(voiddef)) then
  897. begin
  898. if ret_in_param(aktprocsym^.definition^.rettype.def) then
  899. list^.concat(new(pai_stabs,init(strpnew(
  900. '"'+aktprocsym^.name+':X*'+aktprocsym^.definition^.rettype.def^.numberstring+'",'+
  901. tostr(N_PSYM)+',0,0,'+tostr(procinfo^.return_offset)))))
  902. else
  903. list^.concat(new(pai_stabs,init(strpnew(
  904. '"'+aktprocsym^.name+':X'+aktprocsym^.definition^.rettype.def^.numberstring+'",'+
  905. tostr(N_PSYM)+',0,0,'+tostr(procinfo^.return_offset)))));
  906. if (m_result in aktmodeswitches) then
  907. if ret_in_param(aktprocsym^.definition^.rettype.def) then
  908. list^.concat(new(pai_stabs,init(strpnew(
  909. '"RESULT:X*'+aktprocsym^.definition^.rettype.def^.numberstring+'",'+
  910. tostr(N_PSYM)+',0,0,'+tostr(procinfo^.return_offset)))))
  911. else
  912. list^.concat(new(pai_stabs,init(strpnew(
  913. '"RESULT:X'+aktprocsym^.definition^.rettype.def^.numberstring+'",'+
  914. tostr(N_PSYM)+',0,0,'+tostr(procinfo^.return_offset)))));
  915. end;
  916. mangled_length:=length(aktprocsym^.definition^.mangledname);
  917. getmem(p,mangled_length+50);
  918. strpcopy(p,'192,0,0,');
  919. strpcopy(strend(p),aktprocsym^.definition^.mangledname);
  920. list^.concat(new(pai_stabn,init(strnew(p))));
  921. {list^.concat(new(pai_stabn,init(strpnew('192,0,0,'
  922. +aktprocsym^.definition^.mangledname))));
  923. p[0]:='2';p[1]:='2';p[2]:='4';
  924. strpcopy(strend(p),'_end');}
  925. freemem(p,mangled_length+50);
  926. list^.concat(new(pai_stabn,init(
  927. strpnew('224,0,0,'+aktexit2label^.name))));
  928. { strpnew('224,0,0,'
  929. +aktprocsym^.definition^.mangledname+'_end'))));}
  930. end;
  931. {$endif GDB}
  932. end;
  933. {*****************************************************************************
  934. some abstract definitions
  935. ****************************************************************************}
  936. procedure tcg.a_call_name(list : taasmoutput;const s : string;
  937. offset : longint);
  938. begin
  939. abstract;
  940. end;
  941. procedure tcg.g_stackframe_entry(list : taasmoutput;localsize : longint);
  942. begin
  943. abstract;
  944. end;
  945. procedure tcg.g_maybe_loadself(list : taasmoutput);
  946. begin
  947. abstract;
  948. end;
  949. procedure tcg.g_restore_frame_pointer(list : taasmoutput);
  950. begin
  951. abstract;
  952. end;
  953. procedure g_return_from_proc(list : taasmoutput;parasize : aword);
  954. begin
  955. abstract;
  956. end;
  957. procedure tcg.a_loadaddress_ref_reg(list : taasmoutput;const ref : treference;r : tregister);
  958. begin
  959. abstract;
  960. end;
  961. procedure tcg.g_push_exception_value_reg(list : taasmoutput;reg : tregister);
  962. begin
  963. abstract;
  964. end;
  965. procedure tcg.g_push_exception_value_const(list : taasmoutput;reg : tregister);
  966. begin
  967. abstract;
  968. end;
  969. procedure tcg.g_pop_exception_value_reg(list : taasmoutput;reg : tregister);
  970. begin
  971. abstract;
  972. end;
  973. procedure tcg.a_load_const_reg(list : taasmoutput;size : tcgsize;a : aword;register : tregister);
  974. begin
  975. abstract;
  976. end;
  977. procedure tcg.a_load_reg_ref(list : taasmoutput;size : tcgsize;register : tregister;const ref : treference);
  978. begin
  979. abstract;
  980. end;
  981. procedure tcg.a_load_ref_reg(list : taasmoutput;size : tcgsize;const ref : treference;register : tregister);
  982. begin
  983. abstract;
  984. end;
  985. procedure tcg.a_load_reg_reg(list : taasmoutput;size : tcgsize;reg1,reg2 : tregister);
  986. begin
  987. abstract;
  988. end;
  989. procedure tcg.a_cmp_reg_const_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;reg : tregister;
  990. l : tasmlabel);
  991. begin
  992. abstract;
  993. end;
  994. procedure tcg.a_cmp_reg_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg1,reg2 : tregister;l : tasmlabel);
  995. begin
  996. abstract;
  997. end;
  998. procedure tcg.a_cmp_reg_ref_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg : tregister;l : tasmlabel);
  999. begin
  1000. abstract;
  1001. end;
  1002. procedure tcg.a_cmp_ref_const_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;reg : tregister;
  1003. l : tasmlabel);
  1004. begin
  1005. abstract;
  1006. end;
  1007. procedure tcg.a_jmp_cond(list : taasmoutput;cond : TOpCmp;l: tasmlabel);
  1008. begin
  1009. abstract;
  1010. end;
  1011. procedure tcg.g_return_from_proc(list : taasmoutput;parasize : aword);
  1012. begin
  1013. abstract;
  1014. end;
  1015. procedure tcg.a_param_reg(list : taasmoutput;size : tcgsize;r : tregister;nr : longint);
  1016. begin
  1017. abstract;
  1018. end;
  1019. procedure tcg.a_paramaddr_ref(list : taasmoutput;const r : treference;nr : longint);
  1020. begin
  1021. abstract;
  1022. end;
  1023. end.
  1024. {
  1025. $Log$
  1026. Revision 1.1 2001-08-26 13:36:37 florian
  1027. * some cg reorganisation
  1028. * some PPC updates
  1029. Revision 1.1 2000/07/13 06:30:07 michael
  1030. + Initial import
  1031. Revision 1.38 2000/04/29 09:01:06 jonas
  1032. * nmem compiles again (at least for powerpc)
  1033. Revision 1.37 2000/04/22 14:25:03 jonas
  1034. * aasm.pas: pai_align instead of pai_align_abstract if cpu <> i386
  1035. + systems.pas: info for macos/ppc
  1036. * new/cgobj.pas: compiles again without newst define
  1037. * new/powerpc/cgcpu: generate different entry/exit code depending on
  1038. whether target_os is MacOs or Linux
  1039. Revision 1.36 2000/03/11 21:11:24 daniel
  1040. * Ported hcgdata to new symtable.
  1041. * Alignment code changed as suggested by Peter
  1042. + Usage of my is operator replacement, is_object
  1043. Revision 1.35 2000/03/01 15:36:13 florian
  1044. * some new stuff for the new cg
  1045. Revision 1.34 2000/02/20 20:49:46 florian
  1046. * newcg is compiling
  1047. * fixed the dup id problem reported by Paul Y.
  1048. Revision 1.33 2000/01/07 01:14:53 peter
  1049. * updated copyright to 2000
  1050. Revision 1.32 1999/12/01 12:42:33 peter
  1051. * fixed bug 698
  1052. * removed some notes about unused vars
  1053. Revision 1.31 1999/11/05 13:15:00 florian
  1054. * some fixes to get the new cg compiling again
  1055. Revision 1.30 1999/11/05 07:05:56 jonas
  1056. + a_jmp_cond()
  1057. Revision 1.29 1999/10/21 16:41:41 florian
  1058. * problems with readln fixed: esi wasn't restored correctly when
  1059. reading ordinal fields of objects futher the register allocation
  1060. didn't take care of the extra register when reading ordinal values
  1061. * enumerations can now be used in constant indexes of properties
  1062. Revision 1.28 1999/10/12 21:20:46 florian
  1063. * new codegenerator compiles again
  1064. Revision 1.27 1999/09/29 11:46:20 florian
  1065. * fixed bug 292 from bugs directory
  1066. Revision 1.26 1999/09/14 11:16:09 florian
  1067. * only small updates to work with the current compiler
  1068. Revision 1.25 1999/09/03 13:09:09 jonas
  1069. * fixed typo regarding scratchregs pointer
  1070. Revision 1.24 1999/08/26 14:51:54 jonas
  1071. * changed get_scratch_reg so it actually uses the
  1072. scratch_reg_array_pointer
  1073. Revision 1.23 1999/08/25 12:00:11 jonas
  1074. * changed pai386, paippc and paiapha (same for tai*) to paicpu (taicpu)
  1075. Revision 1.22 1999/08/18 17:05:55 florian
  1076. + implemented initilizing of data for the new code generator
  1077. so it should compile now simple programs
  1078. Revision 1.21 1999/08/07 14:21:08 florian
  1079. * some small problems fixed
  1080. Revision 1.20 1999/08/06 18:05:52 florian
  1081. * implemented some stuff for assignments
  1082. Revision 1.19 1999/08/06 17:00:54 florian
  1083. + definition of concatcopy
  1084. Revision 1.18 1999/08/06 16:37:45 jonas
  1085. * completed bugfix done by Florian o I wouldn't get conflicts :)
  1086. Revision 1.17 1999/08/06 16:27:26 florian
  1087. * for Jonas: else he will get conflicts
  1088. Revision 1.16 1999/08/06 16:04:05 michael
  1089. + introduced tainstruction
  1090. Revision 1.15 1999/08/06 15:53:50 florian
  1091. * made the alpha version compilable
  1092. Revision 1.14 1999/08/06 14:15:51 florian
  1093. * made the alpha version compilable
  1094. Revision 1.13 1999/08/06 13:26:50 florian
  1095. * more changes ...
  1096. Revision 1.12 1999/08/05 17:10:56 florian
  1097. * some more additions, especially procedure
  1098. exit code generation
  1099. Revision 1.11 1999/08/05 14:58:11 florian
  1100. * some fixes for the floating point registers
  1101. * more things for the new code generator
  1102. Revision 1.10 1999/08/04 00:23:52 florian
  1103. * renamed i386asm and i386base to cpuasm and cpubase
  1104. Revision 1.9 1999/08/02 23:13:21 florian
  1105. * more changes to compile for the Alpha
  1106. Revision 1.8 1999/08/02 17:14:07 florian
  1107. + changed the temp. generator to an object
  1108. Revision 1.7 1999/08/01 23:05:55 florian
  1109. * changes to compile with FPC
  1110. Revision 1.6 1999/08/01 18:22:33 florian
  1111. * made it again compilable
  1112. Revision 1.5 1999/01/23 23:29:46 florian
  1113. * first running version of the new code generator
  1114. * when compiling exceptions under Linux fixed
  1115. Revision 1.4 1999/01/13 22:52:36 florian
  1116. + YES, finally the new code generator is compilable, but it doesn't run yet :(
  1117. Revision 1.3 1998/12/26 15:20:30 florian
  1118. + more changes for the new version
  1119. Revision 1.2 1998/12/15 22:18:55 florian
  1120. * some code added
  1121. Revision 1.1 1998/12/15 16:32:58 florian
  1122. + first version, derived from old routines
  1123. }