This is an automated email from the ASF dual-hosted git repository. tqchen pushed a commit to branch tqchen/printer-refinement in repository https://gitbox.apache.org/repos/asf/tvm.git
commit 33cd84020c93eafc239465e532369deb0d00a3cc Author: Tianqi Chen <[email protected]> AuthorDate: Thu Oct 1 20:41:36 2026 +0000 Use direct type formatting for valid call result types --- src/script/printer/ir/utils.cc | 7 +------ src/tirx/script/printer/expr.cc | 14 +++----------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/script/printer/ir/utils.cc b/src/script/printer/ir/utils.cc index 4674395bcb..6c597fd0a7 100644 --- a/src/script/printer/ir/utils.cc +++ b/src/script/printer/ir/utils.cc @@ -214,12 +214,7 @@ ExprDoc RawCall(DocTranslatorObj* d, const CallNode* call, bool infer_result, } if (!infer_result) { keys.push_back("ty"); - auto primitive = call->ty.as<PrimType>(); - // Call interprets the string "handle" as a void pointer, not PrimType. - bool dtype_literal = !primitive || - !primitive.value().MatchesCode(DLDataTypeCode::kDLOpaqueHandle) || - primitive.value().IsVoid(); - values.push_back(TypeValue(d, call->ty, dtype_literal)); + values.push_back(TypeValue(d, call->ty)); } return NamespaceDoc("ir")->Attr("Call")->Call({callee, ListDoc(args)}, keys, values); } diff --git a/src/tirx/script/printer/expr.cc b/src/tirx/script/printer/expr.cc index c995887c52..d27dbe46c8 100644 --- a/src/tirx/script/printer/expr.cc +++ b/src/tirx/script/printer/expr.cc @@ -181,14 +181,6 @@ bool CanTranslateExplicitResultCall(const CallNode* call) { }); } -ExprDoc ExplicitCallResultType(DocTranslatorObj* d, const Type& type) { - PrimType primitive = type.as_or_throw<PrimType>(); - // The Python Call constructor interprets the string "handle" as a pointer. - bool dtype_literal = - !primitive.MatchesCode(DLDataTypeCode::kDLOpaqueHandle) || primitive.IsVoid(); - return TypeValue(d, type, dtype_literal); -} - ffi::Optional<ExprDoc> CallExternDocTranslate(DocTranslatorObj* d, ffi::AnyView input, const ffi::Object*) { const auto* call = @@ -201,7 +193,7 @@ ffi::Optional<ExprDoc> CallExternDocTranslate(DocTranslatorObj* d, ffi::AnyView if (!name) return RawCall(d, call, false); ExprDoc name_doc = LiteralDoc::Str(name->value, std::nullopt); d->RecordOrigin(name_doc, call->args[0]); - ffi::Array<ExprDoc> args = {ExplicitCallResultType(d, call->ty), name_doc}; + ffi::Array<ExprDoc> args = {TypeValue(d, call->ty), name_doc}; for (size_t i = 1; i < call->args.size(); ++i) { args.push_back(MaterializeCallArgument(d, call->args[i], d->Translate(call->args[i]).value())); } @@ -260,7 +252,7 @@ ffi::Optional<ExprDoc> CUDAFuncCallDocTranslate(DocTranslatorObj* d, ffi::AnyVie ffi::Array<ExprDoc> values = {source_doc}; if (!ffi::StructuralEqual()(call->ty, PrimType::Void())) { keys.push_back("return_type"); - values.push_back(ExplicitCallResultType(d, call->ty)); + values.push_back(TypeValue(d, call->ty)); } return NamespaceDoc("tirx")->Attr("cuda")->Attr("func_call")->Call(args, keys, values); } @@ -349,7 +341,7 @@ ffi::Optional<ExprDoc> LLVMIntrinsicDocTranslate(DocTranslatorObj* d, ffi::AnyVi } ExprDoc name_doc = LiteralDoc::Str(name, std::nullopt); d->RecordOrigin(name_doc, call->args[0]); - ffi::Array<ExprDoc> args = {ExplicitCallResultType(d, call->ty), name_doc}; + ffi::Array<ExprDoc> args = {TypeValue(d, call->ty), name_doc}; for (size_t i = 1; i < call->args.size(); ++i) { args.push_back(MaterializeCallArgument(d, call->args[i], d->Translate(call->args[i]).value())); }
