-
Notifications
You must be signed in to change notification settings - Fork 98
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][LLVMLowering] Add LLVM lowering for unary fp2fp builtins #651
Conversation
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.
Awesome! Some inline comments.
@@ -713,7 +803,8 @@ void LoweringPreparePass::runOnOperation() { | |||
op->walk([&](Operation *op) { | |||
if (isa<CmpThreeWayOp, VAArgOp, GlobalOp, DynamicCastOp, StdFindOp, | |||
IterEndOp, IterBeginOp, ArrayCtor, ArrayDtor, mlir::cir::FuncOp, | |||
FModOp, PowOp>(op)) | |||
CosOp, ExpOp, Exp2Op, LogOp, Log10Op, Log2Op, SinOp, SqrtOp, FModOp, | |||
PowOp>(op)) |
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.
The chain of if
s is getting a bit bigger in runOnOp
. How about:
- We track these in another small vec
mathOpsToTransform
. runOnOp
calls only one function to handle them. Instead of this function dispatching to manylowerUnaryFPToFPBuiltinOp
calls, it could do a table lookup to pick the strings:{ {"cosf", "cos", "cosl"}, .... }
, etc.
This should help us pave the road for some later tablegen based approach.
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.
Great! Implemented this refactor.
This patch adds LLVM lowering support for unary fp2fp builtins. Those builtins that should be lowered to runtime function calls are lowered to such calls during lowering prepare. Other builtins are lowered to LLVM intrinsic calls during LLVM lowering.
ae75a19
to
fb635c8
Compare
LLVM lowering for the following operations is introduced in llvm#616 and llvm#651: cos, exp, exp2, log, log10, log2, sin, sqrt, fmod, and pow. However, they are not lowered to their corresponding LLVM intrinsics; instead they are transformed to libc calls during lowering prepare. This does not match the upstream behavior. This patch tries to correct this mistake.
LLVM lowering for the following operations is introduced in llvm#616 and llvm#651: cos, exp, exp2, log, log10, log2, sin, sqrt, fmod, and pow. However, they are not lowered to their corresponding LLVM intrinsics; instead they are transformed to libc calls during lowering prepare. This does not match the upstream behavior. This patch tries to correct this mistake.
LLVM lowering for the following operations is introduced in llvm#616 and llvm#651: cos, exp, exp2, log, log10, log2, sin, sqrt, fmod, and pow. However, they are not lowered to their corresponding LLVM intrinsics; instead they are transformed to libc calls during lowering prepare. This does not match the upstream behavior. This patch tries to correct this mistake.
LLVM lowering for the following operations is introduced in llvm#616 and llvm#651: cos, exp, exp2, log, log10, log2, sin, sqrt, fmod, and pow. However, they are not lowered to their corresponding LLVM intrinsics; instead they are transformed to libc calls during lowering prepare. This does not match the upstream behavior. This patch tries to correct this mistake.
LLVM lowering for the following operations is introduced in #616 and #651: `cos`, `exp`, `exp2`, `log`, `log10`, `log2`, `sin`, `sqrt`, `fmod`, and `pow`. However, they are not lowered to their corresponding LLVM intrinsics; instead they are transformed to libc calls during lowering prepare. This does not match the upstream behavior. This PR tries to correct this mistake. It makes all CIR FP intrinsic ops lower to their corresponding LLVM intrinsics (`fmod` is a special case and it is lowered to the `frem` LLVM instruction).
LLVM lowering for the following operations is introduced in llvm#616 and llvm#651: `cos`, `exp`, `exp2`, `log`, `log10`, `log2`, `sin`, `sqrt`, `fmod`, and `pow`. However, they are not lowered to their corresponding LLVM intrinsics; instead they are transformed to libc calls during lowering prepare. This does not match the upstream behavior. This PR tries to correct this mistake. It makes all CIR FP intrinsic ops lower to their corresponding LLVM intrinsics (`fmod` is a special case and it is lowered to the `frem` LLVM instruction).
LLVM lowering for the following operations is introduced in llvm#616 and llvm#651: `cos`, `exp`, `exp2`, `log`, `log10`, `log2`, `sin`, `sqrt`, `fmod`, and `pow`. However, they are not lowered to their corresponding LLVM intrinsics; instead they are transformed to libc calls during lowering prepare. This does not match the upstream behavior. This PR tries to correct this mistake. It makes all CIR FP intrinsic ops lower to their corresponding LLVM intrinsics (`fmod` is a special case and it is lowered to the `frem` LLVM instruction).
LLVM lowering for the following operations is introduced in llvm#616 and llvm#651: `cos`, `exp`, `exp2`, `log`, `log10`, `log2`, `sin`, `sqrt`, `fmod`, and `pow`. However, they are not lowered to their corresponding LLVM intrinsics; instead they are transformed to libc calls during lowering prepare. This does not match the upstream behavior. This PR tries to correct this mistake. It makes all CIR FP intrinsic ops lower to their corresponding LLVM intrinsics (`fmod` is a special case and it is lowered to the `frem` LLVM instruction).
LLVM lowering for the following operations is introduced in llvm#616 and llvm#651: `cos`, `exp`, `exp2`, `log`, `log10`, `log2`, `sin`, `sqrt`, `fmod`, and `pow`. However, they are not lowered to their corresponding LLVM intrinsics; instead they are transformed to libc calls during lowering prepare. This does not match the upstream behavior. This PR tries to correct this mistake. It makes all CIR FP intrinsic ops lower to their corresponding LLVM intrinsics (`fmod` is a special case and it is lowered to the `frem` LLVM instruction).
This patch adds LLVM lowering support for unary fp2fp builtins. Those builtins that should be lowered to runtime function calls are lowered to such calls during lowering prepare. Other builtins are lowered to LLVM intrinsic calls during LLVM lowering.
LLVM lowering for the following operations is introduced in #616 and #651: `cos`, `exp`, `exp2`, `log`, `log10`, `log2`, `sin`, `sqrt`, `fmod`, and `pow`. However, they are not lowered to their corresponding LLVM intrinsics; instead they are transformed to libc calls during lowering prepare. This does not match the upstream behavior. This PR tries to correct this mistake. It makes all CIR FP intrinsic ops lower to their corresponding LLVM intrinsics (`fmod` is a special case and it is lowered to the `frem` LLVM instruction).
This patch adds LLVM lowering support for unary fp2fp builtins.
Those builtins that should be lowered to runtime function calls are lowered to such calls during lowering prepare. Other builtins are lowered to LLVM intrinsic calls during LLVM lowering.