narmcal.pas 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. {
  2. Copyright (c) 2002 by Florian Klaempfl
  3. Implements the ARM specific part of 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 narmcal;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. symdef,ncal,ncgcal;
  22. type
  23. tarmcallnode = class(tcgcallnode)
  24. procedure gen_syscall_para(para: tcallparanode); override;
  25. procedure set_result_location(realresdef: tstoreddef);override;
  26. public
  27. procedure do_syscall;override;
  28. end;
  29. implementation
  30. uses
  31. verbose,globtype,globals,aasmdata,aasmtai,
  32. symconst,symtype,symbase,symsym,symcpu,parabase,paramgr,
  33. cgbase,cgobj,cgutils,cpuinfo,cpubase,cutils,
  34. ncgutil,tgobj,nld,
  35. systems;
  36. procedure tarmcallnode.gen_syscall_para(para: tcallparanode);
  37. begin
  38. { lib parameter has no special type but proccalloptions must be a syscall }
  39. para.left:=cloadnode.create(tcpuprocdef(procdefinition).libsym,tcpuprocdef(procdefinition).libsym.owner);
  40. end;
  41. procedure tarmcallnode.do_syscall;
  42. var
  43. tmpref: treference;
  44. begin
  45. case target_info.system of
  46. system_arm_aros:
  47. begin
  48. if (po_syscall_baselast in tprocdef(procdefinition).procoptions) then
  49. begin
  50. current_asmdata.CurrAsmList.concat(tai_comment.create(strpnew('AROS SysCall')));
  51. cg.getcpuregister(current_asmdata.CurrAsmList,NR_R12);
  52. get_syscall_call_ref(tmpref,NR_R12);
  53. cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,tmpref,NR_R12);
  54. cg.a_call_reg(current_asmdata.CurrAsmList,NR_R12);
  55. cg.ungetcpuregister(current_asmdata.CurrAsmList,NR_R12);
  56. exit;
  57. end;
  58. internalerror(2016110601);
  59. end;
  60. else
  61. internalerror(2016110602);
  62. end;
  63. end;
  64. procedure tarmcallnode.set_result_location(realresdef: tstoreddef);
  65. begin
  66. if (realresdef.typ=floatdef) and
  67. (target_info.abi<>abi_eabihf) and
  68. (procdefinition.proccalloption<>pocall_hardfloat) and
  69. ((cs_fp_emulation in current_settings.moduleswitches) or
  70. (current_settings.fputype in [fpu_vfpv2,fpu_vfpv3,fpu_vfpv4,fpu_vfpv3_d16,fpu_fpv4_s16])) then
  71. begin
  72. { keep the fpu values in integer registers for now, the code
  73. generator will move them to memory or an mmregister when necessary
  74. (avoids double moves in case a function result is assigned to
  75. another function result, or passed as a parameter) }
  76. case retloc.size of
  77. OS_32,
  78. OS_F32:
  79. location_allocate_register(current_asmdata.CurrAsmList,location,s32inttype,false);
  80. OS_64,
  81. OS_F64:
  82. location_allocate_register(current_asmdata.CurrAsmList,location,s64inttype,false);
  83. else
  84. internalerror(2010053008);
  85. end
  86. end
  87. else if (resultdef.typ=floatdef) and
  88. (location.loc=LOC_REGISTER) and
  89. (current_settings.fputype in [fpu_fpa,fpu_fpa10,fpu_fpa11]) then
  90. begin
  91. location_reset_ref(location,LOC_REFERENCE,location.size,resultdef.alignment,[]);
  92. tg.gethltemp(current_asmdata.CurrAsmList,resultdef,resultdef.size,tt_normal,location.reference);
  93. end
  94. else
  95. inherited;
  96. end;
  97. begin
  98. ccallnode:=tarmcallnode;
  99. end.