narmmat.pas 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Generate ARM 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 narmmat;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. node,nmat,ncgmat;
  23. type
  24. tarmnotnode = class(tcgnotnode)
  25. procedure second_boolean;override;
  26. end;
  27. tarmunaryminusnode = class(tcgunaryminusnode)
  28. procedure second_float;override;
  29. end;
  30. implementation
  31. uses
  32. globtype,systems,
  33. cutils,verbose,globals,
  34. symconst,symdef,
  35. aasmbase,aasmcpu,aasmtai,
  36. defutil,
  37. cgbase,cgobj,pass_1,pass_2,
  38. ncon,
  39. cpubase,cpuinfo,
  40. ncgutil,cgcpu,cg64f32,rgobj;
  41. {*****************************************************************************
  42. TARMNOTNODE
  43. *****************************************************************************}
  44. procedure tarmnotnode.second_boolean;
  45. var
  46. hl : tasmlabel;
  47. ins : taicpu;
  48. begin
  49. { if the location is LOC_JUMP, we do the secondpass after the
  50. labels are allocated
  51. }
  52. if left.expectloc=LOC_JUMP then
  53. begin
  54. hl:=truelabel;
  55. truelabel:=falselabel;
  56. falselabel:=hl;
  57. secondpass(left);
  58. maketojumpbool(exprasmlist,left,lr_load_regvars);
  59. hl:=truelabel;
  60. truelabel:=falselabel;
  61. falselabel:=hl;
  62. location.loc:=LOC_JUMP;
  63. end
  64. else
  65. begin
  66. secondpass(left);
  67. case left.location.loc of
  68. LOC_FLAGS :
  69. begin
  70. location_copy(location,left.location);
  71. inverse_flags(location.resflags);
  72. end;
  73. LOC_REGISTER,LOC_CREGISTER,LOC_REFERENCE,LOC_CREFERENCE :
  74. begin
  75. location_force_reg(exprasmlist,left.location,def_cgsize(left.resulttype.def),true);
  76. exprasmlist.concat(taicpu.op_reg_const(A_CMP,left.location.register,0));
  77. location_reset(location,LOC_FLAGS,OS_NO);
  78. location.resflags:=F_EQ;
  79. end;
  80. else
  81. internalerror(2003042401);
  82. end;
  83. end;
  84. end;
  85. {*****************************************************************************
  86. TARMUNARYMINUSNODE
  87. *****************************************************************************}
  88. procedure tarmunaryminusnode.second_float;
  89. begin
  90. secondpass(left);
  91. location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
  92. location_force_fpureg(exprasmlist,left.location,false);
  93. location:=left.location;
  94. exprasmlist.concat(setoppostfix(taicpu.op_reg_reg_const(A_RSF,
  95. location.register,left.location.register,0),
  96. cgsize2fpuoppostfix[def_cgsize(resulttype.def)]));
  97. end;
  98. begin
  99. cnotnode:=tarmnotnode;
  100. cunaryminusnode:=tarmunaryminusnode;
  101. end.
  102. {
  103. $Log$
  104. Revision 1.8 2004-10-24 07:54:25 florian
  105. * fixed compilation of arm compiler
  106. Revision 1.7 2004/06/20 08:55:31 florian
  107. * logs truncated
  108. Revision 1.6 2004/03/13 18:45:40 florian
  109. * floating compares fixed
  110. * unary minus for floats fixed
  111. Revision 1.5 2004/01/28 15:36:47 florian
  112. * fixed another couple of arm bugs
  113. }