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 "
CAPIGenRegistration.h
"
15
#include "
CommonAttrOrTypeCAPIGen.h
"
16
#include "
CommonCAPIGen.h
"
17
18
#include <mlir/TableGen/AttrOrTypeDef.h>
19
#include <mlir/TableGen/GenInfo.h>
20
21
#include <llvm/Support/CommandLine.h>
22
#include <llvm/Support/FormatVariadic.h>
23
#include <llvm/TableGen/Record.h>
24
#include <llvm/TableGen/TableGenBackend.h>
25
26
using namespace
mlir
;
27
using namespace
mlir::tblgen
;
28
30
static
bool
emitAttrCAPIHeader(
const
llvm::RecordKeeper &records, raw_ostream &os) {
31
emitSourceFileHeader(
"Attr C API Declarations"
, os, records);
32
33
AttrOrTypeHeaderGenerator
generator(
"Attribute"
, os);
34
generator.genPrologue();
35
36
for
(
const
auto
*def : records.getAllDerivedDefinitions(
"AttrDef"
)) {
37
const
AttrOrTypeDef attr(def);
38
generator.genCompleteRecord(attr);
39
}
40
41
generator.genEpilogue();
42
return
false
;
43
}
44
46
static
bool
emitAttrCAPIImpl(
const
llvm::RecordKeeper &records, raw_ostream &os) {
47
emitSourceFileHeader(
"Attr C API Implementations"
, os, records);
48
49
AttrOrTypeImplementationGenerator
generator(
"Attribute"
, os);
50
generator.genPrologue();
51
52
for
(
const
auto
*def : records.getAllDerivedDefinitions(
"AttrDef"
)) {
53
const
AttrOrTypeDef attr(def);
54
generator.genCompleteRecord(attr);
55
}
56
57
return
false
;
58
}
59
60
void
llzk::registerAttrCAPIGenerators
() {
61
static
mlir::GenRegistration genAttrCAPIHeader(
62
"gen-attr-capi-header"
,
"Generate attribute C API header declarations"
, &emitAttrCAPIHeader
63
);
64
65
static
mlir::GenRegistration genAttrCAPIImpl(
66
"gen-attr-capi-impl"
,
"Generate attribute C API implementations"
, &emitAttrCAPIImpl
67
);
68
}
CAPIGenRegistration.h
CommonAttrOrTypeCAPIGen.h
CommonCAPIGen.h
llzk::registerAttrCAPIGenerators
void registerAttrCAPIGenerators()
Register the attribute C API generators before command-line parsing.
Definition
AttrCAPIGen.cpp:60
mlir::tblgen
Definition
CommonCAPIGen.h:50
mlir
Definition
CommonCAPIGen.h:50
AttrOrTypeHeaderGenerator
Generator for attribute/type C header files.
Definition
CommonAttrOrTypeCAPIGen.h:24
AttrOrTypeImplementationGenerator
Generator for attribute/type C implementation files.
Definition
CommonAttrOrTypeCAPIGen.h:177
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.