n68kmat.pas 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Generate 680x0 assembler for math nodes
  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 n68kmat;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. node,nmat;
  23. type
  24. tm68knotnode = class(tnotnode)
  25. procedure pass_2;override;
  26. end;
  27. implementation
  28. uses
  29. globtype,systems,
  30. cutils,verbose,globals,
  31. symconst,symdef,aasmbase,aasmtai,aasmcpu,defbase,
  32. cginfo,cgbase,pass_1,pass_2,
  33. ncon,
  34. cpubase,cpuinfo,paramgr,
  35. tgobj,ncgutil,cgobj,rgobj,rgcpu,cgcpu,cg64f32;
  36. {*****************************************************************************
  37. TM68KNOTNODE
  38. *****************************************************************************}
  39. procedure tm68knotnode.pass_2;
  40. var
  41. hl : tasmlabel;
  42. opsize : tcgsize;
  43. begin
  44. opsize:=def_cgsize(resulttype.def);
  45. if is_boolean(resulttype.def) then
  46. begin
  47. { the second pass could change the location of left }
  48. { if it is a register variable, so we've to do }
  49. { this before the case statement }
  50. if left.location.loc<>LOC_JUMP then
  51. secondpass(left);
  52. case left.location.loc of
  53. LOC_JUMP :
  54. begin
  55. location_reset(location,LOC_JUMP,OS_NO);
  56. hl:=truelabel;
  57. truelabel:=falselabel;
  58. falselabel:=hl;
  59. secondpass(left);
  60. maketojumpbool(exprasmlist,left,lr_load_regvars);
  61. hl:=truelabel;
  62. truelabel:=falselabel;
  63. falselabel:=hl;
  64. end;
  65. LOC_FLAGS :
  66. begin
  67. location_copy(location,left.location);
  68. location_release(exprasmlist,left.location);
  69. inverse_flags(location.resflags);
  70. end;
  71. LOC_CONSTANT,
  72. LOC_REGISTER,
  73. LOC_CREGISTER,
  74. LOC_REFERENCE,
  75. LOC_CREFERENCE :
  76. begin
  77. location_force_reg(exprasmlist,left.location,def_cgsize(resulttype.def),true);
  78. exprasmlist.concat(taicpu.op_reg(A_TST,tcgsize2opsize[opsize],left.location.register));
  79. location_release(exprasmlist,left.location);
  80. location_reset(location,LOC_FLAGS,OS_NO);
  81. location.resflags:=F_E;
  82. end;
  83. else
  84. internalerror(200203224);
  85. end;
  86. end
  87. else if is_64bitint(left.resulttype.def) then
  88. begin
  89. secondpass(left);
  90. location_copy(location,left.location);
  91. location_force_reg(exprasmlist,location,OS_64,false);
  92. cg64.a_op64_loc_reg(exprasmlist,OP_NOT,location,
  93. joinreg64(location.registerlow,location.registerhigh));
  94. end
  95. else
  96. begin
  97. secondpass(left);
  98. location_copy(location,left.location);
  99. location_force_reg(exprasmlist,location,opsize,false);
  100. cg.a_op_reg_reg(exprasmlist,OP_NOT,opsize,location.register,location.register);
  101. end;
  102. end;
  103. begin
  104. cnotnode:=tm68knotnode;
  105. end.
  106. {
  107. $Log$
  108. Revision 1.4 2002-09-07 15:25:13 peter
  109. * old logs removed and tabs fixed
  110. Revision 1.3 2002/08/15 15:15:55 carl
  111. * jmpbuf size allocation for exceptions is now cpu specific (as it should)
  112. * more generic nodes for maths
  113. * several fixes for better m68k support
  114. Revision 1.2 2002/08/15 08:13:54 carl
  115. - a_load_sym_ofs_reg removed
  116. * loadvmt now calls loadaddr_ref_reg instead
  117. Revision 1.1 2002/08/14 19:16:34 carl
  118. + m68k type conversion nodes
  119. + started some mathematical nodes
  120. * out of bound references should now be handled correctly
  121. }