zxybazh commented on a change in pull request #7809:
URL: https://github.com/apache/tvm/pull/7809#discussion_r618637227
##########
File path: src/target/llvm/intrin_rule_llvm.cc
##########
@@ -25,155 +25,175 @@
#include "intrin_rule_llvm.h"
#include <tvm/tir/op.h>
+#include <tvm/tir/op_attr_types.h>
namespace tvm {
namespace codegen {
namespace llvm {
+using tir::FLowerIntrinsic;
-TVM_REGISTER_GLOBAL("tvm.intrin.rule.llvm.prefetch")
- .set_body(DispatchLLVMIntrin<::llvm::Intrinsic::prefetch, 4>);
+TVM_REGISTER_OP("tir.prefetch")
+ .set_attr<FLowerIntrinsic>("llvm.FLowerIntrinsic",
+
PackedFunc(DispatchLLVMIntrin<::llvm::Intrinsic::prefetch, 4>));
-TVM_REGISTER_GLOBAL("tvm.intrin.rule.llvm.exp")
- .set_body(DispatchLLVMPureIntrin<::llvm::Intrinsic::exp, 1>);
+TVM_REGISTER_OP("tir.exp").set_attr<FLowerIntrinsic>(
+ "llvm.FLowerIntrinsic",
PackedFunc(DispatchLLVMPureIntrin<::llvm::Intrinsic::exp, 1>));
-TVM_REGISTER_GLOBAL("tvm.intrin.rule.llvm.exp2")
- .set_body(DispatchLLVMPureIntrin<::llvm::Intrinsic::exp2, 1>);
+TVM_REGISTER_OP("tir.exp2")
+ .set_attr<FLowerIntrinsic>("llvm.FLowerIntrinsic",
+
PackedFunc(DispatchLLVMPureIntrin<::llvm::Intrinsic::exp2, 1>));
// TODO(tvm-team): migrate the legalization transformations as a separate
// set of rules in TIR that can be shared across backends.
-TVM_REGISTER_GLOBAL("tvm.intrin.rule.llvm.exp10")
- .set_body([](const TVMArgs& targs, TVMRetValue* rv) {
- using tir::make_const;
- using tir::make_zero;
+TVM_REGISTER_OP("tir.exp10")
+ .set_attr<FLowerIntrinsic>("llvm.FLowerIntrinsic",
+ PackedFunc([](const TVMArgs& targs,
TVMRetValue* rv) {
+ using tir::make_const;
+ using tir::make_zero;
+ PrimExpr e = targs[0];
Review comment:
It seems that in order to use typed version of `PackedFunc` the
signature of the later function must be exactly the same, i.e., changing
signatures of all functions to `PrimExpr(PrimExpr)`. I think the current
functions are pretty much in good shape and if we want to change the function
type of `FLowerIntrinsic` in the future we don't have to modify the code. What
do you think?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]