cg64f64.pas 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. {
  2. $Id$
  3. Copyright (c) 2002 by Florian Klaempfl
  4. Member of the Free Pascal development team
  5. This unit implements the code generation for 64 bit int
  6. arithmethics on 64 bit processors
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. ****************************************************************************
  19. }
  20. {# This unit implements the code generation for 64 bit int arithmethics on
  21. 64 bit processors.
  22. }
  23. unit cg64f64;
  24. {$i fpcdefs.inc}
  25. interface
  26. uses
  27. aasmbase,aasmtai,aasmcpu,
  28. cpuinfo, cpubase,
  29. cgbase,cgobj,
  30. symtype;
  31. {$ifndef cpu64bit}
  32. type
  33. {# Defines all the methods required on 32-bit processors
  34. to handle 64-bit integers.
  35. }
  36. tcg64f64 = class(tcg64)
  37. procedure a_reg_alloc(list : taasmoutput;r : tregister64);override;
  38. procedure a_reg_dealloc(list : taasmoutput;r : tregister64);override;
  39. procedure a_load64_const_ref(list : taasmoutput;value : int64;const ref : treference);override;
  40. procedure a_load64_reg_ref(list : taasmoutput;reg : tregister64;const ref : treference);override;
  41. procedure a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64);override;
  42. procedure a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64);override;
  43. procedure a_load64_const_reg(list : taasmoutput;value: int64;reg : tregister64);override;
  44. procedure a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64);override;
  45. procedure a_load64_loc_ref(list : taasmoutput;const l : tlocation;const ref : treference);override;
  46. procedure a_load64_const_loc(list : taasmoutput;value : int64;const l : tlocation);override;
  47. procedure a_load64_reg_loc(list : taasmoutput;reg : tregister64;const l : tlocation);override;
  48. procedure a_load64high_reg_ref(list : taasmoutput;reg : tregister;const ref : treference);override;
  49. procedure a_load64low_reg_ref(list : taasmoutput;reg : tregister;const ref : treference);override;
  50. procedure a_load64high_ref_reg(list : taasmoutput;const ref : treference;reg : tregister);override;
  51. procedure a_load64low_ref_reg(list : taasmoutput;const ref : treference;reg : tregister);override;
  52. procedure a_load64high_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister);override;
  53. procedure a_load64low_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister);override;
  54. procedure a_op64_reg_ref(list : taasmoutput;op:TOpCG;regsrc : tregister64;const ref : treference);override;
  55. procedure a_op64_ref_reg(list : taasmoutput;op:TOpCG;const ref : treference;reg : tregister64);override;
  56. procedure a_op64_const_loc(list : taasmoutput;op:TOpCG;value:int64;const l: tlocation);override;
  57. procedure a_op64_reg_loc(list : taasmoutput;op:TOpCG;reg : tregister64;const l : tlocation);override;
  58. procedure a_op64_loc_reg(list : taasmoutput;op:TOpCG;const l : tlocation;reg : tregister64);override;
  59. procedure a_op64_const_reg(list : taasmoutput;op:TOpCG;value : int64;regdst : tregister64);override;
  60. procedure a_op64_const_ref(list : taasmoutput;op:TOpCG;value : int64;const ref : treference);override;
  61. procedure a_param64_reg(list : taasmoutput;reg : tregister64;const locpara : tparalocation);override;
  62. procedure a_param64_const(list : taasmoutput;value : int64;const locpara : tparalocation);override;
  63. procedure a_param64_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);override;
  64. procedure a_param64_loc(list : taasmoutput;const l : tlocation;const locpara : tparalocation);override;
  65. function optimize64_op_const_reg(list: taasmoutput; var op: topcg; var a : int64; var reg: tregister64): boolean;override;
  66. { override to catch 64bit rangechecks }
  67. procedure g_rangecheck64(list: taasmoutput; const l:tlocation;fromdef,todef: tdef); override;
  68. end;
  69. {$endif cpu64bit}
  70. implementation
  71. uses
  72. verbose;
  73. {$ifndef cpu64bit}
  74. procedure tcg64f64.a_load64_const_ref(list : taasmoutput;value : int64;const ref : treference);
  75. begin
  76. cg.a_load_const_ref(list,OS_64,value,ref);
  77. end;
  78. procedure tcg64f64.a_load64_reg_ref(list : taasmoutput;reg : tregister64;const ref : treference);
  79. begin
  80. cg.a_load_reg_ref(list,OS_64,OS_64,reg,ref);
  81. end;
  82. procedure tcg64f64.a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64);
  83. begin
  84. cg.a_load_ref_reg(list,OS_64,OS_64,ref,reg);
  85. end;
  86. procedure tcg64f64.a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64);
  87. begin
  88. cg.a_load_reg_reg(list,OS_64,OS_64,regsrc,regdst);
  89. end;
  90. procedure tcg64f64.a_load64_const_reg(list : taasmoutput;value : int64;reg : tregister64);
  91. begin
  92. cg.a_load_const_reg(list,OS_64,value,reg);
  93. end;
  94. procedure tcg64f64.a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64);
  95. begin
  96. cg.a_load_loc_reg(list,l.size,l,reg);
  97. end;
  98. procedure tcg64f64.a_load64_loc_ref(list : taasmoutput;const l : tlocation;const ref : treference);
  99. begin
  100. cg.a_load_loc_ref(list,l.size,l,ref);
  101. end;
  102. procedure tcg64f64.a_load64_const_loc(list : taasmoutput;value : int64;const l : tlocation);
  103. begin
  104. cg.a_load_const_loc(list,value,l);
  105. end;
  106. procedure tcg64f64.a_load64_reg_loc(list : taasmoutput;reg : tregister64;const l : tlocation);
  107. begin
  108. cg.a_load_reg_loc(list,OS_64,reg,l);
  109. end;
  110. procedure tcg64f64.a_load64high_reg_ref(list : taasmoutput;reg : tregister;const ref : treference);
  111. begin
  112. internalerror(200404211);
  113. end;
  114. procedure tcg64f64.a_load64low_reg_ref(list : taasmoutput;reg : tregister;const ref : treference);
  115. begin
  116. internalerror(200404212);
  117. end;
  118. procedure tcg64f64.a_load64high_ref_reg(list : taasmoutput;const ref : treference;reg : tregister);
  119. begin
  120. internalerror(200404213);
  121. end;
  122. procedure tcg64f64.a_load64low_ref_reg(list : taasmoutput;const ref : treference;reg : tregister);
  123. begin
  124. internalerror(200404214);
  125. end;
  126. procedure tcg64f64.a_load64high_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister);
  127. begin
  128. internalerror(200404215);
  129. end;
  130. procedure tcg64f64.a_load64low_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister);
  131. begin
  132. internalerror(200404216);
  133. end;
  134. procedure tcg64f64.a_op64_ref_reg(list : taasmoutput;op:TOpCG;const ref : treference;reg : tregister64);
  135. begin
  136. cg.a_op_ref_reg(list,op,OS_64,ref,reg);
  137. end;
  138. procedure tcg64f64.a_op64_reg_ref(list : taasmoutput;op:TOpCG;regsrc : tregister64;const ref : treference);
  139. begin
  140. cg.a_op_reg_ref(list,op,OS_64,regsrc,ref);
  141. end;
  142. procedure tcg64f64.a_op64_const_reg(list : taasmoutput;op:TOpCG;value : int64;regdst : tregister64);
  143. begin
  144. cg.a_op_const_reg(list,op,OS_64,value,regdst);
  145. end;
  146. procedure tcg64f64.a_op64_const_ref(list : taasmoutput;op:TOpCG;value : int64;const ref : treference);
  147. begin
  148. cg.a_op_const_ref(list,op,OS_64,value,ref);
  149. end;
  150. procedure tcg64f64.a_op64_const_loc(list : taasmoutput;op:TOpCG;value : int64;const l: tlocation);
  151. begin
  152. cg.a_op_const_loc(list,op,value,l);
  153. end;
  154. procedure tcg64f64.a_op64_reg_loc(list : taasmoutput;op:TOpCG;reg : tregister64;const l : tlocation);
  155. begin
  156. cg.a_op_reg_loc(list,op,reg,l);
  157. end;
  158. procedure tcg64f64.a_op64_loc_reg(list : taasmoutput;op:TOpCG;const l : tlocation;reg : tregister64);
  159. begin
  160. internalerror(200404217);
  161. end;
  162. procedure tcg64f64.a_param64_reg(list : taasmoutput;reg : tregister64;const locpara : tparalocation);
  163. begin
  164. cg.a_param_reg(list,OS_64,reg,locpara);
  165. end;
  166. procedure tcg64f64.a_param64_const(list : taasmoutput;value : int64;const locpara : tparalocation);
  167. begin
  168. cg.a_param_const(list,OS_64,value,locpara);
  169. end;
  170. procedure tcg64f64.a_param64_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);
  171. begin
  172. cg.a_param_ref(list,OS_64,r,locpara);
  173. end;
  174. procedure tcg64f64.a_param64_loc(list : taasmoutput;const l : tlocation;const locpara : tparalocation);
  175. begin
  176. cg.a_param_loc(list,l,locpara);
  177. end;
  178. procedure tcg64f64.g_rangecheck64(list: taasmoutput; const l:tlocation;fromdef,todef: tdef);
  179. begin
  180. cg.g_rangecheck(list,l,fromdef,todef);
  181. end;
  182. function tcg64f64.optimize64_op_const_reg(list: taasmoutput; var op: topcg; var a : int64; var reg: tregister64): boolean;
  183. begin
  184. result:=cg.optimize_op_const_reg(list,op,a,reg);
  185. end;
  186. procedure tcg64f64.a_reg_alloc(list : taasmoutput;r : tregister64);
  187. begin
  188. list.concat(tai_regalloc.alloc(r));
  189. end;
  190. procedure tcg64f64.a_reg_dealloc(list : taasmoutput;r : tregister64);
  191. begin
  192. list.concat(tai_regalloc.dealloc(r));
  193. end;
  194. {$endif cpu64bit}
  195. end.
  196. {
  197. $Log$
  198. Revision 1.13 2004-06-20 08:55:28 florian
  199. * logs truncated
  200. Revision 1.12 2004/06/16 20:07:07 florian
  201. * dwarf branch merged
  202. Revision 1.11.2.2 2004/04/27 18:18:25 peter
  203. * aword -> aint
  204. Revision 1.11.2.1 2004/04/21 18:54:29 florian
  205. + implemented most methods as redirections to cg
  206. Revision 1.11 2004/01/13 18:08:58 florian
  207. * x86-64 compilation fixed
  208. }