Lunderberg commented on a change in pull request #10710:
URL: https://github.com/apache/tvm/pull/10710#discussion_r833366295
##########
File path: src/target/llvm/codegen_hexagon.cc
##########
@@ -572,6 +574,43 @@ llvm::Value* CodeGenHexagon::CreateIntrinsic(const
CallNode* op) {
return CodeGenLLVM::CreateIntrinsic(op);
}
+void CodeGenHexagon::CreatePrintf(const std::string& format,
+ const std::vector<llvm::Value*> format_args)
{
+ // This function generates LLVM instructions to call HAP_debug_v2,
+ // as if the FARF macro in `HAP_farf.h` were called as
+ // FARF(ALWAYS, format, format_args[0], format_args[1], ...)
+ std::string func_name = "HAP_debug_v2";
+
+ llvm::Function* func = module_->getFunction(func_name);
+ if (func == nullptr) {
+ llvm::FunctionType* ftype = llvm::FunctionType::get(
+ t_void_, {t_int32_, t_char_->getPointerTo(), t_int32_,
t_char_->getPointerTo()}, true);
+ func = llvm::Function::Create(ftype, llvm::Function::ExternalLinkage,
func_name, module_.get());
+ }
+
+ llvm::Value* format_str = builder_->CreateGlobalStringPtr(format + "\0");
+ format_str->setName("printf_format_str");
+
+ // The value of FARF_ALWAYS_LEVEL, defined as HAP_LEVEL_HIGH
+ llvm::Value* level = ConstInt32(2);
+ level->setName("farf_always_level");
+
+ // There is no such filename for this print statement
+ llvm::Value* filename =
builder_->CreateGlobalStringPtr("generated-LLVM-code");
+ filename->setName("dummy_filename");
+
+ // There is no such line number for this print statement
+ llvm::Value* line_number = ConstInt32(1);
+ line_number->setName("dummy_line_number");
+
+ std::vector<llvm::Value*> func_args = {level, filename, line_number,
format_str};
+ for (auto arg : format_args) {
+ func_args.push_back(arg);
+ }
Review comment:
And updated, both here and the corresponding `CodeGenLLVM::CreatePrintf`
--
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]