kparzysz-quic commented on code in PR #14568:
URL: https://github.com/apache/tvm/pull/14568#discussion_r1162824009


##########
src/target/llvm/codegen_cpu.cc:
##########
@@ -300,6 +296,36 @@ llvm::DIType* CodeGenCPU::GetDebugType(const Type& ty_tir, 
llvm::Type* ty_llvm)
                                              : nullptr;
     return dbg_info_->di_builder_->createPointerType(pointee_type,
                                                      
ty_llvm->getPrimitiveSizeInBits());
+
+  } else if (auto* prim_type = ty_tir.as<PrimTypeNode>()) {
+    DataType dtype = prim_type->dtype;
+    auto [name, dwarf_type] = [&]() -> std::tuple<const char*, 
llvm::dwarf::TypeKind> {

Review Comment:
   `llvm::StringRef` is the "LLVM way" rather than `const char*`.



##########
src/target/llvm/codegen_cpu.cc:
##########
@@ -300,6 +296,36 @@ llvm::DIType* CodeGenCPU::GetDebugType(const Type& ty_tir, 
llvm::Type* ty_llvm)
                                              : nullptr;
     return dbg_info_->di_builder_->createPointerType(pointee_type,
                                                      
ty_llvm->getPrimitiveSizeInBits());
+
+  } else if (auto* prim_type = ty_tir.as<PrimTypeNode>()) {
+    DataType dtype = prim_type->dtype;
+    auto [name, dwarf_type] = [&]() -> std::tuple<const char*, 
llvm::dwarf::TypeKind> {
+      if (dtype.is_bool()) {
+        return {"bool", llvm::dwarf::DW_ATE_boolean};
+      } else if (dtype.is_float()) {
+        return {"float", llvm::dwarf::DW_ATE_float};
+      } else if (dtype.is_int()) {
+        return {"int", llvm::dwarf::DW_ATE_signed};
+      } else if (dtype.is_uint()) {
+        return {"uint", llvm::dwarf::DW_ATE_unsigned};
+      } else {
+        LOG(FATAL) << "No DWARF representation for TIR type " << dtype;
+      }
+    }();
+
+    std::stringstream ss;
+    ss << name;
+
+    if (!dtype.is_bool()) {
+      ss << dtype.bits();
+    }
+    if (dtype.lanes() > 1) {
+      ss << "x" << dtype.lanes();
+    }

Review Comment:
   There is already a function that gets the string from `DataType` 
[here](https://github.com/apache/tvm/blob/51dcafb4abc7dbc3583c1719d3c483ae52d67859/include/tvm/runtime/data_type.h#L316).
   
   Please add `#include <sstream>` for `std::stringstream` if you decide to 
keep it.



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