diff ir/irfunction.cpp @ 1024:9167d492cbc2

Abstracted more (most) ABI details out of the normal codegen.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Tue, 03 Mar 2009 02:51:21 +0100
parents 1714836f2c0b
children 45af482e3832
line wrap: on
line diff
--- a/ir/irfunction.cpp	Sun Mar 01 22:40:15 2009 +0100
+++ b/ir/irfunction.cpp	Tue Mar 03 02:51:21 2009 +0100
@@ -1,6 +1,7 @@
 
 #include "gen/llvm.h"
 #include "gen/tollvm.h"
+#include "gen/abi.h"
 #include "ir/irfunction.h"
 
 #include <sstream>
@@ -9,6 +10,55 @@
 //////////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////////
 
+IrFuncTyArg::IrFuncTyArg(Type* t, bool bref, unsigned a)
+{
+    type = t;
+    ltype = bref ? DtoType(t->pointerTo()) : DtoType(t);
+    attrs = a;
+    byref = bref;
+    rewrite = NULL;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+llvm::Value* IrFuncTy::putRet(Type* dty, llvm::Value* val)
+{
+    assert(!arg_sret);
+    if (ret->rewrite)
+        return ret->rewrite->put(dty, val);
+    return val;
+}
+
+llvm::Value* IrFuncTy::getRet(Type* dty, llvm::Value* val)
+{
+    assert(!arg_sret);
+    if (ret->rewrite)
+        return ret->rewrite->get(dty, val);
+    return val;
+}
+
+llvm::Value* IrFuncTy::putParam(Type* dty, int idx, llvm::Value* val)
+{
+    assert(idx >= 0 && idx < args.size() && "invalid putParam");
+    if (args[idx]->rewrite)
+        return args[idx]->rewrite->put(dty, val);
+    return val;
+}
+
+llvm::Value* IrFuncTy::getParam(Type* dty, int idx, llvm::Value* val)
+{
+    assert(idx >= 0 && idx < args.size() && "invalid getParam");
+    if (args[idx]->rewrite)
+        return args[idx]->rewrite->get(dty, val);
+    return val;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
 IrFunction::IrFunction(FuncDeclaration* fd)
 {
     decl = fd;