nllvmcal.pas 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. {
  2. Copyright (c) 2014 by Jonas Maebe
  3. Generate LLVM bytecode 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 nllvmcal;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. parabase,
  22. ncgcal,
  23. cgutils;
  24. type
  25. tllvmcallparanode = class(tcgcallparanode)
  26. protected
  27. function push_zero_sized_value_para: boolean; override;
  28. end;
  29. tllvmcallnode = class(tcgcallnode)
  30. protected
  31. function can_call_ref(var ref: treference): boolean; override;
  32. procedure pushparas; override;
  33. end;
  34. implementation
  35. uses
  36. verbose,
  37. ncal;
  38. {*****************************************************************************
  39. TLLVMCALLPARANODE
  40. *****************************************************************************}
  41. function tllvmcallparanode.push_zero_sized_value_para: boolean;
  42. begin
  43. { part of the signature -> need to be pushed }
  44. result:=true;
  45. end;
  46. {*****************************************************************************
  47. TLLVMCALLNODE
  48. *****************************************************************************}
  49. function tllvmcallnode.can_call_ref(var ref: treference): boolean;
  50. begin
  51. result:=false;
  52. end;
  53. procedure tllvmcallnode.pushparas;
  54. var
  55. n: tcgcallparanode;
  56. paraindex: longint;
  57. begin
  58. { we just pass the temp paralocs here }
  59. if not assigned(varargsparas) then
  60. setlength(paralocs,procdefinition.paras.count)
  61. else
  62. setlength(paralocs,procdefinition.paras.count+varargsparas.count);
  63. n:=tcgcallparanode(left);
  64. while assigned(n) do
  65. begin
  66. { TODO: check whether this is correct for left-to-right calling
  67. conventions, may also depend on whether or not llvm knows about
  68. the calling convention }
  69. if not(cpf_varargs_para in n.callparaflags) then
  70. paraindex:=procdefinition.paras.indexof(n.parasym)
  71. else
  72. paraindex:=procdefinition.paras.count+varargsparas.indexof(n.parasym);
  73. if paraindex=-1 then
  74. internalerror(2014010602);
  75. paralocs[paraindex]:[email protected];
  76. n:=tcgcallparanode(n.right);
  77. end;
  78. end;
  79. begin
  80. ccallnode:=tllvmcallnode;
  81. end.