1//===-- Attributes.td - Attribute mapping for Python -------*- tablegen -*-===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8// 9// This defines the mapping between MLIR ODS attributes and the corresponding 10// Python binding classes. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef PYTHON_BINDINGS_ATTRIBUTES 15#define PYTHON_BINDINGS_ATTRIBUTES 16 17// A mapping between the attribute storage type and the corresponding Python 18// type. There is not necessarily a 1-1 match for non-builtin attributes. 19class PythonAttr<string c, string p> { 20 string cppStorageType = c; 21 string pythonType = p; 22} 23 24// Mappings between supported builtin attribtues and Python types. 25def : PythonAttr<"::mlir::Attribute", "_ir.Attribute">; 26def : PythonAttr<"::mlir::BoolAttr", "_ir.BoolAttr">; 27def : PythonAttr<"::mlir::IntegerAttr", "_ir.IntegerAttr">; 28def : PythonAttr<"::mlir::FloatAttr", "_ir.FloatAttr">; 29def : PythonAttr<"::mlir::StringAttr", "_ir.StringAttr">; 30def : PythonAttr<"::mlir::DenseElementsAttr", "_ir.DenseElementsAttr">; 31def : PythonAttr<"::mlir::DenseIntElementsAttr", "_ir.DenseIntElementsAttr">; 32def : PythonAttr<"::mlir::DenseFPElementsAttr", "_ir.DenseFPElementsAttr">; 33 34#endif 35