rgcpu.pas 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. This unit implements the powerpc specific class for the register
  4. allocator
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit rgcpu;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. aasmbase,aasmtai,aasmdata,aasmcpu,
  23. cgbase,cgutils,
  24. cpubase,
  25. rgobj;
  26. type
  27. trgcpu = class(trgobj)
  28. procedure do_spill_read(list:TAsmList;pos:tai;const spilltemp:treference;tempreg:tregister);override;
  29. procedure do_spill_written(list:TAsmList;pos:tai;const spilltemp:treference;tempreg:tregister);override;
  30. end;
  31. implementation
  32. uses
  33. verbose, cutils,
  34. cgobj,
  35. procinfo;
  36. procedure trgcpu.do_spill_read(list:TAsmList;pos:tai;const spilltemp:treference;tempreg:tregister);
  37. var
  38. tmpref : treference;
  39. helplist : TAsmList;
  40. l : tasmlabel;
  41. hreg : tregister;
  42. begin
  43. if (spilltemp.offset<low(smallint)) or
  44. (spilltemp.offset>high(smallint)) then
  45. begin
  46. helplist:=TAsmList.create;
  47. if (spilltemp.index<>NR_NO) then
  48. internalerror(200704201);
  49. if getregtype(tempreg)=R_INTREGISTER then
  50. hreg:=getregisterinline(helplist,R_SUBWHOLE)
  51. else
  52. hreg:=cg.getintregister(helplist,OS_ADDR);
  53. reference_reset(tmpref);
  54. tmpref.offset:=spilltemp.offset;
  55. tmpref.refaddr:=addr_hi;
  56. helplist.concat(taicpu.op_reg_reg_ref(A_ADDIS,hreg,spilltemp.base,tmpref));
  57. tmpref:=spilltemp;
  58. tmpref.refaddr:=addr_lo;
  59. tmpref.base:=hreg;
  60. helplist.concat(spilling_create_load(tmpref,tempreg));
  61. if getregtype(tempreg)=R_INTREGISTER then
  62. ungetregisterinline(helplist,hreg);
  63. list.insertlistafter(pos,helplist);
  64. helplist.free;
  65. end
  66. else
  67. inherited do_spill_read(list,pos,spilltemp,tempreg);
  68. end;
  69. procedure trgcpu.do_spill_written(list:TAsmList;pos:tai;const spilltemp:treference;tempreg:tregister);
  70. var
  71. tmpref : treference;
  72. helplist : TAsmList;
  73. l : tasmlabel;
  74. hreg : tregister;
  75. begin
  76. if (spilltemp.offset<low(smallint)) or
  77. (spilltemp.offset>high(smallint)) then
  78. begin
  79. helplist:=TAsmList.create;
  80. if (spilltemp.index<>NR_NO) then
  81. internalerror(200704201);
  82. if getregtype(tempreg)=R_INTREGISTER then
  83. hreg:=getregisterinline(helplist,R_SUBWHOLE)
  84. else
  85. hreg:=cg.getintregister(helplist,OS_ADDR);
  86. reference_reset(tmpref);
  87. tmpref.offset:=spilltemp.offset;
  88. tmpref.refaddr:=addr_hi;
  89. helplist.concat(taicpu.op_reg_reg_ref(A_ADDIS,hreg,spilltemp.base,tmpref));
  90. tmpref:=spilltemp;
  91. tmpref.refaddr:=addr_lo;
  92. tmpref.base:=hreg;
  93. helplist.concat(spilling_create_store(tempreg,tmpref));
  94. if getregtype(tempreg)=R_INTREGISTER then
  95. ungetregisterinline(helplist,hreg);
  96. list.insertlistafter(pos,helplist);
  97. helplist.free;
  98. end
  99. else
  100. inherited do_spill_written(list,pos,spilltemp,tempreg);
  101. end;
  102. end.