[LLVMdev] LLVM Backend

Tim Northover t.p.northover at gmail.com
Mon Feb 16 09:22:34 PST 2015


Hi Ambuj,

On 16 February 2015 at 08:19, Ambuj Agrawal <ambujbwt at gmail.com> wrote:
> SDValue Value   = Op->getOperand(2);
>
> intValue = Value.get_integer_value  //get Value as an int

If you know for some reason that it actually is a constant, you can
write "Op->getConstantOperandVal(2)". If not, you obviously have to
check that before trying to get the value. The usual idiom is
something like:

    uint64_t IntVal = -1;
    if (auto *CN = dyn_cast<ConstantSDNode>(Value))
      IntVal = CN->getZExtValue(); // Or some other accessor.

Cheers.

Tim.



More information about the llvm-dev mailing list