LLZK 0.1.0
Veridise's ZK Language IR
Loading...
Searching...
No Matches
AttributeHelper.cpp
Go to the documentation of this file.
1//===-- AttributeHelper.cpp -------------------------------------*- 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
12
13using namespace mlir;
14
15namespace llzk {
16
17// Adapted from AsmPrinter::printStrippedAttrOrType(), but without printing type.
18void printAttrs(AsmPrinter &printer, ArrayRef<Attribute> attrs, const StringRef &separator) {
19 llvm::interleave(attrs, printer.getStream(), [&printer](Attribute a) {
20 if (auto intAttr = mlir::dyn_cast_if_present<IntegerAttr>(a)) {
21 if (isDynamic(intAttr)) {
22 printer.getStream() << "?";
23 return;
24 }
25 }
26 if (succeeded(printer.printAlias(a))) {
27 return;
28 }
29 raw_ostream &os = printer.getStream();
30 uint64_t posPrior = os.tell();
31 printer.printAttributeWithoutType(a);
32 // Fallback to printing with prefix if the above failed to write anything to the output stream.
33 if (posPrior == os.tell()) {
34 printer << a;
35 }
36 }, separator);
37}
38
39} // namespace llzk
void printAttrs(AsmPrinter &printer, ArrayRef< Attribute > attrs, const StringRef &separator)