Displaying 12 results from an estimated 12 matches for "element_end".
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 (which I want to compare to
DIType::getOffsetInBits()). Or if there is...
2010 Mar 15
0
[LLVMdev] [patch] Writing ConstantUnions
...y 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 @@
unsigned Align = getAlignmentInfo(AGGREGATE_ALIGN, 0, abi_or_p...
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
...> (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
&g...
2010 Jan 09
0
[LLVMdev] [PATCH] - Union types, attempt 2
...king 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 eliminate empty unions they should get a bit simpler.
Otherwise th...
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
...t;;
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())
+ Result += ">";
break;
Please use '>' in...
2019 Apr 19
2
Question: How to access c++ vtable pointer to use as Value* in LLVM pass
...ructors
and its API is straightforward while I can't find the similar API
calls in the LLVM counter part.
So far I am able to get the class object itself from a loadInst or
CallInst and I can iterate through the StructType, and the structs
"Types" contained within via element_begin()/element_end() to confirm
what I am looking at is the object. e.g.:
i32 (...)*** (this is how vtable is represented according to online
sources as a generic pointer)
i32 (class member in this case an int)
But this doesn't give me a Value* handle i can grab to and use later.
How can I lever...
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
...: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 eliminate empty unions
> t...
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).