annotate gen/arrays.h @ 1117:4c20fcc4252b

Fun with parameter attributes: For several of the "synthetic" parameters added to D functions, we can apply noalias and nocapture. They are sret parameters, 'nest' pointers passed to nested functions, and _argptr: Nocapture: - Sret and nest are nocapture because they don't represent D-level variables, and thus the callee can't (validly) obtain a pointer to them, let alone keep it around after it returns. - _argptr is nocapture because although the callee has access to it as a pointer, that pointer is invalidated when it returns. All three are noalias because they're function-local variables - Sret and _argptr are noalias because they're freshly alloca'd memory only used for a single function call that's not allowed to keep an aliasing pointer to it around (since the parameter is nocapture). - 'Nest' is noalias because the callee only ever has access to one such pointer per parent function, and every parent function has a different one. This commit also ensures attributes set on sret, _arguments and _argptr are propagated to calls to such functions. It also adds one exception to the general rule that attributes on function types should propagate to calls: the type of a delegate's function pointer has a 'nest' parameter, but this can either be a true 'nest' (for delegates to nested functions) or a 'this' (for delegates to member functions). Since 'this' is neither noalias nor nocapture, and there's generally no way to tell which one it is, we remove these attributes at the call site if the callee is a delegate.
author Frits van Bommel <fvbommel wxs.nl>
date Sat, 14 Mar 2009 22:15:31 +0100
parents 340acf1535d0
children 79758fd2f48a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff changeset
1 #ifndef LLVMC_GEN_ARRAYS_H
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff changeset
2 #define LLVMC_GEN_ARRAYS_H
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff changeset
3
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 81
diff changeset
4 struct DSliceValue;
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 81
diff changeset
5
234
9760f54af0b7 [svn r250] Fixed the warning about dropping arguments to _Dmain when optimizing.
lindquist
parents: 213
diff changeset
6 const llvm::StructType* DtoArrayType(Type* arrayTy);
9760f54af0b7 [svn r250] Fixed the warning about dropping arguments to _Dmain when optimizing.
lindquist
parents: 213
diff changeset
7 const llvm::StructType* DtoArrayType(const LLType* elemTy);
9760f54af0b7 [svn r250] Fixed the warning about dropping arguments to _Dmain when optimizing.
lindquist
parents: 213
diff changeset
8 const llvm::ArrayType* DtoStaticArrayType(Type* sarrayTy);
4
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff changeset
9
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 203
diff changeset
10 LLConstant* DtoConstArrayInitializer(ArrayInitializer* si);
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 203
diff changeset
11 LLConstant* DtoConstSlice(LLConstant* dim, LLConstant* ptr);
34
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 21
diff changeset
12
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 102
diff changeset
13 void DtoArrayCopySlices(DSliceValue* dst, DSliceValue* src);
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 102
diff changeset
14 void DtoArrayCopyToSlice(DSliceValue* dst, DValue* src);
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 81
diff changeset
15
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 308
diff changeset
16 void DtoArrayInit(Loc& loc, DValue* array, DValue* value);
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 203
diff changeset
17 void DtoArrayAssign(LLValue* l, LLValue* r);
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 203
diff changeset
18 void DtoSetArray(LLValue* arr, LLValue* dim, LLValue* ptr);
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 203
diff changeset
19 void DtoSetArrayToNull(LLValue* v);
4
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff changeset
20
591
e6bcc4d9e5ff Add _d_newarrayvT and _d_newarraymvT to create arrays without initialization.
Christian Kamm <kamm incasoftware de>
parents: 442
diff changeset
21 DSliceValue* DtoNewDynArray(Loc& loc, Type* arrayType, DValue* dim, bool defaultInit=true);
e6bcc4d9e5ff Add _d_newarrayvT and _d_newarraymvT to create arrays without initialization.
Christian Kamm <kamm incasoftware de>
parents: 442
diff changeset
22 DSliceValue* DtoNewMulDimDynArray(Loc& loc, Type* arrayType, DValue** dims, size_t ndims, bool defaultInit=true);
203
e881c9b1c738 [svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents: 132
diff changeset
23 DSliceValue* DtoResizeDynArray(Type* arrayType, DValue* array, DValue* newdim);
21
8d45266bbabe [svn r25] * Fixed a lot of problems with string literals
lindquist
parents: 11
diff changeset
24
203
e881c9b1c738 [svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents: 132
diff changeset
25 DSliceValue* DtoCatAssignElement(DValue* arr, Expression* exp);
e881c9b1c738 [svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents: 132
diff changeset
26 DSliceValue* DtoCatAssignArray(DValue* arr, Expression* exp);
e881c9b1c738 [svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents: 132
diff changeset
27 DSliceValue* DtoCatArrays(Type* type, Expression* e1, Expression* e2);
e881c9b1c738 [svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents: 132
diff changeset
28 DSliceValue* DtoCatArrayElement(Type* type, Expression* exp1, Expression* exp2);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
29
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 203
diff changeset
30 void DtoStaticArrayCopy(LLValue* dst, LLValue* src);
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 48
diff changeset
31
424
c8d98ccad0cc Error if static array is cast to an array such that oldarraysize % newelemsize != 0.
Christian Kamm <kamm incasoftware de>
parents: 399
diff changeset
32 LLValue* DtoArrayEquals(Loc& loc, TOK op, DValue* l, DValue* r);
c8d98ccad0cc Error if static array is cast to an array such that oldarraysize % newelemsize != 0.
Christian Kamm <kamm incasoftware de>
parents: 399
diff changeset
33 LLValue* DtoArrayCompare(Loc& loc, TOK op, DValue* l, DValue* r);
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 52
diff changeset
34
308
6b62e8cdf970 [svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents: 295
diff changeset
35 LLValue* DtoDynArrayIs(TOK op, DValue* l, DValue* r);
52
0c77619e803b [svn r56] Initial support for TypeInfo.
lindquist
parents: 48
diff changeset
36
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 234
diff changeset
37 LLValue* DtoArrayCastLength(LLValue* len, const LLType* elemty, const LLType* newelemty);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
38
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 203
diff changeset
39 LLValue* DtoArrayLen(DValue* v);
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 203
diff changeset
40 LLValue* DtoArrayPtr(DValue* v);
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 81
diff changeset
41
424
c8d98ccad0cc Error if static array is cast to an array such that oldarraysize % newelemsize != 0.
Christian Kamm <kamm incasoftware de>
parents: 399
diff changeset
42 DValue* DtoCastArray(Loc& loc, DValue* val, Type* to);
102
027b8d8b71ec [svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents: 99
diff changeset
43
442
76078c8ab5b9 Move DtoArrayBoundsCheck from llvmhelpers to arrays.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
44 // generates an array bounds check
76078c8ab5b9 Move DtoArrayBoundsCheck from llvmhelpers to arrays.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
45 void DtoArrayBoundsCheck(Loc& loc, DValue* arr, DValue* index, bool isslice);
76078c8ab5b9 Move DtoArrayBoundsCheck from llvmhelpers to arrays.
Christian Kamm <kamm incasoftware de>
parents: 424
diff changeset
46
4
e116aa1488e6 [svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
diff changeset
47 #endif // LLVMC_GEN_ARRAYS_H