annotate gen/structs.h @ 100:5071469303d4 trunk

[svn r104] TONS OF FIXES. Split up declaration, constant initializer gen and definition for globals, structs, classes and functions. Improved ClassInfo support (not complete), not in vtable yet. Fixed a bunch of forward reference problems. Much more. Major commit! :)
author lindquist
date Fri, 16 Nov 2007 08:21:47 +0100
parents 058d3925950e
children 027b8d8b71ec
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
1 #ifndef LLVMD_GEN_STRUCTS_H
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
2 #define LLVMD_GEN_STRUCTS_H
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
3
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
4 struct StructInitializer;
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 88
diff changeset
5
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
6 const llvm::Type* DtoStructType(Type* t);
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 88
diff changeset
7
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
8 llvm::Value* DtoStructZeroInit(llvm::Value* v);
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
9 llvm::Value* DtoStructCopy(llvm::Value* dst, llvm::Value* src);
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 88
diff changeset
10
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
11 llvm::Constant* DtoConstStructInitializer(StructInitializer* si);
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 88
diff changeset
12
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 88
diff changeset
13 /**
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 88
diff changeset
14 * Provides the llvm declaration for a struct
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 88
diff changeset
15 */
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 88
diff changeset
16 void DtoDeclareStruct(StructDeclaration* sd);
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 88
diff changeset
17
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 88
diff changeset
18 /**
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 88
diff changeset
19 * Constructs the constant default initializer a struct
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 88
diff changeset
20 */
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 88
diff changeset
21 void DtoConstInitStruct(StructDeclaration* sd);
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 88
diff changeset
22
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 88
diff changeset
23 /**
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 88
diff changeset
24 * Provides the llvm definition for a struct
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 88
diff changeset
25 */
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 88
diff changeset
26 void DtoDefineStruct(StructDeclaration* sd);
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 88
diff changeset
27
88
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
28 llvm::Value* DtoIndexStruct(llvm::Value* ptr, StructDeclaration* sd, Type* t, unsigned os, std::vector<unsigned>& idxs);
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
29
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
30 struct DUnionField
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
31 {
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
32 unsigned offset;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
33 size_t size;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
34 std::vector<const llvm::Type*> types;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
35 llvm::Constant* init;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
36 size_t initsize;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
37
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
38 DUnionField() {
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
39 offset = 0;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
40 size = 0;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
41 init = NULL;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
42 initsize = 0;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
43 }
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
44 };
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
45
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
46 struct DUnionIdx
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
47 {
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
48 unsigned idx,idxos;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
49 llvm::Constant* c;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
50
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
51 DUnionIdx()
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
52 : idx(0), c(0) {}
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
53 DUnionIdx(unsigned _idx, unsigned _idxos, llvm::Constant* _c)
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
54 : idx(_idx), idxos(_idxos), c(_c) {}
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
55 bool operator<(const DUnionIdx& i) const {
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
56 return (idx < i.idx) || (idx == i.idx && idxos < i.idxos);
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
57 }
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
58 };
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
59
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
60 class DUnion
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
61 {
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
62 std::vector<DUnionField> fields;
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
63 public:
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
64 DUnion();
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
65 llvm::Constant* getConst(std::vector<DUnionIdx>& in);
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
66 };
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
67
058d3925950e [svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
diff changeset
68 #endif