rgcpu.pas 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. cginfo,cgbase,aasmbase,rgobj;
  28. type
  29. trgcpu=class(trgobj)
  30. function GetRegisterFpu(list:TAasmOutput;size:Tcgsize):TRegister;override;
  31. function GetExplicitRegisterInt(list:taasmoutput;Reg:Tnewregister):tregister;override;
  32. procedure UngetregisterInt(list:taasmoutput;Reg:tregister);override;
  33. end;
  34. implementation
  35. uses
  36. cgobj,verbose;
  37. function TRgCpu.GetRegisterFpu(list:TAasmOutput;size:Tcgsize):TRegister;
  38. var
  39. i: Toldregister;
  40. r: Tregister;
  41. begin
  42. for i:=firstsavefpureg to lastsavefpureg do
  43. begin
  44. if (i in unusedregsfpu) and
  45. (
  46. (size=OS_F32) or
  47. (not odd(ord(i)-ord(R_F0)))
  48. ) then
  49. begin
  50. exclude(unusedregsfpu,i);
  51. include(usedinproc,i);
  52. include(usedbyproc,i);
  53. dec(countunusedregsfpu);
  54. r.enum:=i;
  55. list.concat(tai_regalloc.alloc(r));
  56. result := r;
  57. exit;
  58. end;
  59. end;
  60. internalerror(10);
  61. end;
  62. function TRgCpu.GetExplicitRegisterInt(list:TAasmOutput;reg:TNewRegister):TRegister;
  63. var
  64. r:TRegister;
  65. begin
  66. if (reg=NR_O7) or (reg=NR_I7) then
  67. begin
  68. r.enum:=R_INTREGISTER;
  69. r.number:=reg;
  70. cg.a_reg_alloc(list,r);
  71. result:=r;
  72. end
  73. else
  74. result:=inherited GetExplicitRegisterInt(list,reg);
  75. end;
  76. procedure trgcpu.UngetRegisterInt(list:taasmoutput;reg:tregister);
  77. begin
  78. if reg.enum<>R_INTREGISTER then
  79. internalerror(200302191);
  80. if (reg.number=RS_O7) or (reg.number=NR_I7) then
  81. cg.a_reg_dealloc(list,reg)
  82. else
  83. inherited ungetregisterint(list,reg);
  84. end;
  85. begin
  86. rg := trgcpu.create(24); {24 registers.}
  87. end.
  88. {
  89. $Log$
  90. Revision 1.11 2003-06-01 21:38:07 peter
  91. * getregisterfpu size parameter added
  92. * op_const_reg size parameter added
  93. * sparc updates
  94. Revision 1.10 2003/05/31 01:00:51 peter
  95. * register fixes
  96. Revision 1.9 2003/04/22 10:09:35 daniel
  97. + Implemented the actual register allocator
  98. + Scratch registers unavailable when new register allocator used
  99. + maybe_save/maybe_restore unavailable when new register allocator used
  100. Revision 1.8 2003/03/15 22:51:58 mazen
  101. * remaking sparc rtl compile
  102. Revision 1.7 2003/03/10 21:59:54 mazen
  103. * fixing index overflow in handling new registers arrays.
  104. Revision 1.6 2003/02/19 22:00:17 daniel
  105. * Code generator converted to new register notation
  106. - Horribily outdated todo.txt removed
  107. Revision 1.5 2003/01/08 18:43:58 daniel
  108. * Tregister changed into a record
  109. Revision 1.4 2002/10/13 21:46:07 mazen
  110. * assembler output format fixed
  111. Revision 1.3 2002/10/12 19:03:23 mazen
  112. * Get/Unget expilit registers to be re-examined
  113. }