ncpucon.pas 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. {
  2. Copyright (c) 2005 by Florian Klaempfl
  3. Code generation for const nodes on the AArch64
  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 ncpucon;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. node,ncgcon,cpubase;
  22. type
  23. taarch64realconstnode = class(tcgrealconstnode)
  24. function pass_1 : tnode;override;
  25. procedure pass_generate_code;override;
  26. end;
  27. implementation
  28. uses
  29. verbose,
  30. globtype,globals,
  31. cpuinfo,
  32. aasmbase,aasmtai,aasmdata,aasmcpu,
  33. symdef,
  34. defutil,
  35. cgbase,cgutils,cgobj,
  36. procinfo,
  37. ncon;
  38. {*****************************************************************************
  39. TARMREALCONSTNODE
  40. *****************************************************************************}
  41. function taarch64realconstnode.pass_1 : tnode;
  42. begin
  43. result:=nil;
  44. if IsFloatImmediate(tfloatdef(resultdef).floattype,value_real) then
  45. expectloc:=LOC_MMREGISTER
  46. else
  47. result:=Inherited pass_1;
  48. end;
  49. procedure taarch64realconstnode.pass_generate_code;
  50. var
  51. hreg : TRegister;
  52. begin
  53. if IsFloatImmediate(tfloatdef(resultdef).floattype,value_real) then
  54. begin
  55. location_reset(location,LOC_MMREGISTER,def_cgsize(resultdef));
  56. location.register:=cg.getmmregister(current_asmdata.CurrAsmList,location.size);
  57. current_asmdata.CurrAsmList.concat(taicpu.op_reg_realconst(A_FMOV,
  58. location.register,value_real));
  59. end
  60. { cast and compare the bit pattern as we cannot handle -0.0 }
  61. else if bestrealrec(value_real).Data=0 then
  62. begin
  63. location_reset(location,LOC_MMREGISTER,def_cgsize(resultdef));
  64. location.register:=cg.getmmregister(current_asmdata.CurrAsmList,location.size);
  65. hreg:=newreg(R_MMREGISTER,getsupreg(location.register),R_SUBMM16B);
  66. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_EOR,
  67. hreg,hreg,hreg));
  68. end
  69. else
  70. Inherited pass_generate_code;
  71. end;
  72. begin
  73. crealconstnode:=taarch64realconstnode;
  74. end.