Mercurial > projects > ldc
diff gen/structs.cpp @ 435:74101be2a553
Added type param to DVarValue as DMD sometimes overrides the type of the VarDeclaration.
Added support for align(1)/packed structs, other alignments are still ignored.
Fixed some problems with accessing lazy arguments.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Wed, 30 Jul 2008 10:12:55 +0200 |
parents | f273f5c58a9a |
children | 44f08170f4ef |
line wrap: on
line diff
--- a/gen/structs.cpp Wed Jul 30 09:21:06 2008 +0200 +++ b/gen/structs.cpp Wed Jul 30 10:12:55 2008 +0200 @@ -124,10 +124,14 @@ TypeStruct* ts = (TypeStruct*)DtoDType(sd->type); + bool ispacked = (ts->alignsize() == 1); + IrStruct* irstruct = new IrStruct(ts); sd->ir.irStruct = irstruct; gIR->structs.push_back(irstruct); + irstruct->packed = ispacked; + // fields Array* arr = &sd->fields; for (int k=0; k < arr->dim; k++) { @@ -170,7 +174,7 @@ { Logger::println("has no fields"); fieldtypes.push_back(LLType::Int8Ty); - structtype = llvm::StructType::get(fieldtypes); + structtype = llvm::StructType::get(fieldtypes, ispacked); } else { @@ -239,7 +243,7 @@ } Logger::println("creating struct type"); - structtype = llvm::StructType::get(fieldtypes); + structtype = llvm::StructType::get(fieldtypes, ispacked); } // refine abstract types for stuff like: struct S{S* next;} @@ -329,7 +333,7 @@ } // generate the union mapper - sd->ir.irStruct->dunion = new DUnion; // uses gIR->topstruct() + sd->ir.irStruct->dunion = new DUnion(); // uses gIR->topstruct() // always generate the constant initalizer if (!sd->zeroInit) { @@ -445,6 +449,8 @@ } } + ispacked = topstruct->packed; + /*{ LOG_SCOPE; Logger::println("******** DUnion BEGIN"); @@ -533,7 +539,7 @@ for (size_t i=0; i<nout; ++i) tys.push_back(out[i]->getType()); - const llvm::StructType* st = llvm::StructType::get(tys); + const llvm::StructType* st = llvm::StructType::get(tys, ispacked); return llvm::ConstantStruct::get(st, out); }