MLIR  17.0.0git
FunctionCallUtils.h
Go to the documentation of this file.
1 //===- FunctionCallUtils.h - Utilities for C function calls -----*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares helper functions to call common simple C functions in
10 // LLVMIR (e.g. among others to support printing and debugging).
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef MLIR_DIALECT_LLVMIR_FUNCTIONCALLUTILS_H_
15 #define MLIR_DIALECT_LLVMIR_FUNCTIONCALLUTILS_H_
16 
17 #include "mlir/IR/Operation.h"
18 #include "mlir/Support/LLVM.h"
19 
20 namespace mlir {
21 class Location;
22 class ModuleOp;
23 class OpBuilder;
24 class Operation;
25 class Type;
26 class ValueRange;
27 
28 namespace LLVM {
29 class LLVMFuncOp;
30 
31 /// Helper functions to lookup or create the declaration for commonly used
32 /// external C function calls. The list of functions provided here must be
33 /// implemented separately (e.g. as part of a support runtime library or as part
34 /// of the libc).
35 LLVM::LLVMFuncOp lookupOrCreatePrintI64Fn(ModuleOp moduleOp);
36 LLVM::LLVMFuncOp lookupOrCreatePrintU64Fn(ModuleOp moduleOp);
37 LLVM::LLVMFuncOp lookupOrCreatePrintF32Fn(ModuleOp moduleOp);
38 LLVM::LLVMFuncOp lookupOrCreatePrintF64Fn(ModuleOp moduleOp);
39 LLVM::LLVMFuncOp lookupOrCreatePrintStrFn(ModuleOp moduleOp);
40 LLVM::LLVMFuncOp lookupOrCreatePrintOpenFn(ModuleOp moduleOp);
41 LLVM::LLVMFuncOp lookupOrCreatePrintCloseFn(ModuleOp moduleOp);
42 LLVM::LLVMFuncOp lookupOrCreatePrintCommaFn(ModuleOp moduleOp);
43 LLVM::LLVMFuncOp lookupOrCreatePrintNewlineFn(ModuleOp moduleOp);
44 LLVM::LLVMFuncOp lookupOrCreateMallocFn(ModuleOp moduleOp, Type indexType);
45 LLVM::LLVMFuncOp lookupOrCreateAlignedAllocFn(ModuleOp moduleOp,
46  Type indexType);
47 LLVM::LLVMFuncOp lookupOrCreateFreeFn(ModuleOp moduleOp);
48 LLVM::LLVMFuncOp lookupOrCreateGenericAllocFn(ModuleOp moduleOp,
49  Type indexType);
50 LLVM::LLVMFuncOp lookupOrCreateGenericAlignedAllocFn(ModuleOp moduleOp,
51  Type indexType);
52 LLVM::LLVMFuncOp lookupOrCreateGenericFreeFn(ModuleOp moduleOp);
53 LLVM::LLVMFuncOp lookupOrCreateMemRefCopyFn(ModuleOp moduleOp, Type indexType,
54  Type unrankedDescriptorType);
55 
56 /// Create a FuncOp with signature `resultType`(`paramTypes`)` and name `name`.
57 LLVM::LLVMFuncOp lookupOrCreateFn(ModuleOp moduleOp, StringRef name,
58  ArrayRef<Type> paramTypes = {},
59  Type resultType = {});
60 
61 } // namespace LLVM
62 } // namespace mlir
63 
64 #endif // MLIR_DIALECT_LLVMIR_FUNCTIONCALLUTILS_H_
LLVM::LLVMFuncOp lookupOrCreateGenericFreeFn(ModuleOp moduleOp)
LLVM::LLVMFuncOp lookupOrCreateAlignedAllocFn(ModuleOp moduleOp, Type indexType)
LLVM::LLVMFuncOp lookupOrCreateMemRefCopyFn(ModuleOp moduleOp, Type indexType, Type unrankedDescriptorType)
LLVM::LLVMFuncOp lookupOrCreateGenericAlignedAllocFn(ModuleOp moduleOp, Type indexType)
LLVM::LLVMFuncOp lookupOrCreateFreeFn(ModuleOp moduleOp)
LLVM::LLVMFuncOp lookupOrCreateFn(ModuleOp moduleOp, StringRef name, ArrayRef< Type > paramTypes={}, Type resultType={})
Create a FuncOp with signature resultType(paramTypes)and namename`.
LLVM::LLVMFuncOp lookupOrCreateMallocFn(ModuleOp moduleOp, Type indexType)
LLVM::LLVMFuncOp lookupOrCreatePrintU64Fn(ModuleOp moduleOp)
LLVM::LLVMFuncOp lookupOrCreatePrintF64Fn(ModuleOp moduleOp)
LLVM::LLVMFuncOp lookupOrCreateGenericAllocFn(ModuleOp moduleOp, Type indexType)
LLVM::LLVMFuncOp lookupOrCreatePrintNewlineFn(ModuleOp moduleOp)
LLVM::LLVMFuncOp lookupOrCreatePrintCommaFn(ModuleOp moduleOp)
LLVM::LLVMFuncOp lookupOrCreatePrintCloseFn(ModuleOp moduleOp)
LLVM::LLVMFuncOp lookupOrCreatePrintF32Fn(ModuleOp moduleOp)
LLVM::LLVMFuncOp lookupOrCreatePrintOpenFn(ModuleOp moduleOp)
LLVM::LLVMFuncOp lookupOrCreatePrintI64Fn(ModuleOp moduleOp)
Helper functions to lookup or create the declaration for commonly used external C function calls.
LLVM::LLVMFuncOp lookupOrCreatePrintStrFn(ModuleOp moduleOp)
@ Type
An inlay hint that for a type annotation.
Include the generated interface declarations.