aoptcpub.pas 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. {
  2. Copyright (c) 1998-2002 by Jonas Maebe, member of the Free Pascal
  3. Development Team
  4. This unit contains several types and constants necessary for the
  5. optimizer to work on the ARM architecture
  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. }
  19. Unit aoptcpub; { Assembler OPTimizer CPU specific Base }
  20. {$i fpcdefs.inc}
  21. { enable the following define if memory references can have a scaled index }
  22. { define RefsHaveScale}
  23. { enable the following define if memory references can have a segment }
  24. { override }
  25. { define RefsHaveSegment}
  26. Interface
  27. Uses
  28. cpubase,
  29. cgbase,
  30. aasmcpu,aasmtai,
  31. AOptBase;
  32. Type
  33. { type of a normal instruction }
  34. TInstr = Taicpu;
  35. PInstr = ^TInstr;
  36. { ************************************************************************* }
  37. { **************************** TCondRegs ********************************** }
  38. { ************************************************************************* }
  39. { Info about the conditional registers }
  40. TCondRegs = Object
  41. Constructor Init;
  42. Destructor Done;
  43. End;
  44. { ************************************************************************* }
  45. { **************************** TAoptBaseCpu ******************************* }
  46. { ************************************************************************* }
  47. TAoptBaseCpu = class(TAoptBase)
  48. function RegModifiedByInstruction(Reg: TRegister; p1: tai): boolean; override;
  49. End;
  50. { ************************************************************************* }
  51. { ******************************* Constants ******************************* }
  52. { ************************************************************************* }
  53. Const
  54. { the maximum number of things (registers, memory, ...) a single instruction }
  55. { changes }
  56. MaxCh = 2;
  57. {Oper index of operand that contains the source (reference) with a load }
  58. {instruction }
  59. LoadSrc = 1;
  60. {Oper index of operand that contains the destination (register) with a load }
  61. {instruction }
  62. LoadDst = 0;
  63. {Oper index of operand that contains the source (register) with a store }
  64. {instruction }
  65. StoreSrc = 1;
  66. {Oper index of operand that contains the destination (reference) with a load }
  67. {instruction }
  68. StoreDst = 0;
  69. aopt_uncondjmp = [A_RJMP,A_JMP];
  70. aopt_condjmp = A_BRxx;
  71. Implementation
  72. { ************************************************************************* }
  73. { **************************** TCondRegs ********************************** }
  74. { ************************************************************************* }
  75. Constructor TCondRegs.init;
  76. Begin
  77. End;
  78. Destructor TCondRegs.Done; {$ifdef inl} inline; {$endif inl}
  79. Begin
  80. End;
  81. function TAoptBaseCpu.RegModifiedByInstruction(Reg: TRegister; p1: tai): boolean;
  82. var
  83. i : Longint;
  84. begin
  85. result:=false;
  86. If (p1.typ = ait_instruction) and (taicpu(p1).opcode in [A_MUL,A_MULS,A_FMUL,A_FMULS,A_FMULSU]) and
  87. ((getsupreg(reg)=RS_R0) or (getsupreg(reg)=RS_R1)) then
  88. begin
  89. Result:=true;
  90. exit;
  91. end;
  92. for i:=0 to taicpu(p1).ops-1 do
  93. if (taicpu(p1).oper[i]^.typ=top_reg) and (taicpu(p1).oper[i]^.reg=Reg) and (taicpu(p1).spilling_get_operation_type(i) in [operand_write,operand_readwrite]) then
  94. begin
  95. result:=true;
  96. exit;
  97. end;
  98. end;
  99. End.