Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I probably need to add more tests, and maybe need to improve some things. Still, I wanted to already send this out to get feedback on the general approach here.
The RFC with more discussion is here:
https://llvm.discourse.group/t/rfc-add-a-builtin-complexattr/3316/28
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp | ||
---|---|---|
1944 | nit: Drop trivial braces here. | |
mlir/lib/Dialect/StandardOps/IR/Ops.cpp | ||
1024 | ||
1038 | ||
mlir/lib/IR/BuiltinAttributes.cpp | ||
589 | You shouldn't need vector here, can you not use ArrayRef directly, which supports creation from an initializer list? You might need to explicitly type that values as Attribute. | |
598 | Same here. |
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp | ||
---|---|---|
1946 | I think you also need to check more here, in particular that the two are the same type to form a valid complex? | |
mlir/lib/Dialect/StandardOps/IR/Ops.cpp | ||
1045 | Are the changes around standard constant exercised in a test? | |
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | ||
113 | If you don't intend to support anything else than a complex, more invariants checking is necessary. | |
119 | Can you replace auto with the types here? (except the first one) |
Thanks for the review comments :) And sorry for taking so long to respond. I was busy with some other tasks.
mlir/lib/Dialect/StandardOps/IR/Ops.cpp | ||
---|---|---|
1045 | I had looked around but didn't find tests for valid constants. I have now added tests for complex constants to Standard/ops.mlir. There were already tests for invalid constants in Standard/invalid.mlir, and I added additional tests to cover the new logic. | |
mlir/lib/IR/BuiltinAttributes.cpp | ||
589 | Thanks for the suggestion :) Done. | |
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | ||
113 | So if I understand correctly, most of the checks should be done in the Verifier. Is there another one except LLVM::ConstantOp verifier that I would have to adapt? |
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | ||
---|---|---|
113 | Yes you're right, the verifier will be enough. However the verifier checks an MLIR type: | |
115 | What is this catching/exercising by the way? |
mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h | ||
---|---|---|
335 ↗ | (On Diff #344782) | I have added this to be able to return an error for nested structs. |
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | ||
113 | Good point, I didn't realize that I need to check for LLVMStructType in the verifier. I think I understand a bit better now how the interaction of the verifier and ModuleTranslation is. I hope the code I added makes now more sense :) | |
115 | Yes, that should be an error. But this logic is now also part of the verifier. |
It seems one of the tests I have added triggered an assertion error. I added a check that the FloatAttr has the correct type before calling ConstantFP::get.
Please take another look :)
nit: Drop trivial braces here.