comparison 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
comparison
equal deleted inserted replaced
1023:ca191c141cec 1024:9167d492cbc2
1 1
2 #include "gen/llvm.h" 2 #include "gen/llvm.h"
3 #include "gen/tollvm.h" 3 #include "gen/tollvm.h"
4 #include "gen/abi.h"
4 #include "ir/irfunction.h" 5 #include "ir/irfunction.h"
5 6
6 #include <sstream> 7 #include <sstream>
8
9 //////////////////////////////////////////////////////////////////////////////
10 //////////////////////////////////////////////////////////////////////////////
11 //////////////////////////////////////////////////////////////////////////////
12
13 IrFuncTyArg::IrFuncTyArg(Type* t, bool bref, unsigned a)
14 {
15 type = t;
16 ltype = bref ? DtoType(t->pointerTo()) : DtoType(t);
17 attrs = a;
18 byref = bref;
19 rewrite = NULL;
20 }
21
22 //////////////////////////////////////////////////////////////////////////////
23 //////////////////////////////////////////////////////////////////////////////
24 //////////////////////////////////////////////////////////////////////////////
25
26 llvm::Value* IrFuncTy::putRet(Type* dty, llvm::Value* val)
27 {
28 assert(!arg_sret);
29 if (ret->rewrite)
30 return ret->rewrite->put(dty, val);
31 return val;
32 }
33
34 llvm::Value* IrFuncTy::getRet(Type* dty, llvm::Value* val)
35 {
36 assert(!arg_sret);
37 if (ret->rewrite)
38 return ret->rewrite->get(dty, val);
39 return val;
40 }
41
42 llvm::Value* IrFuncTy::putParam(Type* dty, int idx, llvm::Value* val)
43 {
44 assert(idx >= 0 && idx < args.size() && "invalid putParam");
45 if (args[idx]->rewrite)
46 return args[idx]->rewrite->put(dty, val);
47 return val;
48 }
49
50 llvm::Value* IrFuncTy::getParam(Type* dty, int idx, llvm::Value* val)
51 {
52 assert(idx >= 0 && idx < args.size() && "invalid getParam");
53 if (args[idx]->rewrite)
54 return args[idx]->rewrite->get(dty, val);
55 return val;
56 }
7 57
8 ////////////////////////////////////////////////////////////////////////////// 58 //////////////////////////////////////////////////////////////////////////////
9 ////////////////////////////////////////////////////////////////////////////// 59 //////////////////////////////////////////////////////////////////////////////
10 ////////////////////////////////////////////////////////////////////////////// 60 //////////////////////////////////////////////////////////////////////////////
11 61