MLIR  17.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;
34  return wrap(LLVMFunctionType::get(
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 }
MlirType mlirLLVMFunctionTypeGet(MlirType resultType, intptr_t nArgumentTypes, MlirType const *argumentTypes, bool isVarArg)
Creates an llvm.func type.
Definition: LLVM.cpp:31
MlirType mlirLLVMVoidTypeGet(MlirContext ctx)
Creates an llmv.void type.
Definition: LLVM.cpp:23
MlirType mlirLLVMArrayTypeGet(MlirType elementType, unsigned numElements)
Creates an llvm.array type.
Definition: LLVM.cpp:27
MlirType mlirLLVMPointerTypeGet(MlirType pointee, unsigned addressSpace)
Creates an llvm.ptr type.
Definition: LLVM.cpp:19
MlirType mlirLLVMStructTypeLiteralGet(MlirContext ctx, intptr_t nFieldTypes, MlirType const *fieldTypes, bool isPacked)
Creates an LLVM literal (unnamed) struct type.
Definition: LLVM.cpp:39
#define MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Name, Namespace, ClassName)
Definition: Registration.h:36
static llvm::ArrayRef< CppTy > unwrapList(size_t size, CTy *first, llvm::SmallVectorImpl< CppTy > &storage)
Definition: Wrap.h:40
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:447
mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)
Definition: Diagnostics.h:19
MlirDiagnostic wrap(mlir::Diagnostic &diagnostic)
Definition: Diagnostics.h:24
Include the generated interface declarations.
Definition: CallGraph.h:229
This header declares functions that assit transformations in the MemRef dialect.