Hi Folks.
In my code I need to check constraint on an attribute with respect to another operand. What is the right way to do it?
Below I try to ask with a simple example so it is easier for you to answer concretely. I show how I compare an operand
trait with another operand
s and that works.
But when I try comparing and operand
trait with an attribute value, i cant seem to get that working
class MyDialect_Op<string mnemonic, list<OpTrait> traits = []> :
Op<MyDialect_Dialect, mnemonic, traits>;
class OpBitWidthsMatch<int i, int j> :
CPred<"$_op.getOperand(" # " i # ").getType()....getIntOrFloatBitWidth()==" #
"$_op.getOperand(" # " j # ").getType()...getIntOrFloatBitWidth()"
>;
def Op1 : MyDialect_Op<"Op1",
[NoSideEffect,
PredOpTrait<"my ops operands bit width match", OpBitWidthsMatch<0,1>>
]> {
let summary = "ask mlir forum how to compare operand and attribute";
let arguments = (ins MyType:$src1, MyType:$src2, I32Attr:$myAttr);
}
Above I want to check myAttr
is , say, same as getIntOrFloatBitWidth
returned value. How do i do it elegantly? Using …
Confined<I32Attr, [IntMinValue<5>]:myAttr
… I could check attribute value on itself, but in my case I need to, e.g. compare myAttr
. with operand(0)....getIntOrFloatBitWidth()
.
Thanks