[MLIR][PDL] Allow `pdl_interp.apply_rewrite` to return null attribute (#228456)
If an attribute is null, `executeCreateOperation` will not add that
attribute:
```cpp
// void ByteCodeExecutor::executeCreateOperation(PatternRewriter &rewriter, ...
for (unsigned i = 0, e = read(); i != e; ++i) {
StringAttr name = read<StringAttr>();
if (Attribute attr = read<Attribute>())
state.addAttribute(name, attr);
}
```
This is desired, as it gives user-defined rewrites the ability to make
the attribute they return "optional".
However, when assertions are enabled, such a null attribute currently
triggers an assertion in `processNativeFunResults`. This is a bug and is
solved by implementing casting for `PDLValue` and using
`llvm::dyn_cast_if_present` on the attribute instead.
This issue also shows up in the C API and is solved similarly by using
`llvm::dyn_cast_if_present`.
Assisted-by: Claude Code (Claude Opus 5.5).