Mercurial > projects > ldc
comparison ir/irfunction.h @ 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 | 9dca7182aa75 |
comparison
equal
deleted
inserted
replaced
1023:ca191c141cec | 1024:9167d492cbc2 |
---|---|
1 #ifndef LDC_IR_IRFUNCTION_H | 1 #ifndef LDC_IR_IRFUNCTION_H |
2 #define LDC_IR_IRFUNCTION_H | 2 #define LDC_IR_IRFUNCTION_H |
3 | 3 |
4 #include "gen/llvm.h" | |
4 #include "ir/ir.h" | 5 #include "ir/ir.h" |
5 #include "ir/irlandingpad.h" | 6 #include "ir/irlandingpad.h" |
6 | 7 |
7 #include <vector> | 8 #include <vector> |
8 #include <stack> | 9 #include <stack> |
9 #include <map> | 10 #include <map> |
11 | |
12 struct ABIRewrite; | |
13 | |
14 // represents a function type argument | |
15 // both explicit and implicit as well as return values | |
16 struct IrFuncTyArg : IrBase | |
17 { | |
18 Type* type; | |
19 const llvm::Type* ltype; | |
20 unsigned attrs; | |
21 bool byref; | |
22 | |
23 ABIRewrite* rewrite; | |
24 | |
25 bool isInReg() const { return (attrs & llvm::Attribute::InReg) != 0; } | |
26 bool isSRet() const { return (attrs & llvm::Attribute::StructRet) != 0; } | |
27 bool isByVal() const { return (attrs & llvm::Attribute::ByVal) != 0; } | |
28 | |
29 IrFuncTyArg(Type* t, bool byref, unsigned a = 0); | |
30 }; | |
31 | |
32 // represents a function type | |
33 struct IrFuncTy : IrBase | |
34 { | |
35 // return value | |
36 IrFuncTyArg* ret; | |
37 | |
38 // null if not applicable | |
39 IrFuncTyArg* arg_sret; | |
40 IrFuncTyArg* arg_this; | |
41 IrFuncTyArg* arg_nest; | |
42 IrFuncTyArg* arg_arguments; | |
43 IrFuncTyArg* arg_argptr; | |
44 | |
45 // normal explicit arguments | |
46 LLSmallVector<IrFuncTyArg*, 4> args; | |
47 | |
48 // C varargs | |
49 bool c_vararg; | |
50 | |
51 // range of normal parameters to reverse | |
52 bool reverseParams; | |
53 | |
54 IrFuncTy() | |
55 : ret(NULL), | |
56 arg_sret(NULL), | |
57 arg_this(NULL), | |
58 arg_nest(NULL), | |
59 arg_arguments(NULL), | |
60 arg_argptr(NULL), | |
61 c_vararg(false), | |
62 reverseParams(false) | |
63 {} | |
64 | |
65 llvm::Value* putRet(Type* dty, llvm::Value* val); | |
66 llvm::Value* getRet(Type* dty, llvm::Value* val); | |
67 | |
68 llvm::Value* getParam(Type* dty, int idx, llvm::Value* val); | |
69 llvm::Value* putParam(Type* dty, int idx, llvm::Value* val); | |
70 }; | |
10 | 71 |
11 // represents a function | 72 // represents a function |
12 struct IrFunction : IrBase | 73 struct IrFunction : IrBase |
13 { | 74 { |
14 llvm::Function* func; | 75 llvm::Function* func; |