annotate ir/irtypeclass.h @ 1650:40bd4a0d4870

Update to work with LLVM 2.7. Removed use of dyn_cast, llvm no compiles without exceptions and rtti by default. We do need exceptions for the libconfig stuff, but rtti isn't necessary (anymore). Debug info needs to be rewritten, as in LLVM 2.7 the format has completely changed. To have something to look at while rewriting, the old code has been wrapped inside #ifndef DISABLE_DEBUG_INFO , this means that you have to define this to compile at the moment. Updated tango 0.99.9 patch to include updated EH runtime code, which is needed for LLVM 2.7 as well.
author Tomas Lindquist Olsen
date Wed, 19 May 2010 12:42:32 +0200
parents 465a77c904d4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
1 #ifndef __LDC_IR_IRTYPECLASS_H__
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
2 #define __LDC_IR_IRTYPECLASS_H__
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
3
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
4 #include "ir/irtypestruct.h"
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
5
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
6 ///
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
7 class IrTypeClass : public IrTypeAggr
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
8 {
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
9 public:
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
10 ///
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
11 IrTypeClass(ClassDeclaration* cd);
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
12
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
13 ///
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
14 virtual IrTypeClass* isClass() { return this; }
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
15
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
16 ///
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
17 const llvm::Type* buildType();
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
18
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
19 ///
1230
e67c85d6e680 Completed interface implementation. Hopefully that's it for now..
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
20 const llvm::Type* get();
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
21
1230
e67c85d6e680 Completed interface implementation. Hopefully that's it for now..
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
22 /// Returns the vtable type for this class.
e67c85d6e680 Completed interface implementation. Hopefully that's it for now..
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
23 const llvm::Type* getVtbl() { return vtbl_pa.get(); }
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
24
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
25 /// Get index to interface implementation.
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
26 /// Returns the index of a specific interface implementation in this
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
27 /// class or ~0 if not found.
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
28 size_t getInterfaceIndex(ClassDeclaration* inter);
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
29
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
30 /// Returns the total number of pointers in the vtable.
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
31 unsigned getVtblSize() { return vtbl_size; }
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
32
1230
e67c85d6e680 Completed interface implementation. Hopefully that's it for now..
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
33 /// Returns the number of interface implementations (vtables) in this
e67c85d6e680 Completed interface implementation. Hopefully that's it for now..
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
34 /// class.
e67c85d6e680 Completed interface implementation. Hopefully that's it for now..
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
35 unsigned getNumInterfaceVtbls() { return num_interface_vtbls; }
e67c85d6e680 Completed interface implementation. Hopefully that's it for now..
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
36
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
37 protected:
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
38 ///
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
39 ClassDeclaration* cd;
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
40 ///
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
41 TypeClass* tc;
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
42
1230
e67c85d6e680 Completed interface implementation. Hopefully that's it for now..
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
43 /// Type holder for the vtable type.
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
44 llvm::PATypeHolder vtbl_pa;
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
45
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
46 /// Number of pointers in vtable.
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
47 unsigned vtbl_size;
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
48
1230
e67c85d6e680 Completed interface implementation. Hopefully that's it for now..
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
49 /// Number of interface implementations (vtables) in this class.
e67c85d6e680 Completed interface implementation. Hopefully that's it for now..
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
50 unsigned num_interface_vtbls;
e67c85d6e680 Completed interface implementation. Hopefully that's it for now..
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
51
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
52 /// std::map type mapping ClassDeclaration* to size_t.
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
53 typedef std::map<ClassDeclaration*, size_t> ClassIndexMap;
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
54
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
55 /// Map for mapping the index of a specific interface implementation
1230
e67c85d6e680 Completed interface implementation. Hopefully that's it for now..
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
56 /// in this class to its ClassDeclaration.
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
57 ClassIndexMap interfaceMap;
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
58
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
59 //////////////////////////////////////////////////////////////////////////
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
60
1230
e67c85d6e680 Completed interface implementation. Hopefully that's it for now..
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
61 /// Builds a vtable type given the type of the first entry and an array
e67c85d6e680 Completed interface implementation. Hopefully that's it for now..
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1228
diff changeset
62 /// of all entries.
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
63 const llvm::Type* buildVtblType(Type* first, Array* vtbl_array);
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
64
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
65 ///
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
66 void addBaseClassData(
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
67 std::vector<const llvm::Type*>& defaultTypes,
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
68 ClassDeclaration* base,
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
69 size_t& offset,
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
70 size_t& field_index);
1245
465a77c904d4 Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1230
diff changeset
71
465a77c904d4 Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1230
diff changeset
72 /// Adds the interface and all it's base interface to the interface
465a77c904d4 Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1230
diff changeset
73 /// to index map.
465a77c904d4 Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents: 1230
diff changeset
74 void addInterfaceToMap(ClassDeclaration* inter, size_t index);
1228
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
75 };
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
76
79758fd2f48a Added Doxygen file.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
diff changeset
77 #endif