LLZK 0.1.0
Veridise's ZK Language IR
Loading...
Searching...
No Matches
Felt.cpp
Go to the documentation of this file.
1//===-- Felt.cpp - Felt dialect C API 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
14
15#include "llzk-c/Dialect/Felt.h"
16
17#include <mlir/CAPI/Registration.h>
18#include <mlir/CAPI/Wrap.h>
19
20using namespace llzk::felt;
21
23
24MlirAttribute llzkFeltConstAttrGet(MlirContext ctx, int64_t value) {
25 return wrap(FeltConstAttr::get(unwrap(ctx), llzk::toAPInt(value)));
26}
27
28MlirAttribute llzkFeltConstAttrGetWithBits(MlirContext ctx, unsigned numBits, int64_t value) {
29 return wrap(FeltConstAttr::get(unwrap(ctx), llvm::APInt(numBits, value)));
30}
31
32MlirAttribute llzkFeltConstAttrGetFromString(MlirContext ctx, unsigned numBits, MlirStringRef str) {
33 return wrap(FeltConstAttr::get(unwrap(ctx), numBits, unwrap(str)));
34}
35
37 MlirContext context, unsigned numBits, const uint64_t *parts, intptr_t nParts
38) {
39 return wrap(FeltConstAttr::get(unwrap(context), numBits, llvm::ArrayRef(parts, nParts)));
40}
41
42bool llzkAttributeIsAFeltConstAttr(MlirAttribute attr) {
43 return llvm::isa<FeltConstAttr>(unwrap(attr));
44}
45
46MlirType llzkFeltTypeGet(MlirContext ctx) { return wrap(FeltType::get(unwrap(ctx))); }
47
48bool llzkTypeIsAFeltType(MlirType type) { return llvm::isa<FeltType>(unwrap(type)); }
MlirAttribute llzkFeltConstAttrGet(MlirContext ctx, int64_t value)
Creates a llzk::felt::FeltConstAttr.
Definition Felt.cpp:24
MlirAttribute llzkFeltConstAttrGetFromParts(MlirContext context, unsigned numBits, const uint64_t *parts, intptr_t nParts)
Creates a llzk::felt::FeltConstAttr from an array of big-integer parts in LSB order.
Definition Felt.cpp:36
MlirType llzkFeltTypeGet(MlirContext ctx)
Creates a llzk::felt::FeltType.
Definition Felt.cpp:46
bool llzkTypeIsAFeltType(MlirType type)
Definition Felt.cpp:48
bool llzkAttributeIsAFeltConstAttr(MlirAttribute attr)
Definition Felt.cpp:42
MlirAttribute llzkFeltConstAttrGetWithBits(MlirContext ctx, unsigned numBits, int64_t value)
Creates a llzk::felt::FeltConstAttr with a set bit length.
Definition Felt.cpp:28
MlirAttribute llzkFeltConstAttrGetFromString(MlirContext ctx, unsigned numBits, MlirStringRef str)
Creates a llzk::felt::FeltConstAttr from a base-10 representation of a number.
Definition Felt.cpp:32
MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Polymorphic, llzk__polymorphic, llzk::polymorphic::PolymorphicDialect) MlirType llzkTypeVarTypeGet(MlirContext ctx
::llzk::felt::FeltType get(::mlir::MLIRContext *context)
Definition Types.h.inc:23
llvm::APInt toAPInt(int64_t i)