Mercurial > projects > ldc
comparison gen/tollvm.c @ 6:35d93ce68cf4 trunk
[svn r10] Updated for LLVM rev. 20070913
Applied fixes from wilsonk on the forum
Some tweaks to work with gc 7.0
Fixed aggregate members of aggregates
Fixed cyclic/recursive class declarations
Other minor tweaks
author | lindquist |
---|---|
date | Wed, 26 Sep 2007 19:05:18 +0200 |
parents | e116aa1488e6 |
children | 5e69b77a5c51 |
comparison
equal
deleted
inserted
replaced
5:3d60e549b0c2 | 6:35d93ce68cf4 |
---|---|
97 } | 97 } |
98 | 98 |
99 case Tclass: { | 99 case Tclass: { |
100 if (t->llvmType == 0) | 100 if (t->llvmType == 0) |
101 { | 101 { |
102 // recursive or cyclic declaration | |
103 if (!gIR->structs.empty()) | |
104 { | |
105 IRStruct* found = 0; | |
106 for (IRState::StructVector::iterator i=gIR->structs.begin(); i!=gIR->structs.end(); ++i) | |
107 { | |
108 if (t == i->type) | |
109 { | |
110 return llvm::PointerType::get(i->recty.get()); | |
111 } | |
112 } | |
113 } | |
114 | |
115 // forward declaration | |
102 TypeClass* tc = (TypeClass*)t; | 116 TypeClass* tc = (TypeClass*)t; |
103 assert(tc->sym); | 117 assert(tc->sym); |
104 if (!tc->sym->llvmInProgress) { | 118 tc->sym->toObjFile(); |
105 tc->sym->toObjFile(); | |
106 } | |
107 else { | |
108 //assert(0 && "circular class referencing"); | |
109 return llvm::OpaqueType::get(); | |
110 } | |
111 } | 119 } |
112 return llvm::PointerType::get(t->llvmType); | 120 return llvm::PointerType::get(t->llvmType); |
113 } | 121 } |
114 | 122 |
115 // functions | 123 // functions |
120 } | 128 } |
121 else { | 129 else { |
122 return t->llvmType; | 130 return t->llvmType; |
123 } | 131 } |
124 } | 132 } |
125 | 133 |
126 // delegates | 134 // delegates |
127 case Tdelegate: | 135 case Tdelegate: |
128 { | 136 { |
129 if (t->llvmType == 0) { | 137 if (t->llvmType == 0) { |
130 return LLVM_DtoDelegateType(t); | 138 return LLVM_DtoDelegateType(t); |
801 else { | 809 else { |
802 Logger::println("unsupported initializer: %s", init->toChars()); | 810 Logger::println("unsupported initializer: %s", init->toChars()); |
803 } | 811 } |
804 return _init; | 812 return _init; |
805 } | 813 } |
814 | |
815 llvm::Value* LLVM_DtoGEP(llvm::Value* ptr, llvm::Value* i0, llvm::Value* i1, const std::string& var, llvm::BasicBlock* bb) | |
816 { | |
817 std::vector<llvm::Value*> v(2); | |
818 v[0] = i0; | |
819 v[1] = i1; | |
820 return new llvm::GetElementPtrInst(ptr, v.begin(), v.end(), var, bb); | |
821 } |