nx86cal.pas 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Common x86 support for call 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 nx86cal;
  18. {$i fpcdefs.inc}
  19. interface
  20. { $define AnsiStrRef}
  21. uses
  22. symdef,
  23. ncgcal;
  24. type
  25. { tx86callnode }
  26. tx86callnode = class(tcgcallnode)
  27. protected
  28. procedure do_release_unused_return_value;override;
  29. procedure set_result_location(realresdef: tstoreddef);override;
  30. end;
  31. implementation
  32. uses
  33. cgobj,
  34. cgbase,cgutils,cpubase,cgx86,cga;
  35. {*****************************************************************************
  36. TX86CALLNODE
  37. *****************************************************************************}
  38. procedure tx86callnode.do_release_unused_return_value;
  39. begin
  40. case location.loc of
  41. LOC_FPUREGISTER :
  42. begin
  43. { release FPU stack }
  44. emit_reg(A_FSTP,S_NO,NR_FPU_RESULT_REG);
  45. tcgx86(cg).dec_fpu_stack;
  46. end
  47. else
  48. inherited do_release_unused_return_value;
  49. end;
  50. end;
  51. procedure tx86callnode.set_result_location(realresdef: tstoreddef);
  52. begin
  53. if (retloc.location^.loc=LOC_FPUREGISTER) then
  54. begin
  55. tcgx86(cg).inc_fpu_stack;
  56. location_reset(location,LOC_FPUREGISTER,retloc.location^.size);
  57. location.register:=retloc.location^.register;
  58. end
  59. else
  60. inherited set_result_location(realresdef);
  61. end;
  62. end.