-
Notifications
You must be signed in to change notification settings - Fork 156
[CIR][CIRGen][Builtin] Support __builtin_memcpy_inline #1069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Another potential design here would be to add an |
It is an alternative, and the pro is that we have less CIR Ops and more unified code, another small con is the current Op name of "cir.libc.memcpy" would be confusing as in the case of inline, there should never been a call to lib func. Also, may not be a con necessarily, but |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Direction looks good.
"Note that the size argument must be a compile time constant."
Looks like you sacrificed using an attribute directly to avoid changing CIR_MemCpyOp
? Please use an mlir::IntegerAttr
for the length instead of generating a mlir::cir::ConstantOp
(the PR is explicitly calling into EvaluateKnownConstInt
). You can move the extraClassDeclaration
to only the definitions that make sense. Since you have to touch CIR_MemCpyOp
anyways, please rename it to CIR_MemOp
since in practice it's covering more than memcpys.
Seems like you ignored this and didn't explain why you decided not to reuse the class, just refactor as instructed please, I'd prefer if all of these operations use the same class. |
Sorry for confusion. I wasn't quite sure that you like to use the class, as a big piece of reusing the class is to have commonArgs and push |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thanks for the fast turn-around! LGTM
The test code is from [OG's clang/test/CodeGen/builtins-memcpy-inline.c](https://github.com/llvm/clangir/blob/5f1afad625f1292ffcf02c36402d292c46213c86/clang/test/CodeGen/builtins-memcpy-inline.c#L7) Also, a little design choice when introducing MemCpyInlineOp, I chose to let it inherit CIR_MemCpyOp, so in future when we optimize MemCpy like Ops, we'd have cleaner and more unified code. However, the cost is that during LLVM lowering I'd have to convert the length from ConstOp into IntegerAttr as that's [what LLVM dialect is expecting](https://mlir.llvm.org/docs/Dialects/LLVM/#llvmintrmemcpyinline-llvmmemcpyinlineop)
The test code is from OG's clang/test/CodeGen/builtins-memcpy-inline.c
Also, a little design choice when introducing MemCpyInlineOp, I chose to let it inherit CIR_MemCpyOp, so in future when we optimize MemCpy like Ops, we'd have cleaner and more unified code.
However, the cost is that during LLVM lowering I'd have to convert the length from ConstOp into IntegerAttr as that's what LLVM dialect is expecting