rgcpu.pas 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. This unit implements the i386 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. cpubase,
  23. cpuinfo,
  24. aasmbase,aasmtai,aasmdata,
  25. cclasses,globtype,cgbase,rgobj,rgx86;
  26. type
  27. trgcpu = class(trgx86)
  28. procedure add_constraints(reg:Tregister);override;
  29. end;
  30. trgintcpu = class(trgcpu)
  31. procedure add_cpu_interferences(p : tai);override;
  32. end;
  33. implementation
  34. uses
  35. systems,
  36. verbose,
  37. aasmcpu,
  38. cgutils;
  39. const
  40. { This value is used in tsaved. If the array value is equal
  41. to this, then this means that this register is not used.}
  42. reg_not_saved = $7fffffff;
  43. {************************************************************************
  44. trgcpu
  45. *************************************************************************}
  46. procedure trgcpu.add_constraints(reg:Tregister);
  47. var
  48. supreg : tsuperregister;
  49. begin
  50. if getsubreg(reg) in [R_SUBL,R_SUBH] then
  51. begin
  52. { Some registers have no 8-bit subregister }
  53. supreg:=getsupreg(reg);
  54. add_edge(supreg,RS_SI);
  55. add_edge(supreg,RS_DI);
  56. add_edge(supreg,RS_BP);
  57. end;
  58. end;
  59. procedure trgintcpu.add_cpu_interferences(p : tai);
  60. var
  61. href : treference;
  62. i : integer;
  63. begin
  64. if p.typ=ait_instruction then
  65. begin
  66. for i:=0 to taicpu(p).ops-1 do
  67. begin
  68. if taicpu(p).oper[i]^.typ=top_ref then
  69. begin
  70. href:=taicpu(p).oper[i]^.ref^;
  71. if (href.base<>NR_NO) and (getsupreg(href.base)>=first_int_imreg) then
  72. begin
  73. add_edge(getsupreg(href.base),RS_AX);
  74. add_edge(getsupreg(href.base),RS_CX);
  75. add_edge(getsupreg(href.base),RS_DX);
  76. add_edge(getsupreg(href.base),RS_SI);
  77. add_edge(getsupreg(href.base),RS_DI);
  78. end;
  79. if (href.index<>NR_NO) and (getsupreg(href.index)>=first_int_imreg) then
  80. begin
  81. add_edge(getsupreg(href.index),RS_AX);
  82. add_edge(getsupreg(href.index),RS_BX);
  83. add_edge(getsupreg(href.index),RS_CX);
  84. add_edge(getsupreg(href.index),RS_DX);
  85. add_edge(getsupreg(href.index),RS_BP);
  86. end;
  87. end;
  88. end;
  89. end;
  90. end;
  91. end.