Function that return 'true' if operand is an immediate/constant

Is there any Function in llvm that returns true if the type of an operand in LLVM-IR is an immediate/constant. I am writing a pass and want to find if any of the operand of an instruction is an immediate/constant?
Thanks in anticipation.

You probably want isa<ConstantInt>(Inst->getOperand(i)) or a relative depending on exactly what kinds of constant you’re willing to accept (floating-point? global variable? …).

Take a look at the hierarchy diagram at LLVM: llvm::Constant Class Reference to see what the full list of possibilities is.

1 Like