On 4/19/11 4:37 PM, Anton Korobeynikov wrote:>> llvm-gcc -O3 -emit-llvm hello.c -c -o hello.bc >> it shows to me i should install llvm-gcc4.5 >> when i have installed llvm-gcc 4.5 i get all the times a wrong bc file >> as output, because when i try to execute it with lli it says to me >> invalid signature. > There is no llvm-gcc 4.5. Report this bug to Ubuntu, because it seems > they hacked the stuff somehow. > >> 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 > variable. >There's a typo in the above sentence. ConstantIn should be ConstantInt. :) -- John T.
>> 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 >> variable. >> > > 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?
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 >>> variable. >>> >> 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.