rgobj.pas 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This unit implements the base class for the register allocator
  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. {$i fpcdefs.inc}
  19. { Allow duplicate allocations, can be used to get the .s file written }
  20. { $define ALLOWDUPREG}
  21. unit rgobj;
  22. interface
  23. uses
  24. cutils, cpubase,
  25. aasmbase,aasmtai,aasmcpu,
  26. cclasses,globtype,cgbase,node,
  27. cpuinfo
  28. ;
  29. type
  30. {
  31. regvarother_longintarray = array[tregisterindex] of longint;
  32. regvarother_booleanarray = array[tregisterindex] of boolean;
  33. regvarint_longintarray = array[first_int_supreg..last_int_supreg] of longint;
  34. regvarint_ptreearray = array[first_int_supreg..last_int_supreg] of tnode;
  35. }
  36. {
  37. The interference bitmap contains of 2 layers:
  38. layer 1 - 256*256 blocks with pointers to layer 2 blocks
  39. layer 2 - blocks of 32*256 (32 bytes = 256 bits)
  40. }
  41. Tinterferencebitmap2 = array[byte] of set of byte;
  42. Pinterferencebitmap2 = ^Tinterferencebitmap2;
  43. Tinterferencebitmap1 = array[byte] of Pinterferencebitmap2;
  44. pinterferencebitmap1 = ^tinterferencebitmap1;
  45. Tinterferencebitmap=class
  46. private
  47. maxx1,
  48. maxy1 : byte;
  49. fbitmap : pinterferencebitmap1;
  50. function getbitmap(x,y:tsuperregister):boolean;
  51. procedure setbitmap(x,y:tsuperregister;b:boolean);
  52. public
  53. constructor create;
  54. destructor destroy;override;
  55. property bitmap[x,y:tsuperregister]:boolean read getbitmap write setbitmap;default;
  56. end;
  57. Tmovelistheader=record
  58. count,
  59. maxcount,
  60. sorted_until : cardinal;
  61. end;
  62. Tmovelist=record
  63. header : Tmovelistheader;
  64. data : array[tsuperregister] of Tlinkedlistitem;
  65. end;
  66. Pmovelist=^Tmovelist;
  67. {In the register allocator we keep track of move instructions.
  68. These instructions are moved between five linked lists. There
  69. is also a linked list per register to keep track about the moves
  70. it is associated with. Because we need to determine quickly in
  71. which of the five lists it is we add anu enumeradtion to each
  72. move instruction.}
  73. Tmoveset=(ms_coalesced_moves,ms_constrained_moves,ms_frozen_moves,
  74. ms_worklist_moves,ms_active_moves);
  75. Tmoveins=class(Tlinkedlistitem)
  76. moveset:Tmoveset;
  77. x,y:Tsuperregister;
  78. end;
  79. Treginfoflag=(ri_coalesced,ri_selected);
  80. Treginfoflagset=set of Treginfoflag;
  81. Treginfo=record
  82. live_start,
  83. live_end : Tai;
  84. subreg : tsubregister;
  85. alias : Tsuperregister;
  86. { The register allocator assigns each register a colour }
  87. colour : Tsuperregister;
  88. movelist : Pmovelist;
  89. adjlist : Psuperregisterworklist;
  90. degree : TSuperregister;
  91. flags : Treginfoflagset;
  92. end;
  93. Preginfo=^TReginfo;
  94. tspillreginfo = record
  95. spillreg : tregister;
  96. orgreg : tsuperregister;
  97. tempreg : tregister;
  98. regread,regwritten, mustbespilled: boolean;
  99. end;
  100. tspillregsinfo = array[0..2] of tspillreginfo;
  101. {#------------------------------------------------------------------
  102. This class implements the default register allocator. It is used by the
  103. code generator to allocate and free registers which might be valid
  104. across nodes. It also contains utility routines related to registers.
  105. Some of the methods in this class should be overriden
  106. by cpu-specific implementations.
  107. --------------------------------------------------------------------}
  108. trgobj=class
  109. preserved_by_proc : tcpuregisterset;
  110. used_in_proc : tcpuregisterset;
  111. constructor create(Aregtype:Tregistertype;
  112. Adefaultsub:Tsubregister;
  113. const Ausable:array of tsuperregister;
  114. Afirst_imaginary:Tsuperregister;
  115. Apreserved_by_proc:Tcpuregisterset);
  116. destructor destroy;override;
  117. {# Allocate a register. An internalerror will be generated if there is
  118. no more free registers which can be allocated.}
  119. function getregister(list:Taasmoutput;subreg:Tsubregister):Tregister;virtual;
  120. {# Get the register specified.}
  121. procedure getcpuregister(list:Taasmoutput;r:Tregister);virtual;
  122. procedure ungetcpuregister(list:Taasmoutput;r:Tregister);virtual;
  123. {# Get multiple registers specified.}
  124. procedure alloccpuregisters(list:Taasmoutput;r:Tcpuregisterset);virtual;
  125. {# Free multiple registers specified.}
  126. procedure dealloccpuregisters(list:Taasmoutput;r:Tcpuregisterset);virtual;
  127. function uses_registers:boolean;virtual;
  128. procedure add_reg_instruction(instr:Tai;r:tregister);
  129. procedure add_move_instruction(instr:Taicpu);
  130. {# Do the register allocation.}
  131. procedure do_register_allocation(list:Taasmoutput;headertai:tai);virtual;
  132. { Adds an interference edge.
  133. don't move this to the protected section, the arm cg requires to access this (FK) }
  134. procedure add_edge(u,v:Tsuperregister);
  135. protected
  136. regtype : Tregistertype;
  137. { default subregister used }
  138. defaultsub : tsubregister;
  139. live_registers:Tsuperregisterworklist;
  140. { can be overriden to add cpu specific interferences }
  141. procedure add_cpu_interferences(p : tai);virtual;
  142. procedure add_constraints(reg:Tregister);virtual;
  143. function getregisterinline(list:Taasmoutput;subreg:Tsubregister):Tregister;
  144. procedure ungetregisterinline(list:Taasmoutput;r:Tregister);
  145. function get_spill_subreg(r : tregister) : tsubregister;virtual;
  146. function do_spill_replace(list:Taasmoutput;instr:taicpu;orgreg:tsuperregister;const spilltemp:treference):boolean;virtual;
  147. procedure do_spill_read(list:Taasmoutput;pos:tai;const spilltemp:treference;tempreg:tregister);virtual;
  148. procedure do_spill_written(list:Taasmoutput;pos:tai;const spilltemp:treference;tempreg:tregister);virtual;
  149. function instr_spill_register(list:Taasmoutput;
  150. instr:taicpu;
  151. const r:Tsuperregisterset;
  152. const spilltemplist:Tspill_temp_list): boolean;virtual;
  153. private
  154. {# First imaginary register.}
  155. first_imaginary : Tsuperregister;
  156. {# Highest register allocated until now.}
  157. reginfo : PReginfo;
  158. maxreginfo,
  159. maxreginfoinc,
  160. maxreg : Tsuperregister;
  161. usable_registers_cnt : word;
  162. usable_registers : array[0..maxcpuregister-1] of tsuperregister;
  163. ibitmap : Tinterferencebitmap;
  164. spillednodes,
  165. simplifyworklist,
  166. freezeworklist,
  167. spillworklist,
  168. coalescednodes,
  169. selectstack : tsuperregisterworklist;
  170. worklist_moves,
  171. active_moves,
  172. frozen_moves,
  173. coalesced_moves,
  174. constrained_moves : Tlinkedlist;
  175. {$ifdef EXTDEBUG}
  176. procedure writegraph(loopidx:longint);
  177. {$endif EXTDEBUG}
  178. {# Disposes of the reginfo array.}
  179. procedure dispose_reginfo;
  180. {# Prepare the register colouring.}
  181. procedure prepare_colouring;
  182. {# Clean up after register colouring.}
  183. procedure epilogue_colouring;
  184. {# Colour the registers; that is do the register allocation.}
  185. procedure colour_registers;
  186. procedure insert_regalloc_info(list:Taasmoutput;u:tsuperregister);
  187. procedure insert_regalloc_info_all(list:Taasmoutput);
  188. procedure generate_interference_graph(list:Taasmoutput;headertai:tai);
  189. procedure translate_registers(list:Taasmoutput);
  190. function spill_registers(list:Taasmoutput;headertai:tai):boolean;virtual;
  191. function getnewreg(subreg:tsubregister):tsuperregister;
  192. procedure add_edges_used(u:Tsuperregister);
  193. procedure add_to_movelist(u:Tsuperregister;data:Tlinkedlistitem);
  194. function move_related(n:Tsuperregister):boolean;
  195. procedure make_work_list;
  196. procedure sort_simplify_worklist;
  197. procedure enable_moves(n:Tsuperregister);
  198. procedure decrement_degree(m:Tsuperregister);
  199. procedure simplify;
  200. function get_alias(n:Tsuperregister):Tsuperregister;
  201. procedure add_worklist(u:Tsuperregister);
  202. function adjacent_ok(u,v:Tsuperregister):boolean;
  203. function conservative(u,v:Tsuperregister):boolean;
  204. procedure combine(u,v:Tsuperregister);
  205. procedure coalesce;
  206. procedure freeze_moves(u:Tsuperregister);
  207. procedure freeze;
  208. procedure select_spill;
  209. procedure assign_colours;
  210. procedure clear_interferences(u:Tsuperregister);
  211. end;
  212. const
  213. first_reg = 0;
  214. last_reg = high(tsuperregister)-1;
  215. maxspillingcounter = 20;
  216. implementation
  217. uses
  218. systems,
  219. globals,verbose,tgobj,procinfo;
  220. procedure sort_movelist(ml:Pmovelist);
  221. {Ok, sorting pointers is silly, but it does the job to make Trgobj.combine
  222. faster.}
  223. var h,i,p:word;
  224. t:Tlinkedlistitem;
  225. begin
  226. with ml^ do
  227. begin
  228. if header.count<2 then
  229. exit;
  230. p:=1;
  231. while 2*p<header.count do
  232. p:=2*p;
  233. while p<>0 do
  234. begin
  235. for h:=p to header.count-1 do
  236. begin
  237. i:=h;
  238. t:=data[i];
  239. repeat
  240. if ptrint(data[i-p])<=ptrint(t) then
  241. break;
  242. data[i]:=data[i-p];
  243. dec(i,p);
  244. until i<p;
  245. data[i]:=t;
  246. end;
  247. p:=p shr 1;
  248. end;
  249. header.sorted_until:=header.count-1;
  250. end;
  251. end;
  252. {******************************************************************************
  253. tinterferencebitmap
  254. ******************************************************************************}
  255. constructor tinterferencebitmap.create;
  256. begin
  257. inherited create;
  258. maxx1:=1;
  259. getmem(fbitmap,sizeof(tinterferencebitmap1)*2);
  260. fillchar(fbitmap^,sizeof(tinterferencebitmap1)*2,0);
  261. end;
  262. destructor tinterferencebitmap.destroy;
  263. var i,j:byte;
  264. begin
  265. for i:=0 to maxx1 do
  266. for j:=0 to maxy1 do
  267. if assigned(fbitmap[i,j]) then
  268. dispose(fbitmap[i,j]);
  269. freemem(fbitmap);
  270. end;
  271. function tinterferencebitmap.getbitmap(x,y:tsuperregister):boolean;
  272. var
  273. page : pinterferencebitmap2;
  274. begin
  275. result:=false;
  276. if (x shr 8>maxx1) then
  277. exit;
  278. page:=fbitmap[x shr 8,y shr 8];
  279. result:=assigned(page) and
  280. ((x and $ff) in page^[y and $ff]);
  281. end;
  282. procedure tinterferencebitmap.setbitmap(x,y:tsuperregister;b:boolean);
  283. var
  284. x1,y1 : byte;
  285. begin
  286. x1:=x shr 8;
  287. y1:=y shr 8;
  288. if x1>maxx1 then
  289. begin
  290. reallocmem(fbitmap,sizeof(tinterferencebitmap1)*(x1+1));
  291. fillchar(fbitmap[maxx1+1],sizeof(tinterferencebitmap1)*(x1-maxx1),0);
  292. maxx1:=x1;
  293. end;
  294. if not assigned(fbitmap[x1,y1]) then
  295. begin
  296. if y1>maxy1 then
  297. maxy1:=y1;
  298. new(fbitmap[x1,y1]);
  299. fillchar(fbitmap[x1,y1]^,sizeof(tinterferencebitmap2),0);
  300. end;
  301. if b then
  302. include(fbitmap[x1,y1]^[y and $ff],(x and $ff))
  303. else
  304. exclude(fbitmap[x1,y1]^[y and $ff],(x and $ff));
  305. end;
  306. {******************************************************************************
  307. trgobj
  308. ******************************************************************************}
  309. constructor trgobj.create(Aregtype:Tregistertype;
  310. Adefaultsub:Tsubregister;
  311. const Ausable:array of tsuperregister;
  312. Afirst_imaginary:Tsuperregister;
  313. Apreserved_by_proc:Tcpuregisterset);
  314. var
  315. i : Tsuperregister;
  316. begin
  317. { empty super register sets can cause very strange problems }
  318. if high(Ausable)=0 then
  319. internalerror(200210181);
  320. first_imaginary:=Afirst_imaginary;
  321. maxreg:=Afirst_imaginary;
  322. regtype:=Aregtype;
  323. defaultsub:=Adefaultsub;
  324. preserved_by_proc:=Apreserved_by_proc;
  325. used_in_proc:=[];
  326. live_registers.init;
  327. { Get reginfo for CPU registers }
  328. maxreginfo:=first_imaginary;
  329. maxreginfoinc:=16;
  330. worklist_moves:=Tlinkedlist.create;
  331. reginfo:=allocmem(first_imaginary*sizeof(treginfo));
  332. for i:=0 to first_imaginary-1 do
  333. begin
  334. reginfo[i].degree:=high(tsuperregister);
  335. reginfo[i].alias:=RS_INVALID;
  336. end;
  337. { Usable registers }
  338. fillchar(usable_registers,sizeof(usable_registers),0);
  339. for i:=low(Ausable) to high(Ausable) do
  340. usable_registers[i]:=Ausable[i];
  341. usable_registers_cnt:=high(Ausable)+1;
  342. { Initialize Worklists }
  343. spillednodes.init;
  344. simplifyworklist.init;
  345. freezeworklist.init;
  346. spillworklist.init;
  347. coalescednodes.init;
  348. selectstack.init;
  349. end;
  350. destructor trgobj.destroy;
  351. begin
  352. spillednodes.done;
  353. simplifyworklist.done;
  354. freezeworklist.done;
  355. spillworklist.done;
  356. coalescednodes.done;
  357. selectstack.done;
  358. live_registers.done;
  359. worklist_moves.free;
  360. dispose_reginfo;
  361. end;
  362. procedure Trgobj.dispose_reginfo;
  363. var i:Tsuperregister;
  364. begin
  365. if reginfo<>nil then
  366. begin
  367. for i:=0 to maxreg-1 do
  368. with reginfo[i] do
  369. begin
  370. if adjlist<>nil then
  371. dispose(adjlist,done);
  372. if movelist<>nil then
  373. dispose(movelist);
  374. end;
  375. freemem(reginfo);
  376. reginfo:=nil;
  377. end;
  378. end;
  379. function trgobj.getnewreg(subreg:tsubregister):tsuperregister;
  380. var
  381. oldmaxreginfo : tsuperregister;
  382. begin
  383. result:=maxreg;
  384. inc(maxreg);
  385. if maxreg>=last_reg then
  386. internalerror(200310146);
  387. if maxreg>=maxreginfo then
  388. begin
  389. oldmaxreginfo:=maxreginfo;
  390. inc(maxreginfo,maxreginfoinc);
  391. if maxreginfoinc<256 then
  392. maxreginfoinc:=maxreginfoinc*2;
  393. reallocmem(reginfo,maxreginfo*sizeof(treginfo));
  394. { Do we really need it to clear it ? At least for 1.0.x (PFV) }
  395. fillchar(reginfo[oldmaxreginfo],(maxreginfo-oldmaxreginfo)*sizeof(treginfo),0);
  396. end;
  397. reginfo[result].subreg:=subreg;
  398. end;
  399. function trgobj.getregister(list:Taasmoutput;subreg:Tsubregister):Tregister;
  400. begin
  401. {$ifdef EXTDEBUG}
  402. if reginfo=nil then
  403. InternalError(2004020901);
  404. {$endif EXTDEBUG}
  405. if defaultsub=R_SUBNONE then
  406. result:=newreg(regtype,getnewreg(R_SUBNONE),R_SUBNONE)
  407. else
  408. result:=newreg(regtype,getnewreg(subreg),subreg);
  409. end;
  410. function trgobj.uses_registers:boolean;
  411. begin
  412. result:=(maxreg>first_imaginary);
  413. end;
  414. procedure trgobj.ungetcpuregister(list:Taasmoutput;r:Tregister);
  415. begin
  416. if (getsupreg(r)>=first_imaginary) then
  417. InternalError(2004020901);
  418. list.concat(Tai_regalloc.dealloc(r,nil));
  419. end;
  420. procedure trgobj.getcpuregister(list:Taasmoutput;r:Tregister);
  421. var
  422. supreg:Tsuperregister;
  423. begin
  424. supreg:=getsupreg(r);
  425. if supreg>=first_imaginary then
  426. internalerror(2003121503);
  427. include(used_in_proc,supreg);
  428. list.concat(Tai_regalloc.alloc(r,nil));
  429. end;
  430. procedure trgobj.alloccpuregisters(list:Taasmoutput;r:Tcpuregisterset);
  431. var i:Tsuperregister;
  432. begin
  433. for i:=0 to first_imaginary-1 do
  434. if i in r then
  435. getcpuregister(list,newreg(regtype,i,defaultsub));
  436. end;
  437. procedure trgobj.dealloccpuregisters(list:Taasmoutput;r:Tcpuregisterset);
  438. var i:Tsuperregister;
  439. begin
  440. for i:=0 to first_imaginary-1 do
  441. if i in r then
  442. ungetcpuregister(list,newreg(regtype,i,defaultsub));
  443. end;
  444. procedure trgobj.do_register_allocation(list:Taasmoutput;headertai:tai);
  445. var
  446. spillingcounter:byte;
  447. endspill:boolean;
  448. i:Tsuperregister;
  449. begin
  450. { Insert regalloc info for imaginary registers }
  451. insert_regalloc_info_all(list);
  452. ibitmap:=tinterferencebitmap.create;
  453. generate_interference_graph(list,headertai);
  454. { Don't do the real allocation when -sr is passed }
  455. if (cs_no_regalloc in aktglobalswitches) then
  456. exit;
  457. {Do register allocation.}
  458. spillingcounter:=0;
  459. repeat
  460. prepare_colouring;
  461. colour_registers;
  462. epilogue_colouring;
  463. endspill:=true;
  464. if spillednodes.length<>0 then
  465. begin
  466. inc(spillingcounter);
  467. if spillingcounter>maxspillingcounter then
  468. exit;
  469. if spillingcounter>maxspillingcounter then
  470. internalerror(200309041);
  471. endspill:=not spill_registers(list,headertai);
  472. end;
  473. until endspill;
  474. ibitmap.free;
  475. translate_registers(list);
  476. dispose_reginfo;
  477. end;
  478. procedure trgobj.add_constraints(reg:Tregister);
  479. begin
  480. end;
  481. procedure trgobj.add_edge(u,v:Tsuperregister);
  482. {This procedure will add an edge to the virtual interference graph.}
  483. procedure addadj(u,v:Tsuperregister);
  484. begin
  485. with reginfo[u] do
  486. begin
  487. if adjlist=nil then
  488. new(adjlist,init);
  489. adjlist^.add(v);
  490. end;
  491. end;
  492. begin
  493. if (u<>v) and not(ibitmap[v,u]) then
  494. begin
  495. ibitmap[v,u]:=true;
  496. ibitmap[u,v]:=true;
  497. {Precoloured nodes are not stored in the interference graph.}
  498. if (u>=first_imaginary) then
  499. addadj(u,v);
  500. if (v>=first_imaginary) then
  501. addadj(v,u);
  502. end;
  503. end;
  504. procedure trgobj.add_edges_used(u:Tsuperregister);
  505. var i:word;
  506. begin
  507. with live_registers do
  508. if length>0 then
  509. for i:=0 to length-1 do
  510. add_edge(u,get_alias(buf^[i]));
  511. end;
  512. {$ifdef EXTDEBUG}
  513. procedure trgobj.writegraph(loopidx:longint);
  514. {This procedure writes out the current interference graph in the
  515. register allocator.}
  516. var f:text;
  517. i,j:Tsuperregister;
  518. begin
  519. assign(f,'igraph'+tostr(loopidx));
  520. rewrite(f);
  521. writeln(f,'Interference graph');
  522. writeln(f);
  523. write(f,' ');
  524. for i:=0 to 15 do
  525. for j:=0 to 15 do
  526. write(f,hexstr(i,1));
  527. writeln(f);
  528. write(f,' ');
  529. for i:=0 to 15 do
  530. write(f,'0123456789ABCDEF');
  531. writeln(f);
  532. for i:=0 to maxreg-1 do
  533. begin
  534. write(f,hexstr(i,2):4);
  535. for j:=0 to maxreg-1 do
  536. if ibitmap[i,j] then
  537. write(f,'*')
  538. else
  539. write(f,'-');
  540. writeln(f);
  541. end;
  542. close(f);
  543. end;
  544. {$endif EXTDEBUG}
  545. procedure trgobj.add_to_movelist(u:Tsuperregister;data:Tlinkedlistitem);
  546. begin
  547. with reginfo[u] do
  548. begin
  549. if movelist=nil then
  550. begin
  551. getmem(movelist,sizeof(tmovelistheader)+60*sizeof(pointer));
  552. movelist^.header.maxcount:=60;
  553. movelist^.header.count:=0;
  554. movelist^.header.sorted_until:=0;
  555. end
  556. else
  557. begin
  558. if movelist^.header.count>=movelist^.header.maxcount then
  559. begin
  560. movelist^.header.maxcount:=movelist^.header.maxcount*2;
  561. reallocmem(movelist,sizeof(tmovelistheader)+movelist^.header.maxcount*sizeof(pointer));
  562. end;
  563. end;
  564. movelist^.data[movelist^.header.count]:=data;
  565. inc(movelist^.header.count);
  566. end;
  567. end;
  568. procedure trgobj.add_reg_instruction(instr:Tai;r:tregister);
  569. var
  570. supreg : tsuperregister;
  571. begin
  572. supreg:=getsupreg(r);
  573. if supreg>=first_imaginary then
  574. with reginfo[supreg] do
  575. begin
  576. if not assigned(live_start) then
  577. live_start:=instr;
  578. live_end:=instr;
  579. end;
  580. end;
  581. procedure trgobj.add_move_instruction(instr:Taicpu);
  582. {This procedure notifies a certain as a move instruction so the
  583. register allocator can try to eliminate it.}
  584. var i:Tmoveins;
  585. ssupreg,dsupreg:Tsuperregister;
  586. begin
  587. {$ifdef extdebug}
  588. if (instr.oper[O_MOV_SOURCE]^.typ<>top_reg) or
  589. (instr.oper[O_MOV_DEST]^.typ<>top_reg) then
  590. internalerror(200311291);
  591. {$endif}
  592. i:=Tmoveins.create;
  593. i.moveset:=ms_worklist_moves;
  594. worklist_moves.insert(i);
  595. ssupreg:=getsupreg(instr.oper[O_MOV_SOURCE]^.reg);
  596. add_to_movelist(ssupreg,i);
  597. dsupreg:=getsupreg(instr.oper[O_MOV_DEST]^.reg);
  598. if ssupreg<>dsupreg then
  599. {Avoid adding the same move instruction twice to a single register.}
  600. add_to_movelist(dsupreg,i);
  601. i.x:=ssupreg;
  602. i.y:=dsupreg;
  603. end;
  604. function trgobj.move_related(n:Tsuperregister):boolean;
  605. var i:cardinal;
  606. begin
  607. move_related:=false;
  608. with reginfo[n] do
  609. if movelist<>nil then
  610. with movelist^ do
  611. for i:=0 to header.count-1 do
  612. if Tmoveins(data[i]).moveset in [ms_worklist_moves,ms_active_moves] then
  613. begin
  614. move_related:=true;
  615. break;
  616. end;
  617. end;
  618. procedure Trgobj.sort_simplify_worklist;
  619. {Sorts the simplifyworklist by the number of interferences the
  620. registers in it cause. This allows simplify to execute in
  621. constant time.}
  622. var p,h,i,leni,lent:word;
  623. t:Tsuperregister;
  624. adji,adjt:Psuperregisterworklist;
  625. begin
  626. with simplifyworklist do
  627. begin
  628. if length<2 then
  629. exit;
  630. p:=1;
  631. while 2*p<length do
  632. p:=2*p;
  633. while p<>0 do
  634. begin
  635. for h:=p to length-1 do
  636. begin
  637. i:=h;
  638. t:=buf^[i];
  639. adjt:=reginfo[buf^[i]].adjlist;
  640. lent:=0;
  641. if adjt<>nil then
  642. lent:=adjt^.length;
  643. repeat
  644. adji:=reginfo[buf^[i-p]].adjlist;
  645. leni:=0;
  646. if adji<>nil then
  647. leni:=adji^.length;
  648. if leni<=lent then
  649. break;
  650. buf^[i]:=buf^[i-p];
  651. dec(i,p)
  652. until i<p;
  653. buf^[i]:=t;
  654. end;
  655. p:=p shr 1;
  656. end;
  657. end;
  658. end;
  659. procedure trgobj.make_work_list;
  660. var n:Tsuperregister;
  661. begin
  662. {If we have 7 cpu registers, and the degree of a node is 7, we cannot
  663. assign it to any of the registers, thus it is significant.}
  664. for n:=first_imaginary to maxreg-1 do
  665. with reginfo[n] do
  666. begin
  667. if adjlist=nil then
  668. degree:=0
  669. else
  670. degree:=adjlist^.length;
  671. if degree>=usable_registers_cnt then
  672. spillworklist.add(n)
  673. else if move_related(n) then
  674. freezeworklist.add(n)
  675. else
  676. simplifyworklist.add(n);
  677. end;
  678. sort_simplify_worklist;
  679. end;
  680. procedure trgobj.prepare_colouring;
  681. var i:word;
  682. begin
  683. make_work_list;
  684. active_moves:=Tlinkedlist.create;
  685. frozen_moves:=Tlinkedlist.create;
  686. coalesced_moves:=Tlinkedlist.create;
  687. constrained_moves:=Tlinkedlist.create;
  688. selectstack.clear;
  689. end;
  690. procedure trgobj.enable_moves(n:Tsuperregister);
  691. var m:Tlinkedlistitem;
  692. i:cardinal;
  693. begin
  694. with reginfo[n] do
  695. if movelist<>nil then
  696. for i:=0 to movelist^.header.count-1 do
  697. begin
  698. m:=movelist^.data[i];
  699. if Tmoveins(m).moveset in [ms_worklist_moves,ms_active_moves] then
  700. if Tmoveins(m).moveset=ms_active_moves then
  701. begin
  702. {Move m from the set active_moves to the set worklist_moves.}
  703. active_moves.remove(m);
  704. Tmoveins(m).moveset:=ms_worklist_moves;
  705. worklist_moves.concat(m);
  706. end;
  707. end;
  708. end;
  709. procedure Trgobj.decrement_degree(m:Tsuperregister);
  710. var adj : Psuperregisterworklist;
  711. n : tsuperregister;
  712. d,i : word;
  713. begin
  714. with reginfo[m] do
  715. begin
  716. d:=degree;
  717. if d=0 then
  718. internalerror(200312151);
  719. dec(degree);
  720. if d=usable_registers_cnt then
  721. begin
  722. {Enable moves for m.}
  723. enable_moves(m);
  724. {Enable moves for adjacent.}
  725. adj:=adjlist;
  726. if adj<>nil then
  727. for i:=1 to adj^.length do
  728. begin
  729. n:=adj^.buf^[i-1];
  730. if reginfo[n].flags*[ri_selected,ri_coalesced]<>[] then
  731. enable_moves(n);
  732. end;
  733. {Remove the node from the spillworklist.}
  734. if not spillworklist.delete(m) then
  735. internalerror(200310145);
  736. if move_related(m) then
  737. freezeworklist.add(m)
  738. else
  739. simplifyworklist.add(m);
  740. end;
  741. end;
  742. end;
  743. procedure trgobj.simplify;
  744. var adj : Psuperregisterworklist;
  745. m,n : Tsuperregister;
  746. i : word;
  747. begin
  748. {We take the element with the least interferences out of the
  749. simplifyworklist. Since the simplifyworklist is now sorted, we
  750. no longer need to search, but we can simply take the first element.}
  751. m:=simplifyworklist.get;
  752. {Push it on the selectstack.}
  753. selectstack.add(m);
  754. with reginfo[m] do
  755. begin
  756. include(flags,ri_selected);
  757. adj:=adjlist;
  758. end;
  759. if adj<>nil then
  760. for i:=1 to adj^.length do
  761. begin
  762. n:=adj^.buf^[i-1];
  763. if (n>=first_imaginary) and
  764. (reginfo[n].flags*[ri_selected,ri_coalesced]=[]) then
  765. decrement_degree(n);
  766. end;
  767. end;
  768. function trgobj.get_alias(n:Tsuperregister):Tsuperregister;
  769. begin
  770. while ri_coalesced in reginfo[n].flags do
  771. n:=reginfo[n].alias;
  772. get_alias:=n;
  773. end;
  774. procedure trgobj.add_worklist(u:Tsuperregister);
  775. begin
  776. if (u>=first_imaginary) and
  777. (not move_related(u)) and
  778. (reginfo[u].degree<usable_registers_cnt) then
  779. begin
  780. if not freezeworklist.delete(u) then
  781. internalerror(200308161); {must be found}
  782. simplifyworklist.add(u);
  783. end;
  784. end;
  785. function trgobj.adjacent_ok(u,v:Tsuperregister):boolean;
  786. {Check wether u and v should be coalesced. u is precoloured.}
  787. function ok(t,r:Tsuperregister):boolean;
  788. begin
  789. ok:=(t<first_imaginary) or
  790. (reginfo[t].degree<usable_registers_cnt) or
  791. ibitmap[r,t];
  792. end;
  793. var adj : Psuperregisterworklist;
  794. i : word;
  795. n : tsuperregister;
  796. begin
  797. with reginfo[v] do
  798. begin
  799. adjacent_ok:=true;
  800. adj:=adjlist;
  801. if adj<>nil then
  802. for i:=1 to adj^.length do
  803. begin
  804. n:=adj^.buf^[i-1];
  805. if (flags*[ri_coalesced,ri_selected]=[]) and not ok(n,u) then
  806. begin
  807. adjacent_ok:=false;
  808. break;
  809. end;
  810. end;
  811. end;
  812. end;
  813. function trgobj.conservative(u,v:Tsuperregister):boolean;
  814. var adj : Psuperregisterworklist;
  815. done : Tsuperregisterset; {To prevent that we count nodes twice.}
  816. i,k:word;
  817. n : tsuperregister;
  818. begin
  819. k:=0;
  820. supregset_reset(done,false,maxreg);
  821. with reginfo[u] do
  822. begin
  823. adj:=adjlist;
  824. if adj<>nil then
  825. for i:=1 to adj^.length do
  826. begin
  827. n:=adj^.buf^[i-1];
  828. if flags*[ri_coalesced,ri_selected]=[] then
  829. begin
  830. supregset_include(done,n);
  831. if reginfo[n].degree>=usable_registers_cnt then
  832. inc(k);
  833. end;
  834. end;
  835. end;
  836. adj:=reginfo[v].adjlist;
  837. if adj<>nil then
  838. for i:=1 to adj^.length do
  839. begin
  840. n:=adj^.buf^[i-1];
  841. if not supregset_in(done,n) and
  842. (reginfo[n].degree>=usable_registers_cnt) and
  843. (reginfo[u].flags*[ri_coalesced,ri_selected]=[]) then
  844. inc(k);
  845. end;
  846. conservative:=(k<usable_registers_cnt);
  847. end;
  848. procedure trgobj.combine(u,v:Tsuperregister);
  849. var adj : Psuperregisterworklist;
  850. i,n,p,q:cardinal;
  851. t : tsuperregister;
  852. searched:Tlinkedlistitem;
  853. label l1;
  854. begin
  855. if not freezeworklist.delete(v) then
  856. spillworklist.delete(v);
  857. coalescednodes.add(v);
  858. include(reginfo[v].flags,ri_coalesced);
  859. reginfo[v].alias:=u;
  860. {Combine both movelists. Since the movelists are sets, only add
  861. elements that are not already present. The movelists cannot be
  862. empty by definition; nodes are only coalesced if there is a move
  863. between them. To prevent quadratic time blowup (movelists of
  864. especially machine registers can get very large because of moves
  865. generated during calls) we need to go into disgusting complexity.
  866. (See webtbs/tw2242 for an example that stresses this.)
  867. We want to sort the movelist to be able to search logarithmically.
  868. Unfortunately, sorting the movelist every time before searching
  869. is counter-productive, since the movelist usually grows with a few
  870. items at a time. Therefore, we split the movelist into a sorted
  871. and an unsorted part and search through both. If the unsorted part
  872. becomes too large, we sort.}
  873. if assigned(reginfo[u].movelist) then
  874. begin
  875. {We have to weigh the cost of sorting the list against searching
  876. the cost of the unsorted part. I use factor of 8 here; if the
  877. number of items is less than 8 times the numer of unsorted items,
  878. we'll sort the list.}
  879. with reginfo[u].movelist^ do
  880. if header.count<8*(header.count-header.sorted_until) then
  881. sort_movelist(reginfo[u].movelist);
  882. if assigned(reginfo[v].movelist) then
  883. begin
  884. for n:=0 to reginfo[v].movelist^.header.count-1 do
  885. begin
  886. {Binary search the sorted part of the list.}
  887. searched:=reginfo[v].movelist^.data[n];
  888. p:=0;
  889. q:=reginfo[u].movelist^.header.sorted_until;
  890. i:=0;
  891. if q<>0 then
  892. repeat
  893. i:=(p+q) shr 1;
  894. if ptrint(searched)>ptrint(reginfo[u].movelist^.data[i]) then
  895. p:=i+1
  896. else
  897. q:=i;
  898. until p=q;
  899. with reginfo[u].movelist^ do
  900. if searched<>data[i] then
  901. begin
  902. {Linear search the unsorted part of the list.}
  903. for i:=header.sorted_until+1 to header.count-1 do
  904. if searched=data[i] then
  905. goto l1;
  906. {Not found -> add}
  907. add_to_movelist(u,searched);
  908. l1:
  909. end;
  910. end;
  911. end;
  912. end;
  913. enable_moves(v);
  914. adj:=reginfo[v].adjlist;
  915. if adj<>nil then
  916. for i:=1 to adj^.length do
  917. begin
  918. t:=adj^.buf^[i-1];
  919. with reginfo[t] do
  920. if not(ri_coalesced in flags) then
  921. begin
  922. {t has a connection to v. Since we are adding v to u, we
  923. need to connect t to u. However, beware if t was already
  924. connected to u...}
  925. if (ibitmap[t,u]) and not (ri_selected in flags) then
  926. {... because in that case, we are actually removing an edge
  927. and the degree of t decreases.}
  928. decrement_degree(t)
  929. else
  930. begin
  931. add_edge(t,u);
  932. {We have added an edge to t and u. So their degree increases.
  933. However, v is added to u. That means its neighbours will
  934. no longer point to v, but to u instead. Therefore, only the
  935. degree of u increases.}
  936. if (u>=first_imaginary) and not (ri_selected in flags) then
  937. inc(reginfo[u].degree);
  938. end;
  939. end;
  940. end;
  941. if (reginfo[u].degree>=usable_registers_cnt) and freezeworklist.delete(u) then
  942. spillworklist.add(u);
  943. end;
  944. procedure trgobj.coalesce;
  945. var m:Tmoveins;
  946. x,y,u,v:Tsuperregister;
  947. begin
  948. m:=Tmoveins(worklist_moves.getfirst);
  949. x:=get_alias(m.x);
  950. y:=get_alias(m.y);
  951. if (y<first_imaginary) then
  952. begin
  953. u:=y;
  954. v:=x;
  955. end
  956. else
  957. begin
  958. u:=x;
  959. v:=y;
  960. end;
  961. if (u=v) then
  962. begin
  963. m.moveset:=ms_coalesced_moves; {Already coalesced.}
  964. coalesced_moves.insert(m);
  965. add_worklist(u);
  966. end
  967. {Do u and v interfere? In that case the move is constrained. Two
  968. precoloured nodes interfere allways. If v is precoloured, by the above
  969. code u is precoloured, thus interference...}
  970. else if (v<first_imaginary) or ibitmap[u,v] then
  971. begin
  972. m.moveset:=ms_constrained_moves; {Cannot coalesce yet...}
  973. constrained_moves.insert(m);
  974. add_worklist(u);
  975. add_worklist(v);
  976. end
  977. {Next test: is it possible and a good idea to coalesce??}
  978. else if ((u<first_imaginary) and adjacent_ok(u,v)) or
  979. ((u>=first_imaginary) and conservative(u,v)) then
  980. begin
  981. m.moveset:=ms_coalesced_moves; {Move coalesced!}
  982. coalesced_moves.insert(m);
  983. combine(u,v);
  984. add_worklist(u);
  985. end
  986. else
  987. begin
  988. m.moveset:=ms_active_moves;
  989. active_moves.insert(m);
  990. end;
  991. end;
  992. procedure trgobj.freeze_moves(u:Tsuperregister);
  993. var i:cardinal;
  994. m:Tlinkedlistitem;
  995. v,x,y:Tsuperregister;
  996. begin
  997. if reginfo[u].movelist<>nil then
  998. for i:=0 to reginfo[u].movelist^.header.count-1 do
  999. begin
  1000. m:=reginfo[u].movelist^.data[i];
  1001. if Tmoveins(m).moveset in [ms_worklist_moves,ms_active_moves] then
  1002. begin
  1003. x:=Tmoveins(m).x;
  1004. y:=Tmoveins(m).y;
  1005. if get_alias(y)=get_alias(u) then
  1006. v:=get_alias(x)
  1007. else
  1008. v:=get_alias(y);
  1009. {Move m from active_moves/worklist_moves to frozen_moves.}
  1010. if Tmoveins(m).moveset=ms_active_moves then
  1011. active_moves.remove(m)
  1012. else
  1013. worklist_moves.remove(m);
  1014. Tmoveins(m).moveset:=ms_frozen_moves;
  1015. frozen_moves.insert(m);
  1016. if (v>=first_imaginary) and not(move_related(v)) and
  1017. (reginfo[v].degree<usable_registers_cnt) then
  1018. begin
  1019. freezeworklist.delete(v);
  1020. simplifyworklist.add(v);
  1021. end;
  1022. end;
  1023. end;
  1024. end;
  1025. procedure trgobj.freeze;
  1026. var n:Tsuperregister;
  1027. begin
  1028. { We need to take a random element out of the freezeworklist. We take
  1029. the last element. Dirty code! }
  1030. n:=freezeworklist.get;
  1031. {Add it to the simplifyworklist.}
  1032. simplifyworklist.add(n);
  1033. freeze_moves(n);
  1034. end;
  1035. procedure trgobj.select_spill;
  1036. var
  1037. n : tsuperregister;
  1038. adj : psuperregisterworklist;
  1039. max,p,i:word;
  1040. begin
  1041. { We must look for the element with the most interferences in the
  1042. spillworklist. This is required because those registers are creating
  1043. the most conflicts and keeping them in a register will not reduce the
  1044. complexity and even can cause the help registers for the spilling code
  1045. to get too much conflicts with the result that the spilling code
  1046. will never converge (PFV) }
  1047. max:=0;
  1048. p:=0;
  1049. with spillworklist do
  1050. begin
  1051. {Safe: This procedure is only called if length<>0}
  1052. for i:=0 to length-1 do
  1053. begin
  1054. adj:=reginfo[buf^[i]].adjlist;
  1055. if assigned(adj) and (adj^.length>max) then
  1056. begin
  1057. p:=i;
  1058. max:=adj^.length;
  1059. end;
  1060. end;
  1061. n:=buf^[p];
  1062. deleteidx(p);
  1063. end;
  1064. simplifyworklist.add(n);
  1065. freeze_moves(n);
  1066. end;
  1067. procedure trgobj.assign_colours;
  1068. {Assign_colours assigns the actual colours to the registers.}
  1069. var adj : Psuperregisterworklist;
  1070. i,j,k : word;
  1071. n,a,c : Tsuperregister;
  1072. colourednodes : Tsuperregisterset;
  1073. adj_colours:set of 0..255;
  1074. found : boolean;
  1075. begin
  1076. spillednodes.clear;
  1077. {Reset colours}
  1078. for n:=0 to maxreg-1 do
  1079. reginfo[n].colour:=n;
  1080. {Colour the cpu registers...}
  1081. supregset_reset(colourednodes,false,maxreg);
  1082. for n:=0 to first_imaginary-1 do
  1083. supregset_include(colourednodes,n);
  1084. {Now colour the imaginary registers on the select-stack.}
  1085. for i:=selectstack.length downto 1 do
  1086. begin
  1087. n:=selectstack.buf^[i-1];
  1088. {Create a list of colours that we cannot assign to n.}
  1089. adj_colours:=[];
  1090. adj:=reginfo[n].adjlist;
  1091. if adj<>nil then
  1092. for j:=0 to adj^.length-1 do
  1093. begin
  1094. a:=get_alias(adj^.buf^[j]);
  1095. if supregset_in(colourednodes,a) and (reginfo[a].colour<=255) then
  1096. include(adj_colours,reginfo[a].colour);
  1097. end;
  1098. if regtype=R_INTREGISTER then
  1099. include(adj_colours,RS_STACK_POINTER_REG);
  1100. {Assume a spill by default...}
  1101. found:=false;
  1102. {Search for a colour not in this list.}
  1103. for k:=0 to usable_registers_cnt-1 do
  1104. begin
  1105. c:=usable_registers[k];
  1106. if not(c in adj_colours) then
  1107. begin
  1108. reginfo[n].colour:=c;
  1109. found:=true;
  1110. supregset_include(colourednodes,n);
  1111. include(used_in_proc,c);
  1112. break;
  1113. end;
  1114. end;
  1115. if not found then
  1116. spillednodes.add(n);
  1117. end;
  1118. {Finally colour the nodes that were coalesced.}
  1119. for i:=1 to coalescednodes.length do
  1120. begin
  1121. n:=coalescednodes.buf^[i-1];
  1122. k:=get_alias(n);
  1123. reginfo[n].colour:=reginfo[k].colour;
  1124. if reginfo[k].colour<maxcpuregister then
  1125. include(used_in_proc,reginfo[k].colour);
  1126. end;
  1127. end;
  1128. procedure trgobj.colour_registers;
  1129. begin
  1130. repeat
  1131. if simplifyworklist.length<>0 then
  1132. simplify
  1133. else if not(worklist_moves.empty) then
  1134. coalesce
  1135. else if freezeworklist.length<>0 then
  1136. freeze
  1137. else if spillworklist.length<>0 then
  1138. select_spill;
  1139. until (simplifyworklist.length=0) and
  1140. worklist_moves.empty and
  1141. (freezeworklist.length=0) and
  1142. (spillworklist.length=0);
  1143. assign_colours;
  1144. end;
  1145. procedure trgobj.epilogue_colouring;
  1146. var
  1147. i : Tsuperregister;
  1148. begin
  1149. worklist_moves.clear;
  1150. active_moves.destroy;
  1151. active_moves:=nil;
  1152. frozen_moves.destroy;
  1153. frozen_moves:=nil;
  1154. coalesced_moves.destroy;
  1155. coalesced_moves:=nil;
  1156. constrained_moves.destroy;
  1157. constrained_moves:=nil;
  1158. for i:=0 to maxreg-1 do
  1159. with reginfo[i] do
  1160. if movelist<>nil then
  1161. begin
  1162. dispose(movelist);
  1163. movelist:=nil;
  1164. end;
  1165. end;
  1166. procedure trgobj.clear_interferences(u:Tsuperregister);
  1167. {Remove node u from the interference graph and remove all collected
  1168. move instructions it is associated with.}
  1169. var i : word;
  1170. v : Tsuperregister;
  1171. adj,adj2 : Psuperregisterworklist;
  1172. begin
  1173. adj:=reginfo[u].adjlist;
  1174. if adj<>nil then
  1175. begin
  1176. for i:=1 to adj^.length do
  1177. begin
  1178. v:=adj^.buf^[i-1];
  1179. {Remove (u,v) and (v,u) from bitmap.}
  1180. ibitmap[u,v]:=false;
  1181. ibitmap[v,u]:=false;
  1182. {Remove (v,u) from adjacency list.}
  1183. adj2:=reginfo[v].adjlist;
  1184. if adj2<>nil then
  1185. begin
  1186. adj2^.delete(u);
  1187. if adj2^.length=0 then
  1188. begin
  1189. dispose(adj2,done);
  1190. reginfo[v].adjlist:=nil;
  1191. end;
  1192. end;
  1193. end;
  1194. {Remove ( u,* ) from adjacency list.}
  1195. dispose(adj,done);
  1196. reginfo[u].adjlist:=nil;
  1197. end;
  1198. end;
  1199. function trgobj.getregisterinline(list:Taasmoutput;subreg:Tsubregister):Tregister;
  1200. var
  1201. p : Tsuperregister;
  1202. r : Tregister;
  1203. begin
  1204. p:=getnewreg(subreg);
  1205. live_registers.add(p);
  1206. result:=newreg(regtype,p,subreg);
  1207. add_edges_used(p);
  1208. add_constraints(result);
  1209. end;
  1210. procedure trgobj.ungetregisterinline(list:Taasmoutput;r:Tregister);
  1211. var
  1212. supreg:Tsuperregister;
  1213. begin
  1214. supreg:=getsupreg(r);
  1215. live_registers.delete(supreg);
  1216. insert_regalloc_info(list,supreg);
  1217. end;
  1218. procedure trgobj.insert_regalloc_info(list:Taasmoutput;u:tsuperregister);
  1219. var
  1220. p : tai;
  1221. r : tregister;
  1222. begin
  1223. { Insert regallocs for all imaginary registers }
  1224. with reginfo[u] do
  1225. begin
  1226. r:=newreg(regtype,u,subreg);
  1227. if assigned(live_start) then
  1228. begin
  1229. list.insertbefore(Tai_regalloc.alloc(r,live_start),live_start);
  1230. { Insert live end deallocation before reg allocations
  1231. to reduce conflicts }
  1232. p:=live_end;
  1233. while assigned(p) and
  1234. assigned(p.previous) and
  1235. (tai(p.previous).typ=ait_regalloc) and
  1236. (tai_regalloc(p.previous).ratype=ra_alloc) and
  1237. (tai_regalloc(p.previous).reg<>r) do
  1238. p:=tai(p.previous);
  1239. { , but add release after sync }
  1240. if assigned(p) and
  1241. (p.typ=ait_regalloc) and
  1242. (tai_regalloc(p).ratype=ra_sync) then
  1243. p:=tai(p.next);
  1244. if assigned(p) then
  1245. list.insertbefore(Tai_regalloc.dealloc(r,live_end),p)
  1246. else
  1247. list.concat(Tai_regalloc.dealloc(r,live_end));
  1248. end
  1249. {$ifdef EXTDEBUG}
  1250. else
  1251. Comment(V_Warning,'Register '+std_regname(r)+' not used');
  1252. {$endif EXTDEBUG}
  1253. end;
  1254. end;
  1255. procedure trgobj.insert_regalloc_info_all(list:Taasmoutput);
  1256. var
  1257. supreg : tsuperregister;
  1258. begin
  1259. { Insert regallocs for all imaginary registers }
  1260. for supreg:=first_imaginary to maxreg-1 do
  1261. insert_regalloc_info(list,supreg);
  1262. end;
  1263. procedure trgobj.add_cpu_interferences(p : tai);
  1264. begin
  1265. end;
  1266. procedure trgobj.generate_interference_graph(list:Taasmoutput;headertai:tai);
  1267. var
  1268. p : tai;
  1269. i : integer;
  1270. supreg : tsuperregister;
  1271. begin
  1272. { All allocations are available. Now we can generate the
  1273. interference graph. Walk through all instructions, we can
  1274. start with the headertai, because before the header tai is
  1275. only symbols. }
  1276. live_registers.clear;
  1277. //live_registers.add(RS_STACK_POINTER_REG);
  1278. //live_registers.add(RS_FRAME_POINTER_REG);
  1279. p:=headertai;
  1280. while assigned(p) do
  1281. begin
  1282. if p.typ=ait_regalloc then
  1283. with Tai_regalloc(p) do
  1284. begin
  1285. if (getregtype(reg)=regtype) then
  1286. begin
  1287. supreg:=getsupreg(reg);
  1288. case ratype of
  1289. ra_alloc :
  1290. begin
  1291. live_registers.add(supreg);
  1292. add_edges_used(supreg);
  1293. end;
  1294. ra_dealloc :
  1295. begin
  1296. live_registers.delete(supreg);
  1297. add_edges_used(supreg);
  1298. end;
  1299. end;
  1300. { constraints needs always to be updated }
  1301. add_constraints(reg);
  1302. end;
  1303. end;
  1304. add_cpu_interferences(p);
  1305. p:=Tai(p.next);
  1306. end;
  1307. {$ifdef EXTDEBUG}
  1308. if live_registers.length>0 then
  1309. begin
  1310. for i:=0 to live_registers.length-1 do
  1311. begin
  1312. { Only report for imaginary registers }
  1313. if live_registers.buf^[i]>=first_imaginary then
  1314. Comment(V_Warning,'Register '+std_regname(newreg(R_INTREGISTER,live_registers.buf^[i],defaultsub))+' not released');
  1315. end;
  1316. end;
  1317. {$endif}
  1318. end;
  1319. procedure Trgobj.translate_registers(list:taasmoutput);
  1320. var
  1321. hp,p,q:Tai;
  1322. i:shortint;
  1323. {$ifdef arm}
  1324. so:pshifterop;
  1325. {$endif arm}
  1326. begin
  1327. { Leave when no imaginary registers are used }
  1328. if maxreg<=first_imaginary then
  1329. exit;
  1330. p:=Tai(list.first);
  1331. while assigned(p) do
  1332. begin
  1333. case p.typ of
  1334. ait_regalloc:
  1335. with Tai_regalloc(p) do
  1336. begin
  1337. { Only alloc/dealloc is needed for the optimizer, remove
  1338. other regalloc }
  1339. if not(ratype in [ra_alloc,ra_dealloc]) then
  1340. begin
  1341. q:=Tai(next);
  1342. list.remove(p);
  1343. p.free;
  1344. p:=q;
  1345. continue;
  1346. end
  1347. else
  1348. begin
  1349. if (getregtype(reg)=regtype) then
  1350. setsupreg(reg,reginfo[getsupreg(reg)].colour);
  1351. {
  1352. Remove sequences of release and
  1353. allocation of the same register like. Other combinations
  1354. of release/allocate need to stay in the list.
  1355. # Register X released
  1356. # Register X allocated
  1357. }
  1358. if assigned(previous) and
  1359. (ratype=ra_alloc) and
  1360. (Tai(previous).typ=ait_regalloc) and
  1361. (Tai_regalloc(previous).reg=reg) and
  1362. (Tai_regalloc(previous).ratype=ra_dealloc) then
  1363. begin
  1364. q:=Tai(next);
  1365. hp:=tai(previous);
  1366. list.remove(hp);
  1367. hp.free;
  1368. list.remove(p);
  1369. p.free;
  1370. p:=q;
  1371. continue;
  1372. end;
  1373. end;
  1374. end;
  1375. ait_instruction:
  1376. with Taicpu(p) do
  1377. begin
  1378. aktfilepos:=fileinfo;
  1379. for i:=0 to ops-1 do
  1380. with oper[i]^ do
  1381. case typ of
  1382. Top_reg:
  1383. if (getregtype(reg)=regtype) then
  1384. setsupreg(reg,reginfo[getsupreg(reg)].colour);
  1385. Top_ref:
  1386. begin
  1387. if regtype=R_INTREGISTER then
  1388. with ref^ do
  1389. begin
  1390. if base<>NR_NO then
  1391. setsupreg(base,reginfo[getsupreg(base)].colour);
  1392. if index<>NR_NO then
  1393. setsupreg(index,reginfo[getsupreg(index)].colour);
  1394. end;
  1395. end;
  1396. {$ifdef arm}
  1397. Top_shifterop:
  1398. begin
  1399. so:=shifterop;
  1400. if so^.rs<>NR_NO then
  1401. setsupreg(so^.rs,reginfo[getsupreg(so^.rs)].colour);
  1402. end;
  1403. {$endif arm}
  1404. end;
  1405. { Maybe the operation can be removed when
  1406. it is a move and both arguments are the same }
  1407. if is_same_reg_move(regtype) then
  1408. begin
  1409. q:=Tai(p.next);
  1410. list.remove(p);
  1411. p.free;
  1412. p:=q;
  1413. continue;
  1414. end;
  1415. end;
  1416. end;
  1417. p:=Tai(p.next);
  1418. end;
  1419. aktfilepos:=current_procinfo.exitpos;
  1420. end;
  1421. function trgobj.spill_registers(list:Taasmoutput;headertai:tai):boolean;
  1422. { Returns true if any help registers have been used }
  1423. var
  1424. i : word;
  1425. t : tsuperregister;
  1426. p,q : Tai;
  1427. regs_to_spill_set:Tsuperregisterset;
  1428. spill_temps : ^Tspill_temp_list;
  1429. supreg : tsuperregister;
  1430. templist : taasmoutput;
  1431. begin
  1432. spill_registers:=false;
  1433. live_registers.clear;
  1434. for i:=first_imaginary to maxreg-1 do
  1435. exclude(reginfo[i].flags,ri_selected);
  1436. spill_temps:=allocmem(sizeof(treference)*maxreg);
  1437. supregset_reset(regs_to_spill_set,false,$ffff);
  1438. { Allocate temps and insert in front of the list }
  1439. templist:=taasmoutput.create;
  1440. {Safe: this procedure is only called if there are spilled nodes.}
  1441. with spillednodes do
  1442. for i:=0 to length-1 do
  1443. begin
  1444. t:=buf^[i];
  1445. {Alternative representation.}
  1446. supregset_include(regs_to_spill_set,t);
  1447. {Clear all interferences of the spilled register.}
  1448. clear_interferences(t);
  1449. {Get a temp for the spilled register, the size must at least equal a complete register,
  1450. take also care of the fact that subreg can be larger than a single register like doubles
  1451. that occupy 2 registers }
  1452. tg.gettemp(templist,
  1453. max(tcgsize2size[reg_cgsize(newreg(regtype,t,R_SUBWHOLE))],
  1454. tcgsize2size[reg_cgsize(newreg(regtype,t,reginfo[t].subreg))]),
  1455. tt_noreuse,spill_temps^[t]);
  1456. end;
  1457. list.insertlistafter(headertai,templist);
  1458. templist.free;
  1459. { Walk through all instructions, we can start with the headertai,
  1460. because before the header tai is only symbols }
  1461. p:=headertai;
  1462. while assigned(p) do
  1463. begin
  1464. case p.typ of
  1465. ait_regalloc:
  1466. with Tai_regalloc(p) do
  1467. begin
  1468. if (getregtype(reg)=regtype) then
  1469. begin
  1470. {A register allocation of a spilled register can be removed.}
  1471. supreg:=getsupreg(reg);
  1472. if supregset_in(regs_to_spill_set,supreg) then
  1473. begin
  1474. q:=Tai(p.next);
  1475. list.remove(p);
  1476. p.free;
  1477. p:=q;
  1478. continue;
  1479. end
  1480. else
  1481. begin
  1482. case ratype of
  1483. ra_alloc :
  1484. live_registers.add(supreg);
  1485. ra_dealloc :
  1486. live_registers.delete(supreg);
  1487. end;
  1488. end;
  1489. end;
  1490. end;
  1491. ait_instruction:
  1492. with Taicpu(p) do
  1493. begin
  1494. aktfilepos:=fileinfo;
  1495. if instr_spill_register(list,taicpu(p),regs_to_spill_set,spill_temps^) then
  1496. spill_registers:=true;
  1497. end;
  1498. end;
  1499. p:=Tai(p.next);
  1500. end;
  1501. aktfilepos:=current_procinfo.exitpos;
  1502. {Safe: this procedure is only called if there are spilled nodes.}
  1503. with spillednodes do
  1504. for i:=0 to length-1 do
  1505. tg.ungettemp(list,spill_temps^[buf^[i]]);
  1506. freemem(spill_temps);
  1507. end;
  1508. function trgobj.do_spill_replace(list:Taasmoutput;instr:taicpu;orgreg:tsuperregister;const spilltemp:treference):boolean;
  1509. begin
  1510. result:=false;
  1511. end;
  1512. procedure Trgobj.do_spill_read(list:Taasmoutput;pos:tai;const spilltemp:treference;tempreg:tregister);
  1513. begin
  1514. list.insertafter(spilling_create_load(spilltemp,tempreg),pos);
  1515. end;
  1516. procedure Trgobj.do_spill_written(list:Taasmoutput;pos:tai;const spilltemp:treference;tempreg:tregister);
  1517. begin
  1518. list.insertafter(spilling_create_store(tempreg,spilltemp),pos);
  1519. end;
  1520. function trgobj.get_spill_subreg(r : tregister) : tsubregister;
  1521. begin
  1522. result:=defaultsub;
  1523. end;
  1524. function trgobj.instr_spill_register(list:Taasmoutput;
  1525. instr:taicpu;
  1526. const r:Tsuperregisterset;
  1527. const spilltemplist:Tspill_temp_list): boolean;
  1528. var
  1529. counter, regindex: longint;
  1530. regs: tspillregsinfo;
  1531. spilled: boolean;
  1532. procedure addreginfo(reg: tregister; operation: topertype);
  1533. var
  1534. i, tmpindex: longint;
  1535. supreg : tsuperregister;
  1536. begin
  1537. tmpindex := regindex;
  1538. supreg:=getsupreg(reg);
  1539. { did we already encounter this register? }
  1540. for i := 0 to pred(regindex) do
  1541. if (regs[i].orgreg = supreg) then
  1542. begin
  1543. tmpindex := i;
  1544. break;
  1545. end;
  1546. if tmpindex > high(regs) then
  1547. internalerror(2003120301);
  1548. regs[tmpindex].orgreg := supreg;
  1549. regs[tmpindex].spillreg:=reg;
  1550. if supregset_in(r,supreg) then
  1551. begin
  1552. { add/update info on this register }
  1553. regs[tmpindex].mustbespilled := true;
  1554. case operation of
  1555. operand_read:
  1556. regs[tmpindex].regread := true;
  1557. operand_write:
  1558. regs[tmpindex].regwritten := true;
  1559. operand_readwrite:
  1560. begin
  1561. regs[tmpindex].regread := true;
  1562. regs[tmpindex].regwritten := true;
  1563. end;
  1564. end;
  1565. spilled := true;
  1566. end;
  1567. inc(regindex,ord(regindex=tmpindex));
  1568. end;
  1569. procedure tryreplacereg(var reg: tregister);
  1570. var
  1571. i: longint;
  1572. supreg: tsuperregister;
  1573. begin
  1574. supreg:=getsupreg(reg);
  1575. for i:=0 to pred(regindex) do
  1576. if (regs[i].mustbespilled) and
  1577. (regs[i].orgreg=supreg) then
  1578. begin
  1579. { Only replace supreg }
  1580. setsupreg(reg,getsupreg(regs[i].tempreg));
  1581. break;
  1582. end;
  1583. end;
  1584. var
  1585. loadpos,
  1586. storepos : tai;
  1587. oldlive_registers : tsuperregisterworklist;
  1588. begin
  1589. result := false;
  1590. fillchar(regs,sizeof(regs),0);
  1591. for counter := low(regs) to high(regs) do
  1592. regs[counter].orgreg := RS_INVALID;
  1593. spilled := false;
  1594. regindex := 0;
  1595. { check whether and if so which and how (read/written) this instructions contains
  1596. registers that must be spilled }
  1597. for counter := 0 to instr.ops-1 do
  1598. with instr.oper[counter]^ do
  1599. begin
  1600. case typ of
  1601. top_reg:
  1602. begin
  1603. if (getregtype(reg) = regtype) then
  1604. addreginfo(reg,instr.spilling_get_operation_type(counter));
  1605. end;
  1606. top_ref:
  1607. begin
  1608. if regtype in [R_INTREGISTER,R_ADDRESSREGISTER] then
  1609. with ref^ do
  1610. begin
  1611. if (base <> NR_NO) then
  1612. addreginfo(base,operand_read);
  1613. if (index <> NR_NO) then
  1614. addreginfo(index,operand_read);
  1615. end;
  1616. end;
  1617. {$ifdef ARM}
  1618. top_shifterop:
  1619. begin
  1620. if shifterop^.rs<>NR_NO then
  1621. addreginfo(shifterop^.rs,operand_read);
  1622. end;
  1623. {$endif ARM}
  1624. end;
  1625. end;
  1626. { if no spilling for this instruction we can leave }
  1627. if not spilled then
  1628. exit;
  1629. {$ifdef x86}
  1630. { Try replacing the register with the spilltemp. This is usefull only
  1631. for the i386,x86_64 that support memory locations for several instructions }
  1632. for counter := 0 to pred(regindex) do
  1633. with regs[counter] do
  1634. begin
  1635. if mustbespilled then
  1636. begin
  1637. if do_spill_replace(list,instr,orgreg,spilltemplist[orgreg]) then
  1638. mustbespilled:=false;
  1639. end;
  1640. end;
  1641. {$endif x86}
  1642. {
  1643. There are registers that need are spilled. We generate the
  1644. following code for it. The used positions where code need
  1645. to be inserted are marked using #. Note that code is always inserted
  1646. before the positions using pos.previous. This way the position is always
  1647. the same since pos doesn't change, but pos.previous is modified everytime
  1648. new code is inserted.
  1649. [
  1650. - reg_allocs load spills
  1651. - load spills
  1652. ]
  1653. [#loadpos
  1654. - reg_deallocs
  1655. - reg_allocs
  1656. ]
  1657. [
  1658. - reg_deallocs for load-only spills
  1659. - reg_allocs for store-only spills
  1660. ]
  1661. [#instr
  1662. - original instruction
  1663. ]
  1664. [
  1665. - store spills
  1666. - reg_deallocs store spills
  1667. ]
  1668. [#storepos
  1669. ]
  1670. }
  1671. result := true;
  1672. oldlive_registers.copyfrom(live_registers);
  1673. { Process all tai_regallocs belonging to this instruction. All
  1674. released registers are also added to the live_registers because
  1675. they can't be used during the spilling }
  1676. loadpos:=tai(instr.previous);
  1677. while assigned(loadpos) and
  1678. (loadpos.typ=ait_regalloc) and
  1679. (tai_regalloc(loadpos).instr=instr) do
  1680. begin
  1681. if tai_regalloc(loadpos).ratype=ra_dealloc then
  1682. live_registers.add(getsupreg(tai_regalloc(loadpos).reg));
  1683. loadpos:=tai(loadpos.previous);
  1684. end;
  1685. loadpos:=tai(loadpos.next);
  1686. { Load the spilled registers }
  1687. for counter := 0 to pred(regindex) do
  1688. with regs[counter] do
  1689. begin
  1690. if mustbespilled and regread then
  1691. begin
  1692. tempreg:=getregisterinline(list,get_spill_subreg(regs[counter].spillreg));
  1693. do_spill_read(list,tai(loadpos.previous),spilltemplist[orgreg],tempreg);
  1694. end;
  1695. end;
  1696. { Release temp registers of read-only registers, and add reference of the instruction
  1697. to the reginfo }
  1698. for counter := 0 to pred(regindex) do
  1699. with regs[counter] do
  1700. begin
  1701. if mustbespilled and regread and (not regwritten) then
  1702. begin
  1703. { The original instruction will be the next that uses this register }
  1704. add_reg_instruction(instr,tempreg);
  1705. ungetregisterinline(list,tempreg);
  1706. end;
  1707. end;
  1708. { Allocate temp registers of write-only registers, and add reference of the instruction
  1709. to the reginfo }
  1710. for counter := 0 to pred(regindex) do
  1711. with regs[counter] do
  1712. begin
  1713. if mustbespilled and regwritten then
  1714. begin
  1715. { When the register is also loaded there is already a register assigned }
  1716. if (not regread) then
  1717. tempreg:=getregisterinline(list,get_spill_subreg(regs[counter].spillreg));
  1718. { The original instruction will be the next that uses this register, this
  1719. also needs to be done for read-write registers }
  1720. add_reg_instruction(instr,tempreg);
  1721. end;
  1722. end;
  1723. { store the spilled registers }
  1724. storepos:=tai(instr.next);
  1725. for counter := 0 to pred(regindex) do
  1726. with regs[counter] do
  1727. begin
  1728. if mustbespilled and regwritten then
  1729. begin
  1730. do_spill_written(list,tai(storepos.previous),spilltemplist[orgreg],tempreg);
  1731. ungetregisterinline(list,tempreg);
  1732. end;
  1733. end;
  1734. { now all spilling code is generated we can restore the live registers. This
  1735. must be done after the store because the store can need an extra register
  1736. that also needs to conflict with the registers of the instruction }
  1737. live_registers.done;
  1738. live_registers:=oldlive_registers;
  1739. { substitute registers }
  1740. for counter:=0 to instr.ops-1 do
  1741. with instr.oper[counter]^ do
  1742. begin
  1743. case typ of
  1744. top_reg:
  1745. begin
  1746. if (getregtype(reg) = regtype) then
  1747. tryreplacereg(reg);
  1748. end;
  1749. top_ref:
  1750. begin
  1751. if regtype in [R_INTREGISTER,R_ADDRESSREGISTER] then
  1752. begin
  1753. tryreplacereg(ref^.base);
  1754. tryreplacereg(ref^.index);
  1755. end;
  1756. end;
  1757. {$ifdef ARM}
  1758. top_shifterop:
  1759. begin
  1760. tryreplacereg(shifterop^.rs);
  1761. end;
  1762. {$endif ARM}
  1763. end;
  1764. end;
  1765. end;
  1766. end.
  1767. {
  1768. $Log$
  1769. Revision 1.143 2004-10-15 09:14:17 mazen
  1770. - remove $IFDEF DELPHI and related code
  1771. - remove $IFDEF FPCPROCVAR and related code
  1772. Revision 1.142 2004/10/13 21:12:51 peter
  1773. * -Or fixes for open array
  1774. Revision 1.141 2004/10/11 15:47:03 peter
  1775. * removed warning about register used only once
  1776. Revision 1.140 2004/10/06 20:14:08 peter
  1777. * live_registers must be restored after the spilling store code
  1778. is generate to add correct conflicts for extra temporary registers
  1779. Revision 1.139 2004/10/05 20:41:01 peter
  1780. * more spilling rewrites
  1781. Revision 1.138 2004/10/04 20:46:22 peter
  1782. * spilling code rewritten for x86. It now used the generic
  1783. spilling routines. Special x86 optimization still needs
  1784. to be added.
  1785. * Spilling fixed when both operands needed to be spilled
  1786. * Cleanup of spilling routine, do_spill_readwritten removed
  1787. Revision 1.137 2004/09/26 17:45:30 peter
  1788. * simple regvar support, not yet finished
  1789. Revision 1.136 2004/09/25 14:23:54 peter
  1790. * ungetregister is now only used for cpuregisters, renamed to
  1791. ungetcpuregister
  1792. * renamed (get|unget)explicitregister(s) to ..cpuregister
  1793. * removed location-release/reference_release
  1794. Revision 1.135 2004/09/21 17:25:12 peter
  1795. * paraloc branch merged
  1796. Revision 1.134.4.2 2004/09/21 17:03:26 peter
  1797. * Include aliases of coalesce registers when adding conflicts
  1798. Revision 1.134.4.1 2004/09/12 13:36:40 peter
  1799. * fixed alignment issues
  1800. Revision 1.134 2004/08/24 21:02:32 florian
  1801. * fixed longbool(<int64>) on sparc
  1802. Revision 1.133 2004/07/09 21:38:30 daniel
  1803. * Add check <= 255 when adding to adj_colours
  1804. Revision 1.132 2004/07/08 09:57:55 daniel
  1805. * Use a normal pascal set in assign_colours, since it only will contain
  1806. real registers
  1807. Revision 1.131 2004/07/07 17:35:26 daniel
  1808. * supregset_reset clears 8kb of memory. However, it is being called in
  1809. inner loops, see for example colour_registers. According to profile data
  1810. this causes fillchar to be the most time consuming procedure.
  1811. Some modifications done to make it clear less than 8kb of memory each
  1812. call. Divides time spent in fillchar by two, but it still is the no.1
  1813. procedure.
  1814. Revision 1.130 2004/06/22 18:24:18 florian
  1815. * fixed arm compilation
  1816. Revision 1.129 2004/06/20 08:55:30 florian
  1817. * logs truncated
  1818. Revision 1.128 2004/06/20 08:47:33 florian
  1819. * spilling of doubles on sparc fixed
  1820. Revision 1.127 2004/06/16 20:07:09 florian
  1821. * dwarf branch merged
  1822. Revision 1.126 2004/05/22 23:34:28 peter
  1823. tai_regalloc.allocation changed to ratype to notify rgobj of register size changes
  1824. Revision 1.125 2004/04/26 19:57:50 jonas
  1825. * do not remove "allocation,deallocation" pairs, as those are important
  1826. for the optimizer
  1827. Revision 1.124.2.3 2004/06/13 10:51:16 florian
  1828. * fixed several register allocator problems (sparc/arm)
  1829. }