nllvmcal.pas 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. {$mode objfpc}
  19. interface
  20. uses
  21. ncgcal;
  22. type
  23. tllvmcallnode = class(tcgcallnode)
  24. protected
  25. procedure pushparas; override;
  26. end;
  27. implementation
  28. uses
  29. verbose,
  30. ncal;
  31. { tllvmcallnode }
  32. procedure tllvmcallnode.pushparas;
  33. var
  34. n: tcgcallparanode;
  35. paraindex: longint;
  36. begin
  37. { we just pass the temp paralocs here }
  38. setlength(paralocs,procdefinition.paras.count);
  39. n:=tcgcallparanode(left);
  40. while assigned(n) do
  41. begin
  42. { TODO: check whether this is correct for left-to-right calling
  43. conventions, may also depend on whether or not llvm knows about
  44. the calling convention }
  45. paraindex:=procdefinition.paras.indexof(n.parasym);
  46. if paraindex=-1 then
  47. internalerror(2014010602);
  48. paralocs[paraindex]:[email protected];
  49. n:=tcgcallparanode(n.right);
  50. end;
  51. end;
  52. begin
  53. ccallnode:=tllvmcallnode;
  54. end.