nx64inl.pas 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Generate x86-64 inline 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 nx64inl;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. nx86inl;
  22. type
  23. tx8664inlinenode = class(tx86inlinenode)
  24. protected
  25. procedure maybe_remove_round_trunc_typeconv; override;
  26. end;
  27. implementation
  28. uses
  29. symconst,
  30. node,ncnv,ninl;
  31. procedure tx8664inlinenode.maybe_remove_round_trunc_typeconv;
  32. var
  33. temp: tnode;
  34. begin
  35. { the prototype of trunc()/round() in the system unit is declared
  36. with valreal as parameter type, so the argument will always be
  37. extended -> remove the typeconversion to extended if any; not done
  38. in ninl, because there are other code generators that assume that
  39. the parameter to trunc has been converted to valreal (e.g. PowerPC).
  40. We can always remove such typeconversions here if they exist, because
  41. on the x87 all floating point types are handled the same, and
  42. if we call the inherited version we'll insert a call node, which
  43. will insert the necessary type conversion again }
  44. if (left.nodetype=typeconvn) and
  45. not(nf_explicit in left.flags) and
  46. (ttypeconvnode(left).left.resultdef.typ=floatdef) then
  47. begin
  48. { get rid of the type conversion, so the use_vectorfpu will be
  49. applied to the original type }
  50. temp:=ttypeconvnode(left).left;
  51. ttypeconvnode(left).left:=nil;
  52. left.free;
  53. left:=temp;
  54. end;
  55. end;
  56. begin
  57. cinlinenode:=tx8664inlinenode;
  58. end.