comparison ir/irclass.cpp @ 1554:d6e8d5db259f

LLVMContext changes up to r77366
author Benjamin Kramer <benny.kra@gmail.com>
date Thu, 30 Jul 2009 15:25:10 +0200
parents 7fcb72d518f6
children ed0cffe895ec
comparison
equal deleted inserted replaced
1553:f55ca8a1598c 1554:d6e8d5db259f
80 bool hasDestructor = (classdecl->dtor != NULL); 80 bool hasDestructor = (classdecl->dtor != NULL);
81 bool hasCustomDelete = (classdecl->aggDelete != NULL); 81 bool hasCustomDelete = (classdecl->aggDelete != NULL);
82 // Construct the fields 82 // Construct the fields
83 MDNodeField* mdVals[CD_NumFields]; 83 MDNodeField* mdVals[CD_NumFields];
84 mdVals[CD_BodyType] = llvm::UndefValue::get(bodyType); 84 mdVals[CD_BodyType] = llvm::UndefValue::get(bodyType);
85 mdVals[CD_Finalize] = gIR->context().getConstantInt(LLType::Int1Ty, hasDestructor); 85 mdVals[CD_Finalize] = LLConstantInt::get(LLType::Int1Ty, hasDestructor);
86 mdVals[CD_CustomDelete] = gIR->context().getConstantInt(LLType::Int1Ty, hasCustomDelete); 86 mdVals[CD_CustomDelete] = LLConstantInt::get(LLType::Int1Ty, hasCustomDelete);
87 // Construct the metadata 87 // Construct the metadata
88 llvm::MDNode* metadata = gIR->context().getMDNode(mdVals, CD_NumFields); 88 llvm::MDNode* metadata = gIR->context().getMDNode(mdVals, CD_NumFields);
89 // Insert it into the module 89 // Insert it into the module
90 new llvm::GlobalVariable(*gIR->module, metadata->getType(), true, 90 new llvm::GlobalVariable(*gIR->module, metadata->getType(), true,
91 METADATA_LINKAGE_TYPE, metadata, CD_PREFIX + initname); 91 METADATA_LINKAGE_TYPE, metadata, CD_PREFIX + initname);
168 } 168 }
169 constants.push_back(c); 169 constants.push_back(c);
170 } 170 }
171 171
172 // build the constant struct 172 // build the constant struct
173 constVtbl = gIR->context().getConstantStruct(constants, false); 173 constVtbl = LLConstantStruct::get(constants, false);
174 174
175 #if 0 175 #if 0
176 IF_LOG Logger::cout() << "constVtbl type: " << *constVtbl->getType() << std::endl; 176 IF_LOG Logger::cout() << "constVtbl type: " << *constVtbl->getType() << std::endl;
177 IF_LOG Logger::cout() << "vtbl type: " << *type->irtype->isClass()->getVtbl() << std::endl; 177 IF_LOG Logger::cout() << "vtbl type: " << *type->irtype->isClass()->getVtbl() << std::endl;
178 #endif 178 #endif
312 312
313 // add data members recursively 313 // add data members recursively
314 addBaseClassInits(constants, cd, offset, field_index); 314 addBaseClassInits(constants, cd, offset, field_index);
315 315
316 // build the constant 316 // build the constant
317 llvm::Constant* definit = gIR->context().getConstantStruct(constants, false); 317 llvm::Constant* definit = LLConstantStruct::get(constants, false);
318 318
319 return definit; 319 return definit;
320 } 320 }
321 321
322 ////////////////////////////////////////////////////////////////////////////// 322 //////////////////////////////////////////////////////////////////////////////
380 380
381 constants.push_back(fd->ir.irFunc->func); 381 constants.push_back(fd->ir.irFunc->func);
382 } 382 }
383 383
384 // build the vtbl constant 384 // build the vtbl constant
385 llvm::Constant* vtbl_constant = gIR->context().getConstantStruct(constants, false); 385 llvm::Constant* vtbl_constant = LLConstantStruct::get(constants, false);
386 386
387 // create the global variable to hold it 387 // create the global variable to hold it
388 llvm::GlobalValue::LinkageTypes _linkage = DtoExternalLinkage(aggrdecl); 388 llvm::GlobalValue::LinkageTypes _linkage = DtoExternalLinkage(aggrdecl);
389 389
390 std::string mangle("_D"); 390 std::string mangle("_D");
479 // offset 479 // offset
480 LLConstant* off = DtoConstSize_t(it->offset); 480 LLConstant* off = DtoConstSize_t(it->offset);
481 481
482 // create Interface struct 482 // create Interface struct
483 LLConstant* inits[3] = { ci, vtb, off }; 483 LLConstant* inits[3] = { ci, vtb, off };
484 LLConstant* entry = gIR->context().getConstantStruct(inits, 3); 484 LLConstant* entry = LLConstantStruct::get(inits, 3);
485 constants.push_back(entry); 485 constants.push_back(entry);
486 } 486 }
487 487
488 // create Interface[N] 488 // create Interface[N]
489 const llvm::ArrayType* array_type = llvm::ArrayType::get( 489 const llvm::ArrayType* array_type = llvm::ArrayType::get(
490 constants[0]->getType(), 490 constants[0]->getType(),
491 n); 491 n);
492 492
493 LLConstant* arr = gIR->context().getConstantArray( 493 LLConstant* arr = LLConstantArray::get(
494 array_type, 494 array_type,
495 &constants[0], 495 &constants[0],
496 n); 496 n);
497 497
498 // apply the initializer 498 // apply the initializer