Skip to content

[mlir][polynomial] Remove polynomial dialect #139766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 13, 2025

Conversation

@llvmbot llvmbot added mlir bazel "Peripheral" support tier build system: utils/bazel labels May 13, 2025
@j2kun j2kun changed the title Remove polynomial dialect [mlir][polynomial] Remove polynomial dialect May 13, 2025
@llvmbot
Copy link
Member

llvmbot commented May 13, 2025

@llvm/pr-subscribers-mlir

Author: Jeremy Kun (j2kun)

Changes

Cf. https://discourse.llvm.org/t/future-of-the-polynomial-dialect/86117

For posterity, the polynomial dialect development has moved to HEIR, and as of this writing the different components can be found here:


Patch is 102.50 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/139766.diff

36 Files Affected:

  • (modified) mlir/include/mlir/Dialect/CMakeLists.txt (-1)
  • (removed) mlir/include/mlir/Dialect/Polynomial/CMakeLists.txt (-1)
  • (removed) mlir/include/mlir/Dialect/Polynomial/IR/CMakeLists.txt (-7)
  • (removed) mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.h (-282)
  • (removed) mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.td (-350)
  • (removed) mlir/include/mlir/Dialect/Polynomial/IR/PolynomialAttributes.h (-17)
  • (removed) mlir/include/mlir/Dialect/Polynomial/IR/PolynomialAttributes.td (-222)
  • (removed) mlir/include/mlir/Dialect/Polynomial/IR/PolynomialDialect.h (-19)
  • (removed) mlir/include/mlir/Dialect/Polynomial/IR/PolynomialDialect.td (-55)
  • (removed) mlir/include/mlir/Dialect/Polynomial/IR/PolynomialOps.h (-21)
  • (removed) mlir/include/mlir/Dialect/Polynomial/IR/PolynomialTypes.h (-17)
  • (removed) mlir/include/mlir/Dialect/Polynomial/IR/PolynomialTypes.td (-33)
  • (modified) mlir/include/mlir/InitAllDialects.h (+2-4)
  • (modified) mlir/lib/Dialect/CMakeLists.txt (-1)
  • (removed) mlir/lib/Dialect/Polynomial/CMakeLists.txt (-1)
  • (removed) mlir/lib/Dialect/Polynomial/IR/CMakeLists.txt (-26)
  • (removed) mlir/lib/Dialect/Polynomial/IR/Polynomial.cpp (-68)
  • (removed) mlir/lib/Dialect/Polynomial/IR/PolynomialAttributes.cpp (-236)
  • (removed) mlir/lib/Dialect/Polynomial/IR/PolynomialCanonicalization.td (-44)
  • (removed) mlir/lib/Dialect/Polynomial/IR/PolynomialDialect.cpp (-49)
  • (removed) mlir/lib/Dialect/Polynomial/IR/PolynomialOps.cpp (-298)
  • (removed) mlir/test/Dialect/Polynomial/attributes.mlir (-73)
  • (removed) mlir/test/Dialect/Polynomial/canonicalization.mlir (-47)
  • (removed) mlir/test/Dialect/Polynomial/ops.mlir (-112)
  • (removed) mlir/test/Dialect/Polynomial/ops_errors.mlir (-126)
  • (removed) mlir/test/Dialect/Polynomial/types.mlir (-65)
  • (removed) mlir/test/IR/parser_dialect_loading.mlir (-19)
  • (modified) mlir/test/lib/Dialect/Test/CMakeLists.txt (-1)
  • (modified) mlir/test/lib/Dialect/Test/TestAttrDefs.td (-17)
  • (modified) mlir/test/lib/Dialect/Test/TestAttributes.h (+5-5)
  • (modified) mlir/test/lib/Dialect/Test/TestOps.td (-10)
  • (modified) mlir/unittests/Dialect/CMakeLists.txt (-1)
  • (removed) mlir/unittests/Dialect/Polynomial/CMakeLists.txt (-8)
  • (removed) mlir/unittests/Dialect/Polynomial/PolynomialMathTest.cpp (-44)
  • (modified) utils/bazel/llvm-project-overlay/mlir/BUILD.bazel (-91)
  • (modified) utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel (-2)
