LLZK
3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Toggle main menu visibility
Loading...
Searching...
No Matches
Attrs.cpp
Go to the documentation of this file.
1
//===-- Attrs.cpp -----------------------------------------------*- C++ -*-===//
2
//
3
// Part of the LLZK Project, under the Apache License v2.0.
4
// See LICENSE.txt for license information.
5
// Copyright 2026 Project LLZK
6
// SPDX-License-Identifier: Apache-2.0
7
//
8
//===----------------------------------------------------------------------===//
9
10
#include "
llzk/Dialect/LLZK/IR/Attrs.h
"
11
12
#include "
llzk/Dialect/Struct/IR/Types.h
"
13
#include "
llzk/Util/Constants.h
"
14
#include "
llzk/Util/TypeHelper.h
"
15
16
#include <mlir/IR/BuiltinAttributes.h>
17
18
using namespace
mlir
;
19
20
namespace
llzk
{
21
22
using namespace
component
;
23
24
FailureOr<StructType>
getTypeFromLlzkMainAttr
(ModuleOp op, Attribute attr) {
25
assert(op);
// pre-condition
26
assert(attr);
// pre-condition
27
28
// If the attribute is present, it must be a TypeAttr of concrete StructType.
29
if
(TypeAttr ta = llvm::dyn_cast<TypeAttr>(attr)) {
30
if
(
auto
st = llvm::dyn_cast<StructType>(ta.getValue())) {
31
if
(
isConcreteType
(st)) {
32
return
success(st);
33
}
34
}
35
}
36
return
op->emitError().append(
37
'"'
,
MAIN_ATTR_NAME
,
"\" on module must be a concrete '"
,
StructType::name
,
38
"' attribute. Found: "
, attr
39
);
40
}
41
42
}
// namespace llzk
Attrs.h
Types.h
TypeHelper.h
llzk::component::StructType::name
static constexpr ::llvm::StringLiteral name
Definition
Types.h.inc:38
Constants.h
llzk::component
Definition
Dialect.cpp:209
llzk
Definition
AnalysisPassEnums.cpp:19
llzk::isConcreteType
bool isConcreteType(Type type, bool allowStructParams)
Definition
TypeHelper.cpp:537
llzk::getTypeFromLlzkMainAttr
FailureOr< StructType > getTypeFromLlzkMainAttr(ModuleOp op, Attribute attr)
Definition
Attrs.cpp:24
llzk::MAIN_ATTR_NAME
constexpr char MAIN_ATTR_NAME[]
Name of the attribute on the top-level ModuleOp that specifies the type of the main struct.
Definition
Constants.h:37
mlir
Definition
ValueModel.h:30
lib
Dialect
LLZK
IR
Attrs.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.