LLZK
3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Toggle main menu visibility
Loading...
Searching...
No Matches
AttrCAPIGen.cpp
Go to the documentation of this file.
1
//===- AttrCAPIGen.cpp - C API generator for attributes -------------------===//
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
// AttrCAPIGen uses the description of attributes to generate C API for the attrs.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#include "
CommonAttrOrTypeCAPIGen.h
"
15
#include "
CommonCAPIGen.h
"
16
17
#include <mlir/TableGen/AttrOrTypeDef.h>
18
#include <mlir/TableGen/GenInfo.h>
19
20
#include <llvm/Support/CommandLine.h>
21
#include <llvm/Support/FormatVariadic.h>
22
#include <llvm/TableGen/Record.h>
23
#include <llvm/TableGen/TableGenBackend.h>
24
25
using namespace
mlir
;
26
using namespace
mlir::tblgen;
27
29
static
bool
emitAttrCAPIHeader(
const
llvm::RecordKeeper &records, raw_ostream &os) {
30
emitSourceFileHeader(
"Attr C API Declarations"
, os, records);
31
32
AttrOrTypeHeaderGenerator
generator(
"Attribute"
, os);
33
generator.genPrologue();
34
35
for
(
const
auto
*def : records.getAllDerivedDefinitions(
"AttrDef"
)) {
36
const
AttrOrTypeDef attr(def);
37
generator.genCompleteRecord(attr);
38
}
39
40
generator.genEpilogue();
41
return
false
;
42
}
43
45
static
bool
emitAttrCAPIImpl(
const
llvm::RecordKeeper &records, raw_ostream &os) {
46
emitSourceFileHeader(
"Attr C API Implementations"
, os, records);
47
48
AttrOrTypeImplementationGenerator
generator(
"Attribute"
, os);
49
generator.genPrologue();
50
51
for
(
const
auto
*def : records.getAllDerivedDefinitions(
"AttrDef"
)) {
52
const
AttrOrTypeDef attr(def);
53
generator.genCompleteRecord(attr);
54
}
55
56
return
false
;
57
}
58
59
static
mlir::GenRegistration genAttrCAPIHeader(
60
"gen-attr-capi-header"
,
"Generate attribute C API header declarations"
, &emitAttrCAPIHeader
61
);
62
63
static
mlir::GenRegistration genAttrCAPIImpl(
64
"gen-attr-capi-impl"
,
"Generate attribute C API implementations"
, &emitAttrCAPIImpl
65
);
CommonAttrOrTypeCAPIGen.h
CommonCAPIGen.h
mlir
Definition
ValueModel.h:30
AttrOrTypeHeaderGenerator
Generator for attribute/type C header files.
Definition
CommonAttrOrTypeCAPIGen.h:24
AttrOrTypeImplementationGenerator
Generator for attribute/type C implementation files.
Definition
CommonAttrOrTypeCAPIGen.h:166
tools
llzk-tblgen
AttrCAPIGen.cpp
Generated by
1.17.0
Copyright 2025 Veridise Inc. under the Apache License v2.0. Copyright 2026 Project LLZK under the Apache License v2.0.