nrvmat.pas 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Generate RiscV 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 nrvmat;
  18. {$I fpcdefs.inc}
  19. interface
  20. uses
  21. ncgmat;
  22. type
  23. trvunaryminusnode = class(tcgunaryminusnode)
  24. procedure second_float;override;
  25. end;
  26. implementation
  27. uses
  28. globtype,
  29. verbose,
  30. nmat,
  31. cpubase,
  32. aasmdata,aasmcpu,
  33. cgbase,cgobj,cgcpu,cgutils,
  34. symdef,
  35. hlcgobj,
  36. defutil,
  37. pass_2;
  38. procedure trvunaryminusnode.second_float;
  39. begin
  40. secondpass(left);
  41. location_reset(location,LOC_FPUREGISTER,def_cgsize(resultdef));
  42. location.register:=hlcg.getregisterfordef(current_asmdata.CurrAsmList,resultdef);
  43. hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,true);
  44. case tfloatdef(left.resultdef).floattype of
  45. s32real:
  46. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_FNEG_S,location.register,left.location.register));
  47. s64real:
  48. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_FNEG_D,location.register,left.location.register));
  49. s128real:
  50. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_FNEG_Q,location.register,left.location.register));
  51. else
  52. Internalerror(2025010901);
  53. end;
  54. cg.maybe_check_for_fpu_exception(current_asmdata.CurrAsmList);
  55. end;
  56. begin
  57. cunaryminusnode := trvunaryminusnode;
  58. end.