I am working on LLVM backend and was wondering if there is any way by which I can access the value stored SDValue so I can either assign it as a literal or move it to register in an user defined instruction.
Something like:
SDValue Value = Op->getOperand(2);
intValue = Value.get_integer_value //get Value as an int
and then
if ( intValue > 31)
Thanks,
Ambuj
I am working on LLVM backend and was wondering if there is any way by which I can access the value stored SDValue so I can either assign it as a literal or move it to register in an user defined instruction.
Something like:
SDValue Value = Op->getOperand(2);
intValue = Value.get_integer_value //get Value as an int
and then
if ( intValue > 31)
emit udi 0,0,0,intValue
else
{
emit
load v1,intValue
udi v1,0,0,0
}
Hi Ambuj,
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.