Wednesday 15 May 2013

how to apply if statement on llvm::value (C++) -



how to apply if statement on llvm::value (C++) -

i trying count number of zeros in register left right. need loop. getting out of loop hard not know how set if statement on llvm::value?

llvm::value* intermediatevalue = llvm::constantint::get(llvm::type::getint32ty(llvm::getglobalcontext()), 1, true); for(int64_t =31; i>=0; i--) { //shifting register right countfirstone = irbuilder->createlshr(llvmregfirstoperand,i,"countfirstonecal"); if(countfirstone == intermediatevalue) { break; } count = count+1; // count has number of zeros }

it looks you're mixing want compiler , want compiled code do. example, loop exists in compiler pass (e.g. compiler run through loop @ compile time) , not in lvm ir. however, creating new llvm ir instructions (left shift) in each of these loop passes , number of loop passes depends on register's value (which isn't known until runtime).

c++ llvm-ir

No comments:

Post a Comment