rgcpu.pas 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This unit implements the SPARC 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. unit rgcpu;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. cpubase,
  23. cpuinfo,
  24. aasmcpu,
  25. aasmtai,
  26. cclasses,globtype,
  27. cgbase,aasmbase,rgobj;
  28. type
  29. trgcpu=class(trgobj)
  30. function GetRegisterFpu(list:TAasmOutput;size:Tcgsize):TRegister;override;
  31. procedure UngetRegisterFpu(list:taasmoutput;reg:tregister;size:TCGsize);override;
  32. end;
  33. implementation
  34. uses
  35. cgobj,verbose;
  36. function TRgCpu.GetRegisterFpu(list:TAasmOutput;size:Tcgsize):TRegister;
  37. var
  38. i: Tsuperregister;
  39. r: Tregister;
  40. begin
  41. for i:=firstsavefpureg to lastsavefpureg do
  42. begin
  43. if (i in unusedregsfpu) and
  44. (
  45. (size=OS_F32) or
  46. (not odd(i-RS_F0))
  47. ) then
  48. begin
  49. exclude(unusedregsfpu,i);
  50. dec(countunusedregsfpu);
  51. r:=newreg(R_FPUREGISTER,i,R_SUBNONE);
  52. list.concat(tai_regalloc.alloc(r));
  53. result := r;
  54. { double need 2 FPU registers }
  55. if size=OS_F64 then
  56. begin
  57. r:=newreg(R_FPUREGISTER,i+1,R_SUBNONE);
  58. exclude(unusedregsfpu,i+1);
  59. dec(countunusedregsfpu);
  60. list.concat(tai_regalloc.alloc(r));
  61. end;
  62. exit;
  63. end;
  64. end;
  65. internalerror(10);
  66. end;
  67. procedure trgcpu.UngetRegisterFpu(list:taasmoutput;reg:tregister;size:TCGsize);
  68. var
  69. r : tregister;
  70. supreg : tsuperregister;
  71. begin
  72. supreg:=getsupreg(reg);
  73. { double need 2 FPU registers }
  74. if (size=OS_F64) then
  75. begin
  76. { Only even FP registers are allowed }
  77. if odd(supreg-RS_F0) then
  78. internalerror(200306101);
  79. r:=newreg(R_FPUREGISTER,supreg+1,R_SUBNONE);
  80. inc(countunusedregsfpu);
  81. include(unusedregsfpu,getsupreg(r));
  82. list.concat(tai_regalloc.dealloc(r));
  83. end;
  84. inc(countunusedregsfpu);
  85. include(unusedregsfpu,supreg);
  86. list.concat(tai_regalloc.dealloc(reg));
  87. end;
  88. end.
  89. {
  90. $Log$
  91. Revision 1.19 2003-10-01 20:34:50 peter
  92. * procinfo unit contains tprocinfo
  93. * cginfo renamed to cgbase
  94. * moved cgmessage to verbose
  95. * fixed ppc and sparc compiles
  96. Revision 1.18 2003/09/14 19:19:05 peter
  97. * updates for new ra
  98. Revision 1.17 2003/09/03 15:55:01 peter
  99. * NEWRA branch merged
  100. Revision 1.16.2.2 2003/09/02 17:49:17 peter
  101. * newra updates
  102. Revision 1.16.2.1 2003/09/01 21:02:55 peter
  103. * sparc updates for new tregister
  104. Revision 1.16 2003/08/11 21:18:20 peter
  105. * start of sparc support for newra
  106. Revision 1.15 2003/07/02 22:18:04 peter
  107. * paraloc splitted in callerparaloc,calleeparaloc
  108. * sparc calling convention updates
  109. Revision 1.14 2003/06/17 16:36:11 peter
  110. * freeintparaloc added
  111. Revision 1.13 2003/06/12 22:47:52 mazen
  112. - unused temp var r removed in GetExplicitRegisterInt function
  113. * some case added for var and fauncions naming
  114. Revision 1.12 2003/06/12 21:11:44 peter
  115. * updates like the powerpc
  116. Revision 1.11 2003/06/01 21:38:07 peter
  117. * getregisterfpu size parameter added
  118. * op_const_reg size parameter added
  119. * sparc updates
  120. Revision 1.10 2003/05/31 01:00:51 peter
  121. * register fixes
  122. Revision 1.9 2003/04/22 10:09:35 daniel
  123. + Implemented the actual register allocator
  124. + Scratch registers unavailable when new register allocator used
  125. + maybe_save/maybe_restore unavailable when new register allocator used
  126. Revision 1.8 2003/03/15 22:51:58 mazen
  127. * remaking sparc rtl compile
  128. Revision 1.7 2003/03/10 21:59:54 mazen
  129. * fixing index overflow in handling new registers arrays.
  130. Revision 1.6 2003/02/19 22:00:17 daniel
  131. * Code generator converted to new register notation
  132. - Horribily outdated todo.txt removed
  133. Revision 1.5 2003/01/08 18:43:58 daniel
  134. * Tregister changed into a record
  135. Revision 1.4 2002/10/13 21:46:07 mazen
  136. * assembler output format fixed
  137. Revision 1.3 2002/10/12 19:03:23 mazen
  138. * Get/Unget expilit registers to be re-examined
  139. }