rgcpu.pas 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. This unit implements the LoongArch64 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; orgsupreg: tsuperregister); override;
  29. procedure do_spill_written(list: TAsmList; pos: tai; const spilltemp: treference; tempreg: tregister; orgsupreg: tsuperregister); override;
  30. end;
  31. trgintcpu = class(trgcpu)
  32. end;
  33. implementation
  34. uses
  35. verbose, cutils,globtype,
  36. cgobj,
  37. procinfo;
  38. procedure trgcpu.do_spill_read(list: TAsmList; pos: tai; const spilltemp: treference; tempreg: tregister; orgsupreg: tsuperregister);
  39. var
  40. tmpref : treference;
  41. helplist : TAsmList;
  42. hreg : tregister;
  43. helpins: Taicpu;
  44. begin
  45. if not is_simm12(spilltemp.offset) then
  46. begin
  47. helplist:=tasmlist.create;
  48. if getregtype(tempreg)=R_INTREGISTER then
  49. hreg:=tempreg
  50. else
  51. hreg:=cg.getintregister(helplist,OS_ADDR);
  52. helplist.concat(taicpu.op_reg_const(A_LI_D,hreg,spilltemp.offset));
  53. helplist.concat(taicpu.op_reg_reg_reg(A_ADD_D,hreg,hreg,spilltemp.base));
  54. reference_reset_base(tmpref,hreg,0,ctempposinvalid,sizeof(aint),[]);
  55. helpins:=spilling_create_load(tmpref,tempreg);
  56. helplist.concat(helpins);
  57. list.insertlistafter(pos,helplist);
  58. helplist.free;
  59. end
  60. else
  61. inherited;
  62. end;
  63. procedure trgcpu.do_spill_written(list: TAsmList; pos: tai; const spilltemp: treference; tempreg: tregister; orgsupreg: tsuperregister);
  64. var
  65. tmpref : treference;
  66. helplist : tasmlist;
  67. hreg : tregister;
  68. begin
  69. if not is_simm12(spilltemp.offset) then
  70. begin
  71. helplist:=tasmlist.create;
  72. if getregtype(tempreg)=R_INTREGISTER then
  73. hreg:=getregisterinline(helplist,[R_SUBWHOLE])
  74. else
  75. hreg:=cg.getintregister(helplist,OS_ADDR);
  76. helplist.concat(taicpu.op_reg_const(A_LI_D,hreg,spilltemp.offset));
  77. helplist.concat(taicpu.op_reg_reg_reg(A_ADD_D,hreg,hreg,spilltemp.base));
  78. reference_reset_base(tmpref,hreg,0,ctempposinvalid,sizeof(aint),[]);
  79. helplist.concat(spilling_create_store(tempreg,tmpref));
  80. if getregtype(tempreg)=R_INTREGISTER then
  81. ungetregisterinline(helplist,hreg);
  82. list.insertlistafter(pos,helplist);
  83. helplist.free;
  84. end
  85. else
  86. inherited;
  87. end;
  88. end.