2
0

aoptppc.pas 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. {
  2. Copyright (c) 1998-2002 by Jonas Maebe, member of the Free Pascal
  3. Development Team
  4. This unit implements the generic PowerPC optimizer object
  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 aoptppc;
  19. Interface
  20. {$i fpcdefs.inc}
  21. uses cpubase, cgbase, aopt, aasmtai;
  22. Type
  23. TPPCAsmOptimizer = class(TAsmOptimizer)
  24. function RegLoadedWithNewValue(reg : tregister; hp : tai) : boolean; override;
  25. End;
  26. Implementation
  27. uses
  28. cutils, verbose, cgcpu, cgobj, aasmcpu;
  29. function TPPCAsmOptimizer.RegLoadedWithNewValue(reg: tregister; hp: tai): boolean;
  30. var
  31. p: taicpu;
  32. begin
  33. Result := false;
  34. if not(assigned(hp) and (hp.typ = ait_instruction)) then
  35. exit;
  36. p := taicpu(hp);
  37. if not(p.ops > 0) then
  38. exit;
  39. case p.opcode of
  40. A_CMP,
  41. A_CMPI,
  42. A_CMPL,
  43. A_CMPLI:
  44. begin
  45. result:=reg=NR_CR;
  46. exit;
  47. end;
  48. A_STB,
  49. { the register forming the address is modified so no new value is loaded }
  50. A_STBU,
  51. A_STBUX,
  52. A_STBX,
  53. A_STH,
  54. A_STHBRX,
  55. A_STHU,
  56. A_STHUX,
  57. A_STHX,
  58. A_STMW:
  59. exit;
  60. else
  61. ;
  62. end;
  63. case p.oper[0]^.typ of
  64. top_reg:
  65. Result := (p.oper[0]^.reg = reg) ;
  66. else
  67. ;
  68. end;
  69. end;
  70. End.