comparison ir/irclass.cpp @ 1569:755abafbf25d

Push the context through StructType::get. Requires LLVM >= 78258. Also remove old #if's.
author Benjamin Kramer <benny.kra@gmail.com>
date Thu, 06 Aug 2009 01:47:39 +0200
parents 95d710d405e3
children 8d086d552909
comparison
equal deleted inserted replaced
1568:a591aa6bd6dc 1569:755abafbf25d
3 3
4 #include "aggregate.h" 4 #include "aggregate.h"
5 #include "declaration.h" 5 #include "declaration.h"
6 #include "mtype.h" 6 #include "mtype.h"
7 7
8 #include "gen/llvm-version.h"
9 #include "gen/irstate.h" 8 #include "gen/irstate.h"
10 #include "gen/logger.h" 9 #include "gen/logger.h"
11 #include "gen/tollvm.h" 10 #include "gen/tollvm.h"
12 #include "gen/llvmhelpers.h" 11 #include "gen/llvmhelpers.h"
13 #include "gen/utils.h" 12 #include "gen/utils.h"
85 MDNodeField* mdVals[CD_NumFields]; 84 MDNodeField* mdVals[CD_NumFields];
86 mdVals[CD_BodyType] = llvm::UndefValue::get(bodyType); 85 mdVals[CD_BodyType] = llvm::UndefValue::get(bodyType);
87 mdVals[CD_Finalize] = LLConstantInt::get(LLType::Int1Ty, hasDestructor); 86 mdVals[CD_Finalize] = LLConstantInt::get(LLType::Int1Ty, hasDestructor);
88 mdVals[CD_CustomDelete] = LLConstantInt::get(LLType::Int1Ty, hasCustomDelete); 87 mdVals[CD_CustomDelete] = LLConstantInt::get(LLType::Int1Ty, hasCustomDelete);
89 // Construct the metadata 88 // Construct the metadata
90 #if LLVM_REV < 77733
91 llvm::MetadataBase* metadata = gIR->context().getMDNode(mdVals, CD_NumFields);
92 #else
93 llvm::MetadataBase* metadata = llvm::MDNode::get(gIR->context(), mdVals, CD_NumFields); 89 llvm::MetadataBase* metadata = llvm::MDNode::get(gIR->context(), mdVals, CD_NumFields);
94 #endif
95 // Insert it into the module 90 // Insert it into the module
96 std::string metaname = CD_PREFIX + initname; 91 std::string metaname = CD_PREFIX + initname;
97 llvm::NamedMDNode::Create(metaname, &metadata, 1, gIR->module); 92 llvm::NamedMDNode::Create(metaname, &metadata, 1, gIR->module);
98 } 93 }
99 #endif // USE_METADATA 94 #endif // USE_METADATA
175 } 170 }
176 constants.push_back(c); 171 constants.push_back(c);
177 } 172 }
178 173
179 // build the constant struct 174 // build the constant struct
180 constVtbl = LLConstantStruct::get(constants, false); 175 constVtbl = LLConstantStruct::get(gIR->context(), constants, false);
181 176
182 #if 0 177 #if 0
183 IF_LOG Logger::cout() << "constVtbl type: " << *constVtbl->getType() << std::endl; 178 IF_LOG Logger::cout() << "constVtbl type: " << *constVtbl->getType() << std::endl;
184 IF_LOG Logger::cout() << "vtbl type: " << *type->irtype->isClass()->getVtbl() << std::endl; 179 IF_LOG Logger::cout() << "vtbl type: " << *type->irtype->isClass()->getVtbl() << std::endl;
185 #endif 180 #endif
319 314
320 // add data members recursively 315 // add data members recursively
321 addBaseClassInits(constants, cd, offset, field_index); 316 addBaseClassInits(constants, cd, offset, field_index);
322 317
323 // build the constant 318 // build the constant
324 llvm::Constant* definit = LLConstantStruct::get(constants, false); 319 llvm::Constant* definit = LLConstantStruct::get(gIR->context(), constants, false);
325 320
326 return definit; 321 return definit;
327 } 322 }
328 323
329 ////////////////////////////////////////////////////////////////////////////// 324 //////////////////////////////////////////////////////////////////////////////
387 382
388 constants.push_back(fd->ir.irFunc->func); 383 constants.push_back(fd->ir.irFunc->func);
389 } 384 }
390 385
391 // build the vtbl constant 386 // build the vtbl constant
392 llvm::Constant* vtbl_constant = LLConstantStruct::get(constants, false); 387 llvm::Constant* vtbl_constant = LLConstantStruct::get(gIR->context(), constants, false);
393 388
394 // create the global variable to hold it 389 // create the global variable to hold it
395 llvm::GlobalValue::LinkageTypes _linkage = DtoExternalLinkage(aggrdecl); 390 llvm::GlobalValue::LinkageTypes _linkage = DtoExternalLinkage(aggrdecl);
396 391
397 std::string mangle("_D"); 392 std::string mangle("_D");
486 // offset 481 // offset
487 LLConstant* off = DtoConstSize_t(it->offset); 482 LLConstant* off = DtoConstSize_t(it->offset);
488 483
489 // create Interface struct 484 // create Interface struct
490 LLConstant* inits[3] = { ci, vtb, off }; 485 LLConstant* inits[3] = { ci, vtb, off };
491 LLConstant* entry = LLConstantStruct::get(inits, 3); 486 LLConstant* entry = LLConstantStruct::get(gIR->context(), inits, 3);
492 constants.push_back(entry); 487 constants.push_back(entry);
493 } 488 }
494 489
495 // create Interface[N] 490 // create Interface[N]
496 const llvm::ArrayType* array_type = llvm::ArrayType::get( 491 const llvm::ArrayType* array_type = llvm::ArrayType::get(