You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/01/18 19:28:57 UTC

[GitHub] [tvm] tkonolige opened a new pull request #9964: [LLVM,TIR] Print LLVM intrinsic names instead of ids

tkonolige opened a new pull request #9964:
URL: https://github.com/apache/tvm/pull/9964


   This makes it much easy to understand what is happening with llvm intrinsics.
   
   @masahi 
   


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

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] masahi merged pull request #9964: [LLVM,TIR] Print LLVM intrinsic names instead of ids

Posted by GitBox <gi...@apache.org>.
masahi merged pull request #9964:
URL: https://github.com/apache/tvm/pull/9964


   


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

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] kparzysz-quic commented on a change in pull request #9964: [LLVM,TIR] Print LLVM intrinsic names instead of ids

Posted by GitBox <gi...@apache.org>.
kparzysz-quic commented on a change in pull request #9964:
URL: https://github.com/apache/tvm/pull/9964#discussion_r787242043



##########
File path: src/target/llvm/llvm_module.cc
##########
@@ -485,6 +485,11 @@ TVM_REGISTER_GLOBAL("target.llvm_lookup_intrinsic_id")
       return static_cast<int64_t>(llvm::Function::lookupIntrinsicID(name));
     });
 
+TVM_REGISTER_GLOBAL("target.llvm_get_intrinsic_name")
+    .set_body_typed([](int64_t id) -> String {
+      return std::string(llvm::Intrinsic::getName(static_cast<llvm::Intrinsic::ID>(id)));

Review comment:
       The function `getName` is overloaded, and the version that only takes the intrinsic id will not work with overloaded LLVM intrinsics (such as `llvm.ctpop.i32`).  With the newer LLVM it's better to use `getBaseName`, but that function was only added in LLVM13.  In the older LLVMs, this function has changed several times, so you may need to add specific #if's for different versions.  You can check for overloading with `isOverloaded`.  To get the exact overloaded name, you'd need to generate the LLVM types for the arguments, so that may be too involved for just printing the TIR.




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

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] tkonolige commented on a change in pull request #9964: [LLVM,TIR] Print LLVM intrinsic names instead of ids

Posted by GitBox <gi...@apache.org>.
tkonolige commented on a change in pull request #9964:
URL: https://github.com/apache/tvm/pull/9964#discussion_r789225710



##########
File path: src/target/llvm/llvm_module.cc
##########
@@ -485,6 +485,11 @@ TVM_REGISTER_GLOBAL("target.llvm_lookup_intrinsic_id")
       return static_cast<int64_t>(llvm::Function::lookupIntrinsicID(name));
     });
 
+TVM_REGISTER_GLOBAL("target.llvm_get_intrinsic_name")
+    .set_body_typed([](int64_t id) -> String {
+      return std::string(llvm::Intrinsic::getName(static_cast<llvm::Intrinsic::ID>(id)));

Review comment:
       I've switched to using `getBaseName` when llvm >= 13. On lower versions of llvm I still use `getName`, but I use the overloaded types version. When provided with an empty array of types, this version will return the generic name which I think is what we want.




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

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org