Mercurial > projects > ldc
comparison gen/structs.h @ 88:058d3925950e trunk
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
author | lindquist |
---|---|
date | Tue, 06 Nov 2007 10:03:14 +0100 |
parents | |
children | 5071469303d4 |
comparison
equal
deleted
inserted
replaced
87:25d4fcce53f4 | 88:058d3925950e |
---|---|
1 #ifndef LLVMD_GEN_STRUCTS_H | |
2 #define LLVMD_GEN_STRUCTS_H | |
3 | |
4 struct StructInitializer; | |
5 const llvm::Type* DtoStructType(Type* t); | |
6 llvm::Value* DtoStructZeroInit(llvm::Value* v); | |
7 llvm::Value* DtoStructCopy(llvm::Value* dst, llvm::Value* src); | |
8 llvm::Constant* DtoConstStructInitializer(StructInitializer* si); | |
9 llvm::Value* DtoIndexStruct(llvm::Value* ptr, StructDeclaration* sd, Type* t, unsigned os, std::vector<unsigned>& idxs); | |
10 | |
11 struct DUnionField | |
12 { | |
13 unsigned offset; | |
14 size_t size; | |
15 std::vector<const llvm::Type*> types; | |
16 llvm::Constant* init; | |
17 size_t initsize; | |
18 | |
19 DUnionField() { | |
20 offset = 0; | |
21 size = 0; | |
22 init = NULL; | |
23 initsize = 0; | |
24 } | |
25 }; | |
26 | |
27 struct DUnionIdx | |
28 { | |
29 unsigned idx,idxos; | |
30 llvm::Constant* c; | |
31 | |
32 DUnionIdx() | |
33 : idx(0), c(0) {} | |
34 DUnionIdx(unsigned _idx, unsigned _idxos, llvm::Constant* _c) | |
35 : idx(_idx), idxos(_idxos), c(_c) {} | |
36 bool operator<(const DUnionIdx& i) const { | |
37 return (idx < i.idx) || (idx == i.idx && idxos < i.idxos); | |
38 } | |
39 }; | |
40 | |
41 class DUnion | |
42 { | |
43 std::vector<DUnionField> fields; | |
44 public: | |
45 DUnion(); | |
46 llvm::Constant* getConst(std::vector<DUnionIdx>& in); | |
47 }; | |
48 | |
49 #endif |