문제

How do I get the whole name of an operator in LLVM?

I'm iterating through blocks, and then, in each of their instructions, I try to get the operator name, but I do only get a part of it. Running the following code:

virtual bool runOnBasicBlock(BasicBlock &bb) {
    for (auto it(bb.begin()); it != bb.end(); ++it) {
        errs() << it->getName() << '\t' << *it << '\n';
    }
}

I get output lines like:

icmp        %cmp = icmp slt i32 %i.0, %argc
icmp        %cmp1 = icmp sgt i32 %call, %max.0
add       %inc = add nsw i32 %i.0, 1

I'd like to get icmp slt, icmp sgt, and add nsw, instead of icmp and add.

도움이 되었습니까?

해결책

Well, slt, sgt and others for icmp are just arguments. You can access them with getPredicate (a method of CmpInst). Also see the useful function getPredicateText in lib/IR/AsmWriter.cpp.

For stuff like nsw, check out the method hasNoSignedWrap and similar methods.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top