annotate gen/metadata.h @ 1317:4099548c80e0

Allocate objects on the stack if they (a) don't have a destructor, and (b) don't override the delete operator (on top of the regular conditions for stack allocation that also apply to arrays, structs, etc.). The "no destructor" clause is not strictly necessary, but calling them at the right time would be tricky to say the least; it would involve, among other things, "manually" inserting a try-finally block around anything that might throw exceptions not caught in the current function. Note: objects with custom new operators are automatically ignored because they don't use the regular allocation runtime call, so there's no need to pay special attention to them.
author Frits van Bommel <fvbommel wxs.nl>
date Sat, 09 May 2009 00:50:15 +0200
parents 8c65217be813
children c21a6654cce2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1284
5851c18e4c6d Add metadata for TypeInfo -> llvm::Type mapping.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
1 #ifndef LDC_GEN_METADATA_H
5851c18e4c6d Add metadata for TypeInfo -> llvm::Type mapping.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
2 #define LDC_GEN_METADATA_H
5851c18e4c6d Add metadata for TypeInfo -> llvm::Type mapping.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
3
5851c18e4c6d Add metadata for TypeInfo -> llvm::Type mapping.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
4 #include "gen/llvm-version.h"
5851c18e4c6d Add metadata for TypeInfo -> llvm::Type mapping.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
5
5851c18e4c6d Add metadata for TypeInfo -> llvm::Type mapping.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
6 #if LLVM_REV >= 68420
1291
875afb7a93b6 Factor out some constants into the header so producers and consumers of
Frits van Bommel <fvbommel wxs.nl>
parents: 1284
diff changeset
7 // Yay, we have metadata!
875afb7a93b6 Factor out some constants into the header so producers and consumers of
Frits van Bommel <fvbommel wxs.nl>
parents: 1284
diff changeset
8
875afb7a93b6 Factor out some constants into the header so producers and consumers of
Frits van Bommel <fvbommel wxs.nl>
parents: 1284
diff changeset
9 #define USE_METADATA
875afb7a93b6 Factor out some constants into the header so producers and consumers of
Frits van Bommel <fvbommel wxs.nl>
parents: 1284
diff changeset
10 #define METADATA_LINKAGE_TYPE llvm::GlobalValue::WeakODRLinkage
875afb7a93b6 Factor out some constants into the header so producers and consumers of
Frits van Bommel <fvbommel wxs.nl>
parents: 1284
diff changeset
11
875afb7a93b6 Factor out some constants into the header so producers and consumers of
Frits van Bommel <fvbommel wxs.nl>
parents: 1284
diff changeset
12 // *** Metadata for TypeInfo instances ***
875afb7a93b6 Factor out some constants into the header so producers and consumers of
Frits van Bommel <fvbommel wxs.nl>
parents: 1284
diff changeset
13 #define TD_PREFIX "llvm.ldc.typeinfo."
875afb7a93b6 Factor out some constants into the header so producers and consumers of
Frits van Bommel <fvbommel wxs.nl>
parents: 1284
diff changeset
14
875afb7a93b6 Factor out some constants into the header so producers and consumers of
Frits van Bommel <fvbommel wxs.nl>
parents: 1284
diff changeset
15 /// The fields in the metadata node for a TypeInfo instance.
875afb7a93b6 Factor out some constants into the header so producers and consumers of
Frits van Bommel <fvbommel wxs.nl>
parents: 1284
diff changeset
16 /// (Its name will be TD_PREFIX ~ <Name of TypeInfo global>)
875afb7a93b6 Factor out some constants into the header so producers and consumers of
Frits van Bommel <fvbommel wxs.nl>
parents: 1284
diff changeset
17 enum TypeDataFields {
1316
8c65217be813 Work around an LLVM bug by not referring to globals from metadata. This was
Frits van Bommel <fvbommel wxs.nl>
parents: 1291
diff changeset
18 // TD_Confirm is disabled for now due to an LLVM bug when MDNodes contain
8c65217be813 Work around an LLVM bug by not referring to globals from metadata. This was
Frits van Bommel <fvbommel wxs.nl>
parents: 1291
diff changeset
19 // globals (see http://llvm.org/PR4180 / http://llvm.org/PR4046 )
8c65217be813 Work around an LLVM bug by not referring to globals from metadata. This was
Frits van Bommel <fvbommel wxs.nl>
parents: 1291
diff changeset
20 TD_Confirm = -1,/// The TypeInfo this node is for.
8c65217be813 Work around an LLVM bug by not referring to globals from metadata. This was
Frits van Bommel <fvbommel wxs.nl>
parents: 1291
diff changeset
21
1291
875afb7a93b6 Factor out some constants into the header so producers and consumers of
Frits van Bommel <fvbommel wxs.nl>
parents: 1284
diff changeset
22 TD_Type, /// A value of the LLVM type corresponding to this D type
875afb7a93b6 Factor out some constants into the header so producers and consumers of
Frits van Bommel <fvbommel wxs.nl>
parents: 1284
diff changeset
23
875afb7a93b6 Factor out some constants into the header so producers and consumers of
Frits van Bommel <fvbommel wxs.nl>
parents: 1284
diff changeset
24 // Must be kept last:
875afb7a93b6 Factor out some constants into the header so producers and consumers of
Frits van Bommel <fvbommel wxs.nl>
parents: 1284
diff changeset
25 TD_NumFields /// The number of fields in TypeInfo metadata
875afb7a93b6 Factor out some constants into the header so producers and consumers of
Frits van Bommel <fvbommel wxs.nl>
parents: 1284
diff changeset
26 };
875afb7a93b6 Factor out some constants into the header so producers and consumers of
Frits van Bommel <fvbommel wxs.nl>
parents: 1284
diff changeset
27
1317
4099548c80e0 Allocate objects on the stack if they (a) don't have a destructor, and
Frits van Bommel <fvbommel wxs.nl>
parents: 1316
diff changeset
28
4099548c80e0 Allocate objects on the stack if they (a) don't have a destructor, and
Frits van Bommel <fvbommel wxs.nl>
parents: 1316
diff changeset
29 // *** Metadata for ClassInfo instances ***
4099548c80e0 Allocate objects on the stack if they (a) don't have a destructor, and
Frits van Bommel <fvbommel wxs.nl>
parents: 1316
diff changeset
30 #define CD_PREFIX "llvm.ldc.classinfo."
4099548c80e0 Allocate objects on the stack if they (a) don't have a destructor, and
Frits van Bommel <fvbommel wxs.nl>
parents: 1316
diff changeset
31
4099548c80e0 Allocate objects on the stack if they (a) don't have a destructor, and
Frits van Bommel <fvbommel wxs.nl>
parents: 1316
diff changeset
32 /// The fields in the metadata node for a ClassInfo instance.
4099548c80e0 Allocate objects on the stack if they (a) don't have a destructor, and
Frits van Bommel <fvbommel wxs.nl>
parents: 1316
diff changeset
33 /// (Its name will be CD_PREFIX ~ <Name of ClassInfo global>)
4099548c80e0 Allocate objects on the stack if they (a) don't have a destructor, and
Frits van Bommel <fvbommel wxs.nl>
parents: 1316
diff changeset
34 enum ClassDataFields {
4099548c80e0 Allocate objects on the stack if they (a) don't have a destructor, and
Frits van Bommel <fvbommel wxs.nl>
parents: 1316
diff changeset
35 CD_BodyType, /// A value of the LLVM type corresponding to the class body.
4099548c80e0 Allocate objects on the stack if they (a) don't have a destructor, and
Frits van Bommel <fvbommel wxs.nl>
parents: 1316
diff changeset
36 CD_Finalize, /// True if this class (or a base class) has a destructor.
4099548c80e0 Allocate objects on the stack if they (a) don't have a destructor, and
Frits van Bommel <fvbommel wxs.nl>
parents: 1316
diff changeset
37 CD_CustomDelete,/// True if this class has an overridden delete operator.
4099548c80e0 Allocate objects on the stack if they (a) don't have a destructor, and
Frits van Bommel <fvbommel wxs.nl>
parents: 1316
diff changeset
38
4099548c80e0 Allocate objects on the stack if they (a) don't have a destructor, and
Frits van Bommel <fvbommel wxs.nl>
parents: 1316
diff changeset
39 // Must be kept last
4099548c80e0 Allocate objects on the stack if they (a) don't have a destructor, and
Frits van Bommel <fvbommel wxs.nl>
parents: 1316
diff changeset
40 CD_NumFields /// The number of fields in ClassInfo metadata
4099548c80e0 Allocate objects on the stack if they (a) don't have a destructor, and
Frits van Bommel <fvbommel wxs.nl>
parents: 1316
diff changeset
41 };
4099548c80e0 Allocate objects on the stack if they (a) don't have a destructor, and
Frits van Bommel <fvbommel wxs.nl>
parents: 1316
diff changeset
42
1284
5851c18e4c6d Add metadata for TypeInfo -> llvm::Type mapping.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
43 #endif
5851c18e4c6d Add metadata for TypeInfo -> llvm::Type mapping.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
44
5851c18e4c6d Add metadata for TypeInfo -> llvm::Type mapping.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff changeset
45 #endif