narmmat.pas 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Generate ARM assembler for math nodes
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit narmmat;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. node,nmat,ncgmat;
  22. type
  23. tarmnotnode = class(tcgnotnode)
  24. procedure second_boolean;override;
  25. end;
  26. tarmunaryminusnode = class(tcgunaryminusnode)
  27. procedure second_float;override;
  28. end;
  29. implementation
  30. uses
  31. globtype,systems,
  32. cutils,verbose,globals,
  33. symconst,symdef,
  34. aasmbase,aasmcpu,aasmtai,aasmdata,
  35. defutil,
  36. cgbase,cgobj,cgutils,
  37. pass_1,pass_2,procinfo,
  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:=current_procinfo.CurrTrueLabel;
  55. current_procinfo.CurrTrueLabel:=current_procinfo.CurrFalseLabel;
  56. current_procinfo.CurrFalseLabel:=hl;
  57. secondpass(left);
  58. maketojumpbool(current_asmdata.CurrAsmList,left,lr_load_regvars);
  59. hl:=current_procinfo.CurrTrueLabel;
  60. current_procinfo.CurrTrueLabel:=current_procinfo.CurrFalseLabel;
  61. current_procinfo.CurrFalseLabel:=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. LOC_SUBSETREG,LOC_CSUBSETREG,LOC_SUBSETREF,LOC_CSUBSETREF :
  75. begin
  76. location_force_reg(current_asmdata.CurrAsmList,left.location,def_cgsize(left.resultdef),true);
  77. current_asmdata.CurrAsmList.concat(taicpu.op_reg_const(A_CMP,left.location.register,0));
  78. location_reset(location,LOC_FLAGS,OS_NO);
  79. location.resflags:=F_EQ;
  80. end;
  81. else
  82. internalerror(2003042401);
  83. end;
  84. end;
  85. end;
  86. {*****************************************************************************
  87. TARMUNARYMINUSNODE
  88. *****************************************************************************}
  89. procedure tarmunaryminusnode.second_float;
  90. begin
  91. secondpass(left);
  92. location_reset(location,LOC_FPUREGISTER,def_cgsize(resultdef));
  93. location_force_fpureg(current_asmdata.CurrAsmList,left.location,false);
  94. location:=left.location;
  95. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg_const(A_RSF,
  96. location.register,left.location.register,0),
  97. cgsize2fpuoppostfix[def_cgsize(resultdef)]));
  98. end;
  99. begin
  100. cnotnode:=tarmnotnode;
  101. cunaryminusnode:=tarmunaryminusnode;
  102. end.