Mercurial > projects > ldc
comparison gen/typinf.cpp @ 1291:875afb7a93b6
Factor out some constants into the header so producers and consumers of
metadata stay in sync (and are more readable).
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Sat, 02 May 2009 20:42:58 +0200 |
parents | 5851c18e4c6d |
children | 8c65217be813 |
comparison
equal
deleted
inserted
replaced
1290:c86a629f24dd | 1291:875afb7a93b6 |
---|---|
286 | 286 |
287 tid->ir.irGlobal = irg; | 287 tid->ir.irGlobal = irg; |
288 | 288 |
289 #ifdef USE_METADATA | 289 #ifdef USE_METADATA |
290 // Add some metadata for use by optimization passes. | 290 // Add some metadata for use by optimization passes. |
291 static std::string prefix = "llvm.ldc.typeinfo."; | 291 std::string metaname = std::string(TD_PREFIX) + mangle; |
292 std::string metaname = prefix + mangle; | |
293 LLGlobalVariable* meta = gIR->module->getGlobalVariable(metaname); | 292 LLGlobalVariable* meta = gIR->module->getGlobalVariable(metaname); |
294 // Don't generate metadata for non-concrete types | 293 // Don't generate metadata for non-concrete types |
295 // (such as tuple types, slice types, typeof(expr), etc.) | 294 // (such as tuple types, slice types, typeof(expr), etc.) |
296 if (!meta && tid->tinfo->toBasetype()->ty < Terror) { | 295 if (!meta && tid->tinfo->toBasetype()->ty < Terror) { |
297 LLConstant* mdVals[] = { | 296 // Construct the fields |
298 llvm::cast<LLConstant>(irg->value), | 297 LLConstant* mdVals[TD_NumFields]; |
299 llvm::UndefValue::get(DtoType(tid->tinfo)) | 298 mdVals[TD_Confirm] = llvm::cast<LLConstant>(irg->value); |
300 }; | 299 mdVals[TD_Type] = llvm::UndefValue::get(DtoType(tid->tinfo)); |
301 llvm::MDNode* metadata = | 300 // Construct the metadata |
302 llvm::MDNode::get(mdVals, sizeof(mdVals) / sizeof(mdVals[0])); | 301 llvm::MDNode* metadata = llvm::MDNode::get(mdVals, TD_NumFields); |
302 // Insert it into the module | |
303 new llvm::GlobalVariable(metadata->getType(), true, | 303 new llvm::GlobalVariable(metadata->getType(), true, |
304 METADATA_LINKAGE_TYPE, metadata, metaname, gIR->module); | 304 METADATA_LINKAGE_TYPE, metadata, metaname, gIR->module); |
305 } | 305 } |
306 #endif | 306 #endif |
307 | 307 |