Displaying 20 results from an estimated 34 matches for "getsizeof".
Did you mean:
getsize
2013 Jan 20
0
[LLVMdev] Sizeof a type?
...malloc() to allocate space for it. Can I get the size as an llvm::Constant* (or other llvm::Value*) given an llvm::StructType* or other llvm::Type*?
if you have DataLayout available, use the getTypeAllocSize method. If you don't
have information about the target then you can use ConstantExpr::getSizeOf. The
advantage of DataLayout is that it returns a number (eg: 8) while getSizeOf
returns a mysterious expression (the optimizers will simplify it to a number,
the same as getTypeAllocSize returns, if you provide them with DataLayout).
Ciao, Duncan.
2013 Jan 20
1
[LLVMdev] Sizeof a type?
On Jan 20, 2013, at 3:21 , Duncan Sands <baldrick at free.fr> wrote:
> if you have DataLayout available, use the getTypeAllocSize method. If you don't
> have information about the target then you can use ConstantExpr::getSizeOf. The
> advantage of DataLayout is that it returns a number (eg: 8) while getSizeOf
> returns a mysterious expression (the optimizers will simplify it to a number,
> the same as getTypeAllocSize returns, if you provide them with DataLayout).
Thanks, Duncan. What's the difference betwe...
2013 Jan 20
5
[LLVMdev] Sizeof a type?
Is there a way to get the sizeof a type? Say I've created a struct type without any explicit attribtues, and I want to call malloc() to allocate space for it. Can I get the size as an llvm::Constant* (or other llvm::Value*) given an llvm::StructType* or other llvm::Type*?
TIA,
--
Rick
2010 Nov 09
2
[LLVMdev] Next round of DWARF issues/questions
...;typeClass() == Type::Class ? dwarf::DW_TAG_class_type :
> dwarf::DW_TAG_structure_type,
> dbgCompileUnit_,
> type->typeDefn()->linkageName().c_str(),
> genDIFile(type->typeDefn()),
> getSourceLineNumber(type->typeDefn()->location()),
> getSizeOfInBits(type->irType()),
> getAlignOfInBits(type->irType()),
> getInt64Val(0), 0,
> DIType(),
> dbgFactory_.GetOrCreateArray(members.data(), members.size()));
>
> The 'getSizeOfInBits()' function and the others like it basically call
> llvm::...
2009 Oct 21
1
[LLVMdev] A few more questions about DIFactory and source-level debugging.
...evel debugging docs that line
and column numbers are 1-based, not 0-based. I know that might seem obvious
but it threw me off for a bit.
7) Another thing that confused me for a while is that the debugging APIs all
want size, offset, and alignment values to be in bits, not bytes - but
ConstantExpr::getSizeOf() et al return a size in bytes (which makse sense,
since it behaves like C sizeof). More confusing, however, the comments for
getSizeOf() doesn't say what units its result is in - I automatically
assumed that getSizeOf and DIFactory were compatible. Probably the simplest
thing would be to add...
2009 Sep 23
2
[LLVMdev] DebugFactory
...:getAlignment(const Type * type) {
> // Calculates the alignment of T using "sizeof({i8, T}) - sizeof
> (T)"
> return ConstantExpr::getSub(
> getSize(StructType::get(Type::Int8Ty, type, NULL)),
> getSize(type));
> }
Are ConstantExpr::getAlignOf, getSizeOf, and getOffsetOf what
you're looking for?
Dan
2010 Nov 09
0
[LLVMdev] Next round of DWARF issues/questions
...Type::Class ? dwarf::DW_TAG_class_type : dwarf::DW_TAG_structure_type,
>> dbgCompileUnit_,
>> type->typeDefn()->linkageName().c_str(),
>> genDIFile(type->typeDefn()),
>> getSourceLineNumber(type->typeDefn()->location()),
>> getSizeOfInBits(type->irType()),
>> getAlignOfInBits(type->irType()),
>> getInt64Val(0), 0,
>> DIType(),
>> dbgFactory_.GetOrCreateArray(members.data(), members.size()));
>>
>> The 'getSizeOfInBits()' function and the others like it...
2010 Nov 26
3
[LLVMdev] Next round of DWARF issues/questions
...ass ? dwarf::DW_TAG_class_type :
>> dwarf::DW_TAG_structure_type,
>> dbgCompileUnit_,
>> type->typeDefn()->linkageName().c_str(),
>> genDIFile(type->typeDefn()),
>> getSourceLineNumber(type->typeDefn()->location()),
>> getSizeOfInBits(type->irType()),
>> getAlignOfInBits(type->irType()),
>> getInt64Val(0), 0,
>> DIType(),
>> dbgFactory_.GetOrCreateArray(members.data(), members.size()));
>>
>> The 'getSizeOfInBits()' function and the others like it ba...
2020 Apr 15
2
question on the signature of malloc
...all,
consider the following function from Core.cpp in LLVM 9.0.0:
LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef B, LLVMTypeRef Ty,
const char *Name) {
Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext());
Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty));
AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy);
Instruction* Malloc = CallInst::CreateMalloc(unwrap(B)->GetInsertBlock(),
ITy, unwrap(Ty), AllocSize,
nullptr, nullptr, &quo...
2015 Jan 27
2
[LLVMdev] Create a call to function malloc using LLVM API
...Try to generate LLVM IR for it:
Type *tp = p->getType();
AllocaInst* arg_alloc = builder.CreateAlloca(tp);//builder is IRBuilder
if(tp->isPointerTy()){
Type* tpp = tp->getPointerElementType();
Type* ITy = Type::getInt32Ty(getGlobalContext());
Constant* AllocSize = ConstantExpr::getSizeOf(tpp)
AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy);
CallInst::CreateMalloc(arg_alloc, ITy, tpp, AllocSize);
}
But the generated LLVM IR seems incorrect:
%malloccall = tail call i8* bitcast (i8* (i64)* @malloc to i8* (i32)*)(i32
ptrtoint (i32* getelementptr (i32* null, i32 1) to...
2009 Sep 23
0
[LLVMdev] DebugFactory
...type) {
>> // Calculates the alignment of T using "sizeof({i8, T}) - sizeof(T)"
>> return ConstantExpr::getSub(
>> getSize(StructType::get(Type::Int8Ty, type, NULL)),
>> getSize(type));
>> }
>>
>
> Are ConstantExpr::getAlignOf, getSizeOf, and getOffsetOf what
> you're looking for?
>
> That will work. Now all I need is for the methods of DIFactory to take a
Constant* instead of uint64.
--
-- Talin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-d...
2014 Sep 24
2
[LLVMdev] Runtime alignment
For the size of a type to be calculated at runtime, there is a known trick with gep. Is there any similar trick for determining the alignment of a type at runtime for target-independent IR?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140924/887f8612/attachment.html>
2005 Apr 21
2
[LLVMdev] Geting the size of a structure?
How does LLVM-GCC emit the correct size for structures? Is structure
packing part of the "platform specific" magic that GCC knows, or is
there some "portable" way to put a structure size into LLVM byte code?
Actually, I don't care if it is portable, as long as LLVM has some way
to compute it for me, and I don't have to know about the underlying
platform.
Thanks,
2005 Apr 21
0
[LLVMdev] Geting the size of a structure?
...; there some "portable" way to put a structure size into LLVM byte code?
>
> Actually, I don't care if it is portable, as long as LLVM has some way
> to compute it for me, and I don't have to know about the underlying
> platform.
You may want to look at ConstantExpr::getSizeOf(const Type*)
--
Alkis
2010 Jul 21
1
[LLVMdev] Union type, is it really used or necessary?
On Tue, Jul 20, 2010 at 2:46 PM, Talin <viridia at gmail.com> wrote:
> On Tue, Jul 20, 2010 at 8:34 AM, Chris Lattner <clattner at apple.com> wrote:
>
>>
>> On Jul 20, 2010, at 1:36 AM, Anton Korobeynikov wrote:
>>
>> >> used to make the code manipulating the union type "well typed". This
>> >> approach seems work very well, is
2010 Nov 26
0
[LLVMdev] Next round of DWARF issues/questions
...s_type :
>>> dwarf::DW_TAG_structure_type,
>>> dbgCompileUnit_,
>>> type->typeDefn()->linkageName().c_str(),
>>> genDIFile(type->typeDefn()),
>>> getSourceLineNumber(type->typeDefn()->location()),
>>> getSizeOfInBits(type->irType()),
>>> getAlignOfInBits(type->irType()),
>>> getInt64Val(0), 0,
>>> DIType(),
>>> dbgFactory_.GetOrCreateArray(members.data(), members.size()));
>>>
>>> The 'getSizeOfInBits()' function a...
2010 Nov 07
3
[LLVMdev] Next round of DWARF issues/questions
...ompositeTypeEx(
type->typeClass() == Type::Class ? dwarf::DW_TAG_class_type :
dwarf::DW_TAG_structure_type,
dbgCompileUnit_,
type->typeDefn()->linkageName().c_str(),
genDIFile(type->typeDefn()),
getSourceLineNumber(type->typeDefn()->location()),
getSizeOfInBits(type->irType()),
getAlignOfInBits(type->irType()),
getInt64Val(0), 0,
DIType(),
dbgFactory_.GetOrCreateArray(members.data(), members.size()));
The 'getSizeOfInBits()' function and the others like it basically call
llvm::ConstantExpr::getSizeOf() and then...
2010 Nov 08
0
[LLVMdev] Next round of DWARF issues/questions
...e->typeClass() == Type::Class ? dwarf::DW_TAG_class_type : dwarf::DW_TAG_structure_type,
> dbgCompileUnit_,
> type->typeDefn()->linkageName().c_str(),
> genDIFile(type->typeDefn()),
> getSourceLineNumber(type->typeDefn()->location()),
> getSizeOfInBits(type->irType()),
> getAlignOfInBits(type->irType()),
> getInt64Val(0), 0,
> DIType(),
> dbgFactory_.GetOrCreateArray(members.data(), members.size()));
>
> The 'getSizeOfInBits()' function and the others like it basically call llvm::Con...
2009 Sep 23
2
[LLVMdev] DebugFactory
...; // Calculates the alignment of T using "sizeof({i8, T}) - sizeof(T)"
>>> return ConstantExpr::getSub(
>>> getSize(StructType::get(Type::Int8Ty, type, NULL)),
>>> getSize(type));
>>> }
>>
>> Are ConstantExpr::getAlignOf, getSizeOf, and getOffsetOf what
>> you're looking for?
>>
> That will work. Now all I need is for the methods of DIFactory to take a
> Constant* instead of uint64.
ok. Feel free to add
/// CreateBasicType - Create a basic type like int, float, etc.
DIBasicType CreateBasicType(D...
2011 Feb 04
3
[LLVMdev] ConstantBuilder proposal
...----------------------------------------------------------===//
/// GetAlignOf constant expr - computes the alignment of a type in a
target
/// independent way (Note: the return type is an i64).
static Constant *GetAlignOf(const Type* Ty) {
return ConstantExpr::getAlignOf(Ty);
}
/// GetSizeOf constant expr - computes the (alloc) size of a type (in
/// address-units, not bits) in a target independent way (Note: the return
/// type is an i64).
///
static Constant *GetSizeOf(const Type* Ty) {
return ConstantExpr::getSizeOf(Ty);
}
/// GetOffsetOf constant expr - computes th...