comparison ir/irfunction.h @ 1042:45af482e3832

Updated ABI handling to be more flexible with regard to reusing lvalues and allocating fewer temporaries.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Wed, 04 Mar 2009 17:24:25 +0100
parents 9dca7182aa75
children 6bb04dbee21f
comparison
equal deleted inserted replaced
1041:9dca7182aa75 1042:45af482e3832
17 { 17 {
18 /** This is the original D type as the frontend knows it 18 /** This is the original D type as the frontend knows it
19 * May NOT be rewritten!!! */ 19 * May NOT be rewritten!!! */
20 Type* type; 20 Type* type;
21 21
22 /// This is the final LLVM Type used for the parameter/returnvalue type 22 /// This is the final LLVM Type used for the parameter/return value type
23 const llvm::Type* ltype; 23 const llvm::Type* ltype;
24 24
25 /** These are the final llvm attributes needed 25 /** These are the final LLVM attributes used for the function.
26 * must be valid for the LLVM Type and byref setting */ 26 * Must be valid for the LLVM Type and byref setting */
27 unsigned attrs; 27 unsigned attrs;
28 28
29 /** true if the argument final argument is a reference argument 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 30 * Must be true when the D Type is a value type, but the final
31 * LLVM Type is a reference type */ 31 * LLVM Type is a reference type! */
32 bool byref; 32 bool byref;
33 33
34 /** Pointer to the ABIRewrite structure needed to rewrite llvm ValueS 34 /** Pointer to the ABIRewrite structure needed to rewrite LLVM ValueS
35 * to match the final LLVM Type */ 35 * to match the final LLVM Type when passing arguments and getting
36 * return values */
36 ABIRewrite* rewrite; 37 ABIRewrite* rewrite;
37 38
38 /// Helper to check is the 'inreg' attribute is set 39 /// Helper to check if the 'inreg' attribute is set
39 bool isInReg() const { return (attrs & llvm::Attribute::InReg) != 0; } 40 bool isInReg() const { return (attrs & llvm::Attribute::InReg) != 0; }
40 /// Helper to check is the 'sret' attribute is set 41 /// Helper to check if the 'sret' attribute is set
41 bool isSRet() const { return (attrs & llvm::Attribute::StructRet) != 0; } 42 bool isSRet() const { return (attrs & llvm::Attribute::StructRet) != 0; }
42 /// Helper to check is the 'byval' attribute is set 43 /// Helper to check if the 'byval' attribute is set
43 bool isByVal() const { return (attrs & llvm::Attribute::ByVal) != 0; } 44 bool isByVal() const { return (attrs & llvm::Attribute::ByVal) != 0; }
44 45
45 /** Constructor 46 /** @param t D type of argument/return value as known by the frontend
46 * @param t D type of argument/returnvalue as known by the frontend 47 * @param byref Initial value for the 'byref' field. If true the initial
47 * @param byref Initial value for the 'byref' field. If true the initial LLVM Type will be of type->pointerTo() 48 * LLVM Type will be of DtoType(type->pointerTo()), instead
48 */ 49 * of just DtoType(type) */
49 IrFuncTyArg(Type* t, bool byref, unsigned a = 0); 50 IrFuncTyArg(Type* t, bool byref, unsigned a = 0);
50 }; 51 };
51 52
52 // represents a function type 53 // represents a function type
53 struct IrFuncTy : IrBase 54 struct IrFuncTy : IrBase
80 arg_argptr(NULL), 81 arg_argptr(NULL),
81 c_vararg(false), 82 c_vararg(false),
82 reverseParams(false) 83 reverseParams(false)
83 {} 84 {}
84 85
85 llvm::Value* putRet(Type* dty, llvm::Value* val); 86 llvm::Value* putRet(Type* dty, DValue* dval);
86 llvm::Value* getRet(Type* dty, llvm::Value* val); 87 llvm::Value* getRet(Type* dty, DValue* dval);
87 88
88 llvm::Value* getParam(Type* dty, int idx, llvm::Value* val); 89 llvm::Value* putParam(Type* dty, int idx, DValue* dval);
89 llvm::Value* putParam(Type* dty, int idx, llvm::Value* val); 90 llvm::Value* getParam(Type* dty, int idx, DValue* dval);
91 void getParam(Type* dty, int idx, DValue* dval, llvm::Value* lval);
90 }; 92 };
91 93
92 // represents a function 94 // represents a function
93 struct IrFunction : IrBase 95 struct IrFunction : IrBase
94 { 96 {