search for: element_iterator

Displaying 11 results from an estimated 11 matches for "element_iterator".

2010 Oct 26
2
[LLVMdev] StructType member offset
Hi, how can i correctly calculate the size of a member of a struct (including alignment etc)? This doesn't work : const StructType *STy = cast<StructType>(Ty); for (StructType::element_iterator I = STy->element_begin(), E = STy->element_end(); I != E; ++I) { usigned size =I->get()->getScalarSizeInBits(); //often returns 0, not what I need } Basically I want to add up the sizes of the different members to calculate the offset (w...
2010 Mar 15
0
[LLVMdev] [patch] Writing ConstantUnions
...case Type::StructTyID: // Get the layout annotation... which is lazily created on demand. return getStructLayout(cast<StructType>(Ty))->getSizeInBits(); + case Type::UnionTyID: { + const UnionType *UnTy = cast<UnionType>(Ty); + uint64_t Size = 0; + for (UnionType::element_iterator i = UnTy->element_begin(), + e = UnTy->element_end(); i != e; ++i) { + Size = std::max(Size, getTypeSizeInBits(*i)); + } + return Size; + } case Type::IntegerTyID: return cast<IntegerType>(Ty)->getBitWidth(); case Type::VoidTyID: @@ -516,6 +525,17 @...
2010 Mar 15
3
[LLVMdev] [patch] Writing ConstantUnions
Hello, I noticed a bit of a gap in the current code for unions: a ConstantUnion cannot be written out to .ll. Hopefully I'm not stepping on Talin's toes by posting this, it's a fairly straightforward adaptation of the code for structs just above. Tim. -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. --------------
2010 Nov 03
0
[LLVMdev] StructType member offset
.... > > > how can i correctly calculate the size of a member of a struct > > (including alignment etc)? > > This doesn't work : > > > > const StructType *STy = cast<StructType>(Ty); > > for (StructType::element_iterator I = STy->element_begin(), > > E = STy->element_end(); I != E; ++I) > > { > > usigned size =I->get()->getScalarSizeInBits(); //often > > returns 0, not what I need > > } > &g...
2010 Jan 09
0
[LLVMdev] [PATCH] - Union types, attempt 2
...duplication of code. +++ lib/Bitcode/Writer/BitcodeWriter.cpp (working copy) ... + case Type::UnionTyID: { + const UnionType *ST = cast<UnionType>(T); + // UNION: [eltty x N] + Code = bitc::TYPE_CODE_UNION; + // Output all of the element types. + for (StructType::element_iterator I = ST->element_begin(), + E = ST->element_end(); I != E; ++I) + TypeVals.push_back(VE.getTypeID(*I)); + AbbrevToUse = UnionAbbrev; + break; + } Please rename ST -> UT and use the right iterator type. I didn't look closely at the C bindings. If you elim...
2010 Jan 06
3
[LLVMdev] [PATCH] - Union types, attempt 2
This patch adds a UnionType to DerivedTypes.h. It also adds code to the bitcode reader / writer and the assembly parser for the new type, as well as a tiny .ll test file in test/Assembler. It does not contain any code related to code generation or type layout - I wanted to see if this much was acceptable before I proceeded any further. Unlike my previous patch, in which the Union type was
2006 Dec 08
0
[LLVMdev] Proposed: first class packed structures
...@@ static void calcTypeName(const Type *Ty, Result += ")"; break; } case Type::StructTyID: { const StructType *STy = cast<StructType>(Ty); + if (STy->isPacked()) + Result += "<"; Result += "{ "; for (StructType::element_iterator I = STy->element_begin(), E = STy->element_end(); I != E; ++I) { if (I != STy->element_begin()) Result += ", "; calcTypeName(*I, TypeStack, TypeNames, Result); } Result += " }"; + if (STy->isPacked()) + Resul...
2010 Oct 26
0
[LLVMdev] llvm-dis fails to parse bytecode emitted by clang
Hi, For the first problem, try clang -S -emit-llvm test.c -o test.ll you should get the llvm IR and you don't need to use llvm-dis. Although I have tried your example with the exact commands and source code you posted and it worked just fine for me. I also use clang and LLVM 2.8 compiled from sources. For the second problem, suppress -emit-llvm, since you want the executable, not an object
2010 Jan 11
2
[LLVMdev] [PATCH] - Union types, attempt 2
...ode/Writer/BitcodeWriter.cpp (working copy) > ... > + case Type::UnionTyID: { > + const UnionType *ST = cast<UnionType>(T); > + // UNION: [eltty x N] > + Code = bitc::TYPE_CODE_UNION; > + // Output all of the element types. > + for (StructType::element_iterator I = ST->element_begin(), > + E = ST->element_end(); I != E; ++I) > + TypeVals.push_back(VE.getTypeID(*I)); > + AbbrevToUse = UnionAbbrev; > + break; > + } > > Please rename ST -> UT and use the right iterator type. > > I didn't l...
2006 Dec 06
4
[LLVMdev] Proposed: first class packed structures
Currently, Structure layout is left to targets, which implement them according to the ABI of that platform. While this is fine for most structures, it makes packed structures very ugly. All fields in a packed type must be converted to byte arrays with casts to access fields, which bloats accesses and obsfucates the types. First class support for packed types would clean up the generated code
2010 Oct 25
5
[LLVMdev] llvm-dis fails to parse bytecode emitted by clang
Hi, I am trying to generate LLVM bytecode using CLANG and I ran into the following problem. If I run clang with the -emit-llvm option and then try to get a textual representation of the output using llvm-dis, the latter crashes because of a failed assertion in BitCodeReader.cpp, mentioning a "Type mismatch in value table" (the exact error message is appended at the end of this email).