MLIR  15.0.0git
LLVM.cpp
Go to the documentation of this file.
1 //===- LLVM.cpp - C Interface for LLVM dialect ----------------------------===//
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 #include "mlir-c/Dialect/LLVM.h"
10 #include "mlir/CAPI/Registration.h"
13 
14 using namespace mlir;
15 using namespace mlir::LLVM;
16 
18 
19 MlirType mlirLLVMPointerTypeGet(MlirType pointee, unsigned addressSpace) {
20  return wrap(LLVMPointerType::get(unwrap(pointee), addressSpace));
21 }
22 
23 MlirType mlirLLVMVoidTypeGet(MlirContext ctx) {
24  return wrap(LLVMVoidType::get(unwrap(ctx)));
25 }
26 
27 MlirType mlirLLVMArrayTypeGet(MlirType elementType, unsigned numElements) {
28  return wrap(LLVMArrayType::get(unwrap(elementType), numElements));
29 }
30 
31 MlirType mlirLLVMFunctionTypeGet(MlirType resultType, intptr_t nArgumentTypes,
32  MlirType const *argumentTypes, bool isVarArg) {
33  SmallVector<Type, 2> argumentStorage;
35  unwrap(resultType),
36  unwrapList(nArgumentTypes, argumentTypes, argumentStorage), isVarArg));
37 }
38 
39 MlirType mlirLLVMStructTypeLiteralGet(MlirContext ctx, intptr_t nFieldTypes,
40  MlirType const *fieldTypes,
41  bool isPacked) {
42  SmallVector<Type, 2> fieldStorage;
44  unwrap(ctx), unwrapList(nFieldTypes, fieldTypes, fieldStorage),
45  isPacked));
46 }
TODO: Remove this file when SCCP and integer range analysis have been ported to the new framework...
The OpAsmOpInterface, see OpAsmInterface.td for more details.
Definition: CallGraph.h:221
static LLVMStructType getLiteral(MLIRContext *context, ArrayRef< Type > types, bool isPacked=false)
Gets or creates a literal struct with the given body in the provided context.
Definition: LLVMTypes.cpp:414
static LLVMArrayType get(Type elementType, unsigned numElements)
Gets or creates an instance of LLVM dialect array type containing numElements of elementType, in the same context as elementType.
Definition: LLVMTypes.cpp:39
MlirType mlirLLVMArrayTypeGet(MlirType elementType, unsigned numElements)
Creates an llvm.array type.
Definition: LLVM.cpp:27
static LLVMFunctionType get(Type result, ArrayRef< Type > arguments, bool isVarArg=false)
Gets or creates an instance of LLVM dialect function in the same context as the result type...
Definition: LLVMTypes.cpp:107
MlirType mlirLLVMPointerTypeGet(MlirType pointee, unsigned addressSpace)
Creates an llvm.ptr type.
Definition: LLVM.cpp:19
MlirType mlirLLVMFunctionTypeGet(MlirType resultType, intptr_t nArgumentTypes, MlirType const *argumentTypes, bool isVarArg)
Creates an llvm.func type.
Definition: LLVM.cpp:31
static llvm::ArrayRef< CppTy > unwrapList(size_t size, CTy *first, llvm::SmallVectorImpl< CppTy > &storage)
Definition: Wrap.h:40
static LLVMPointerType get(MLIRContext *context, unsigned addressSpace=0)
Gets or creates an instance of LLVM dialect pointer type pointing to an object of pointee type in the...
Definition: LLVMTypes.cpp:188
MlirType mlirLLVMVoidTypeGet(MlirContext ctx)
Creates an llmv.void type.
Definition: LLVM.cpp:23
MlirType mlirLLVMStructTypeLiteralGet(MlirContext ctx, intptr_t nFieldTypes, MlirType const *fieldTypes, bool isPacked)
Creates an LLVM literal (unnamed) struct type.
Definition: LLVM.cpp:39
MlirDiagnostic wrap(mlir::Diagnostic &diagnostic)
Definition: Diagnostics.h:24
MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(SparseTensor, sparse_tensor, mlir::sparse_tensor::SparseTensorDialect) static_assert(static_cast< int >(MLIR_SPARSE_TENSOR_DIM_LEVEL_DENSE)
mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)
Definition: Diagnostics.h:19