-
Notifications
You must be signed in to change notification settings - Fork 100
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
[CIR] [CodeGen] Introduce IsFPClassOp to support builtin_isfpclass #971
Conversation
✅ With the latest revision this PR passed the C/C++ code formatter. |
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.
One last nit and the rest of this PR LGTM!
Thank you for looking into the issue! Really glad you are offering a hand to tackle builtins and intrinsics. |
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.
I'd like us try to use IntrinsicCallOp instead of introducing new CIR Op.
details below.
#971 (comment)
@ghehg in mlir, we have https://github.com/llvm/llvm-project/blob/bb89988174e5f1a9a419637cadae07e4e8c61c3e/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td#L103-L107 So I think it makes sense to match their structure there and I think a new CIR Op maybe helpful to improve the readability and more expressive. |
@ghehg thanks for the review. I think I see where you come from for the general point of view, but this sounds like a nice abstraction (and it already covers a bunch of other builtins). The level of abstraction that @ChuanqiXu9 picked feels good to me. I'm also a bit confused with your suggestion for using |
Oh, sorry for |
That's exactly my concern that we just move LLVM Ops into CIR, especially given LLVM dialect has dozens of such intrinsic Ops. |
sounds like we think this Op has enough abstraction level to be added into CIR, so let's have it then!
@ghehg The sole purpose of |
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.
LGTM after minor style fix
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.
Good to go once conflict is fixed
Oh boy, I was reviewing/merging in chronological order and you just got bitten by refactoring again! |
I saw the main was force updated. So I have to rebase any way : ) Hope we can work on the real trunk some day : ) |
That's going to be speed up pretty soon, stay tuned! |
) The llvm's intrinsic `llvm.is.fpclass` is used to support multiple float point builtins: https://clang.llvm.org/docs/LanguageExtensions.html#builtin-isfpclass > The `__builtin_isfpclass()` builtin is a generalization of functions > isnan, isinf, isfinite and some others defined by the C standard. It tests > if the floating-point value, specified by the first argument, falls into > any of data classes, specified by the second argument. I meant to support this by creating IntrinsicCallOp directly. But I can't make it due to #480 since the return type of the intrinsic will mismatch. So I have to create a new Op for it. But I feel it might not be too bad. At least it is more explicit and more expressive.
The llvm's intrinsic
llvm.is.fpclass
is used to support multiple float point builtins: https://clang.llvm.org/docs/LanguageExtensions.html#builtin-isfpclassI meant to support this by creating IntrinsicCallOp directly. But I can't make it due to #480 since the return type of the intrinsic will mismatch. So I have to create a new Op for it. But I feel it might not be too bad. At least it is more explicit and more expressive.