cg64f64.pas 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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. cginfo, cgobj,
  30. symtype;
  31. type
  32. {# Defines all the methods required on 32-bit processors
  33. to handle 64-bit integers.
  34. }
  35. tcg64f64 = class(tcg64)
  36. procedure a_reg_alloc(list : taasmoutput;r : tregister64);override;
  37. procedure a_reg_dealloc(list : taasmoutput;r : tregister64);override;
  38. procedure a_load64_const_ref(list : taasmoutput;value : AWord;const ref : treference);override;
  39. procedure a_load64_reg_ref(list : taasmoutput;reg : tregister64;const ref : treference);override;
  40. procedure a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64);override;
  41. procedure a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64);override;
  42. procedure a_load64_const_reg(list : taasmoutput;value: qword;reg : tregister64);override;
  43. procedure a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64);override;
  44. procedure a_load64_loc_ref(list : taasmoutput;const l : tlocation;const ref : treference);override;
  45. procedure a_load64_const_loc(list : taasmoutput;value : qword;const l : tlocation);override;
  46. procedure a_load64_reg_loc(list : taasmoutput;reg : tregister64;const l : tlocation);override;
  47. procedure a_load64high_reg_ref(list : taasmoutput;reg : tregister;const ref : treference);override;
  48. procedure a_load64low_reg_ref(list : taasmoutput;reg : tregister;const ref : treference);override;
  49. procedure a_load64high_ref_reg(list : taasmoutput;const ref : treference;reg : tregister);override;
  50. procedure a_load64low_ref_reg(list : taasmoutput;const ref : treference;reg : tregister);override;
  51. procedure a_load64high_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister);override;
  52. procedure a_load64low_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister);override;
  53. procedure a_op64_reg_ref(list : taasmoutput;op:TOpCG;regsrc : tregister64;const ref : treference);override;
  54. procedure a_op64_ref_reg(list : taasmoutput;op:TOpCG;const ref : treference;reg : tregister64);override;
  55. procedure a_op64_const_loc(list : taasmoutput;op:TOpCG;value:qword;const l: tlocation);override;
  56. procedure a_op64_reg_loc(list : taasmoutput;op:TOpCG;reg : tregister64;const l : tlocation);override;
  57. procedure a_op64_loc_reg(list : taasmoutput;op:TOpCG;const l : tlocation;reg : tregister64);override;
  58. procedure a_op64_const_reg(list : taasmoutput;op:TOpCG;value : qword;regdst : tregister64);override;
  59. procedure a_op64_const_ref(list : taasmoutput;op:TOpCG;value : qword;const ref : treference);override;
  60. procedure a_param64_reg(list : taasmoutput;reg : tregister64;const locpara : tparalocation);override;
  61. procedure a_param64_const(list : taasmoutput;value : qword;const locpara : tparalocation);override;
  62. procedure a_param64_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);override;
  63. procedure a_param64_loc(list : taasmoutput;const l : tlocation;const locpara : tparalocation);override;
  64. function optimize64_op_const_reg(list: taasmoutput; var op: topcg; var a : qword; var reg: tregister64): boolean;override;
  65. { override to catch 64bit rangechecks }
  66. procedure g_rangecheck64(list: taasmoutput; const l: tlocation;fromdef,todef: tdef); override;
  67. end;
  68. implementation
  69. procedure tcg64f64.a_load64_const_ref(list : taasmoutput;value : qword;const ref : treference);
  70. begin
  71. cg.a_load_const_ref(list,OS_64,value,ref);
  72. end;
  73. procedure tcg64f64.a_load64_reg_ref(list : taasmoutput;reg : tregister64;const ref : treference);
  74. begin
  75. cg.a_load_reg_ref(list,OS_64,reg,ref);
  76. end;
  77. procedure tcg64f64.a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64);
  78. begin
  79. cg.a_load_ref_reg(list,OS_64,ref,reg);
  80. end;
  81. procedure tcg64f64.a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64);
  82. begin
  83. cg.a_load_reg_reg(list,OS_64,OS_64,regsrc,regdst);
  84. end;
  85. procedure tcg64f64.a_load64_const_reg(list : taasmoutput;value : qword;reg : tregister64);
  86. begin
  87. cg.a_load_const_reg(list,OS_64,value,reg);
  88. end;
  89. procedure tcg64f64.a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64);
  90. begin
  91. cg.a_load_loc_reg(list,l.size,l,reg);
  92. end;
  93. procedure tcg64f64.a_load64_loc_ref(list : taasmoutput;const l : tlocation;const ref : treference);
  94. begin
  95. cg.a_load_loc_ref(list,l,ref);
  96. end;
  97. procedure tcg64f64.a_load64_const_loc(list : taasmoutput;value : qword;const l : tlocation);
  98. begin
  99. cg.a_load_const_loc(list,value,l);
  100. end;
  101. procedure tcg64f64.a_load64_reg_loc(list : taasmoutput;reg : tregister64;const l : tlocation);
  102. begin
  103. cg.a_load_reg_loc(list,OS_64,reg,l);
  104. end;
  105. procedure tcg64f64.a_load64high_reg_ref(list : taasmoutput;reg : tregister;const ref : treference);
  106. begin
  107. end;
  108. procedure tcg64f64.a_load64low_reg_ref(list : taasmoutput;reg : tregister;const ref : treference);
  109. begin
  110. end;
  111. procedure tcg64f64.a_load64high_ref_reg(list : taasmoutput;const ref : treference;reg : tregister);
  112. begin
  113. end;
  114. procedure tcg64f64.a_load64low_ref_reg(list : taasmoutput;const ref : treference;reg : tregister);
  115. begin
  116. end;
  117. procedure tcg64f64.a_load64high_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister);
  118. begin
  119. end;
  120. procedure tcg64f64.a_load64low_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister);
  121. begin
  122. end;
  123. procedure tcg64f64.a_op64_ref_reg(list : taasmoutput;op:TOpCG;const ref : treference;reg : tregister64);
  124. begin
  125. cg.a_op_ref_reg(list,op,OS_64,ref,reg);
  126. end;
  127. procedure tcg64f64.a_op64_reg_ref(list : taasmoutput;op:TOpCG;regsrc : tregister64;const ref : treference);
  128. begin
  129. end;
  130. procedure tcg64f64.a_op64_const_reg(list : taasmoutput;op:TOpCG;value : qword;regdst : tregister64);
  131. begin
  132. end;
  133. procedure tcg64f64.a_op64_const_ref(list : taasmoutput;op:TOpCG;value : qword;const ref : treference);
  134. begin
  135. end;
  136. procedure tcg64f64.a_op64_const_loc(list : taasmoutput;op:TOpCG;value : qword;const l: tlocation);
  137. begin
  138. end;
  139. procedure tcg64f64.a_op64_reg_loc(list : taasmoutput;op:TOpCG;reg : tregister64;const l : tlocation);
  140. begin
  141. end;
  142. procedure tcg64f64.a_op64_loc_reg(list : taasmoutput;op:TOpCG;const l : tlocation;reg : tregister64);
  143. begin
  144. end;
  145. procedure tcg64f64.a_param64_reg(list : taasmoutput;reg64 : tregister;const locpara : tparalocation);
  146. begin
  147. end;
  148. procedure tcg64f64.a_param64_const(list : taasmoutput;value : qword;const locpara : tparalocation);
  149. begin
  150. end;
  151. procedure tcg64f64.a_param64_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);
  152. begin
  153. end;
  154. procedure tcg64f64.a_param64_loc(list : taasmoutput;const l : tlocation;const locpara : tparalocation);
  155. begin
  156. end;
  157. procedure tcg64f64.g_rangecheck64(list: taasmoutput; const p: tnode;def: tdef);
  158. begin
  159. end;
  160. function tcg64f64.optimize64_op_const_reg(list: taasmoutput; var op: topcg; var a : qword; var reg: tregister64): boolean;
  161. begin
  162. { this should be the same routine as optimize_const_reg!!!!!!!! }
  163. end;
  164. procedure tcg64f64.a_reg_alloc(list : taasmoutput;r : tregister64);
  165. begin
  166. list.concat(tai_regalloc.alloc(r));
  167. end;
  168. procedure tcg64f64.a_reg_dealloc(list : taasmoutput;r : tregister64);
  169. begin
  170. list.concat(tai_regalloc.dealloc(r));
  171. end;
  172. end.
  173. {
  174. $Log$
  175. Revision 1.8 2003-06-03 21:11:09 peter
  176. * cg.a_load_* get a from and to size specifier
  177. * makeregsize only accepts newregister
  178. * i386 uses generic tcgnotnode,tcgunaryminus
  179. Revision 1.7 2003/05/30 23:49:18 jonas
  180. * a_load_loc_reg now has an extra size parameter for the destination
  181. register (properly fixes what I worked around in revision 1.106 of
  182. ncgutil.pas)
  183. Revision 1.6 2003/01/05 13:36:53 florian
  184. * x86-64 compiles
  185. + very basic support for float128 type (x86-64 only)
  186. Revision 1.5 2002/09/07 15:25:00 peter
  187. * old logs removed and tabs fixed
  188. Revision 1.4 2002/08/19 18:17:48 carl
  189. + optimize64_op_const_reg implemented (optimizes 64-bit constant opcodes)
  190. * more fixes to m68k for 64-bit operations
  191. Revision 1.3 2002/08/17 22:09:43 florian
  192. * result type handling in tcgcal.pass_2 overhauled
  193. * better tnode.dowrite
  194. * some ppc stuff fixed
  195. Revision 1.2 2002/07/01 16:23:52 peter
  196. * cg64 patch
  197. * basics for currency
  198. * asnode updates for class and interface (not finished)
  199. Revision 1.1 2002/06/08 19:36:54 florian
  200. * initial release
  201. }