comparison gen/tollvm.cpp @ 157:5c17f81fc1c1 trunk

[svn r173] moved IR state previously stored in Type into IrType and a Type->IrType map; fixes #7
author ChristianK
date Thu, 01 May 2008 13:32:08 +0200
parents ccd07d9f2ce9
children b77664331d06
comparison
equal deleted inserted replaced
156:ccd07d9f2ce9 157:5c17f81fc1c1
96 case Tvoid: 96 case Tvoid:
97 return llvm::Type::VoidTy; 97 return llvm::Type::VoidTy;
98 98
99 // aggregates 99 // aggregates
100 case Tstruct: { 100 case Tstruct: {
101 if (!t->llvmType || *t->llvmType == NULL) { 101 if (!gIR->irType[t].type || *gIR->irType[t].type == NULL) {
102 // recursive or cyclic declaration 102 // recursive or cyclic declaration
103 if (!gIR->structs.empty()) 103 if (!gIR->structs.empty())
104 { 104 {
105 IrStruct* found = 0; 105 IrStruct* found = 0;
106 for (IRState::StructVector::iterator i=gIR->structs.begin(); i!=gIR->structs.end(); ++i) 106 for (IRState::StructVector::iterator i=gIR->structs.begin(); i!=gIR->structs.end(); ++i)
114 } 114 }
115 115
116 TypeStruct* ts = (TypeStruct*)t; 116 TypeStruct* ts = (TypeStruct*)t;
117 assert(ts->sym); 117 assert(ts->sym);
118 DtoResolveDsymbol(ts->sym); 118 DtoResolveDsymbol(ts->sym);
119 return gIR->irDsymbol[ts->sym].irStruct->recty.get();//t->llvmType->get(); 119 return gIR->irDsymbol[ts->sym].irStruct->recty.get(); // gIR->irType[t].type->get();
120 } 120 }
121 121
122 case Tclass: { 122 case Tclass: {
123 /*if (!t->llvmType || *t->llvmType == NULL) { 123 /*if (!gIR->irType[t].type || *gIR->irType[t].type == NULL) {
124 // recursive or cyclic declaration 124 // recursive or cyclic declaration
125 if (!gIR->structs.empty()) 125 if (!gIR->structs.empty())
126 { 126 {
127 IrStruct* found = 0; 127 IrStruct* found = 0;
128 for (IRState::StructVector::iterator i=gIR->structs.begin(); i!=gIR->structs.end(); ++i) 128 for (IRState::StructVector::iterator i=gIR->structs.begin(); i!=gIR->structs.end(); ++i)
137 }*/ 137 }*/
138 138
139 TypeClass* tc = (TypeClass*)t; 139 TypeClass* tc = (TypeClass*)t;
140 assert(tc->sym); 140 assert(tc->sym);
141 DtoResolveDsymbol(tc->sym); 141 DtoResolveDsymbol(tc->sym);
142 return getPtrToType(gIR->irDsymbol[tc->sym].irStruct->recty.get());//t->llvmType->get()); 142 return getPtrToType(gIR->irDsymbol[tc->sym].irStruct->recty.get()); // gIR->irType[t].type->get());
143 } 143 }
144 144
145 // functions 145 // functions
146 case Tfunction: 146 case Tfunction:
147 { 147 {
148 if (!t->llvmType || *t->llvmType == NULL) { 148 if (!gIR->irType[t].type || *gIR->irType[t].type == NULL) {
149 return DtoFunctionType(t,NULL); 149 return DtoFunctionType(t,NULL);
150 } 150 }
151 else { 151 else {
152 return t->llvmType->get(); 152 return gIR->irType[t].type->get();
153 } 153 }
154 } 154 }
155 155
156 // delegates 156 // delegates
157 case Tdelegate: 157 case Tdelegate:
158 { 158 {
159 if (!t->llvmType || *t->llvmType == NULL) { 159 if (!gIR->irType[t].type || *gIR->irType[t].type == NULL) {
160 return DtoDelegateType(t); 160 return DtoDelegateType(t);
161 } 161 }
162 else { 162 else {
163 return t->llvmType->get(); 163 return gIR->irType[t].type->get();
164 } 164 }
165 } 165 }
166 166
167 // typedefs 167 // typedefs
168 // enum 168 // enum
1795 // build interface info type 1795 // build interface info type
1796 std::vector<const llvm::Type*> types; 1796 std::vector<const llvm::Type*> types;
1797 // ClassInfo classinfo 1797 // ClassInfo classinfo
1798 ClassDeclaration* cd2 = ClassDeclaration::classinfo; 1798 ClassDeclaration* cd2 = ClassDeclaration::classinfo;
1799 DtoResolveClass(cd2); 1799 DtoResolveClass(cd2);
1800 types.push_back(getPtrToType(cd2->type->llvmType->get())); 1800 types.push_back(getPtrToType(gIR->irType[cd2->type].type->get()));
1801 // void*[] vtbl 1801 // void*[] vtbl
1802 std::vector<const llvm::Type*> vtbltypes; 1802 std::vector<const llvm::Type*> vtbltypes;
1803 vtbltypes.push_back(DtoSize_t()); 1803 vtbltypes.push_back(DtoSize_t());
1804 const llvm::Type* byteptrptrty = getPtrToType(getPtrToType(llvm::Type::Int8Ty)); 1804 const llvm::Type* byteptrptrty = getPtrToType(getPtrToType(llvm::Type::Int8Ty));
1805 vtbltypes.push_back(byteptrptrty); 1805 vtbltypes.push_back(byteptrptrty);