criswell at cs.uiuc.edu
Fri Apr 22 08:52:45 PDT 2011
On 4/22/11 10:42 AM, Nabila ABDESSAIED wrote:
>>> i would like to add the value of the size od a basic bloc to this
>>>> global variable
>>>> how to convert the size of a basic bloc to integer?
>>> Size = number of LLVM IR instructions there? If yes, just grab the
>>> number, convert it to ConstantIn and use as an initializer / store to
>> There's a typo in the above sentence. ConstantIn should be ConstantInt.
>> -- John T.
> //i->size() is the nuber of instruction in the bloc i
> hi i tried to convert it to constant but it does'nt work, here what i have done
> const int n= cast<int> (i->size());
> ConstantInt* inValue =& llvm::cast< llvm::ConstantInt>(n); // it does'nt work
> any help?
Look at the doxygen information for the ConstantInt class
(http://llvm.org/doxygen/classllvm_1_1ConstantInt.html). There's a
static get() method to create a ConstantInt given an LLVM integer type
and an integer value.
Note that the type is needed to indicate what type of integer you want.
For example, you could create an 8-bit integer (i8 5) or a 32-bit
integer (i32 5).
-- John T.
More information about the llvm-dev