================ @@ -0,0 +1,303 @@ +//===------ AVR.cpp - Emit LLVM Code for AVR builtins ---------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This contains code to emit Builtin calls as LLVM code. +// +//===----------------------------------------------------------------------===// + +#include "CGBuiltin.h" +#include "clang/Basic/TargetBuiltins.h" +#include "llvm/IR/InlineAsm.h" +#include "llvm/IR/IntrinsicsAVR.h" + +using namespace clang; +using namespace CodeGen; +using namespace llvm; + +/// Emit an inline-asm-based fractional multiply (fmul/fmuls/fmulsu). +/// All three variants share the same shape: two i8 inputs → one i16 output, +/// with the result collected from R1:R0 via movw, then R1 cleared. +static Value *EmitAVRFMulInlineAsm(CodeGenFunction &CGF, const CallExpr *E, + const char *AsmInsn) { + Value *Arg0 = CGF.EmitScalarExpr(E->getArg(0)); + Value *Arg1 = CGF.EmitScalarExpr(E->getArg(1)); + llvm::LLVMContext &Ctx = CGF.getLLVMContext(); + llvm::Type *ResTy = llvm::Type::getInt16Ty(Ctx); + llvm::Type *ArgTy = llvm::Type::getInt8Ty(Ctx); + llvm::FunctionType *FTy = + llvm::FunctionType::get(ResTy, {ArgTy, ArgTy}, false); + + // Build the asm string: "<insn> $1, $2\n\tmovw $0, r0\n\tclr r1" + std::string Asm = std::string(AsmInsn) + " $1, $2\n\tmovw $0, r0\n\tclr r1"; ---------------- benshi001 wrote:
As my previous suggestion, you can implement `*mul` in another patch. https://github.com/llvm/llvm-project/pull/203214 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
