Mercurial > projects > ldc
comparison ir/irfunction.h @ 1051:dc608dc33081
Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
same LDC call.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sat, 07 Mar 2009 14:25:30 +0100 |
parents | 6bb04dbee21f |
children | 40caa8207b3e |
comparison
equal
deleted
inserted
replaced
1050:32ead42679d1 | 1051:dc608dc33081 |
---|---|
6 #include "ir/irlandingpad.h" | 6 #include "ir/irlandingpad.h" |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 #include <stack> | 9 #include <stack> |
10 #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 /** This is the original D type as the frontend knows it | |
19 * May NOT be rewritten!!! */ | |
20 Type* type; | |
21 | |
22 /// This is the final LLVM Type used for the parameter/return value type | |
23 const llvm::Type* ltype; | |
24 | |
25 /** These are the final LLVM attributes used for the function. | |
26 * Must be valid for the LLVM Type and byref setting */ | |
27 unsigned attrs; | |
28 | |
29 /** 'true' if the final LLVM argument is a LLVM reference type. | |
30 * Must be true when the D Type is a value type, but the final | |
31 * LLVM Type is a reference type! */ | |
32 bool byref; | |
33 | |
34 /** Pointer to the ABIRewrite structure needed to rewrite LLVM ValueS | |
35 * to match the final LLVM Type when passing arguments and getting | |
36 * return values */ | |
37 ABIRewrite* rewrite; | |
38 | |
39 /// Helper to check if the 'inreg' attribute is set | |
40 bool isInReg() const { return (attrs & llvm::Attribute::InReg) != 0; } | |
41 /// Helper to check if the 'sret' attribute is set | |
42 bool isSRet() const { return (attrs & llvm::Attribute::StructRet) != 0; } | |
43 /// Helper to check if the 'byval' attribute is set | |
44 bool isByVal() const { return (attrs & llvm::Attribute::ByVal) != 0; } | |
45 | |
46 /** @param t D type of argument/return value as known by the frontend | |
47 * @param byref Initial value for the 'byref' field. If true the initial | |
48 * LLVM Type will be of DtoType(type->pointerTo()), instead | |
49 * of just DtoType(type) */ | |
50 IrFuncTyArg(Type* t, bool byref, unsigned a = 0); | |
51 }; | |
52 | |
53 // represents a function type | |
54 struct IrFuncTy : IrBase | |
55 { | |
56 // return value | |
57 IrFuncTyArg* ret; | |
58 | |
59 // null if not applicable | |
60 IrFuncTyArg* arg_sret; | |
61 IrFuncTyArg* arg_this; | |
62 IrFuncTyArg* arg_nest; | |
63 IrFuncTyArg* arg_arguments; | |
64 IrFuncTyArg* arg_argptr; | |
65 | |
66 // normal explicit arguments | |
67 typedef LLSmallVector<IrFuncTyArg*, 4> ArgList; | |
68 typedef ArgList::iterator ArgIter; | |
69 ArgList args; | |
70 | |
71 // C varargs | |
72 bool c_vararg; | |
73 | |
74 // range of normal parameters to reverse | |
75 bool reverseParams; | |
76 | |
77 IrFuncTy() | |
78 : ret(NULL), | |
79 arg_sret(NULL), | |
80 arg_this(NULL), | |
81 arg_nest(NULL), | |
82 arg_arguments(NULL), | |
83 arg_argptr(NULL), | |
84 c_vararg(false), | |
85 reverseParams(false) | |
86 {} | |
87 | |
88 llvm::Value* putRet(Type* dty, DValue* dval); | |
89 llvm::Value* getRet(Type* dty, DValue* dval); | |
90 | |
91 llvm::Value* putParam(Type* dty, int idx, DValue* dval); | |
92 llvm::Value* getParam(Type* dty, int idx, DValue* dval); | |
93 void getParam(Type* dty, int idx, DValue* dval, llvm::Value* lval); | |
94 }; | |
95 | 11 |
96 // represents a function | 12 // represents a function |
97 struct IrFunction : IrBase | 13 struct IrFunction : IrBase |
98 { | 14 { |
99 llvm::Function* func; | 15 llvm::Function* func; |