comparison gen/functions.cpp @ 1072:802d508f66f1

Ignore the ABI some more for intrinsics
author Frits van Bommel <fvbommel wxs.nl>
date Mon, 09 Mar 2009 03:44:11 +0100
parents dc608dc33081
children 4c20fcc4252b
comparison
equal deleted inserted replaced
1071:7d9957c6350e 1072:802d508f66f1
35 if (type->ir.type != NULL) { 35 if (type->ir.type != NULL) {
36 //assert(f->fty != NULL); 36 //assert(f->fty != NULL);
37 return llvm::cast<llvm::FunctionType>(type->ir.type->get()); 37 return llvm::cast<llvm::FunctionType>(type->ir.type->get());
38 } 38 }
39 39
40 // Tell the ABI we're resolving a new function type 40 if (f->linkage != LINKintrinsic) {
41 gABI->newFunctionType(f); 41 // Tell the ABI we're resolving a new function type
42 gABI->newFunctionType(f);
43 }
42 44
43 // start new ir funcTy 45 // start new ir funcTy
44 f->fty.reset(); 46 f->fty.reset();
45 47
46 // llvm idx counter 48 // llvm idx counter
55 else 57 else
56 { 58 {
57 Type* rt = f->next; 59 Type* rt = f->next;
58 unsigned a = 0; 60 unsigned a = 0;
59 // sret return 61 // sret return
60 if (gABI->returnInArg(f)) 62 if (f->linkage != LINKintrinsic)
61 { 63 if (gABI->returnInArg(f))
62 f->fty.arg_sret = new IrFuncTyArg(rt, true, llvm::Attribute::StructRet); 64 {
63 rt = Type::tvoid; 65 f->fty.arg_sret = new IrFuncTyArg(rt, true, llvm::Attribute::StructRet);
64 lidx++; 66 rt = Type::tvoid;
65 } 67 lidx++;
66 // sext/zext return 68 }
67 else if (unsigned se = DtoShouldExtend(rt)) 69 // sext/zext return
68 { 70 else if (unsigned se = DtoShouldExtend(rt))
69 a = se; 71 {
70 } 72 a = se;
73 }
71 f->fty.ret = new IrFuncTyArg(rt, false, a); 74 f->fty.ret = new IrFuncTyArg(rt, false, a);
72 } 75 }
73 lidx++; 76 lidx++;
74 77
75 // member functions 78 // member functions
143 TypeFunction *ltf = new TypeFunction(NULL, arg->type, 0, LINKd); 146 TypeFunction *ltf = new TypeFunction(NULL, arg->type, 0, LINKd);
144 TypeDelegate *ltd = new TypeDelegate(ltf); 147 TypeDelegate *ltd = new TypeDelegate(ltf);
145 argtype = ltd; 148 argtype = ltd;
146 } 149 }
147 // byval 150 // byval
148 else if (gABI->passByVal(argtype)) 151 else if (f->linkage != LINKintrinsic
152 && gABI->passByVal(argtype))
149 { 153 {
150 if (!byref) a |= llvm::Attribute::ByVal; 154 if (!byref) a |= llvm::Attribute::ByVal;
151 byref = true; 155 byref = true;
152 } 156 }
153 // sext/zext 157 // sext/zext
158 162
159 f->fty.args.push_back(new IrFuncTyArg(argtype, byref, a)); 163 f->fty.args.push_back(new IrFuncTyArg(argtype, byref, a));
160 lidx++; 164 lidx++;
161 } 165 }
162 166
163 // let the abi rewrite the types as necesary 167 if (f->linkage != LINKintrinsic) {
164 gABI->rewriteFunctionType(f); 168 // let the abi rewrite the types as necesary
165 169 gABI->rewriteFunctionType(f);
166 // Tell the ABI we're done with this function type 170
167 gABI->doneWithFunctionType(); 171 // Tell the ABI we're done with this function type
172 gABI->doneWithFunctionType();
173 }
168 174
169 // build the function type 175 // build the function type
170 std::vector<const LLType*> argtypes; 176 std::vector<const LLType*> argtypes;
171 argtypes.reserve(lidx); 177 argtypes.reserve(lidx);
172 178