rgcpu.pas 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. aasmbase,aasmcpu,aasmtai,
  23. cgbase,cgutils,
  24. cpubase,
  25. rgobj;
  26. type
  27. trgcpu=class(trgobj)
  28. procedure add_constraints(reg:tregister);override;
  29. function get_spill_subreg(r : tregister) : tsubregister;override;
  30. procedure do_spill_read(list:Taasmoutput;pos:tai;const spilltemp:treference;tempreg:tregister);override;
  31. procedure do_spill_written(list:Taasmoutput;pos:tai;const spilltemp:treference;tempreg:tregister);override;
  32. end;
  33. implementation
  34. uses
  35. verbose,cutils,
  36. cgobj;
  37. procedure trgcpu.add_constraints(reg:tregister);
  38. var
  39. supreg,i : Tsuperregister;
  40. begin
  41. case getsubreg(reg) of
  42. { Let 64bit floats conflict with all odd float regs }
  43. R_SUBFD:
  44. begin
  45. supreg:=getsupreg(reg);
  46. i:=RS_F1;
  47. while (i<=RS_F31) do
  48. begin
  49. add_edge(supreg,i);
  50. inc(i,2);
  51. end;
  52. end;
  53. { Let 64bit ints conflict with all odd int regs }
  54. R_SUBQ:
  55. begin
  56. supreg:=getsupreg(reg);
  57. i:=RS_G1;
  58. while (i<=RS_I7) do
  59. begin
  60. add_edge(supreg,i);
  61. inc(i,2);
  62. end;
  63. end;
  64. end;
  65. end;
  66. function trgcpu.get_spill_subreg(r : tregister) : tsubregister;
  67. begin
  68. if getregtype(r)=R_FPUREGISTER then
  69. result:=getsubreg(r)
  70. else
  71. result:=defaultsub;
  72. end;
  73. procedure trgcpu.do_spill_read(list:Taasmoutput;pos:tai;const spilltemp:treference;tempreg:tregister);
  74. var
  75. helpins : tai;
  76. tmpref : treference;
  77. helplist : taasmoutput;
  78. hreg : tregister;
  79. begin
  80. if abs(spilltemp.offset)>4095 then
  81. begin
  82. helplist:=taasmoutput.create;
  83. if getregtype(tempreg)=R_INTREGISTER then
  84. hreg:=tempreg
  85. else
  86. hreg:=cg.getintregister(helplist,OS_ADDR);
  87. reference_reset(tmpref);
  88. tmpref.offset:=spilltemp.offset;
  89. tmpref.refaddr:=addr_hi;
  90. helplist.concat(taicpu.op_ref_reg(A_SETHI,tmpref,hreg));
  91. tmpref.refaddr:=addr_lo;
  92. helplist.concat(taicpu.op_reg_ref_reg(A_OR,hreg,tmpref,hreg));
  93. reference_reset_base(tmpref,hreg,0);
  94. tmpref.index:=spilltemp.base;
  95. helpins:=spilling_create_load(tmpref,tempreg);
  96. helplist.concat(helpins);
  97. list.insertlistafter(pos,helplist)
  98. end
  99. else
  100. inherited do_spill_read(list,pos,spilltemp,tempreg);
  101. end;
  102. procedure trgcpu.do_spill_written(list:Taasmoutput;pos:tai;const spilltemp:treference;tempreg:tregister);
  103. var
  104. helpins : tai;
  105. tmpref : treference;
  106. helplist : taasmoutput;
  107. hreg : tregister;
  108. begin
  109. if abs(spilltemp.offset)>4095 then
  110. begin
  111. helplist:=taasmoutput.create;
  112. if getregtype(tempreg)=R_INTREGISTER then
  113. hreg:=getregisterinline(helplist,R_SUBWHOLE)
  114. else
  115. hreg:=cg.getintregister(helplist,OS_ADDR);
  116. reference_reset(tmpref);
  117. tmpref.offset:=spilltemp.offset;
  118. tmpref.refaddr:=addr_hi;
  119. helplist.concat(taicpu.op_ref_reg(A_SETHI,tmpref,hreg));
  120. tmpref.refaddr:=addr_lo;
  121. helplist.concat(taicpu.op_reg_ref_reg(A_OR,hreg,tmpref,hreg));
  122. reference_reset_base(tmpref,hreg,0);
  123. tmpref.index:=spilltemp.base;
  124. helpins:=spilling_create_store(tempreg,tmpref);
  125. helplist.concat(helpins);
  126. if getregtype(tempreg)=R_INTREGISTER then
  127. ungetregisterinline(helplist,hreg);
  128. list.insertlistafter(pos,helplist)
  129. end
  130. else
  131. inherited do_spill_written(list,pos,spilltemp,tempreg);
  132. end;
  133. end.
  134. {
  135. $Log$
  136. Revision 1.32 2005-02-14 17:13:10 peter
  137. * truncate log
  138. }