llvm-project/mlir/lib/Dialect/Polynomial/IR/PolynomialDialect.cpp
Jeremy Kun 55b6f17071
Add a polynomial dialect shell, attributes, and types (#72081)
RFC:
https://discourse.llvm.org/t/rfc-a-poly-dialect-for-polynomial-arithmetic/73891

This PR implements the minimal work needed to represent the polynomial
type such that it can be tested with `lit`.

In this PR:

- Dialect shell
- `Polynomial` data structure needed for folding
- Polynomial attributes (`PolynomialAttr` and `RingAttr` which store a polynomial)
- `polynomial.polynomial` type
- Basic lit tests

---------

Co-authored-by: Jeremy Kun <j2kun@users.noreply.github.com>
2024-04-15 09:12:00 -07:00

42 lines
1.4 KiB
C++

//===- PolynomialDialect.cpp - Polynomial dialect ---------------*- 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
//
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/Polynomial/IR/Polynomial.h"
#include "mlir/Dialect/Polynomial/IR/PolynomialAttributes.h"
#include "mlir/Dialect/Polynomial/IR/PolynomialOps.h"
#include "mlir/Dialect/Polynomial/IR/PolynomialTypes.h"
#include "llvm/ADT/TypeSwitch.h"
using namespace mlir;
using namespace mlir::polynomial;
#include "mlir/Dialect/Polynomial/IR/PolynomialDialect.cpp.inc"
#define GET_ATTRDEF_CLASSES
#include "mlir/Dialect/Polynomial/IR/PolynomialAttributes.cpp.inc"
#define GET_TYPEDEF_CLASSES
#include "mlir/Dialect/Polynomial/IR/PolynomialTypes.cpp.inc"
#define GET_OP_CLASSES
#include "mlir/Dialect/Polynomial/IR/Polynomial.cpp.inc"
void PolynomialDialect::initialize() {
addAttributes<
#define GET_ATTRDEF_LIST
#include "mlir/Dialect/Polynomial/IR/PolynomialAttributes.cpp.inc"
>();
addTypes<
#define GET_TYPEDEF_LIST
#include "mlir/Dialect/Polynomial/IR/PolynomialTypes.cpp.inc"
>();
addOperations<
#define GET_OP_LIST
#include "mlir/Dialect/Polynomial/IR/Polynomial.cpp.inc"
>();
}