LLZK
3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Toggle main menu visibility
Loading...
Searching...
No Matches
Dialect.cpp
Go to the documentation of this file.
1
//===-- Dialect.cpp - Polymorphic dialect implementation --------*- 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
#include "
llzk/Dialect/Polymorphic/IR/Dialect.h
"
11
12
#include "
llzk/Dialect/LLZK/IR/Versioning.h
"
13
#include "
llzk/Dialect/Polymorphic/IR/Ops.h
"
14
#include "
llzk/Dialect/Polymorphic/IR/Types.h
"
15
16
#include <mlir/Dialect/Arith/IR/Arith.h>
17
#include <mlir/IR/Builders.h>
18
#include <mlir/IR/BuiltinAttributes.h>
19
#include <mlir/IR/BuiltinTypes.h>
20
#include <mlir/IR/DialectImplementation.h>
21
22
#include <llvm/ADT/TypeSwitch.h>
23
24
// TableGen'd implementation files
25
#include "
llzk/Dialect/Polymorphic/IR/Dialect.cpp.inc
"
26
27
#define GET_TYPEDEF_CLASSES
28
#include "
llzk/Dialect/Polymorphic/IR/Types.cpp.inc
"
29
30
//===------------------------------------------------------------------===//
31
// PolymorphicDialect
32
//===------------------------------------------------------------------===//
33
34
mlir::Operation *
llzk::polymorphic::PolymorphicDialect::materializeConstant
(
35
mlir::OpBuilder &builder, mlir::Attribute value, mlir::Type type, mlir::Location loc
36
) {
37
if
(llvm::isa<mlir::IndexType, mlir::IntegerType>(type)) {
38
if
(
auto
intAttr = llvm::dyn_cast<mlir::IntegerAttr>(value)) {
39
return
builder.create<mlir::arith::ConstantOp>(loc, intAttr);
40
}
41
}
42
return
nullptr
;
43
}
44
45
auto
llzk::polymorphic::PolymorphicDialect::initialize() ->
void
{
46
// clang-format off
47
addOperations<
48
#define GET_OP_LIST
49
#include "
llzk/Dialect/Polymorphic/IR/Ops.cpp.inc
"
50
>();
51
52
// Suppress false positive from `clang-tidy`
53
// NOLINTNEXTLINE(clang-analyzer-core.StackAddressEscape)
54
addTypes<
55
#define GET_TYPEDEF_LIST
56
#include "
llzk/Dialect/Polymorphic/IR/Types.cpp.inc
"
57
>();
58
// clang-format on
59
addInterfaces<LLZKDialectBytecodeInterface<PolymorphicDialect>>();
60
}
Dialect.cpp.inc
Dialect.h
Ops.cpp.inc
Ops.h
Types.cpp.inc
Types.h
Versioning.h
llzk::polymorphic::PolymorphicDialect::materializeConstant
::mlir::Operation * materializeConstant(::mlir::OpBuilder &builder, ::mlir::Attribute value, ::mlir::Type type, ::mlir::Location loc) override
Materialize a single constant operation from a given attribute value with the desired resultant type.
Definition
Dialect.cpp:34
lib
Dialect
Polymorphic
IR
Dialect.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.