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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to