fpc/compiler/llvm/nllvmcal.pas
Jonas Maebe 6dcfd73d21 + support for a_call_name() on the llvm target:
o make use of the fact that callparanodes always first load everything
     in temporary parameters (allocated via paramanager.createtempparaloc)
     -> we pass those temporary paralocs to the llvm call nodes and ignore
     the "real" locations with physical registers
   o all function results are forced to memory before handing them back
     to the generic code generator to avoid having to deal with special
     result locations and llvm<->pascal type differences (llvm removes
     the extra temp stores/loads while optimising)
   o ideally, the llvm code generator should share the common code with
      the generic code generator for a_load_ref_cgpara() at some point in
      the future

git-svn-id: branches/hlcgllvm@27013 -
2014-03-06 21:42:14 +00:00

71 lines
1.9 KiB
ObjectPascal

{
Copyright (c) 2014 by Jonas Maebe
Generate LLVM bytecode for call nodes
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
****************************************************************************
}
unit nllvmcal;
{$mode objfpc}
interface
uses
ncgcal;
type
tllvmcallnode = class(tcgcallnode)
protected
procedure pushparas; override;
end;
implementation
uses
verbose,
ncal;
{ tllvmcallnode }
procedure tllvmcallnode.pushparas;
var
n: tcgcallparanode;
paraindex: longint;
begin
{ we just pass the temp paralocs here }
setlength(paralocs,procdefinition.paras.count);
n:=tcgcallparanode(left);
while assigned(n) do
begin
{ TODO: check whether this is correct for left-to-right calling
conventions, may also depend on whether or not llvm knows about
the calling convention }
paraindex:=procdefinition.paras.indexof(n.parasym);
if paraindex=-1 then
internalerror(2014010602);
paralocs[paraindex]:=@n.tempcgpara;
n:=tcgcallparanode(n.right);
end;
end;
begin
ccallnode:=tllvmcallnode;
end.