rgcpu.pas 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. {******************************************************************************
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************}
  16. unit rgcpu;
  17. { This unit implements the processor specific class for the register allocator}
  18. {$INCLUDE fpcdefs.inc}
  19. interface
  20. uses
  21. cpubase,
  22. cpuinfo,
  23. aasmcpu,
  24. aasmtai,
  25. cclasses,globtype,cgbase,aasmbase,rgobj;
  26. type
  27. {This class implements the cpu spaecific register allocator. It is used by the
  28. code generator to allocate and free registers which might be valid across
  29. nodes. It also contains utility routines related to registers. Some of the
  30. methods in this class overrides generic implementations in rgobj.pas.}
  31. trgcpu=class(trgobj)
  32. function GetExplicitRegisterInt(list:taasmoutput;Reg:Tnewregister):tregister;override;
  33. procedure UngetregisterInt(list:taasmoutput;Reg:tregister);override;
  34. end;
  35. implementation
  36. uses
  37. cgobj,verbose;
  38. function TRgCpu.GetExplicitRegisterInt(list:TAasmOutput;reg:TNewRegister):TRegister;
  39. var
  40. r:TRegister;
  41. begin
  42. if(reg=NR_O7)or(reg=NR_I7)
  43. then
  44. begin
  45. r.enum:=R_INTREGISTER;
  46. r.number:=reg;
  47. cg.a_reg_alloc(list,r);
  48. result:=r;
  49. end
  50. else
  51. result:=inherited GetExplicitRegisterInt(list,reg);
  52. end;
  53. procedure trgcpu.UngetRegisterInt(list:taasmoutput;reg:tregister);
  54. begin
  55. if reg.enum<>R_INTREGISTER
  56. then
  57. internalerror(200302191);
  58. if (reg.number=RS_O7) or (reg.number=NR_I7)
  59. then
  60. cg.a_reg_dealloc(list,reg)
  61. else
  62. inherited ungetregisterint(list,reg);
  63. end;
  64. begin
  65. rg := trgcpu.create(24); {24 registers.}
  66. end.
  67. {
  68. $Log$
  69. Revision 1.10 2003-05-31 01:00:51 peter
  70. * register fixes
  71. Revision 1.9 2003/04/22 10:09:35 daniel
  72. + Implemented the actual register allocator
  73. + Scratch registers unavailable when new register allocator used
  74. + maybe_save/maybe_restore unavailable when new register allocator used
  75. Revision 1.8 2003/03/15 22:51:58 mazen
  76. * remaking sparc rtl compile
  77. Revision 1.7 2003/03/10 21:59:54 mazen
  78. * fixing index overflow in handling new registers arrays.
  79. Revision 1.6 2003/02/19 22:00:17 daniel
  80. * Code generator converted to new register notation
  81. - Horribily outdated todo.txt removed
  82. Revision 1.5 2003/01/08 18:43:58 daniel
  83. * Tregister changed into a record
  84. Revision 1.4 2002/10/13 21:46:07 mazen
  85. * assembler output format fixed
  86. Revision 1.3 2002/10/12 19:03:23 mazen
  87. * Get/Unget expilit registers to be re-examined
  88. }