2
0

rgcpu.pas 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This unit implements the powerpc specific class for the register
  5. allocator
  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 rgcpu;
  20. {$i fpcdefs.inc}
  21. interface
  22. uses
  23. aasmbase,aasmtai,
  24. cpubase,
  25. rgobj;
  26. type
  27. trgcpu = class(trgobj)
  28. {
  29. function getexplicitregisterint(list: taasmoutput; reg: Tnewregister): tregister; override;
  30. procedure ungetregisterint(list: taasmoutput; reg: tregister); override;
  31. function getexplicitregisterfpu(list : taasmoutput; r : Toldregister) : tregister;override;
  32. procedure ungetregisterfpu(list: taasmoutput; r : tregister; size:TCGsize);override;
  33. procedure cleartempgen; override;
  34. private
  35. usedpararegs: Tsupregset;
  36. usedparafpuregs: tregisterset;
  37. }
  38. end;
  39. implementation
  40. uses
  41. cgobj, verbose, cutils;
  42. (*
  43. function trgcpu.getexplicitregisterint(list: taasmoutput; reg: Tnewregister): tregister;
  44. begin
  45. if ((reg shr 8) in [RS_R0]) and
  46. not((reg shr 8) in is_reg_var_int) then
  47. begin
  48. if (reg shr 8) in usedpararegs then
  49. internalerror(2003060701);
  50. { comment(v_warning,'Double allocation of register '+tostr((reg shr 8)-1));}
  51. include(usedpararegs,reg shr 8);
  52. result.enum:=R_INTREGISTER;
  53. result.number:=reg;
  54. cg.a_reg_alloc(list,result);
  55. end
  56. else result := inherited getexplicitregisterint(list,reg);
  57. end;
  58. procedure trgcpu.ungetregisterint(list: taasmoutput; reg: tregister);
  59. begin
  60. if ((reg.number shr 8) in [RS_R0]) and
  61. not((reg.number shr 8) in is_reg_var_int) then
  62. begin
  63. if not((reg.number shr 8) in usedpararegs) then
  64. internalerror(2003060702);
  65. { comment(v_warning,'Double free of register '+tostr((reg.number shr 8)-1));}
  66. exclude(usedpararegs,reg.number shr 8);
  67. cg.a_reg_dealloc(list,reg);
  68. end
  69. else
  70. inherited ungetregisterint(list,reg);
  71. end;
  72. function trgcpu.getexplicitregisterfpu(list : taasmoutput; r : Toldregister) : tregister;
  73. begin
  74. if (r in [R_F1..R_F13]) and
  75. not is_reg_var_other[r] then
  76. begin
  77. if r in usedparafpuregs then
  78. internalerror(2003060902);
  79. include(usedparafpuregs,r);
  80. result.enum := r;
  81. cg.a_reg_alloc(list,result);
  82. end
  83. else
  84. result := inherited getexplicitregisterfpu(list,r);
  85. end;
  86. procedure trgcpu.ungetregisterfpu(list: taasmoutput; r : tregister; size:TCGsize);
  87. begin
  88. if (r.enum in [R_F1..R_F13]) and
  89. not is_reg_var_other[r.enum] then
  90. begin
  91. if not(r.enum in usedparafpuregs) then
  92. internalerror(2003060903);
  93. exclude(usedparafpuregs,r.enum);
  94. cg.a_reg_dealloc(list,r);
  95. end
  96. else
  97. inherited ungetregisterfpu(list,r,size);
  98. end;
  99. procedure trgcpu.cleartempgen;
  100. begin
  101. inherited cleartempgen;
  102. usedpararegs := [];
  103. usedparafpuregs := [];
  104. end;
  105. *)
  106. end.
  107. {
  108. $Log$
  109. Revision 1.16 2003-10-01 20:34:49 peter
  110. * procinfo unit contains tprocinfo
  111. * cginfo renamed to cgbase
  112. * moved cgmessage to verbose
  113. * fixed ppc and sparc compiles
  114. Revision 1.15 2003/09/14 17:27:56 jonas
  115. - removed initialization code
  116. Revision 1.14 2003/09/03 19:35:24 peter
  117. * powerpc compiles again
  118. Revision 1.13 2003/07/06 15:27:44 jonas
  119. * make sure all registers except r0 are handled by the register
  120. allocator for -dnewra
  121. Revision 1.12 2003/06/17 16:34:44 jonas
  122. * lots of newra fixes (need getfuncretparaloc implementation for i386)!
  123. * renamed all_intregisters to volatile_intregisters and made it
  124. processor dependent
  125. Revision 1.11 2003/06/14 22:32:43 jonas
  126. * ppc compiles with -dnewra, haven't tried to compile anything with it
  127. yet though
  128. Revision 1.10 2003/06/12 22:09:54 jonas
  129. * tcginnode.pass_2 doesn't call a helper anymore in any case
  130. * fixed ungetregisterfpu compilation problems
  131. Revision 1.9 2003/06/09 14:54:26 jonas
  132. * (de)allocation of registers for parameters is now performed properly
  133. (and checked on the ppc)
  134. - removed obsolete allocation of all parameter registers at the start
  135. of a procedure (and deallocation at the end)
  136. Revision 1.8 2003/06/07 18:57:04 jonas
  137. + added freeintparaloc
  138. * ppc get/freeintparaloc now check whether the parameter regs are
  139. properly allocated/deallocated (and get an extra list para)
  140. * ppc a_call_* now internalerrors if pi_do_call is not yet set
  141. * fixed lot of missing pi_do_call's
  142. Revision 1.7 2003/05/24 13:38:04 jonas
  143. * don't save callee-save registers in the caller as well (the ppc code
  144. that we generate is slow enough as it is without resorting to doing
  145. double work :)
  146. Revision 1.6 2003/04/22 10:09:35 daniel
  147. + Implemented the actual register allocator
  148. + Scratch registers unavailable when new register allocator used
  149. + maybe_save/maybe_restore unavailable when new register allocator used
  150. Revision 1.5 2003/02/19 22:00:16 daniel
  151. * Code generator converted to new register notation
  152. - Horribily outdated todo.txt removed
  153. Revision 1.4 2003/01/08 18:43:58 daniel
  154. * Tregister changed into a record
  155. Revision 1.3 2002/07/07 09:44:32 florian
  156. * powerpc target fixed, very simple units can be compiled
  157. Revision 1.2 2002/05/16 19:46:53 carl
  158. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  159. + try to fix temp allocation (still in ifdef)
  160. + generic constructor calls
  161. + start of tassembler / tmodulebase class cleanup
  162. Revision 1.1 2002/04/06 18:13:02 jonas
  163. * several powerpc-related additions and fixes
  164. }