llvm/mlir/lib/Dialect/LLVMIR/IR/FunctionCallUtils.cpp

//===- FunctionCallUtils.cpp - Utilities for C function calls -------------===//
//
// 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 file implements helper functions to call common simple C functions in
// LLVMIR (e.g. amon others to support printing and debugging).
//
//===----------------------------------------------------------------------===//

#include "mlir/Dialect/LLVMIR/FunctionCallUtils.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/Support/LLVM.h"

usingnamespacemlir;
usingnamespacemlir::LLVM;

/// Helper functions to lookup or create the declaration for commonly used
/// external C function calls. The list of functions provided here must be
/// implemented separately (e.g. as  part of a support runtime library or as
/// part of the libc).
static constexpr llvm::StringRef kPrintI64 =;
static constexpr llvm::StringRef kPrintU64 =;
static constexpr llvm::StringRef kPrintF16 =;
static constexpr llvm::StringRef kPrintBF16 =;
static constexpr llvm::StringRef kPrintF32 =;
static constexpr llvm::StringRef kPrintF64 =;
static constexpr llvm::StringRef kPrintString =;
static constexpr llvm::StringRef kPrintOpen =;
static constexpr llvm::StringRef kPrintClose =;
static constexpr llvm::StringRef kPrintComma =;
static constexpr llvm::StringRef kPrintNewline =;
static constexpr llvm::StringRef kMalloc =;
static constexpr llvm::StringRef kAlignedAlloc =;
static constexpr llvm::StringRef kFree =;
static constexpr llvm::StringRef kGenericAlloc =;
static constexpr llvm::StringRef kGenericAlignedAlloc =;
static constexpr llvm::StringRef kGenericFree =;
static constexpr llvm::StringRef kMemRefCopy =;

/// Generic print function lookupOrCreate helper.
LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateFn(Operation *moduleOp,
                                              StringRef name,
                                              ArrayRef<Type> paramTypes,
                                              Type resultType, bool isVarArg) {}

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintI64Fn(Operation *moduleOp) {}

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintU64Fn(Operation *moduleOp) {}

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintF16Fn(Operation *moduleOp) {}

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintBF16Fn(Operation *moduleOp) {}

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintF32Fn(Operation *moduleOp) {}

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintF64Fn(Operation *moduleOp) {}

static LLVM::LLVMPointerType getCharPtr(MLIRContext *context) {}

static LLVM::LLVMPointerType getVoidPtr(MLIRContext *context) {}

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintStringFn(
    Operation *moduleOp, std::optional<StringRef> runtimeFunctionName) {}

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintOpenFn(Operation *moduleOp) {}

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintCloseFn(Operation *moduleOp) {}

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintCommaFn(Operation *moduleOp) {}

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintNewlineFn(Operation *moduleOp) {}

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateMallocFn(Operation *moduleOp,
                                                    Type indexType) {}

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateAlignedAllocFn(Operation *moduleOp,
                                                          Type indexType) {}

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateFreeFn(Operation *moduleOp) {}

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateGenericAllocFn(Operation *moduleOp,
                                                          Type indexType) {}

LLVM::LLVMFuncOp
mlir::LLVM::lookupOrCreateGenericAlignedAllocFn(Operation *moduleOp,
                                                Type indexType) {}

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateGenericFreeFn(Operation *moduleOp) {}

LLVM::LLVMFuncOp
mlir::LLVM::lookupOrCreateMemRefCopyFn(Operation *moduleOp, Type indexType,
                                       Type unrankedDescriptorType) {}