diff --git a/mlir/include/mlir/Dialect/CMakeLists.txt b/mlir/include/mlir/Dialect/CMakeLists.txt
index 9d1a840d6644b..56dc97282fa4a 100644
--- a/mlir/include/mlir/Dialect/CMakeLists.txt
+++ b/mlir/include/mlir/Dialect/CMakeLists.txt
@@ -28,7 +28,6 @@ add_subdirectory(OpenACCMPCommon)
 add_subdirectory(OpenMP)
 add_subdirectory(PDL)
 add_subdirectory(PDLInterp)
-add_subdirectory(Polynomial)
 add_subdirectory(Ptr)
 add_subdirectory(Quant)
 add_subdirectory(SCF)
diff --git a/mlir/include/mlir/Dialect/Polynomial/CMakeLists.txt b/mlir/include/mlir/Dialect/Polynomial/CMakeLists.txt
deleted file mode 100644
index f33061b2d87cf..0000000000000
--- a/mlir/include/mlir/Dialect/Polynomial/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-add_subdirectory(IR)
diff --git a/mlir/include/mlir/Dialect/Polynomial/IR/CMakeLists.txt b/mlir/include/mlir/Dialect/Polynomial/IR/CMakeLists.txt
deleted file mode 100644
index ecdea158ddefb..0000000000000
--- a/mlir/include/mlir/Dialect/Polynomial/IR/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-add_mlir_dialect(Polynomial polynomial)
-add_mlir_doc(Polynomial PolynomialDialect Dialects/ -gen-dialect-doc -dialect=polynomial)
-
-set(LLVM_TARGET_DEFINITIONS PolynomialAttributes.td)
-mlir_tablegen(PolynomialAttributes.cpp.inc -gen-attrdef-defs -attrdefs-dialect=polynomial)
-mlir_tablegen(PolynomialAttributes.h.inc -gen-attrdef-decls -attrdefs-dialect=polynomial)
-add_public_tablegen_target(MLIRPolynomialAttributesIncGen)
diff --git a/mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.h b/mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.h
deleted file mode 100644
index 8d7f1436fdc60..0000000000000
--- a/mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.h
+++ /dev/null
@@ -1,282 +0,0 @@
-//===- Polynomial.h - A data class for polynomials --------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef MLIR_DIALECT_POLYNOMIAL_IR_POLYNOMIAL_H_
-#define MLIR_DIALECT_POLYNOMIAL_IR_POLYNOMIAL_H_
-
-#include "mlir/Support/LLVM.h"
-#include "llvm/ADT/APFloat.h"
-#include "llvm/ADT/APInt.h"
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/Hashing.h"
-#include "llvm/ADT/SmallString.h"
-#include "llvm/ADT/Twine.h"
-#include "llvm/Support/raw_ostream.h"
-
-namespace mlir {
-
-class MLIRContext;
-
-namespace polynomial {
-
-/// This restricts statically defined polynomials to have at most 64-bit
-/// coefficients. This may be relaxed in the future, but it seems unlikely one
-/// would want to specify 128-bit polynomials statically in the source code.
-constexpr unsigned apintBitWidth = 64;
-
-template <class Derived, typename CoefficientType>
-class MonomialBase {
-public:
-  MonomialBase(const CoefficientType &coeff, const APInt &expo)
-      : coefficient(coeff), exponent(expo) {}
-  virtual ~MonomialBase() = default;
-
-  const CoefficientType &getCoefficient() const { return coefficient; }
-  CoefficientType &getMutableCoefficient() { return coefficient; }
-  const APInt &getExponent() const { return exponent; }
-  void setCoefficient(const CoefficientType &coeff) { coefficient = coeff; }
-  void setExponent(const APInt &exp) { exponent = exp; }
-
-  bool operator==(const MonomialBase &other) const {
-    return other.coefficient == coefficient && other.exponent == exponent;
-  }
-  bool operator!=(const MonomialBase &other) const {
-    return other.coefficient != coefficient || other.exponent != exponent;
-  }
-
-  /// Monomials are ordered by exponent.
-  bool operator<(const MonomialBase &other) const {
-    return (exponent.ult(other.exponent));
-  }
-
-  Derived add(const Derived &other) {
-    assert(exponent == other.exponent);
-    CoefficientType newCoeff = coefficient + other.coefficient;
-    Derived result;
-    result.setCoefficient(newCoeff);
-    result.setExponent(exponent);
-    return result;
-  }
-
-  virtual bool isMonic() const = 0;
-  virtual void
-  coefficientToString(llvm::SmallString<16> &coeffString) const = 0;
-
-  template <class D, typename T>
-  friend ::llvm::hash_code hash_value(const MonomialBase<D, T> &arg);
-
-protected:
-  CoefficientType coefficient;
-  APInt exponent;
-};
-
-/// A class representing a monomial of a single-variable polynomial with integer
-/// coefficients.
-class IntMonomial : public MonomialBase<IntMonomial, APInt> {
-public:
-  IntMonomial(int64_t coeff, uint64_t expo)
-      : MonomialBase(APInt(apintBitWidth, coeff), APInt(apintBitWidth, expo)) {}
-
-  IntMonomial()
-      : MonomialBase(APInt(apintBitWidth, 0), APInt(apintBitWidth, 0)) {}
-
-  ~IntMonomial() override = default;
-
-  bool isMonic() const override { return coefficient == 1; }
-
-  void coefficientToString(llvm::SmallString<16> &coeffString) const override {
-    coefficient.toStringSigned(coeffString);
-  }
-};
-
-/// A class representing a monomial of a single-variable polynomial with integer
-/// coefficients.
-class FloatMonomial : public MonomialBase<FloatMonomial, APFloat> {
-public:
-  FloatMonomial(double coeff, uint64_t expo)
-      : MonomialBase(APFloat(coeff), APInt(apintBitWidth, expo)) {}
-
-  FloatMonomial() : MonomialBase(APFloat((double)0), APInt(apintBitWidth, 0)) {}
-
-  ~FloatMonomial() override = default;
-
-  bool isMonic() const override { return coefficient == APFloat(1.0); }
-
-  void coefficientToString(llvm::SmallString<16> &coeffString) const override {
-    coefficient.toString(coeffString);
-  }
-};
-
-template <class Derived, typename Monomial>
-class PolynomialBase {
-public:
-  PolynomialBase() = delete;
-
-  explicit PolynomialBase(ArrayRef<Monomial> terms) : terms(terms) {};
-
-  explicit operator bool() const { return !terms.empty(); }
-  bool operator==(const PolynomialBase &other) const {
-    return other.terms == terms;
-  }
-  bool operator!=(const PolynomialBase &other) const {
-    return !(other.terms == terms);
-  }
-
-  void print(raw_ostream &os, ::llvm::StringRef separator,
-             ::llvm::StringRef exponentiation) const {
-    bool first = true;
-    for (const Monomial &term : getTerms()) {
-      if (first) {
-        first = false;
-      } else {
-        os << separator;
-      }
-      std::string coeffToPrint;
-      if (term.isMonic() && term.getExponent().uge(1)) {
-        coeffToPrint = "";
-      } else {
-        llvm::SmallString<16> coeffString;
-        term.coefficientToString(coeffString);
-        coeffToPrint = coeffString.str();
-      }
-
-      if (term.getExponent() == 0) {
-        os << coeffToPrint;
-      } else if (term.getExponent() == 1) {
-        os << coeffToPrint << "x";
-      } else {
-        llvm::SmallString<16> expString;
-        term.getExponent().toStringSigned(expString);
-        os << coeffToPrint << "x" << exponentiation << expString;
-      }
-    }
-  }
-
-  Derived add(const Derived &other) {
-    SmallVector<Monomial> newTerms;
-    auto it1 = terms.begin();
-    auto it2 = other.terms.begin();
-    while (it1 != terms.end() || it2 != other.terms.end()) {
-      if (it1 == terms.end()) {
-        newTerms.emplace_back(*it2);
-        it2++;
-        continue;
-      }
-
-      if (it2 == other.terms.end()) {
-        newTerms.emplace_back(*it1);
-        it1++;
-        continue;
-      }
-
-      while (it1->getExponent().ult(it2->getExponent())) {
-        newTerms.emplace_back(*it1);
-        it1++;
-        if (it1 == terms.end())
-          break;
-      }
-
-      while (it2->getExponent().ult(it1->getExponent())) {
-        newTerms.emplace_back(*it2);
-        it2++;
-        if (it2 == terms.end())
-          break;
-      }
-
-      newTerms.emplace_back(it1->add(*it2));
-      it1++;
-      it2++;
-    }
-    return Derived(newTerms);
-  }
-
-  // Prints polynomial to 'os'.
-  void print(raw_ostream &os) const { print(os, " + ", "**"); }
-
-  void dump() const;
-
-  // Prints polynomial so that it can be used as a valid identifier
-  std::string toIdentifier() const {
-    std::string result;
-    llvm::raw_string_ostream os(result);
-    print(os, "_", "");
-    return os.str();
-  }
-
-  unsigned getDegree() const {
-    return terms.back().getExponent().getZExtValue();
-  }
-
-  ArrayRef<Monomial> getTerms() const { return terms; }
-
-  template <class D, typename T>
-  friend ::llvm::hash_code hash_value(const PolynomialBase<D, T> &arg);
-
-private:
-  // The monomial terms for this polynomial.
-  SmallVector<Monomial> terms;
-};
-
-/// A single-variable polynomial with integer coefficients.
-///
-/// Eg: x^1024 + x + 1
-class IntPolynomial : public PolynomialBase<IntPolynomial, IntMonomial> {
-public:
-  explicit IntPolynomial(ArrayRef<IntMonomial> terms) : PolynomialBase(terms) {}
-
-  // Returns a Polynomial from a list of monomials.
-  // Fails if two monomials have the same exponent.
-  static FailureOr<IntPolynomial>
-  fromMonomials(ArrayRef<IntMonomial> monomials);
-
-  /// Returns a polynomial with coefficients given by `coeffs`. The value
-  /// coeffs[i] is converted to a monomial with exponent i.
-  static IntPolynomial fromCoefficients(ArrayRef<int64_t> coeffs);
-};
-
-/// A single-variable polynomial with double coefficients.
-///
-/// Eg: 1.0 x^1024 + 3.5 x + 1e-05
-class FloatPolynomial : public PolynomialBase<FloatPolynomial, FloatMonomial> {
-public:
-  explicit FloatPolynomial(ArrayRef<FloatMonomial> terms)
-      : PolynomialBase(terms) {}
-
-  // Returns a Polynomial from a list of monomials.
-  // Fails if two monomials have the same exponent.
-  static FailureOr<FloatPolynomial>
-  fromMonomials(ArrayRef<FloatMonomial> monomials);
-
-  /// Returns a polynomial with coefficients given by `coeffs`. The value
-  /// coeffs[i] is converted to a monomial with exponent i.
-  static FloatPolynomial fromCoefficients(ArrayRef<double> coeffs);
-};
-
-// Make Polynomials hashable.
-template <class D, typename T>
-inline ::llvm::hash_code hash_value(const PolynomialBase<D, T> &arg) {
-  return ::llvm::hash_combine_range(arg.terms);
-}
-
-template <class D, typename T>
-inline ::llvm::hash_code hash_value(const MonomialBase<D, T> &arg) {
-  return llvm::hash_combine(::llvm::hash_value(arg.coefficient),
-                            ::llvm::hash_value(arg.exponent));
-}
-
-template <class D, typename T>
-inline raw_ostream &operator<<(raw_ostream &os,
-                               const PolynomialBase<D, T> &polynomial) {
-  polynomial.print(os);
-  return os;
-}
-
-} // namespace polynomial
-} // namespace mlir
-
-#endif // MLIR_DIALECT_POLYNOMIAL_IR_POLYNOMIAL_H_
diff --git a/mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.td b/mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.td
deleted file mode 100644
index 755396c8b9023..0000000000000
--- a/mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.td
+++ /dev/null
@@ -1,350 +0,0 @@
-//===- Polynomial.td - Polynomial dialect ------------------*- tablegen -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef POLYNOMIAL_OPS
-#define POLYNOMIAL_OPS
-
-include "mlir/IR/BuiltinAttributes.td"
-include "mlir/IR/OpBase.td"
-include "mlir/Interfaces/InferTypeOpInterface.td"
-include "mlir/Interfaces/SideEffectInterfaces.td"
-include "mlir/Dialect/Polynomial/IR/PolynomialDialect.td"
-include "mlir/Dialect/Polynomial/IR/PolynomialAttributes.td"
-include "mlir/Dialect/Polynomial/IR/PolynomialTypes.td"
-
-class Polynomial_Op<string mnemonic, list<Trait> traits = []> :
-    Op<Polynomial_Dialect, mnemonic, traits # [Pure]> {
-  let assemblyFormat = "operands attr-dict `:` functional-type(operands, results)";
-}
-
-class Polynomial_UnaryOp<string mnemonic, list<Trait> traits = []> :
-    Polynomial_Op<mnemonic, traits # [SameOperandsAndResultType]> {
-  let arguments = (ins Polynomial_PolynomialType:$operand);
-  let results = (outs Polynomial_PolynomialType:$result);
-}
-
-class Polynomial_BinaryOp<string mnemonic, list<Trait> traits = []> :
-    Polynomial_Op<mnemonic, !listconcat(traits, [Pure, SameOperandsAndResultType, ElementwiseMappable])> {
-  let arguments = (ins PolynomialLike:$lhs, PolynomialLike:$rhs);
-  let results = (outs PolynomialLike:$result);
-  let assemblyFormat = "operands attr-dict `:` type($result)";
-}
-
-def Polynomial_AddOp : Polynomial_BinaryOp<"add", [Commutative]> {
-  let summary = "Addition operation between polynomials.";
-  let description = [{
-    Performs polynomial addition on the operands. The operands may be single
-    polynomials or containers of identically-typed polynomials, i.e., polynomials
-    from the same underlying ring with the same coefficient types.
-
-    Addition is defined to occur in the ring defined by the ring attribute of
-    the two operands, meaning the addition is taken modulo the coefficientModulus
-    and the polynomialModulus of the ring.
-
-    Example:
-
-    ```mlir
-    // add two polynomials modulo x^1024 - 1
-    #poly = #polynomial.int_polynomial<x**1024 - 1>
-    #ring = #polynomial.ring<coefficientType=i32, coefficientModulus=65536:i32, polynomialModulus=#poly>
-    %0 = polynomial.constant int<1 + x**2> : !polynomial.polynomial<#ring>
-    %1 = polynomial.constant int<x**5 - x + 1> : !polynomial.polynomial<#ring>
-    %2 = polynomial.add %0, %1 : !polynomial.polynomial<#ring>
-    ```
-  }];
-}
-
-def Polynomial_SubOp : Polynomial_BinaryOp<"sub"> {
-  let summary = "Subtraction operation between polynomials.";
-  let description = [{
-    Performs polynomial subtraction on the operands. The operands may be single
-    polynomials or containers of identically-typed polynomials, i.e., polynomials
-    from the same underlying ring with the same coefficient types.
-
-    Subtraction is defined to occur in the ring defined by the ring attribute of
-    the two operands, meaning the subtraction is taken modulo the coefficientModulus
-    and the polynomialModulus of the ring.
-
-    Example:
-
-    ```mlir
-    // subtract two polynomials modulo x^1024 - 1
-    #poly = #polynomial.int_polynomial<x**1024 - 1>
-    #ring = #polynomial.ring<coefficientType=i32, coefficientModulus=65536:i32, polynomialModulus=#poly>
-    %0 = polynomial.constant int<1 + x**2> : !polynomial.polynomial<#ring>
-    %1 = polynomial.constant int<x**5 - x + 1> : !polynomial.polynomial<#ring>
-    %2 = polynomial.sub %0, %1 : !polynomial.polynomial<#ring>
-    ```
-  }];
-  let hasCanonicalizer = 1;
-}
-
-def Polynomial_MulOp : Polynomial_BinaryOp<"mul", [Commutative]> {
-  let summary = "Multiplication operation between polynomials.";
-  let description = [{
-    Performs polynomial multiplication on the operands. The operands may be single
-    polynomials or containers of identically-typed polynomials, i.e., polynomials
-    from the same underlying ring with the same coefficient types.
-
-    Multiplication is defined to occur in the ring defined by the ring attribute of
-    the two operands, meaning the multiplication is taken modulo the coefficientModulus
-    and the polynomialModulus of the ring.
-
-    Example:
-
-    ```mlir
-    // multiply two polynomials modulo x^1024 - 1
-    #poly = #polynomial.int_polynomial<x**1024 - 1>
-    #ring = #polynomial.ring<coefficientType=i32, coefficientModulus=65536:i32, polynomialModulus=#poly>
-    %0 = polynomial.constant int<1 + x**2> : !polynomial.polynomial<#ring>
-    %1 = polynomial.constant int<x**5 - x + 1> : !polynomial.polynomial<#ring>
-    %2 = polynomial.mul %0, %1 : !polynomial.polynomial<#ring>
-    ```
-  }];
-}
-
-def Polynomial_MulScalarOp : Polynomial_Op<"mul_scalar", [
-      ElementwiseMappable, AllTypesMatch<["polynomial", "output"]>]> {
-  let summary = "Multiplication by a scalar of the field.";
-  let description = [{
-    Multiplies the polynomial operand's coefficients by a given scalar value.
-    The operation is defined to occur in the ring defined by the ring attribute
-    of the two operands, meaning the multiplication is taken modulo the
-    coefficientModulus of the ring.
-
-    The `scalar` input must have the same type as the polynomial ring's
-    coefficientType.
-
-    Example:
-
-    ```mlir
-    // multiply two polynomials modulo x^1024 - 1
-    #poly = #polynomial.int_polynomial<x**1024 - 1>
-    #ring = #polynomial.ring<coefficientType=i32, coefficientModulus=65536:i32, polynomialModulus=#poly>
-    %0 = polynomial.constant int<1 + x**2> : !polynomial.polynomial<#ring>
-    %1 = arith.constant 3 : i32
-    %2 = polynomial.mul_scalar %0, %1 : !polynomial.polynomial<#ring>, i32
-    ```
-  }];
-
-  let arguments = (ins
-    PolynomialLike:$polynomial,
-    AnyInteger:$scalar
-  );
-  let results = (outs
-    PolynomialLike:$output
-  );
-  let assemblyFormat = "operands attr-dict `:` type($polynomial) `,` type($scalar)";
-  let hasVerifier = 1;
-}
-
-def Polynomial_LeadingTermOp: Polynomial_Op<"leading_term"> {
-  let summary = "Compute the leading term of the polynomial.";
-  let description = [{
-    The degree of a polynomial is the largest $k$ for which the coefficient
-    `a_k` of `x^k` is nonzero. The leading term is the term `a_k * x^k`, which
-    this op represents as a pair of results. The first is the degree `k` as an
-    index, and the second is the coefficient, whose type matches the
-    coefficient type of the polynomial's ring attribute.
-
-    Example:
-
-    ```mlir
-    #poly = #polynomial.int_polynomial<x**1024 - 1>
-    #ring = #polynomial.ring<coefficientType=i32, coefficientModulus=65536:i32, polynomialModulus=#poly>
-    %0 = polynomial.constant int<1 + x**2> : !polynomial.polynomial<#ring>
-    %1, %2 = polynomial.leading_term %0 : !polynomial.polynomial<#ring> -> (index, i32)
-    ```
-  }];
-  let arguments = (ins Polynomial_PolynomialType:$input);
-  let results = (outs Index:$degree, AnyInteger:$coefficient);
-  let assemblyFormat = "operands attr-dict `:` type($input) `->` `(` type($degree) `,` type($coefficient) `)`";
-}
-
-def Polynomial_MonomialOp: Polynomial_Op<"monomial"> {
-  let summary = "Create a polynomial that consists of a single monomial.";
-  let description = [{
-    Construct a polynomial that consists of a single monomial term, from its
-    degree and coefficient as dynamic inputs.
-
-    The coefficient type of the output polynomial's ring attribute must match
-    the `coefficient` input type.
-
-    Example:
-
-    ```mlir
-    #poly = #polynomial.int_polynomial<x**1024 - 1>
-    #ring = #polynomial.ring<coefficientType=i32, coefficientModulus=65536:i32, polynomialModulus=#poly>
-    %deg = arith.constant 1023 : index
-    %five = arith.constant 5 : i32
-    %0 = polynomial.monomial %five, %deg : (i32, index) -> !polynomial.polynomial<#ring>
-    ```
-  }];
-  let arguments = (ins AnyInteger:$coefficient, Index:$degree);
-  let results = (outs Polynomial_PolynomialType:$output);
-}
-
-def Polynomial_MonicMonomialMulOp: Polynomial_Op<"monic_monomial_mul", [AllTypesMatch<["input", "output"]>]> {
-  let summary = "Multiply a polynomial by a monic monomial.";
-  let description = [{
-    Multiply a polynomial by a monic monomial, meaning a polynomial of the form
-    `1 * x^k` for an index operand `k`.
-
-    In some special rings of polynomials, such as a ring of polynomials
-    modulo `x^n - 1`, `monomial_mul` can be interpreted as a cyclic shift of
-    the coefficients of the polynomial. For some rings, this results in
-    optimized lowerings that involve rotations and rescaling of the
-    coefficients of the input.
-  }];
-  let arguments = (ins PolynomialLike:$input, Index:$monomialDegree);
-  let results = (outs PolynomialLike:$output);
-}
-
-def Polynomial_FromTensorOp : Polynomial_Op<"from_tensor", [Pure]> {
-  let summary = "Creates a polynomial from integer coefficients stored in a tensor.";
-  let description = [{
-    `polynomial.from_tensor` creates a polynomial value from a tensor of coefficients.
-    The input tensor must list the coefficients in degree-increasing order.
-
-    The input one-dimensional tensor may have size at most the degree of the
-    ring's polynomialModulus generator polynomial, with smaller dimension implying that
-    all higher-degree t...
[truncated]

Copy link

github-actions bot commented May 13, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@j2kun j2kun requested review from joker-eph and removed request for keith, rupprecht and aaronmondal May 13, 2025 17:12
Copy link
Collaborator

@joker-eph joker-eph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@j2kun j2kun merged commit a3d2b7e into llvm:main May 13, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bazel "Peripheral" support tier build system: utils/bazel mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants