LLZK 0.1.0
Veridise's ZK Language IR
Loading...
Searching...
No Matches
Support.h
Go to the documentation of this file.
1//===-- Support.h - C API general utilities -----------------------*- C -*-===//
2//
3// Part of the LLZK Project, under the Apache License v2.0.
4// See LICENSE.txt for license information.
5// Copyright 2025 Veridise Inc.
6// SPDX-License-Identifier: Apache-2.0
7//
8//===----------------------------------------------------------------------===//
9//
10// This header declares utilities for working with the C API.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLZK_C_IR_H
15#define LLZK_C_IR_H
16
17#include "llzk-c/Builder.h" // IWYU pragma: keep
18
19#include <mlir-c/IR.h> // IWYU pragma: keep
20
21#include <stdint.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27//===----------------------------------------------------------------------===//
28// Utility macros for function declarations.
29//===----------------------------------------------------------------------===//
30
31#define LLZK_BUILD_METHOD_NAME(op, suffix) llzk##op##Build##suffix
32#define LLZK_DECLARE_SUFFIX_OP_BUILD_METHOD(op, suffix, ...) \
33 MLIR_CAPI_EXPORTED MlirOperation LLZK_BUILD_METHOD_NAME(op, suffix)( \
34 MlirOpBuilder builder, MlirLocation location, __VA_ARGS__ \
35 )
36// Used for when the build method is "general" and does not have a suffix at the end.
37#define LLZK_DECLARE_OP_BUILD_METHOD(op, ...) LLZK_DECLARE_SUFFIX_OP_BUILD_METHOD(op, , __VA_ARGS__)
38
39#define LLZK_DECLARE_PREDICATE(name, ...) MLIR_CAPI_EXPORTED bool llzk##name(__VA_ARGS__)
40
41#define LLZK_DECLARE_OP_PREDICATE(op, name) \
42 MLIR_CAPI_EXPORTED bool llzk##op##Get##name(MlirOperation op)
43#define LLZK_DECLARE_NARY_OP_PREDICATE(op, name, ...) \
44 MLIR_CAPI_EXPORTED bool llzk##op##Get##name(MlirOperation op, __VA_ARGS__)
45
46#define LLZK_DECLARE_ISA(what, root) MLIR_CAPI_EXPORTED bool llzk##root##IsA##what(Mlir##root what)
47#define LLZK_DECLARE_TYPE_ISA(what) LLZK_DECLARE_ISA(what, Type)
48#define LLZK_DECLARE_OP_ISA(what) LLZK_DECLARE_ISA(what, Operation)
49#define LLZK_DECLARE_ATTR_ISA(what) LLZK_DECLARE_ISA(what, Attribute)
50
51//===----------------------------------------------------------------------===//
52// Representation of a mlir::ValueRange.
53//===----------------------------------------------------------------------===//
54
56 MlirValue const *values;
57 intptr_t size;
58};
60
61#ifdef __cplusplus
62}
63#endif
64
65#endif
MlirValue const * values
Definition Support.h:56
intptr_t size
Definition Support.h:57