zxybazh commented on a change in pull request #7809:
URL: https://github.com/apache/tvm/pull/7809#discussion_r617083997



##########
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) {

Review comment:
       Unfortunately if I remove the type conversion I get the following error.
   `tvm/src/target/llvm/intrin_rule_llvm.cc:196:7: note:   cannot convert 
‘<lambda closure object>tvm::codegen::llvm::<lambda(const 
tvm::runtime::TVMArgs&, tvm::runtime::TVMRetValue*)>{}’ (type 
‘tvm::codegen::llvm::<lambda(const tvm::runtime::TVMArgs&, 
tvm::runtime::TVMRetValue*)>’) to type ‘const 
tvm::runtime::TypedPackedFunc<tvm::PrimExpr(tvm::PrimExpr)>&’
        }));`




-- 
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]


Reply via email to