How to iterate through Operators in LLVM IR instruction


How to iterate through Operators in LLVM IR instruction



I have the following llvm instruction:


%or = or i32 shl (i32 1, i32 urem (i32 ptrtoint ([4 x %struct.my_struct1]* getelementptr inbounds (%struct.my_struct2, %struct.my_struct3* null, i32 0, i32 18, i32 48, i32 3) to i32), i32 32)), %add, !dbg !278709



And I need to iterate over all of the operators.



1) Is there a pass (or a flag for clang) which can spilt this instruction?



2) how do I iterate over these operators in a simple way?



Thanks





Doesn't for(auto & i : x->getParent()->getInstList()) { ... } do what you want? Or if you want to use names and separate lines per instruction, ...{ i.setName("foo" + utostr(n++)); }.
– arnt
Jul 2 at 7:03


for(auto & i : x->getParent()->getInstList()) { ... }


...{ i.setName("foo" + utostr(n++)); }





I dont think so, since llvm recognize only %or as an instruction while the other operators are not.
– ldana
Jul 2 at 10:02









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

How to add background colour in existing image using Swift?

Moria Casán

How to make file upload 'Required' in Contact Form 7?