Mercurial > projects > ldc
annotate gen/metadata.h @ 1419:a6dfd3cb5b99 0.9.1
Error instead of assert on delegate literals as constant expressions.
Make function literal linkage internal inside functions and external otherwise.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Wed, 27 May 2009 19:20:18 +0200 |
parents | 3297edb697eb |
children | c88b16d4a13c |
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 |
1343
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
9 // The metadata interface is still in flux... |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
10 #if LLVM_REV >= 71407 |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
11 // MDNode was moved into its own header, and contains Value*s |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
12 #include "llvm/MDNode.h" |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
13 typedef llvm::Value MDNodeField; |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
14 |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
15 // Use getNumElements() and getElement() to access elements. |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
16 inline unsigned MD_GetNumElements(llvm::MDNode* N) { |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
17 return N->getNumElements(); |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
18 } |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
19 inline MDNodeField* MD_GetElement(llvm::MDNode* N, unsigned i) { |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
20 return N->getElement(i); |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
21 } |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
22 #else |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
23 // MDNode is in Constants.h, and contains Constant*s |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
24 #include "llvm/Constants.h" |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
25 typedef llvm::Constant MDNodeField; |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
26 |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
27 // Use getNumOperands() and getOperand() to access elements. |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
28 inline unsigned MD_GetNumElements(llvm::MDNode* N) { |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
29 return N->getNumOperands(); |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
30 } |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
31 inline MDNodeField* MD_GetElement(llvm::MDNode* N, unsigned i) { |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
32 return N->getOperand(i); |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
33 } |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
34 #endif |
c21a6654cce2
Update for metadata changes in LLVM trunk.
Frits van Bommel <fvbommel wxs.nl>
parents:
1317
diff
changeset
|
35 |
1291
875afb7a93b6
Factor out some constants into the header so producers and consumers of
Frits van Bommel <fvbommel wxs.nl>
parents:
1284
diff
changeset
|
36 #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
|
37 #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
|
38 |
875afb7a93b6
Factor out some constants into the header so producers and consumers of
Frits van Bommel <fvbommel wxs.nl>
parents:
1284
diff
changeset
|
39 // *** 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
|
40 #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
|
41 |
875afb7a93b6
Factor out some constants into the header so producers and consumers of
Frits van Bommel <fvbommel wxs.nl>
parents:
1284
diff
changeset
|
42 /// 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
|
43 /// (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
|
44 enum TypeDataFields { |
1344
3297edb697eb
Re-enable consistency check for fixed LLVM versions.
Frits van Bommel <fvbommel wxs.nl>
parents:
1343
diff
changeset
|
45 #if LLVM_REV < 71407 |
3297edb697eb
Re-enable consistency check for fixed LLVM versions.
Frits van Bommel <fvbommel wxs.nl>
parents:
1343
diff
changeset
|
46 // TD_Confirm is disabled for older revisions due to an LLVM bug when |
3297edb697eb
Re-enable consistency check for fixed LLVM versions.
Frits van Bommel <fvbommel wxs.nl>
parents:
1343
diff
changeset
|
47 // MDNodes contain globals |
3297edb697eb
Re-enable consistency check for fixed LLVM versions.
Frits van Bommel <fvbommel wxs.nl>
parents:
1343
diff
changeset
|
48 // (see http://llvm.org/PR4180 / http://llvm.org/PR4046 ) |
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
|
49 TD_Confirm = -1,/// The TypeInfo this node is for. |
1344
3297edb697eb
Re-enable consistency check for fixed LLVM versions.
Frits van Bommel <fvbommel wxs.nl>
parents:
1343
diff
changeset
|
50 #else |
3297edb697eb
Re-enable consistency check for fixed LLVM versions.
Frits van Bommel <fvbommel wxs.nl>
parents:
1343
diff
changeset
|
51 TD_Confirm, /// The TypeInfo this node is for. |
3297edb697eb
Re-enable consistency check for fixed LLVM versions.
Frits van Bommel <fvbommel wxs.nl>
parents:
1343
diff
changeset
|
52 #endif |
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
|
53 |
1291
875afb7a93b6
Factor out some constants into the header so producers and consumers of
Frits van Bommel <fvbommel wxs.nl>
parents:
1284
diff
changeset
|
54 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
|
55 |
875afb7a93b6
Factor out some constants into the header so producers and consumers of
Frits van Bommel <fvbommel wxs.nl>
parents:
1284
diff
changeset
|
56 // 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
|
57 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
|
58 }; |
875afb7a93b6
Factor out some constants into the header so producers and consumers of
Frits van Bommel <fvbommel wxs.nl>
parents:
1284
diff
changeset
|
59 |
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
|
60 |
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
|
61 // *** 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
|
62 #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
|
63 |
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
|
64 /// 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
|
65 /// (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
|
66 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
|
67 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
|
68 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
|
69 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
|
70 |
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
|
71 // 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
|
72 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
|
73 }; |
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
|
74 |
1284
5851c18e4c6d
Add metadata for TypeInfo -> llvm::Type mapping.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
75 #endif |
5851c18e4c6d
Add metadata for TypeInfo -> llvm::Type mapping.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
76 |
5851c18e4c6d
Add metadata for TypeInfo -> llvm::Type mapping.
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
77 #endif |