nllvmcal.pas 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. tllvmcallnode = class(tcgcallnode)
  26. protected
  27. function can_call_ref(var ref: treference): boolean; override;
  28. procedure pushparas; override;
  29. end;
  30. implementation
  31. uses
  32. verbose,
  33. ncal;
  34. function tllvmcallnode.can_call_ref(var ref: treference): boolean;
  35. begin
  36. result:=false;
  37. end;
  38. procedure tllvmcallnode.pushparas;
  39. var
  40. n: tcgcallparanode;
  41. paraindex: longint;
  42. begin
  43. { we just pass the temp paralocs here }
  44. if not assigned(varargsparas) then
  45. setlength(paralocs,procdefinition.paras.count)
  46. else
  47. setlength(paralocs,procdefinition.paras.count+varargsparas.count);
  48. n:=tcgcallparanode(left);
  49. while assigned(n) do
  50. begin
  51. { TODO: check whether this is correct for left-to-right calling
  52. conventions, may also depend on whether or not llvm knows about
  53. the calling convention }
  54. if not(cpf_varargs_para in n.callparaflags) then
  55. paraindex:=procdefinition.paras.indexof(n.parasym)
  56. else
  57. paraindex:=procdefinition.paras.count+varargsparas.indexof(n.parasym);
  58. if paraindex=-1 then
  59. internalerror(2014010602);
  60. paralocs[paraindex]:[email protected];
  61. n:=tcgcallparanode(n.right);
  62. end;
  63. end;
  64. begin
  65. ccallnode:=tllvmcallnode;
  66. end.