From 9b034f0bfd641799c5ae16acd4fa53093a83c510 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 9 Jan 2019 13:50:20 -0800 Subject: Add tblgen::Attribute to wrap around TableGen Attr defs This CL added a tblgen::Attribute class to wrap around raw TableGen Record getValue*() calls on Attr defs, which will provide a nicer API for handling TableGen Record. PiperOrigin-RevId: 228581107 --- mlir/lib/TableGen/Attribute.cpp | 80 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 mlir/lib/TableGen/Attribute.cpp (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp new file mode 100644 index 00000000000..ff49dc0fe0f --- /dev/null +++ b/mlir/lib/TableGen/Attribute.cpp @@ -0,0 +1,80 @@ +//===- Attribute.cpp - Attribute wrapper class ------------------*- C++ -*-===// +// +// Copyright 2019 The MLIR Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================= +// +// Attribute wrapper to simplify using TableGen Record defining a MLIR +// Attribute. +// +//===----------------------------------------------------------------------===// + +#include "mlir/TableGen/Operator.h" +#include "llvm/TableGen/Record.h" + +using namespace mlir; + +// Returns the initializer's value as string if the given TableGen initializer +// is a code or string initializer. Returns the empty StringRef otherwise. +static StringRef getValueAsString(const llvm::Init *init) { + if (const auto *code = dyn_cast(init)) + return code->getValue().trim(); + else if (const auto *str = dyn_cast(init)) + return str->getValue().trim(); + return {}; +} + +tblgen::Attribute::Attribute(const llvm::Record &def) : def(def) { + assert(def.isSubClassOf("Attr") && + "must be subclass of TableGen 'Attr' class"); +} + +tblgen::Attribute::Attribute(const llvm::DefInit *init) + : Attribute(*init->getDef()) {} + +bool tblgen::Attribute::isDerivedAttr() const { + return def.isSubClassOf("DerivedAttr"); +} + +tblgen::Type tblgen::Attribute::getType() const { + return Type(def.getValueAsDef("type")); +} + +bool tblgen::Attribute::hasStorageType() const { + const auto *init = def.getValueInit("storageType"); + return !getValueAsString(init).empty(); +} + +StringRef tblgen::Attribute::getStorageType() const { + const auto *init = def.getValueInit("storageType"); + auto type = getValueAsString(init); + if (type.empty()) + return "Attribute"; + return type; +} + +StringRef tblgen::Attribute::getReturnType() const { + const auto *init = def.getValueInit("returnType"); + return getValueAsString(init); +} + +StringRef tblgen::Attribute::getConvertFromStorageCall() const { + const auto *init = def.getValueInit("convertFromStorage"); + return getValueAsString(init); +} + +StringRef tblgen::Attribute::getDerivedCodeBody() const { + assert(isDerivedAttr() && "only derived attribute has 'body' field"); + return def.getValueAsString("body"); +} -- cgit v1.2.3 From bd161ae5bcb87c72b94ea09ac06ca240f8b2b3e3 Mon Sep 17 00:00:00 2001 From: Alex Zinenko Date: Wed, 16 Jan 2019 09:23:14 -0800 Subject: TableGen: untie Attr from Type In TableGen definitions, the "Type" class has been used for types of things that can be stored in Attributes, but not necessarily present in the MLIR type system. As a consequence, records like "String" or "DerviedAttrBody" were of class "Type", which can be confusing. Furthermore, the "builderCall" field of the "Type" class serves only for attribute construction. Some TableGen "Type" subclasses that correspond to MLIR kinds of types do not have a canonical way of construction only from the data available in TableGen, e.g. MemRefType would require the list of affine maps. This leads to a conclusion that the entities that describe types of objects appearing in Attributes should be independent of "Type": they have some properties "Type"s don't and vice versa. Do not parameterize Tablegen "Attr" class by an instance of "Type". Instead, provide a "constBuilderCall" field that can be used to build an attribute from a constant value stored in TableGen instead of indirectly going through Attribute.Type.builderCall. Some attributes still don't have a "constBuilderCall" because they used to depend on types without a "builderCall". Drop definitions of class "Type" that don't correspond to MLIR Types. Provide infrastructure to define type-dependent attributes and string-backed attributes for convenience. PiperOrigin-RevId: 229570087 --- mlir/include/mlir/IR/op_base.td | 81 ++++++++++++++++++++---------- mlir/include/mlir/TableGen/Attribute.h | 15 ++++-- mlir/include/mlir/TableGen/Operator.h | 1 + mlir/include/mlir/TableGen/Type.h | 5 -- mlir/lib/TableGen/Attribute.cpp | 18 +++++-- mlir/lib/TableGen/Type.cpp | 10 ---- mlir/test/mlir-tblgen/one-op-one-result.td | 6 +-- mlir/tools/mlir-tblgen/RewriterGen.cpp | 19 ++----- 8 files changed, 88 insertions(+), 67 deletions(-) (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/include/mlir/IR/op_base.td b/mlir/include/mlir/IR/op_base.td index 07aa16ee162..3f3f17df71e 100644 --- a/mlir/include/mlir/IR/op_base.td +++ b/mlir/include/mlir/IR/op_base.td @@ -84,12 +84,20 @@ class TypeConstraint { string description = descr; } -// A specific type that can be constructed. Also carries type constraints, but -// accepts any type by default. -class Type, string descr = ""> : TypeConstraint { - // The builder call to invoke (if specified) to construct the Type. +// A type, carries type constraints, but accepts any type by default. +class Type, string descr = ""> + : TypeConstraint; + +// A type that can be constructed using MLIR::Builder. +// Note that this does not "inherit" from Type because it would require +// duplicating Type subclasses for buildable and non-buildable cases to avoid +// diamond "inheritance". +// TODO(zinenko): we may extend this to a more general 'Buildable' trait, +// making some Types and some Attrs buildable. +class BuildableType { + // The builder call to invoke (if specified) to construct the BuildableType. // Format: this will be affixed to the builder. - code builderCall = ?; + code builderCall = builder; } // Integer types. @@ -103,9 +111,9 @@ def Index : IntegerBase()">, "index">; // Integer type of a specific width. class I - : IntegerBase, "i" # width> { + : IntegerBase, "i" # width>, + BuildableType<"getIntegerType(" # width # ")"> { int bitwidth = width; - let builderCall = "getIntegerType(" # bitwidth # ")"; } def I1 : I<1>; def I32 : I<32>; @@ -118,9 +126,9 @@ def Float : FloatBase()">, "floating point">; // Float type of a specific width. class F - : FloatBase, "f" # width> { + : FloatBase, "f" # width>, + BuildableType<"getF" # width # "Type()"> { int bitwidth = width; - let builderCall = "getF" # width # "Type()"; } def F32 : F<32>; @@ -180,12 +188,6 @@ class TypedTensor def F32Tensor : TypedTensor; -// String type. -def String : Type; - -// Type corresponding to derived attribute. -def DerivedAttrBody : Type; - // Type constraint for integer-like types: integers, indices, vectors of // integers, tensors of integers. def IntegerLike : TypeConstraint { - Type type = t; - +class Attr { code storageType = ?; // The backing mlir::Attribute type code returnType = ?; // The underlying C++ value type @@ -216,36 +216,65 @@ class Attr { // '{0}.getValue().convertToFloat()' for 'FloatAttr val' will expand to // 'getAttrOfType("val").getValue().convertToFloat()'. code convertFromStorage = "{0}.getValue()"; + + // The call expression that builds an attribute from a constant value. + // + // Format: {0} will be expanded to an instance of mlir::Builder, {1} will be + // expanded to the constant value of the attribute. For example, + // '{0}.getStringAttr("{1}")' for 'StringAttr:"foo"' will expand to + // 'builder.getStringAttr("foo")'. + code constBuilderCall = ?; +} + +// A generic attribute that must be constructed around a specific type. +// Backed by a C++ class "attrName". +class TypeBasedAttr : Attr { + let constBuilderCall = + "{0}.get" # attrName # "({0}." # t.builderCall # ", {1})"; + let storageType = attrName; +} + +// An attribute backed by a string type. +class StringBasedAttr : Attr { + let constBuilderCall = [{ {0}.getStringAttr("{1}") }]; + let storageType = [{ StringAttr }]; } -def BoolAttr : Attr { +// Base class for instantiating float attributes of fixed width. +class FloatAttrBase : TypeBasedAttr; + +// Base class for instantiating integer attributes of fixed width. +class IntegerAttrBase : TypeBasedAttr; + +def BoolAttr : Attr { let storageType = [{ BoolAttr }]; let returnType = [{ bool }]; + let constBuilderCall = [{ {0}.getBoolAttr({1})" }]; } -def ElementsAttr : Attr { +def ElementsAttr : Attr { let storageType = [{ ElementsAttr }]; let returnType = [{ ElementsAttr }]; - code convertFromStorage = "{0}"; + let convertFromStorage = "{0}"; } -def F32Attr : Attr { - let storageType = [{ FloatAttr }]; +def F32Attr : FloatAttrBase { let returnType = [{ float }]; let convertFromStorage = [{ {0}.getValue().convertToFloat() }]; } -def I32Attr : Attr { +def I32Attr : IntegerAttrBase { let storageType = [{ IntegerAttr }]; let returnType = [{ int }]; let convertFromStorage = [{ {0}.getValue().getSExtValue() }]; } -def StrAttr : Attr { +def StrAttr : StringBasedAttr { let storageType = [{ StringAttr }]; let returnType = [{ StringRef }]; + let constBuilderCall = [{ {0}.getStringAttr("{1}") }]; } // DerivedAttr are attributes whose value is computed from properties // of the operation. They do not require additional storage and are // materialized as needed. -class DerivedAttr : Attr { +class DerivedAttr : Attr { let returnType = ReturnType; code body = Body; } diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index 3dd22ac79b8..4dc98596ea2 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -24,7 +24,6 @@ #define MLIR_TABLEGEN_ATTRIBUTE_H_ #include "mlir/Support/LLVM.h" -#include "mlir/TableGen/Type.h" #include "llvm/ADT/StringRef.h" namespace llvm { @@ -48,9 +47,6 @@ public: // of `DrivedAttr`). bool isDerivedAttr() const; - // Returns the type of this attribute. - Type getType() const; - // Returns true if this attribute has storage type set. bool hasStorageType() const; @@ -66,6 +62,17 @@ public: // The call will contain a `{0}` which will be expanded to this attribute. StringRef getConvertFromStorageCall() const; + // Returns true if this attribute can be built from a constant value. + bool isConstBuildable() const; + + // Returns the template that can be used to produce an instance of the + // attribute. + // Syntax: {0} should be replaced with a builder, {1} should be replaced with + // the constant value. + StringRef getConstBuilderTemplate() const; + + StringRef getTableGenDefName() const; + // Returns the code body for derived attribute. Aborts if this is not a // derived attribute. StringRef getDerivedCodeBody() const; diff --git a/mlir/include/mlir/TableGen/Operator.h b/mlir/include/mlir/TableGen/Operator.h index db5fe80b7bb..6ee799d7158 100644 --- a/mlir/include/mlir/TableGen/Operator.h +++ b/mlir/include/mlir/TableGen/Operator.h @@ -24,6 +24,7 @@ #include "mlir/Support/LLVM.h" #include "mlir/TableGen/Attribute.h" +#include "mlir/TableGen/Type.h" #include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" diff --git a/mlir/include/mlir/TableGen/Type.h b/mlir/include/mlir/TableGen/Type.h index 5bb40120033..4c0a27a985c 100644 --- a/mlir/include/mlir/TableGen/Type.h +++ b/mlir/include/mlir/TableGen/Type.h @@ -70,11 +70,6 @@ public: // Returns the TableGen def name for this type. StringRef getTableGenDefName() const; - - // Returns the method call to invoke upon a MLIR pattern rewriter to - // construct this type. Returns an empty StringRef if the method call - // is undefined or unset. - StringRef getBuilderCall() const; }; } // end namespace tblgen diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index ff49dc0fe0f..59e45d7bfd7 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -47,10 +47,6 @@ bool tblgen::Attribute::isDerivedAttr() const { return def.isSubClassOf("DerivedAttr"); } -tblgen::Type tblgen::Attribute::getType() const { - return Type(def.getValueAsDef("type")); -} - bool tblgen::Attribute::hasStorageType() const { const auto *init = def.getValueInit("storageType"); return !getValueAsString(init).empty(); @@ -74,6 +70,20 @@ StringRef tblgen::Attribute::getConvertFromStorageCall() const { return getValueAsString(init); } +bool tblgen::Attribute::isConstBuildable() const { + const auto *init = def.getValueInit("constBuilderCall"); + return !getValueAsString(init).empty(); +} + +StringRef tblgen::Attribute::getConstBuilderTemplate() const { + const auto *init = def.getValueInit("constBuilderCall"); + return getValueAsString(init); +} + +StringRef tblgen::Attribute::getTableGenDefName() const { + return def.getName(); +} + StringRef tblgen::Attribute::getDerivedCodeBody() const { assert(isDerivedAttr() && "only derived attribute has 'body' field"); return def.getValueAsString("body"); diff --git a/mlir/lib/TableGen/Type.cpp b/mlir/lib/TableGen/Type.cpp index efdc6ecd6b3..87017bb66ab 100644 --- a/mlir/lib/TableGen/Type.cpp +++ b/mlir/lib/TableGen/Type.cpp @@ -62,13 +62,3 @@ tblgen::Type::Type(const llvm::Record &record) : TypeConstraint(record) { tblgen::Type::Type(const llvm::DefInit *init) : Type(*init->getDef()) {} StringRef tblgen::Type::getTableGenDefName() const { return def.getName(); } - -StringRef tblgen::Type::getBuilderCall() const { - const auto *val = def.getValue("builderCall"); - assert(val && "TableGen 'Type' class should have 'builderCall' field"); - - if (const auto *builder = dyn_cast(val->getValue())) - return builder->getValue(); - return {}; -} - diff --git a/mlir/test/mlir-tblgen/one-op-one-result.td b/mlir/test/mlir-tblgen/one-op-one-result.td index 8f523b432f3..b3581a7fa0c 100644 --- a/mlir/test/mlir-tblgen/one-op-one-result.td +++ b/mlir/test/mlir-tblgen/one-op-one-result.td @@ -3,10 +3,8 @@ include "mlir/IR/op_base.td" // Create a Type and Attribute. -def YT : Type { - let builderCall = "buildYT()"; -} -def Y_Attr : Attr; +def YT : BuildableType<"buildYT">; +def Y_Attr : TypeBasedAttr; def Y_Const_Attr { Attr attr = Y_Attr; string value = "attrValue"; diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp index 58f3bf52866..d8d7a391b15 100644 --- a/mlir/tools/mlir-tblgen/RewriterGen.cpp +++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp @@ -19,6 +19,7 @@ // //===----------------------------------------------------------------------===// +#include "mlir/TableGen/Attribute.h" #include "mlir/TableGen/GenInfo.h" #include "mlir/TableGen/Operator.h" #include "mlir/TableGen/Predicate.h" @@ -93,24 +94,14 @@ private: void Pattern::emitAttributeValue(Record *constAttr) { Attribute attr(constAttr->getValueAsDef("attr")); auto value = constAttr->getValue("value"); - Type type = attr.getType(); - auto storageType = attr.getStorageType(); - - // For attributes stored as strings we do not need to query builder etc. - if (storageType == "StringAttr") { - os << formatv("rewriter.getStringAttr({0})", - value->getValue()->getAsString()); - return; - } - auto builder = type.getBuilderCall(); - if (builder.empty()) + if (!attr.isConstBuildable()) PrintFatalError(pattern->getLoc(), - "no builder specified for " + type.getTableGenDefName()); + "Attribute " + attr.getTableGenDefName() + + " does not have the 'constBuilderCall' field"); - // Construct the attribute based on storage type and builder. // TODO(jpienaar): Verify the constants here - os << formatv("{0}::get(rewriter.{1}, {2})", storageType, builder, + os << formatv(attr.getConstBuilderTemplate().str().c_str(), "rewriter", value->getValue()->getAsUnquotedString()); } -- cgit v1.2.3 From a5827fc91d3c2ebe447a7f8e22ff7f2bfd9ba440 Mon Sep 17 00:00:00 2001 From: Jacques Pienaar Date: Wed, 16 Jan 2019 10:23:21 -0800 Subject: Add attribute matching and transform to pattern rewrites. Start simple with single predicate match & transform rules for attributes. * Its unclear whether modelling Attr predicates will be needed so start with allowing matching attributes with a single predicate. * The input and output attr type often differs and so add ability to specify a transform between the input and output format. PiperOrigin-RevId: 229580879 --- mlir/g3doc/OpDefinitions.md | 3 ++ mlir/include/mlir/IR/op_base.td | 27 +++++++++- mlir/include/mlir/TableGen/Attribute.h | 4 +- mlir/lib/TableGen/Attribute.cpp | 24 ++++----- mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | 2 +- mlir/tools/mlir-tblgen/RewriterGen.cpp | 77 +++++++++++++++++++++-------- 6 files changed, 101 insertions(+), 36 deletions(-) (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/g3doc/OpDefinitions.md b/mlir/g3doc/OpDefinitions.md index af77133cefd..90f72903869 100644 --- a/mlir/g3doc/OpDefinitions.md +++ b/mlir/g3doc/OpDefinitions.md @@ -338,6 +338,9 @@ single output. (e.g., bias add rule only matches the case where both Tensors have F32 elements). + 1. Attributes can be transformed by transform rules to produce an attribute + of a type different than the type matched. + TODO: Add constraints on the matching rules. TODO: Describe the generation of benefit metric given pattern. diff --git a/mlir/include/mlir/IR/op_base.td b/mlir/include/mlir/IR/op_base.td index 3f3f17df71e..4a9614d842b 100644 --- a/mlir/include/mlir/IR/op_base.td +++ b/mlir/include/mlir/IR/op_base.td @@ -224,6 +224,9 @@ class Attr { // '{0}.getStringAttr("{1}")' for 'StringAttr:"foo"' will expand to // 'builder.getStringAttr("foo")'. code constBuilderCall = ?; + + // TODO(jpienaar): Add predicate to verify the validity of Attr so + // that verification can be generated. } // A generic attribute that must be constructed around a specific type. @@ -249,7 +252,12 @@ class IntegerAttrBase : TypeBasedAttr; def BoolAttr : Attr { let storageType = [{ BoolAttr }]; let returnType = [{ bool }]; - let constBuilderCall = [{ {0}.getBoolAttr({1})" }]; + let constBuilderCall = [{ {0}.getBoolAttr({1}) }]; +} +def ArrayAttr : Attr { + let storageType = [{ ArrayAttr }]; + let returnType = [{ ArrayAttr }]; + code convertFromStorage = "{0}"; } def ElementsAttr : Attr { let storageType = [{ ElementsAttr }]; @@ -407,4 +415,21 @@ class Pattern resultOps> { // Form of a pattern which produces a single result. class Pat : Pattern; +// Attribute matcher. This is the base class to specify a predicate +// that has to match. Used on the input attributes of a rewrite rule. +class mAttr { + // Code to match the attribute. + // Format: {0} represents the attribute. + CPred predicate = pred; +} + +// Attribute transforms. This is the base class to specify a +// transformation of a matched attribute. Used on the output of a rewrite +// rule. +class tAttr { + // Code to transform the attribute. + // Format: {0} represents the attribute. + code attrTransform = transform; +} + #endif // OP_BASE diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index 4dc98596ea2..d6c550a0f7a 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -40,7 +40,7 @@ namespace tblgen { class Attribute { public: explicit Attribute(const llvm::Record &def); - explicit Attribute(const llvm::Record *def) : Attribute(*def) {} + explicit Attribute(const llvm::Record *def); explicit Attribute(const llvm::DefInit *init); // Returns true if this attribute is a derived attribute (i.e., a subclass @@ -79,7 +79,7 @@ public: private: // The TableGen definition of this attribute. - const llvm::Record &def; + const llvm::Record *def; }; } // end namespace tblgen diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index 59e45d7bfd7..46a784e831e 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -35,25 +35,27 @@ static StringRef getValueAsString(const llvm::Init *init) { return {}; } -tblgen::Attribute::Attribute(const llvm::Record &def) : def(def) { - assert(def.isSubClassOf("Attr") && +tblgen::Attribute::Attribute(const llvm::Record *def) : def(def) { + assert(def->isSubClassOf("Attr") && "must be subclass of TableGen 'Attr' class"); } +tblgen::Attribute::Attribute(const llvm::Record &def) : Attribute(&def) {} + tblgen::Attribute::Attribute(const llvm::DefInit *init) : Attribute(*init->getDef()) {} bool tblgen::Attribute::isDerivedAttr() const { - return def.isSubClassOf("DerivedAttr"); + return def->isSubClassOf("DerivedAttr"); } bool tblgen::Attribute::hasStorageType() const { - const auto *init = def.getValueInit("storageType"); + const auto *init = def->getValueInit("storageType"); return !getValueAsString(init).empty(); } StringRef tblgen::Attribute::getStorageType() const { - const auto *init = def.getValueInit("storageType"); + const auto *init = def->getValueInit("storageType"); auto type = getValueAsString(init); if (type.empty()) return "Attribute"; @@ -61,30 +63,30 @@ StringRef tblgen::Attribute::getStorageType() const { } StringRef tblgen::Attribute::getReturnType() const { - const auto *init = def.getValueInit("returnType"); + const auto *init = def->getValueInit("returnType"); return getValueAsString(init); } StringRef tblgen::Attribute::getConvertFromStorageCall() const { - const auto *init = def.getValueInit("convertFromStorage"); + const auto *init = def->getValueInit("convertFromStorage"); return getValueAsString(init); } bool tblgen::Attribute::isConstBuildable() const { - const auto *init = def.getValueInit("constBuilderCall"); + const auto *init = def->getValueInit("constBuilderCall"); return !getValueAsString(init).empty(); } StringRef tblgen::Attribute::getConstBuilderTemplate() const { - const auto *init = def.getValueInit("constBuilderCall"); + const auto *init = def->getValueInit("constBuilderCall"); return getValueAsString(init); } StringRef tblgen::Attribute::getTableGenDefName() const { - return def.getName(); + return def->getName(); } StringRef tblgen::Attribute::getDerivedCodeBody() const { assert(isDerivedAttr() && "only derived attribute has 'body' field"); - return def.getValueAsString("body"); + return def->getValueAsString("body"); } diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp index dbddd5a8102..25d86393f8c 100644 --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -190,7 +190,7 @@ void OpEmitter::emitAttrGetters() { OUT(2) << attr.getReturnType() << ' ' << name << "() const {\n"; // Return the queried attribute with the correct return type. - std::string attrVal = formatv("this->getAttrOfType<{0}>(\"{1}\")", + std::string attrVal = formatv("this->getAttr(\"{1}\").dyn_cast<{0}>()", attr.getStorageType(), name); OUT(4) << "return " << formatv(attr.getConvertFromStorageCall(), attrVal) << ";\n }\n"; diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp index d8d7a391b15..b4839f5968a 100644 --- a/mlir/tools/mlir-tblgen/RewriterGen.cpp +++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp @@ -44,21 +44,19 @@ using mlir::tblgen::Type; namespace { -// Wrapper around dag argument. +// Wrapper around DAG argument. struct DagArg { - DagArg(Init *init) : init(init) {} + DagArg(mlir::tblgen::Operator::Argument arg, Init *constraintInit) + : arg(arg), constraintInit(constraintInit) {} bool isAttr(); - Init *init; + mlir::tblgen::Operator::Argument arg; + Init *constraintInit; }; } // end namespace -bool DagArg::isAttr() { - if (auto defInit = dyn_cast(init)) - return defInit->getDef()->isSubClassOf("Attr"); - return false; -} +bool DagArg::isAttr() { return arg.is(); } namespace { class Pattern { @@ -80,9 +78,18 @@ private: // Collect bound arguments. void collectBoundArguments(DagInit *tree); + // Helper function to match patterns. + void matchOp(DagInit *tree, int depth); + + // Returns the Operator stored for the given record. + Operator &getOperator(const llvm::Record *record); + // Map from bound argument name to DagArg. StringMap boundArguments; + // Map from Record* to Operator. + DenseMap opMap; + // Number of the operations in the input pattern. int numberOfOpsMatched = 0; @@ -91,6 +98,11 @@ private: }; } // end namespace +// Returns the Operator stored for the given record. +auto Pattern::getOperator(const llvm::Record *record) -> Operator & { + return opMap.try_emplace(record, record).first->second; +} + void Pattern::emitAttributeValue(Record *constAttr) { Attribute attr(constAttr->getValueAsDef("attr")); auto value = constAttr->getValue("value"); @@ -107,6 +119,7 @@ void Pattern::emitAttributeValue(Record *constAttr) { void Pattern::collectBoundArguments(DagInit *tree) { ++numberOfOpsMatched; + Operator &op = getOperator(cast(tree->getOperator())->getDef()); // TODO(jpienaar): Expand to multiple matches. for (int i = 0, e = tree->getNumArgs(); i != e; ++i) { auto arg = tree->getArg(i); @@ -117,14 +130,13 @@ void Pattern::collectBoundArguments(DagInit *tree) { auto name = tree->getArgNameStr(i); if (name.empty()) continue; - boundArguments.try_emplace(name, arg); + boundArguments.try_emplace(name, op.getArg(i), arg); } } // Helper function to match patterns. -static void matchOp(Record *pattern, DagInit *tree, int depth, - raw_ostream &os) { - Operator op(cast(tree->getOperator())->getDef()); +void Pattern::matchOp(DagInit *tree, int depth) { + Operator &op = getOperator(cast(tree->getOperator())->getDef()); int indent = 4 + 2 * depth; // Skip the operand matching at depth 0 as the pattern rewriter already does. if (depth != 0) { @@ -148,7 +160,7 @@ static void matchOp(Record *pattern, DagInit *tree, int depth, os.indent(indent + 2) << formatv( "auto op{0} = op{1}->getOperand({2})->getDefiningInst();\n", depth + 1, depth, i); - matchOp(pattern, argTree, depth + 1, os); + matchOp(argTree, depth + 1); os.indent(indent) << "}\n"; continue; } @@ -174,7 +186,19 @@ static void matchOp(Record *pattern, DagInit *tree, int depth, } // TODO(jpienaar): Verify attributes. - if (auto *attr = opArg.dyn_cast()) { + if (auto *namedAttr = opArg.dyn_cast()) { + // TODO(jpienaar): move to helper class. + if (defInit->getDef()->isSubClassOf("mAttr")) { + auto pred = + tblgen::Pred(defInit->getDef()->getValueInit("predicate")); + os.indent(indent) + << "if (!(" + << formatv(pred.getCondition().str().c_str(), + formatv("op{0}->getAttrOfType<{1}>(\"{2}\")", depth, + namedAttr->attr.getStorageType(), + namedAttr->getName())) + << ")) return matchFailure();\n"; + } } } @@ -202,7 +226,7 @@ void Pattern::emitMatcher(DagInit *tree) { if (op0->getNumResults() != 1) return matchFailure(); auto state = std::make_unique();)" << "\n"; - matchOp(pattern, tree, 0, os); + matchOp(tree, 0); os.indent(4) << "return matchSuccess(std::move(state));\n }\n"; } @@ -224,9 +248,9 @@ void Pattern::emit(StringRef rewriteName) { // Emit matched state. os << " struct MatchedState : public PatternState {\n"; for (auto &arg : boundArguments) { - if (arg.second.isAttr()) { - DefInit *defInit = cast(arg.second.init); - os.indent(4) << Attribute(defInit).getStorageType() << " " << arg.first() + if (auto namedAttr = + arg.second.arg.dyn_cast()) { + os.indent(4) << namedAttr->attr.getStorageType() << " " << arg.first() << ";\n"; } else { os.indent(4) << "Value* " << arg.first() << ";\n"; @@ -247,7 +271,7 @@ void Pattern::emit(StringRef rewriteName) { } DefInit *resultRoot = cast(resultTree->getOperator()); - Operator resultOp(*resultRoot->getDef()); + Operator &resultOp = getOperator(resultRoot->getDef()); auto resultOperands = resultRoot->getDef()->getValueAsDag("arguments"); os << formatv(R"( @@ -296,8 +320,19 @@ void Pattern::emit(StringRef rewriteName) { if (boundArguments.find(name) == boundArguments.end()) PrintFatalError(pattern->getLoc(), Twine("referencing unbound variable '") + name + "'"); - os << "/*" << opName << "=*/" - << "s." << name; + auto result = "s." + name; + os << "/*" << opName << "=*/"; + if (defInit) { + auto transform = defInit->getDef(); + if (transform->isSubClassOf("tAttr")) { + // TODO(jpienaar): move to helper class. + os << formatv( + transform->getValueAsString("attrTransform").str().c_str(), + result); + continue; + } + } + os << result; continue; } -- cgit v1.2.3 From d6f84fa5d912c1f300c75b18b21ac2b0c6331a0d Mon Sep 17 00:00:00 2001 From: Jacques Pienaar Date: Thu, 17 Jan 2019 10:36:51 -0800 Subject: Add AttrConstraint to enable generating verification for attribute values. Change MinMaxAttr to match hasValidMinMaxAttribute behavior. Post rewriting the other users of that function it could be removed too. The currently generated error message is: error: 'tfl.fake_quant' op attribute 'minmax' failed to satisfy constraint of MinMaxAttr PiperOrigin-RevId: 229775631 --- mlir/include/mlir/IR/op_base.td | 10 +++++++++- mlir/include/mlir/TableGen/Attribute.h | 10 ++++++++++ mlir/include/mlir/TableGen/Predicate.h | 2 ++ mlir/lib/TableGen/Attribute.cpp | 15 +++++++++++++++ mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | 9 +++++++++ 5 files changed, 45 insertions(+), 1 deletion(-) (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/include/mlir/IR/op_base.td b/mlir/include/mlir/IR/op_base.td index 0dc3ad3f1c5..9982fd49b27 100644 --- a/mlir/include/mlir/IR/op_base.td +++ b/mlir/include/mlir/IR/op_base.td @@ -218,8 +218,16 @@ def FloatLike : TypeConstraint { + // The predicates that this type satisfies. + // Format: {0} will be expanded to the attribute. + Pred predicate = condition; +} + // Base class for all attributes. -class Attr { +class Attr> : AttrConstraint { code storageType = ?; // The backing mlir::Attribute type code returnType = ?; // The underlying C++ value type diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index d6c550a0f7a..a720b1be6fb 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -24,6 +24,7 @@ #define MLIR_TABLEGEN_ATTRIBUTE_H_ #include "mlir/Support/LLVM.h" +#include "mlir/TableGen/Predicate.h" #include "llvm/ADT/StringRef.h" namespace llvm { @@ -77,6 +78,15 @@ public: // derived attribute. StringRef getDerivedCodeBody() const; + // Returns the predicate that can be used to check if a attribute satisfies + // this attribute's constraint. + Pred getPredicate() const; + + // Returns the template that can be used to verify that an attribute satisfies + // the constraints for its declared attribute type. + // Syntax: {0} should be replaced with the attribute. + std::string getConditionTemplate() const; + private: // The TableGen definition of this attribute. const llvm::Record *def; diff --git a/mlir/include/mlir/TableGen/Predicate.h b/mlir/include/mlir/TableGen/Predicate.h index 6c15bd41e66..e24b9ac398f 100644 --- a/mlir/include/mlir/TableGen/Predicate.h +++ b/mlir/include/mlir/TableGen/Predicate.h @@ -40,6 +40,8 @@ namespace tblgen { // TableGen class 'Pred'. class Pred { public: + // Constructs the null Predicate (e.g., always true). + explicit Pred() : def(nullptr) {} // Construct a Predicate from a record. explicit Pred(const llvm::Record *record); // Construct a Predicate from an initializer. diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index 46a784e831e..cbcc4c05eb9 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -90,3 +90,18 @@ StringRef tblgen::Attribute::getDerivedCodeBody() const { assert(isDerivedAttr() && "only derived attribute has 'body' field"); return def->getValueAsString("body"); } + +tblgen::Pred tblgen::Attribute::getPredicate() const { + auto *val = def->getValue("predicate"); + // If no predicate is specified, then return the null predicate (which + // corresponds to true). + if (!val) + return Pred(); + + const auto *pred = dyn_cast(val->getValue()); + return Pred(pred); +} + +std::string tblgen::Attribute::getConditionTemplate() const { + return getPredicate().getCondition(); +} diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp index 25d86393f8c..f361ff31109 100644 --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -369,6 +369,15 @@ void OpEmitter::emitVerifier() { OUT(4) << "if (!this->getAttr(\"" << name << "\").dyn_cast_or_null<" << attr.getStorageType() << ">()) return emitOpError(\"requires " << attr.getReturnType() << " attribute '" << name << "'\");\n"; + + auto attrPred = attr.getPredicate(); + if (!attrPred.isNull()) { + OUT(4) << formatv("if (!({0})) return emitOpError(\"attribute '{1}' " + "failed to satisfy constraint of {2}\");\n", + formatv(attrPred.getCondition(), + formatv("this->getAttr(\"{0}\")", name)), + name, attr.getTableGenDefName()); + } } // TODO: Handle variadic. -- cgit v1.2.3 From 34c6f8c6e4df968aa0feb63a685789b3456fcbb8 Mon Sep 17 00:00:00 2001 From: Jacques Pienaar Date: Tue, 22 Jan 2019 10:26:09 -0800 Subject: Add default attr value & define tf.AvgPool op and use pattern for rewrite. Add default values to attributes, to allow attribute being left unspecified. The attr getter will always return an attribute so callers need not check for it, if the attribute is not set then the default will be returned (at present the default will be constructed upon query but this will be changed). Add op definition for tf.AvgPool in ops.td, rewrite matcher using pattern using attribute matching & transforms. Adding some helper functions to make it simpler. Handle attributes with dialect prefix and map them to getter without dialect prefix. Note: VerifyAvgPoolOp could probably be autogenerated by know given the predicate specification on attributes, but deferring that to a follow up. PiperOrigin-RevId: 230364857 --- mlir/include/mlir/IR/op_base.td | 5 ++-- mlir/include/mlir/TableGen/Attribute.h | 8 ++++++ mlir/lib/TableGen/Attribute.cpp | 13 +++++++++ mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | 44 +++++++++++++++++++++++++---- 4 files changed, 62 insertions(+), 8 deletions(-) (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/include/mlir/IR/op_base.td b/mlir/include/mlir/IR/op_base.td index 9982fd49b27..a79eec8a235 100644 --- a/mlir/include/mlir/IR/op_base.td +++ b/mlir/include/mlir/IR/op_base.td @@ -248,8 +248,9 @@ class Attr> : AttrConstraint { // 'builder.getStringAttr("foo")'. code constBuilderCall = ?; - // TODO(jpienaar): Add predicate to verify the validity of Attr so - // that verification can be generated. + // Default value for attribute. + // Requires a constBuilderCall defined. + string defaultValue = ?; } // A generic attribute that must be constructed around a specific type. diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index a720b1be6fb..64c2db02cb9 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -72,6 +72,14 @@ public: // the constant value. StringRef getConstBuilderTemplate() const; + // Returns whether this attribute has a default value. + bool hasDefaultValue() const; + + // Returns the template that can be used to produce the default value of + // the attribute. + // Syntax: {0} should be replaced with a builder. + std::string getDefaultValueTemplate() const; + StringRef getTableGenDefName() const; // Returns the code body for derived attribute. Aborts if this is not a diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index cbcc4c05eb9..42dd333b3f7 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -21,6 +21,7 @@ //===----------------------------------------------------------------------===// #include "mlir/TableGen/Operator.h" +#include "llvm/Support/FormatVariadic.h" #include "llvm/TableGen/Record.h" using namespace mlir; @@ -82,6 +83,18 @@ StringRef tblgen::Attribute::getConstBuilderTemplate() const { return getValueAsString(init); } +bool tblgen::Attribute::hasDefaultValue() const { + const auto *init = def->getValueInit("defaultValue"); + return !getValueAsString(init).empty(); +} + +std::string tblgen::Attribute::getDefaultValueTemplate() const { + assert(isConstBuildable() && "requiers constBuilderCall"); + const auto *init = def->getValueInit("defaultValue"); + return llvm::formatv(getConstBuilderTemplate().str().c_str(), "{0}", + getValueAsString(init)); +} + StringRef tblgen::Attribute::getTableGenDefName() const { return def->getName(); } diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp index ead70a35dee..236fdb37de6 100644 --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -179,20 +179,41 @@ void OpEmitter::emitAttrGetters() { auto name = namedAttr.getName(); const auto &attr = namedAttr.attr; + // Determine the name of the attribute getter. The name matches the + // attribute name excluding dialect prefix. + StringRef getter = name; + auto it = getter.rfind('$'); + if (it != StringRef::npos) + getter = getter.substr(it + 1); + // Emit the derived attribute body. if (attr.isDerivedAttr()) { - OUT(2) << attr.getReturnType() << ' ' << name << "() const {" + OUT(2) << attr.getReturnType() << ' ' << getter << "() const {" << attr.getDerivedCodeBody() << " }\n"; continue; } // Emit normal emitter. - OUT(2) << attr.getReturnType() << ' ' << name << "() const {\n"; + OUT(2) << attr.getReturnType() << ' ' << getter << "() const {\n"; // Return the queried attribute with the correct return type. std::string attrVal = formatv("this->getAttr(\"{1}\").dyn_cast<{0}>()", attr.getStorageType(), name); - OUT(4) << "return " << formatv(attr.getConvertFromStorageCall(), attrVal) + OUT(4) << "auto attr = " << attrVal << ";\n"; + if (attr.hasDefaultValue()) { + // Returns the default value if not set. + // TODO: this is inefficient, we are recreating the attribute for every + // call. This should be set instead. + OUT(4) << "if (!attr)\n"; + OUT(6) << "return " + << formatv( + attr.getConvertFromStorageCall(), + formatv( + attr.getDefaultValueTemplate(), + "mlir::Builder(this->getInstruction()->getContext())")) + << ";\n"; + } + OUT(4) << "return " << formatv(attr.getConvertFromStorageCall(), "attr") << ";\n }\n"; } } @@ -359,25 +380,36 @@ void OpEmitter::emitVerifier() { continue; auto name = namedAttr.getName(); - if (!attr.hasStorageType()) { + if (!attr.hasStorageType() && !attr.hasDefaultValue()) { + // TODO: Some verification can be done even without storage type. OUT(4) << "if (!this->getAttr(\"" << name << "\")) return emitOpError(\"requires attribute '" << name << "'\");\n"; continue; } - OUT(4) << "if (!this->getAttr(\"" << name << "\").dyn_cast_or_null<" + if (attr.hasDefaultValue()) { + // If the attribute has a default value, then only verify the predicate if + // set. This does effectively assume that the default value is valid. + // TODO: verify the debug value is valid (perhaps in debug mode only). + OUT(4) << "if (this->getAttr(\"" << name << "\")) {\n"; + } + + OUT(6) << "if (!this->getAttr(\"" << name << "\").dyn_cast_or_null<" << attr.getStorageType() << ">()) return emitOpError(\"requires " << attr.getReturnType() << " attribute '" << name << "'\");\n"; auto attrPred = attr.getPredicate(); if (!attrPred.isNull()) { - OUT(4) << formatv("if (!({0})) return emitOpError(\"attribute '{1}' " + OUT(6) << formatv("if (!({0})) return emitOpError(\"attribute '{1}' " "failed to satisfy constraint of {2}\");\n", formatv(attrPred.getCondition(), formatv("this->getAttr(\"{0}\")", name)), name, attr.getTableGenDefName()); } + + if (attr.hasDefaultValue()) + OUT(4) << "}\n"; } // TODO: Handle variadic. -- cgit v1.2.3 From 0fbf4ff232cdad9f6131527f2a23019bfb331b9e Mon Sep 17 00:00:00 2001 From: Jacques Pienaar Date: Mon, 28 Jan 2019 07:13:40 -0800 Subject: Define mAttr in terms of AttrConstraint. * Matching an attribute and specifying a attribute constraint is the same thing executionally, so represent it such. * Extract AttrConstraint helper to match TypeConstraint and use that where mAttr was previously used in RewriterGen. PiperOrigin-RevId: 231213580 --- mlir/include/mlir/IR/op_base.td | 8 ++---- mlir/include/mlir/TableGen/Attribute.h | 43 ++++++++++++++++++------------ mlir/lib/TableGen/Attribute.cpp | 48 ++++++++++++++++++++-------------- mlir/lib/TableGen/Type.cpp | 2 +- mlir/tools/mlir-tblgen/RewriterGen.cpp | 19 +++++--------- 5 files changed, 65 insertions(+), 55 deletions(-) (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/include/mlir/IR/op_base.td b/mlir/include/mlir/IR/op_base.td index 85d41a0de3c..63a055f1469 100644 --- a/mlir/include/mlir/IR/op_base.td +++ b/mlir/include/mlir/IR/op_base.td @@ -221,7 +221,7 @@ def FloatLike : TypeConstraint { - // The predicates that this type satisfies. + // The predicates that this attribute satisfies. // Format: {0} will be expanded to the attribute. Pred predicate = condition; } @@ -443,11 +443,7 @@ class Pat : Pattern; // Attribute matcher. This is the base class to specify a predicate // that has to match. Used on the input attributes of a rewrite rule. -class mAttr { - // Code to match the attribute. - // Format: {0} represents the attribute. - CPred predicate = pred; -} +class mAttr : AttrConstraint; // Attribute transforms. This is the base class to specify a // transformation of a matched attribute. Used on the output of a rewrite diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index 64c2db02cb9..eca480410e6 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -35,13 +35,37 @@ class Record; namespace mlir { namespace tblgen { +// Wrapper class with helper methods for accessing Attribute constraints defined +// in TableGen. +class AttrConstraint { +public: + explicit AttrConstraint(const llvm::Record *record); + explicit AttrConstraint(const llvm::DefInit *init); + + // Returns the predicate that can be used to check if a attribute satisfies + // this attribute constraint. + Pred getPredicate() const; + + // Returns the condition template that can be used to check if a attribute + // satisfies this attribute constraint. The template may contain "{0}" that + // must be substituted with an expression returning an mlir::Attribute. + std::string getConditionTemplate() const; + + // Returns the user-readable description of the constraint. If the + // description is not provided, returns an empty string. + StringRef getDescription() const; + +protected: + // The TableGen definition of this attribute. + const llvm::Record *def; +}; + // Wrapper class providing helper methods for accessing MLIR Attribute defined // in TableGen. This class should closely reflect what is defined as class // `Attr` in TableGen. -class Attribute { +class Attribute : public AttrConstraint { public: - explicit Attribute(const llvm::Record &def); - explicit Attribute(const llvm::Record *def); + explicit Attribute(const llvm::Record *record); explicit Attribute(const llvm::DefInit *init); // Returns true if this attribute is a derived attribute (i.e., a subclass @@ -85,19 +109,6 @@ public: // Returns the code body for derived attribute. Aborts if this is not a // derived attribute. StringRef getDerivedCodeBody() const; - - // Returns the predicate that can be used to check if a attribute satisfies - // this attribute's constraint. - Pred getPredicate() const; - - // Returns the template that can be used to verify that an attribute satisfies - // the constraints for its declared attribute type. - // Syntax: {0} should be replaced with the attribute. - std::string getConditionTemplate() const; - -private: - // The TableGen definition of this attribute. - const llvm::Record *def; }; } // end namespace tblgen diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index 42dd333b3f7..f4c040ce179 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -36,15 +36,38 @@ static StringRef getValueAsString(const llvm::Init *init) { return {}; } -tblgen::Attribute::Attribute(const llvm::Record *def) : def(def) { - assert(def->isSubClassOf("Attr") && - "must be subclass of TableGen 'Attr' class"); +tblgen::AttrConstraint::AttrConstraint(const llvm::Record *record) + : def(record) { + assert(def->isSubClassOf("AttrConstraint") && + "must be subclass of TableGen 'AttrConstraint' class"); +} + +tblgen::AttrConstraint::AttrConstraint(const llvm::DefInit *init) + : AttrConstraint(init->getDef()) {} + +tblgen::Pred tblgen::AttrConstraint::getPredicate() const { + auto *val = def->getValue("predicate"); + // If no predicate is specified, then return the null predicate (which + // corresponds to true). + if (!val) + return Pred(); + + const auto *pred = dyn_cast(val->getValue()); + return Pred(pred); +} + +std::string tblgen::AttrConstraint::getConditionTemplate() const { + return getPredicate().getCondition(); } -tblgen::Attribute::Attribute(const llvm::Record &def) : Attribute(&def) {} +tblgen::Attribute::Attribute(const llvm::Record *record) + : AttrConstraint(record) { + assert(record->isSubClassOf("Attr") && + "must be subclass of TableGen 'Attr' class"); +} tblgen::Attribute::Attribute(const llvm::DefInit *init) - : Attribute(*init->getDef()) {} + : AttrConstraint(init->getDef()) {} bool tblgen::Attribute::isDerivedAttr() const { return def->isSubClassOf("DerivedAttr"); @@ -103,18 +126,3 @@ StringRef tblgen::Attribute::getDerivedCodeBody() const { assert(isDerivedAttr() && "only derived attribute has 'body' field"); return def->getValueAsString("body"); } - -tblgen::Pred tblgen::Attribute::getPredicate() const { - auto *val = def->getValue("predicate"); - // If no predicate is specified, then return the null predicate (which - // corresponds to true). - if (!val) - return Pred(); - - const auto *pred = dyn_cast(val->getValue()); - return Pred(pred); -} - -std::string tblgen::Attribute::getConditionTemplate() const { - return getPredicate().getCondition(); -} diff --git a/mlir/lib/TableGen/Type.cpp b/mlir/lib/TableGen/Type.cpp index d7f2d7118f6..0c5def6d621 100644 --- a/mlir/lib/TableGen/Type.cpp +++ b/mlir/lib/TableGen/Type.cpp @@ -53,7 +53,7 @@ llvm::StringRef tblgen::TypeConstraint::getDescription() const { } tblgen::TypeConstraint::TypeConstraint(const llvm::DefInit &init) - : def(*init.getDef()) {} + : TypeConstraint(*init.getDef()) {} tblgen::Type::Type(const llvm::Record &record) : TypeConstraint(record) { assert(def.isSubClassOf("Type") && diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp index 5c83528a8f8..7af3134bcf1 100644 --- a/mlir/tools/mlir-tblgen/RewriterGen.cpp +++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp @@ -208,18 +208,13 @@ void Pattern::matchOp(DagInit *tree, int depth) { // TODO(jpienaar): Verify attributes. if (auto *namedAttr = opArg.dyn_cast()) { - // TODO(jpienaar): move to helper class. - if (defInit->getDef()->isSubClassOf("mAttr")) { - auto pred = - tblgen::Pred(defInit->getDef()->getValueInit("predicate")); - os.indent(indent) - << "if (!(" - << formatv(pred.getCondition().c_str(), - formatv("op{0}->getAttrOfType<{1}>(\"{2}\")", depth, - namedAttr->attr.getStorageType(), - namedAttr->getName())) - << ")) return matchFailure();\n"; - } + auto constraint = tblgen::AttrConstraint(defInit); + std::string condition = formatv( + constraint.getConditionTemplate().c_str(), + formatv("op{0}->getAttrOfType<{1}>(\"{2}\")", depth, + namedAttr->attr.getStorageType(), namedAttr->getName())); + os.indent(indent) << "if (!(" << condition + << ")) return matchFailure();\n"; } } -- cgit v1.2.3 From 726dc08e4d8ede14efff36e2b488d22c5aff2da5 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 30 Jan 2019 05:59:58 -0800 Subject: [doc] Generate more readable description for attributes This CL added "description" field to AttrConstraint and Attr, like what we have for type classes. PiperOrigin-RevId: 231579853 --- mlir/include/mlir/IR/op_base.td | 39 ++++++++++++++++++------------ mlir/include/mlir/TableGen/Attribute.h | 4 +-- mlir/lib/TableGen/Attribute.cpp | 7 ++++++ mlir/test/mlir-tblgen/one-op-one-result.td | 2 +- mlir/tools/mlir-tblgen/OpDocGen.cpp | 8 ++---- 5 files changed, 35 insertions(+), 25 deletions(-) (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/include/mlir/IR/op_base.td b/mlir/include/mlir/IR/op_base.td index ebe60087a79..9cf46cbeb54 100644 --- a/mlir/include/mlir/IR/op_base.td +++ b/mlir/include/mlir/IR/op_base.td @@ -222,14 +222,18 @@ def FloatLike : TypeConstraint { +class AttrConstraint { // The predicates that this attribute satisfies. // Format: {0} will be expanded to the attribute. Pred predicate = condition; + // User-readable description used, e.g., for error reporting. + // If empty, a generic message will be used instead. + string description = descr; } // Base class for all attributes. -class Attr> : AttrConstraint { +class Attr : + AttrConstraint { code storageType = ?; // The backing mlir::Attribute type code returnType = ?; // The underlying C++ value type @@ -257,49 +261,52 @@ class Attr> : AttrConstraint { // A generic attribute that must be constructed around a specific type. // Backed by a C++ class "attrName". -class TypeBasedAttr : Attr { +class TypeBasedAttr : + Attr, descr> { let constBuilderCall = "{0}.get" # attrName # "({0}." # t.builderCall # ", {1})"; let storageType = attrName; } // An attribute backed by a string type. -class StringBasedAttr : Attr { +class StringBasedAttr : Attr, descr> { let constBuilderCall = [{ {0}.getStringAttr("{1}") }]; let storageType = [{ StringAttr }]; } // Base class for instantiating float attributes of fixed width. -class FloatAttrBase : TypeBasedAttr; +class FloatAttrBase : + TypeBasedAttr; // Base class for instantiating integer attributes of fixed width. -class IntegerAttrBase : TypeBasedAttr; +class IntegerAttrBase : + TypeBasedAttr; -def BoolAttr : Attr { +def BoolAttr : Attr, "bool"> { let storageType = [{ BoolAttr }]; let returnType = [{ bool }]; let constBuilderCall = [{ {0}.getBoolAttr({1}) }]; } -def ArrayAttr : Attr { +def ArrayAttr : Attr, "array"> { let storageType = [{ ArrayAttr }]; let returnType = [{ ArrayAttr }]; code convertFromStorage = "{0}"; } -def ElementsAttr : Attr { +def ElementsAttr : Attr, "constant vector/tensor"> { let storageType = [{ ElementsAttr }]; let returnType = [{ ElementsAttr }]; let convertFromStorage = "{0}"; } -def F32Attr : FloatAttrBase { +def F32Attr : FloatAttrBase { let returnType = [{ float }]; let convertFromStorage = [{ {0}.getValue().convertToFloat() }]; } -def I32Attr : IntegerAttrBase { +def I32Attr : IntegerAttrBase { let storageType = [{ IntegerAttr }]; let returnType = [{ int }]; let convertFromStorage = [{ {0}.getValue().getSExtValue() }]; } -def StrAttr : StringBasedAttr { +def StrAttr : StringBasedAttr<"string"> { let storageType = [{ StringAttr }]; let returnType = [{ StringRef }]; let constBuilderCall = [{ {0}.getStringAttr("{1}") }]; @@ -308,9 +315,9 @@ def StrAttr : StringBasedAttr { // DerivedAttr are attributes whose value is computed from properties // of the operation. They do not require additional storage and are // materialized as needed. -class DerivedAttr : Attr { - let returnType = ReturnType; - code body = Body; +class DerivedAttr : Attr, "derived"> { + let returnType = ret; + code body = b; } // Derived attribute that returns a mlir::Type. @@ -448,7 +455,7 @@ class Pat : Pattern; // Attribute matcher. This is the base class to specify a predicate // that has to match. Used on the input attributes of a rewrite rule. -class mAttr : AttrConstraint; +class mAttr : AttrConstraint; // Attribute transforms. This is the base class to specify a // transformation of a matched attribute. Used on the output of a rewrite diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index eca480410e6..b126617f289 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -51,8 +51,8 @@ public: // must be substituted with an expression returning an mlir::Attribute. std::string getConditionTemplate() const; - // Returns the user-readable description of the constraint. If the - // description is not provided, returns an empty string. + // Returns the user-readable description of the constraint. If the description + // is not provided, returns the TableGen def name. StringRef getDescription() const; protected: diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index f4c040ce179..1e9c37cac9a 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -60,6 +60,13 @@ std::string tblgen::AttrConstraint::getConditionTemplate() const { return getPredicate().getCondition(); } +StringRef tblgen::AttrConstraint::getDescription() const { + auto doc = def->getValueAsString("description"); + if (doc.empty()) + return def->getName(); + return doc; +} + tblgen::Attribute::Attribute(const llvm::Record *record) : AttrConstraint(record) { assert(record->isSubClassOf("Attr") && diff --git a/mlir/test/mlir-tblgen/one-op-one-result.td b/mlir/test/mlir-tblgen/one-op-one-result.td index 44fc1ea437a..45056b154ed 100644 --- a/mlir/test/mlir-tblgen/one-op-one-result.td +++ b/mlir/test/mlir-tblgen/one-op-one-result.td @@ -4,7 +4,7 @@ include "mlir/IR/op_base.td" // Create a Type and Attribute. def YT : BuildableType<"buildYT">; -def Y_Attr : TypeBasedAttr; +def Y_Attr : TypeBasedAttr; def Y_Const_Attr { Attr attr = Y_Attr; string value = "attrValue"; diff --git a/mlir/tools/mlir-tblgen/OpDocGen.cpp b/mlir/tools/mlir-tblgen/OpDocGen.cpp index fafe45b8c60..bc124564e69 100644 --- a/mlir/tools/mlir-tblgen/OpDocGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDocGen.cpp @@ -114,12 +114,8 @@ static void emitOpDoc(const RecordKeeper &recordKeeper, raw_ostream &os) { // info. This should be improved. os << "\n### Attributes:\n"; for (auto namedAttr : op.getAttributes()) { - os << "- `" << namedAttr.getName() << "`: "; - if (namedAttr.attr.isDerivedAttr()) - os << "derived"; - else - os << namedAttr.attr.getTableGenDefName(); - os << "\n"; + os << "- `" << namedAttr.getName() + << "`: " << namedAttr.attr.getDescription() << " attribute\n"; } // Emit results. -- cgit v1.2.3 From e0774c008fdcee1d4007ede4fde4cf7ad83cfda8 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 1 Feb 2019 15:40:22 -0800 Subject: [TableGen] Use tblgen::DagLeaf to model DAG arguments This CL added a tblgen::DagLeaf wrapper class with several helper methods for handling DAG arguments. It helps to refactor the rewriter generation logic to be more higher level. This CL also added a tblgen::ConstantAttr wrapper class for constant attributes. PiperOrigin-RevId: 232050683 --- mlir/include/mlir/TableGen/Attribute.h | 18 +++ mlir/include/mlir/TableGen/Pattern.h | 82 +++++++--- mlir/include/mlir/TableGen/Type.h | 1 + mlir/lib/TableGen/Attribute.cpp | 14 ++ mlir/lib/TableGen/Pattern.cpp | 72 ++++++++- mlir/test/mlir-tblgen/one-op-one-result.td | 17 +-- mlir/tools/mlir-tblgen/RewriterGen.cpp | 232 +++++++++++++++-------------- 7 files changed, 292 insertions(+), 144 deletions(-) (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index b126617f289..e601fdf22ea 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -111,6 +111,24 @@ public: StringRef getDerivedCodeBody() const; }; +// Wrapper class providing helper methods for accessing MLIR constant attribute +// defined in TableGen. This class should closely reflect what is defined as +// class `ConstantAttr` in TableGen. +class ConstantAttr { +public: + explicit ConstantAttr(const llvm::DefInit *init); + + // Returns the attribute kind. + Attribute getAttribute() const; + + // Returns the constant value. + StringRef getConstantValue() const; + +private: + // The TableGen definition of this constant attribute. + const llvm::Record *def; +}; + } // end namespace tblgen } // end namespace mlir diff --git a/mlir/include/mlir/TableGen/Pattern.h b/mlir/include/mlir/TableGen/Pattern.h index 6544316313d..80a38329a33 100644 --- a/mlir/include/mlir/TableGen/Pattern.h +++ b/mlir/include/mlir/TableGen/Pattern.h @@ -23,6 +23,7 @@ #ifndef MLIR_TABLEGEN_PATTERN_H_ #define MLIR_TABLEGEN_PATTERN_H_ +#include "mlir/Support/LLVM.h" #include "mlir/TableGen/Argument.h" #include "mlir/TableGen/Operator.h" #include "llvm/ADT/DenseMap.h" @@ -30,9 +31,9 @@ #include "llvm/TableGen/Error.h" namespace llvm { -class Record; -class Init; class DagInit; +class Init; +class Record; class StringRef; } // end namespace llvm @@ -42,19 +43,61 @@ namespace tblgen { // Mapping from TableGen Record to Operator wrapper object using RecordOperatorMap = llvm::DenseMap; -// Wrapper around DAG argument. -struct DagArg { - DagArg(Argument arg, llvm::Init *constraint) - : arg(arg), constraint(constraint) {} +class Pattern; - // Returns true if this DAG argument concerns an operation attribute. - bool isAttr() const; +// Wrapper class providing helper methods for accessing TableGen DAG leaves +// used inside Patterns. This class is lightweight and designed to be used like +// values. +// +// A TableGen DAG construct is of the syntax +// `(operator, arg0, arg1, ...)`. +// +// This class provides getters to retrieve `arg*` as tblgen:: wrapper objects +// for handy helper methods. It only works on `arg*`s that are not nested DAG +// constructs. +class DagLeaf { +public: + explicit DagLeaf(const llvm::Init *def) : def(def) {} - Argument arg; - llvm::Init *constraint; -}; + // Returns true if this DAG leaf is not specified in the pattern. That is, it + // places no further constraints/transforms and just carries over the original + // value. + bool isUnspecified() const; -class Pattern; + // Returns true if this DAG leaf is matching an operand. That is, it specifies + // a type constraint. + bool isOperandMatcher() const; + + // Returns true if this DAG leaf is matching an attribute. That is, it + // specifies an attribute constraint. + bool isAttrMatcher() const; + + // Returns true if this DAG leaf is transforming an attribute. + bool isAttrTransformer() const; + + // Returns true if this DAG leaf is specifying a constant attribute. + bool isConstantAttr() const; + + // Returns this DAG leaf as a type constraint. Asserts if fails. + TypeConstraint getAsTypeConstraint() const; + + // Returns this DAG leaf as an attribute constraint. Asserts if fails. + AttrConstraint getAsAttrConstraint() const; + + // Returns this DAG leaf as an constant attribute. Asserts if fails. + ConstantAttr getAsConstantAttr() const; + + // Returns the matching condition template inside this DAG leaf. Assumes the + // leaf is an operand/attribute matcher and asserts otherwise. + std::string getConditionTemplate() const; + + // Returns the transformation template inside this DAG leaf. Assumes the + // leaf is an attribute matcher and asserts otherwise. + std::string getTransformationTemplate() const; + +private: + const llvm::Init *def; +}; // Wrapper class providing helper methods for accessing TableGen DAG constructs // used inside Patterns. This class is lightweight and designed to be used like @@ -96,10 +139,9 @@ public: // Gets the `index`-th argument as a nested DAG construct if possible. Returns // null DagNode otherwise. DagNode getArgAsNestedDag(unsigned index) const; - // Gets the `index`-th argument as a TableGen DefInit* if possible. Returns - // nullptr otherwise. - // TODO: This method is exposing raw TableGen object and should be changed. - llvm::DefInit *getArgAsDefInit(unsigned index) const; + + // Gets the `index`-th argument as a DAG leaf. + DagLeaf getArgAsLeaf(unsigned index) const; // Returns the specified name of the `index`-th argument. llvm::StringRef getArgName(unsigned index) const; @@ -146,7 +188,7 @@ public: void ensureArgBoundInSourcePattern(llvm::StringRef name) const; // Returns a reference to all the bound arguments in the source pattern. - llvm::StringMap &getSourcePatternBoundArgs(); + llvm::StringMap &getSourcePatternBoundArgs(); // Returns the op that the root node of the source pattern matches. const Operator &getSourceRootOp(); @@ -159,8 +201,10 @@ private: // The TableGen definition of this pattern. const llvm::Record &def; - RecordOperatorMap *recordOpMap; // All operators - llvm::StringMap boundArguments; // All bound arguments + // All operators + RecordOperatorMap *recordOpMap; + // All bound arguments + llvm::StringMap boundArguments; }; } // end namespace tblgen diff --git a/mlir/include/mlir/TableGen/Type.h b/mlir/include/mlir/TableGen/Type.h index fd91ff4dc2c..247e0fc8e4b 100644 --- a/mlir/include/mlir/TableGen/Type.h +++ b/mlir/include/mlir/TableGen/Type.h @@ -42,6 +42,7 @@ public: explicit TypeConstraint(const llvm::DefInit &init); bool operator==(const TypeConstraint &that) { return def == that.def; } + bool operator!=(const TypeConstraint &that) { return def != that.def; } // Returns the predicate that can be used to check if a type satisfies this // type constraint. diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index 1e9c37cac9a..2b8cda031ef 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -133,3 +133,17 @@ StringRef tblgen::Attribute::getDerivedCodeBody() const { assert(isDerivedAttr() && "only derived attribute has 'body' field"); return def->getValueAsString("body"); } + +tblgen::ConstantAttr::ConstantAttr(const llvm::DefInit *init) + : def(init->getDef()) { + assert(def->isSubClassOf("ConstantAttr") && + "must be subclass of TableGen 'ConstantAttr' class"); +} + +tblgen::Attribute tblgen::ConstantAttr::getAttribute() const { + return Attribute(def->getValueAsDef("attr")); +} + +StringRef tblgen::ConstantAttr::getConstantValue() const { + return def->getValueAsString("value"); +} diff --git a/mlir/lib/TableGen/Pattern.cpp b/mlir/lib/TableGen/Pattern.cpp index f9bb4a4b08c..5262141e753 100644 --- a/mlir/lib/TableGen/Pattern.cpp +++ b/mlir/lib/TableGen/Pattern.cpp @@ -28,8 +28,66 @@ using namespace mlir; using mlir::tblgen::Operator; -bool tblgen::DagArg::isAttr() const { - return arg.is(); +bool tblgen::DagLeaf::isUnspecified() const { + return !def || isa(def); +} + +bool tblgen::DagLeaf::isOperandMatcher() const { + if (!def || !isa(def)) + return false; + // Operand matchers specify a type constraint. + return cast(def)->getDef()->isSubClassOf("TypeConstraint"); +} + +bool tblgen::DagLeaf::isAttrMatcher() const { + if (!def || !isa(def)) + return false; + // Attribute matchers specify a type constraint. + return cast(def)->getDef()->isSubClassOf("AttrConstraint"); +} + +bool tblgen::DagLeaf::isAttrTransformer() const { + if (!def || !isa(def)) + return false; + return cast(def)->getDef()->isSubClassOf("tAttr"); +} + +bool tblgen::DagLeaf::isConstantAttr() const { + if (!def || !isa(def)) + return false; + return cast(def)->getDef()->isSubClassOf("ConstantAttr"); +} + +tblgen::TypeConstraint tblgen::DagLeaf::getAsTypeConstraint() const { + assert(isOperandMatcher() && "the DAG leaf must be operand"); + return TypeConstraint(*cast(def)->getDef()); +} + +tblgen::AttrConstraint tblgen::DagLeaf::getAsAttrConstraint() const { + assert(isAttrMatcher() && "the DAG leaf must be attribute"); + return AttrConstraint(cast(def)->getDef()); +} + +tblgen::ConstantAttr tblgen::DagLeaf::getAsConstantAttr() const { + assert(isConstantAttr() && "the DAG leaf must be constant attribute"); + return ConstantAttr(cast(def)); +} + +std::string tblgen::DagLeaf::getConditionTemplate() const { + assert((isOperandMatcher() || isAttrMatcher()) && + "the DAG leaf must be operand/attribute matcher"); + if (isOperandMatcher()) { + return getAsTypeConstraint().getConditionTemplate(); + } + return getAsAttrConstraint().getConditionTemplate(); +} + +std::string tblgen::DagLeaf::getTransformationTemplate() const { + assert(isAttrTransformer() && "the DAG leaf must be attribute transformer"); + return cast(def) + ->getDef() + ->getValueAsString("attrTransform") + .str(); } Operator &tblgen::DagNode::getDialectOp(RecordOperatorMap *mapper) const { @@ -56,8 +114,9 @@ tblgen::DagNode tblgen::DagNode::getArgAsNestedDag(unsigned index) const { return DagNode(dyn_cast_or_null(node->getArg(index))); } -llvm::DefInit *tblgen::DagNode::getArgAsDefInit(unsigned index) const { - return dyn_cast(node->getArg(index)); +tblgen::DagLeaf tblgen::DagNode::getArgAsLeaf(unsigned index) const { + assert(!isNestedDagArg(index)); + return DagLeaf(node->getArg(index)); } StringRef tblgen::DagNode::getArgName(unsigned index) const { @@ -81,7 +140,7 @@ static void collectBoundArguments(const llvm::DagInit *tree, if (name.empty()) continue; - pattern->getSourcePatternBoundArgs().try_emplace(name, op.getArg(i), arg); + pattern->getSourcePatternBoundArgs().try_emplace(name, op.getArg(i)); } } @@ -131,7 +190,8 @@ void tblgen::Pattern::ensureArgBoundInSourcePattern( Twine("referencing unbound variable '") + name + "'"); } -llvm::StringMap &tblgen::Pattern::getSourcePatternBoundArgs() { +llvm::StringMap & +tblgen::Pattern::getSourcePatternBoundArgs() { return boundArguments; } diff --git a/mlir/test/mlir-tblgen/one-op-one-result.td b/mlir/test/mlir-tblgen/one-op-one-result.td index 45056b154ed..3bdd9aa1b96 100644 --- a/mlir/test/mlir-tblgen/one-op-one-result.td +++ b/mlir/test/mlir-tblgen/one-op-one-result.td @@ -3,24 +3,21 @@ include "mlir/IR/op_base.td" // Create a Type and Attribute. -def YT : BuildableType<"buildYT">; -def Y_Attr : TypeBasedAttr; -def Y_Const_Attr { - Attr attr = Y_Attr; - string value = "attrValue"; -} +def T : BuildableType<"buildT">; +def T_Attr : TypeBasedAttr; +def T_Const_Attr : ConstantAttr; // Define ops to rewrite. -def T1: Type, "T1">; +def U: Type, "U">; def X_AddOp : Op<"x.add"> { - let arguments = (ins T1, T1); + let arguments = (ins U, U); } def Y_AddOp : Op<"y.add"> { - let arguments = (ins T1, T1, Y_Attr:$attrName); + let arguments = (ins U, U, T_Attr:$attrName); } // Define rewrite pattern. -def : Pat<(X_AddOp $lhs, $rhs), (Y_AddOp $lhs, T1:$rhs, Y_Const_Attr:$x)>; +def : Pat<(X_AddOp $lhs, $rhs), (Y_AddOp $lhs, U:$rhs, T_Const_Attr:$x)>; // CHECK: struct GeneratedConvert0 : public RewritePattern // CHECK: RewritePattern("x.add", 1, context) diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp index 6b62da7eb04..7ca663071d8 100644 --- a/mlir/tools/mlir-tblgen/RewriterGen.cpp +++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp @@ -39,31 +39,11 @@ using namespace llvm; using namespace mlir; -using mlir::tblgen::Argument; -using mlir::tblgen::Attribute; using mlir::tblgen::DagNode; using mlir::tblgen::NamedAttribute; using mlir::tblgen::Operand; using mlir::tblgen::Operator; -using mlir::tblgen::Pattern; using mlir::tblgen::RecordOperatorMap; -using mlir::tblgen::Type; - -namespace { - -// Wrapper around DAG argument. -struct DagArg { - DagArg(Argument arg, Init *constraintInit) - : arg(arg), constraintInit(constraintInit) {} - bool isAttr(); - - Argument arg; - Init *constraintInit; -}; - -} // end namespace - -bool DagArg::isAttr() { return arg.is(); } namespace { class PatternEmitter { @@ -93,12 +73,19 @@ private: void emitReplaceWithNativeBuilder(DagNode resultTree); // Emits the value of constant attribute to `os`. - void emitAttributeValue(Record *constAttr); + void emitConstantAttr(tblgen::ConstantAttr constAttr); // Emits C++ statements for matching the op constrained by the given DAG // `tree`. void emitOpMatch(DagNode tree, int depth); + // Emits C++ statements for matching the `index`-th argument of the given DAG + // `tree` as an operand. + void emitOperandMatch(DagNode tree, int index, int depth, int indent); + // Emits C++ statements for matching the `index`-th argument of the given DAG + // `tree` as an attribute. + void emitAttributeMatch(DagNode tree, int index, int depth, int indent); + private: // Pattern instantiation location followed by the location of multiclass // prototypes used. This is intended to be used as a whole to @@ -107,14 +94,13 @@ private: // Op's TableGen Record to wrapper object RecordOperatorMap *opMap; // Handy wrapper for pattern being emitted - Pattern pattern; + tblgen::Pattern pattern; raw_ostream &os; }; } // end namespace -void PatternEmitter::emitAttributeValue(Record *constAttr) { - Attribute attr(constAttr->getValueAsDef("attr")); - auto value = constAttr->getValue("value"); +void PatternEmitter::emitConstantAttr(tblgen::ConstantAttr constAttr) { + auto attr = constAttr.getAttribute(); if (!attr.isConstBuildable()) PrintFatalError(loc, "Attribute " + attr.getTableGenDefName() + @@ -122,7 +108,7 @@ void PatternEmitter::emitAttributeValue(Record *constAttr) { // TODO(jpienaar): Verify the constants here os << formatv(attr.getConstBuilderTemplate().str().c_str(), "rewriter", - value->getValue()->getAsUnquotedString()); + constAttr.getConstantValue()); } // Helper function to match patterns. @@ -137,13 +123,17 @@ void PatternEmitter::emitOpMatch(DagNode tree, int depth) { "if (!op{0}->isa<{1}>()) return matchFailure();\n", depth, op.getQualCppClassName()); } - if (tree.getNumArgs() != op.getNumArgs()) - PrintFatalError(loc, Twine("mismatch in number of arguments to op '") + - op.getOperationName() + - "' in pattern and op's definition"); + if (tree.getNumArgs() != op.getNumArgs()) { + PrintFatalError(loc, formatv("op '{0}' argument number mismatch: {1} in " + "pattern vs. {2} in definition", + op.getOperationName(), tree.getNumArgs(), + op.getNumArgs())); + } + for (int i = 0, e = tree.getNumArgs(); i != e; ++i) { auto opArg = op.getArg(i); + // Handle nested DAG construct first if (DagNode argTree = tree.getArgAsNestedDag(i)) { os.indent(indent) << "{\n"; os.indent(indent + 2) << formatv( @@ -154,50 +144,78 @@ void PatternEmitter::emitOpMatch(DagNode tree, int depth) { continue; } - // Verify arguments. - if (auto defInit = tree.getArgAsDefInit(i)) { - // Verify operands. - if (auto *operand = opArg.dyn_cast()) { - // Skip verification where not needed due to definition of op. - if (operand->type == Type(defInit)) - goto StateCapture; - - if (!defInit->getDef()->isSubClassOf("Type")) - PrintFatalError(loc, "type argument required for operand"); - - auto constraint = tblgen::TypeConstraint(*defInit); - os.indent(indent) - << "if (!(" - << formatv(constraint.getConditionTemplate().c_str(), - formatv("op{0}->getOperand({1})->getType()", depth, i)) - << ")) return matchFailure();\n"; - } - - // TODO(jpienaar): Verify attributes. - if (auto *namedAttr = opArg.dyn_cast()) { - auto constraint = tblgen::AttrConstraint(defInit); - std::string condition = formatv( - constraint.getConditionTemplate().c_str(), - formatv("op{0}->getAttrOfType<{1}>(\"{2}\")", depth, - namedAttr->attr.getStorageType(), namedAttr->getName())); - os.indent(indent) << "if (!(" << condition - << ")) return matchFailure();\n"; - } + // Next handle DAG leaf: operand or attribute + if (auto *operand = opArg.dyn_cast()) { + emitOperandMatch(tree, i, depth, indent); + } else if (auto *namedAttr = opArg.dyn_cast()) { + emitAttributeMatch(tree, i, depth, indent); + } else { + PrintFatalError(loc, "unhandled case when matching op"); } + } +} - StateCapture: - auto name = tree.getArgName(i); - if (name.empty()) - continue; - if (opArg.is()) - os.indent(indent) << "state->" << name << " = op" << depth - << "->getOperand(" << i << ");\n"; - if (auto namedAttr = opArg.dyn_cast()) { - os.indent(indent) << "state->" << name << " = op" << depth - << "->getAttrOfType<" - << namedAttr->attr.getStorageType() << ">(\"" - << namedAttr->getName() << "\");\n"; +void PatternEmitter::emitOperandMatch(DagNode tree, int index, int depth, + int indent) { + Operator &op = tree.getDialectOp(opMap); + auto *operand = op.getArg(index).get(); + auto matcher = tree.getArgAsLeaf(index); + + // If a constraint is specified, we need to generate C++ statements to + // check the constraint. + if (!matcher.isUnspecified()) { + if (!matcher.isOperandMatcher()) { + PrintFatalError( + loc, formatv("the {1}-th argument of op '{0}' should be an operand", + op.getOperationName(), index + 1)); } + + // Only need to verify if the matcher's type is different from the one + // of op definition. + if (static_cast(operand->type) != + matcher.getAsTypeConstraint()) { + os.indent(indent) << "if (!(" + << formatv(matcher.getConditionTemplate().c_str(), + formatv("op{0}->getOperand({1})->getType()", + depth, index)) + << ")) return matchFailure();\n"; + } + } + + // Capture the value + auto name = tree.getArgName(index); + if (!name.empty()) { + os.indent(indent) << "state->" << name << " = op" << depth + << "->getOperand(" << index << ");\n"; + } +} + +void PatternEmitter::emitAttributeMatch(DagNode tree, int index, int depth, + int indent) { + Operator &op = tree.getDialectOp(opMap); + auto *namedAttr = op.getArg(index).get(); + auto matcher = tree.getArgAsLeaf(index); + + if (!matcher.isUnspecified() && !matcher.isAttrMatcher()) { + PrintFatalError( + loc, formatv("the {1}-th argument of op '{0}' should be an attribute", + op.getOperationName(), index + 1)); + } + + // If a constraint is specified, we need to generate C++ statements to + // check the constraint. + std::string condition = + formatv(matcher.getConditionTemplate().c_str(), + formatv("op{0}->getAttrOfType<{1}>(\"{2}\")", depth, + namedAttr->attr.getStorageType(), namedAttr->getName())); + os.indent(indent) << "if (!(" << condition << ")) return matchFailure();\n"; + + // Capture the value + auto name = tree.getArgName(index); + if (!name.empty()) { + os.indent(indent) << "state->" << name << " = op" << depth + << "->getAttrOfType<" << namedAttr->attr.getStorageType() + << ">(\"" << namedAttr->getName() << "\");\n"; } } @@ -234,11 +252,12 @@ void PatternEmitter::emit(StringRef rewriteName) { // Emit matched state. os << " struct MatchedState : public PatternState {\n"; for (const auto &arg : pattern.getSourcePatternBoundArgs()) { - if (auto namedAttr = arg.second.arg.dyn_cast()) { - os.indent(4) << namedAttr->attr.getStorageType() << " " << arg.first() + auto fieldName = arg.first(); + if (auto namedAttr = arg.second.dyn_cast()) { + os.indent(4) << namedAttr->attr.getStorageType() << " " << fieldName << ";\n"; } else { - os.indent(4) << "Value* " << arg.first() << ";\n"; + os.indent(4) << "Value* " << fieldName << ";\n"; } } os << " };\n"; @@ -285,10 +304,10 @@ void PatternEmitter::emitReplaceOpWithNewOp(DagNode resultTree) { rewriter.replaceOpWithNewOp<{0}>(op, op->getResult(0)->getType())", resultOp.getCppClassName()); if (numOpArgs != resultTree.getNumArgs()) { - PrintFatalError(loc, Twine("mismatch between arguments of resultant op (") + - Twine(numOpArgs) + - ") and arguments provided for rewrite (" + - Twine(resultTree.getNumArgs()) + Twine(')')); + PrintFatalError(loc, formatv("resultant op '{0}' argument number mismatch: " + "{1} in pattern vs. {2} in definition", + resultOp.getOperationName(), + resultTree.getNumArgs(), numOpArgs)); } // Create the builder call for the result. @@ -312,38 +331,33 @@ void PatternEmitter::emitReplaceOpWithNewOp(DagNode resultTree) { // Start each attribute on its own line. (os << ",\n").indent(6); + auto leaf = resultTree.getArgAsLeaf(i); // The argument in the result DAG pattern. - auto argName = resultTree.getArgName(i); - auto opName = resultOp.getArgName(i); - auto *defInit = resultTree.getArgAsDefInit(i); - auto *value = defInit ? defInit->getDef()->getValue("value") : nullptr; - if (!value) { - pattern.ensureArgBoundInSourcePattern(argName); - auto result = "s." + argName; - os << "/*" << opName << "=*/"; - if (defInit) { - auto transform = defInit->getDef(); - if (transform->isSubClassOf("tAttr")) { - // TODO(jpienaar): move to helper class. - os << formatv( - transform->getValueAsString("attrTransform").str().c_str(), - result); - continue; - } - } - os << result; - continue; + auto patArgName = resultTree.getArgName(i); + // The argument in the op definition. + auto opArgName = resultOp.getArgName(i); + + if (leaf.isUnspecified() || leaf.isOperandMatcher()) { + pattern.ensureArgBoundInSourcePattern(patArgName); + os << formatv("/*{0}=*/s.{1}", opArgName, patArgName); + } else if (leaf.isAttrTransformer()) { + pattern.ensureArgBoundInSourcePattern(patArgName); + std::string result = std::string("s.") + patArgName.str(); + result = formatv(leaf.getTransformationTemplate().c_str(), result); + os << formatv("/*{0}=*/{1}", opArgName, result); + } else if (leaf.isConstantAttr()) { + // TODO(jpienaar): Refactor out into map to avoid recomputing these. + auto argument = resultOp.getArg(i); + if (!argument.is()) + PrintFatalError(loc, Twine("expected attribute ") + Twine(i)); + + if (!patArgName.empty()) + os << "/*" << patArgName << "=*/"; + emitConstantAttr(leaf.getAsConstantAttr()); + // TODO(jpienaar): verify types + } else { + PrintFatalError(loc, "unhandled case when rewriting op"); } - - // TODO(jpienaar): Refactor out into map to avoid recomputing these. - auto argument = resultOp.getArg(i); - if (!argument.is()) - PrintFatalError(loc, Twine("expected attribute ") + Twine(i)); - - if (!argName.empty()) - os << "/*" << argName << "=*/"; - emitAttributeValue(defInit->getDef()); - // TODO(jpienaar): verify types } os << "\n );\n"; } @@ -367,7 +381,7 @@ void PatternEmitter::emitReplaceWithNativeBuilder(DagNode resultTree) { auto name = resultTree.getArgName(i); pattern.ensureArgBoundInSourcePattern(name); const auto &val = boundedValues.find(name); - if (val->second.isAttr() && !printingAttr) { + if (val->second.dyn_cast() && !printingAttr) { os << "}, {"; first = true; printingAttr = true; -- cgit v1.2.3 From c81b16e27979f319e6f7969ac9ed220bc216c1e0 Mon Sep 17 00:00:00 2001 From: Stella Laurenzo Date: Fri, 22 Feb 2019 15:11:00 -0800 Subject: Spike to define real math ops and lowering of one variant of add to corresponding integer ops. The only reason in starting with a fixedpoint add is that it is the absolute simplest variant and illustrates the level of abstraction I'm aiming for. The overall flow would be: 1. Determine quantization parameters (out of scope of this cl). 2. Source dialect rules to lower supported math ops to the quantization dialect (out of scope of this cl). 3. Quantization passes: [-quant-convert-const, -quant-lower-uniform-real-math, -quant-lower-unsupported-to-float] (the last one not implemented yet) 4. Target specific lowering of the integral arithmetic ops (roughly at the level of gemmlowp) to more fundamental operations (i.e. calls to gemmlowp, simd instructions, DSP instructions, etc). How I'm doing this should facilitate implementation of just about any kind of backend except TFLite, which has a very course, adhoc surface area for its quantized kernels. Options there include (I'm not taking an opinion on this - just trying to provide options): a) Not using any of this: just match q/dbarrier + tf math ops to the supported TFLite quantized op set. b) Implement the more fundamental integer math ops on TFLite and convert to those instead of the current op set. Note that I've hand-waved over the process of choosing appropriate quantization parameters. Getting to that next. As you can see, different implementations will likely have different magic combinations of specific math support, and we will need the target system that has been discussed for some of the esoteric cases (i.e. many DSPs only support POT fixedpoint). Two unrelated changes to the overall goal of this CL and can be broken out of desired: - Adding optional attribute support to TabelGen - Allowing TableGen native rewrite hooks to return nullptr, signalling that no rewrite has been done. PiperOrigin-RevId: 235267229 --- mlir/include/mlir/IR/op_base.td | 29 +++++++++++++++++++++++++---- mlir/include/mlir/TableGen/Attribute.h | 3 +++ mlir/lib/TableGen/Attribute.cpp | 4 ++++ mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | 26 +++++++++++++++++++------- 4 files changed, 51 insertions(+), 11 deletions(-) (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/include/mlir/IR/op_base.td b/mlir/include/mlir/IR/op_base.td index 02ddcd37a6d..353fa33aaca 100644 --- a/mlir/include/mlir/IR/op_base.td +++ b/mlir/include/mlir/IR/op_base.td @@ -160,6 +160,7 @@ class F } def F32 : F<32>; +def F64 : F<64>; // A container type is a type that has another type embedded within it. class ContainerType : // Default value for attribute. // Requires a constBuilderCall defined. string defaultValue = ?; + + // Whether the attribute is optional. Typically requires a custom + // convertFromStorage method to handle the case where the attribute is + // not present. + bit isOptional = 0b0; } +// Decorates an attribute to have an (unvalidated) default value if not present. class DefaultValuedAttr : Attr { // Construct this attribute with the input attribute and change only @@ -281,6 +288,19 @@ class DefaultValuedAttr : let defaultValue = val; } +// Decorates an attribute as optional. The return type of the generated +// attribute accessor method will be Optional<>. +class OptionalAttr : + Attr { + // Rewrite the attribute to be optional. + // Note: this has to be kept up to date with Attr above. + let storageType = attr.storageType; + let returnType = "Optional<" # attr.returnType #">"; + let convertFromStorage = "{0} ? " # returnType # "({0}.getValue())" # + " : (llvm::None)"; + let isOptional = 0b1; +} + // A generic attribute that must be constructed around a specific type. // Backed by a C++ class "attrName". class TypeBasedAttr : @@ -299,7 +319,9 @@ class StringBasedAttr : Attr, descr> { // Base class for instantiating float attributes of fixed width. class FloatAttrBase : - TypeBasedAttr; + TypeBasedAttr { + let returnType = [{ APFloat }]; +} // Base class for instantiating integer attributes of fixed width. class IntegerAttrBase : @@ -322,9 +344,8 @@ class ElementsAttrBase : let convertFromStorage = "{0}"; } def ElementsAttr: ElementsAttrBase, "constant vector/tensor">; -def F32Attr : FloatAttrBase { - let returnType = [{ APFloat }]; -} +def F32Attr : FloatAttrBase; +def F64Attr : FloatAttrBase; def I32Attr : IntegerAttrBase { let storageType = [{ IntegerAttr }]; let returnType = [{ int }]; diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index e601fdf22ea..324194dbf64 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -99,6 +99,9 @@ public: // Returns whether this attribute has a default value. bool hasDefaultValue() const; + // Returns whether this attribute is optional. + bool isOptional() const; + // Returns the template that can be used to produce the default value of // the attribute. // Syntax: {0} should be replaced with a builder. diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index 2b8cda031ef..071cd61a4f4 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -118,6 +118,10 @@ bool tblgen::Attribute::hasDefaultValue() const { return !getValueAsString(init).empty(); } +bool tblgen::Attribute::isOptional() const { + return def->getValueAsBit("isOptional"); +} + std::string tblgen::Attribute::getDefaultValueTemplate() const { assert(isConstBuildable() && "requiers constBuilderCall"); const auto *init = def->getValueInit("defaultValue"); diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp index 167d44e2304..7606df0faaf 100644 --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -203,8 +203,9 @@ void OpEmitter::emitAttrGetters() { OUT(2) << attr.getReturnType() << ' ' << getter << "() const {\n"; // Return the queried attribute with the correct return type. - std::string attrVal = formatv("this->getAttr(\"{1}\").dyn_cast<{0}>()", - attr.getStorageType(), name); + std::string attrVal = + formatv("this->getAttr(\"{1}\").dyn_cast_or_null<{0}>()", + attr.getStorageType(), name); OUT(4) << "auto attr = " << attrVal << ";\n"; if (attr.hasDefaultValue()) { // Returns the default value if not set. @@ -265,7 +266,8 @@ void OpEmitter::emitStandaloneParamBuilder(bool isAllSameType) { const auto &attr = namedAttr.attr; if (attr.isDerivedAttr()) break; - os << ", " << attr.getStorageType() << ' ' << namedAttr.getName(); + os << ", /*optional*/" << attr.getStorageType() << ' ' + << namedAttr.getName(); } os << ") {\n"; @@ -315,10 +317,19 @@ void OpEmitter::emitStandaloneParamBuilder(bool isAllSameType) { } // Push all attributes to the result - for (const auto &namedAttr : op.getAttributes()) - if (!namedAttr.attr.isDerivedAttr()) + for (const auto &namedAttr : op.getAttributes()) { + if (!namedAttr.attr.isDerivedAttr()) { + bool emitNotNullCheck = namedAttr.attr.isOptional(); + if (emitNotNullCheck) { + OUT(4) << formatv("if ({0}) {\n", namedAttr.getName()); + } OUT(4) << formatv("result->addAttribute(\"{0}\", {0});\n", namedAttr.getName()); + if (emitNotNullCheck) { + OUT(4) << formatv("}\n"); + } + } + } OUT(2) << "}\n"; } @@ -462,7 +473,8 @@ void OpEmitter::emitVerifier() { continue; } - if (attr.hasDefaultValue()) { + bool allowMissingAttr = attr.hasDefaultValue() || attr.isOptional(); + if (allowMissingAttr) { // If the attribute has a default value, then only verify the predicate if // set. This does effectively assume that the default value is valid. // TODO: verify the debug value is valid (perhaps in debug mode only). @@ -482,7 +494,7 @@ void OpEmitter::emitVerifier() { name, attr.getTableGenDefName()); } - if (attr.hasDefaultValue()) + if (allowMissingAttr) OUT(4) << "}\n"; } -- cgit v1.2.3 From 8f5fa566239f88f5b0f3435103b3dc028b0a672a Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 25 Mar 2019 06:09:26 -0700 Subject: [TableGen] Consolidate constraint related concepts Previously we have multiple mechanisms to specify op definition and match constraints: TypeConstraint, AttributeConstraint, Type, Attr, mAttr, mAttrAnyOf, mPat. These variants are not added because there are so many distinct cases we need to model; essentially, they are all carrying a predicate. It's just an artifact of implementation. It's quite confusing for users to grasp these variants and choose among them. Instead, as the OpBase TableGen file, we need to strike to provide an unified mechanism. Each dialect has the flexibility to define its own aliases if wanted. This CL removes mAttr, mAttrAnyOf, mPat. A new base class, Constraint, is added. Now TypeConstraint and AttrConstraint derive from Constraint. Type and Attr further derive from TypeConstraint and AttrConstraint, respectively. Comments are revised and examples are added to make it clear how to use constraints. PiperOrigin-RevId: 240125076 --- mlir/include/mlir/IR/OpBase.td | 161 ++++++++++++++++++++------------ mlir/include/mlir/TableGen/Attribute.h | 24 +---- mlir/include/mlir/TableGen/Constraint.h | 86 +++++++++++++++++ mlir/include/mlir/TableGen/Pattern.h | 38 +------- mlir/include/mlir/TableGen/Type.h | 35 ++----- mlir/lib/TableGen/Attribute.cpp | 29 +----- mlir/lib/TableGen/Constraint.cpp | 66 +++++++++++++ mlir/lib/TableGen/Operator.cpp | 6 +- mlir/lib/TableGen/Pattern.cpp | 95 +++++-------------- mlir/lib/TableGen/Predicate.cpp | 2 +- mlir/lib/TableGen/Type.cpp | 36 ++----- mlir/tools/mlir-tblgen/RewriterGen.cpp | 60 ++++++------ 12 files changed, 334 insertions(+), 304 deletions(-) create mode 100644 mlir/include/mlir/TableGen/Constraint.h create mode 100644 mlir/lib/TableGen/Constraint.cpp (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index 1dafdeba6f0..228732e03d8 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -24,19 +24,32 @@ #define OP_BASE //===----------------------------------------------------------------------===// -// Predicates. +// Predicate definitions //===----------------------------------------------------------------------===// -// A logical predicate. +// Base class for logical predicates. +// +// Predicates are used to compose constraints (see next section for details). +// There are two categories of predicates: +// +// 1. CPred: the primitive leaf predicate. +// 2. Compound predicate: a predicate composed from child predicates using +// predicate combiners ("conjunction", "disjunction", "negation" or +// "substitution"). class Pred; -// Logical predicate wrapping a C expression. +// A logical predicate wrapping any C expression. +// +// This is the basis for composing more complex predicates. It is the "atom" +// predicate from the perspective of TableGen and the "interface" between +// TableGen and C++. What is inside is already C++ code, which will be treated +// as opaque strings with special placeholders to be substituted. class CPred : Pred { - code predCall = "(" # pred # ")"; + code predExpr = "(" # pred # ")"; } -// Kinds of combined logical predicates. These must closesly match the -// predicates implemented by the C++ backend (tblgen::PredCombinerKind). +// Kinds of predicate combiners. These must closesly match the predicates +// implemented by the C++ backend (tblgen::PredCombinerKind). class PredCombinerKind; def PredCombinerAnd : PredCombinerKind; def PredCombinerOr : PredCombinerKind; @@ -50,6 +63,8 @@ class CombinedPred c> : Pred { list children = c; } +// Predicate combiners + // A predicate that holds if all of its children hold. Always holds for zero // children. class AllOf children> : CombinedPred; @@ -62,9 +77,11 @@ class AnyOf children> : CombinedPred; class Neg : CombinedPred; // A predicate that substitutes "pat" with "repl" in predicate calls of the -// leaves of the predicate tree (i.e., not CombinedPredicates). This is plain -// string substitution without regular expressions or captures, new predicates -// with more complex logical can be introduced should the need arise. +// leaves of the predicate tree (i.e., not CombinedPred). +// +// This is plain string substitution without regular expressions or captures. +// New predicates with more complex logical can be introduced should the need +// arise. class SubstLeaves : CombinedPred { string pattern = pat; @@ -72,7 +89,61 @@ class SubstLeaves } //===----------------------------------------------------------------------===// -// Type predicates. ({0} is replaced by an instance of mlir::Type) +// Constraint definitions +//===----------------------------------------------------------------------===// + +// Base class for named constraints. +// +// An op's operands/attributes/results can have various requirements, e.g., +// having certain types, having values inside a certain range, and so on. +// Besides, for a graph rewrite rule, the source pattern used to match against +// the existing graph has conditions, like the op's operand must be of a more +// constrained subtype, the attribute must have a certain value, and so on. +// +// These requirements and conditions are modeled using this class. Records of +// this class are used to generate verification code in op verifier, and +// matching code in pattern matcher. +// +// Constraints are predicates with descriptive names, to facilitate inspection, +// provide nice error messages, etc. +class Constraint { + // The predicates that this constraint requires. + // Format: {0} will be expanded to the op operand/result's type or attribute. + Pred predicate = pred; + // User-readable description used in error reporting messages. If empty, a + // generic message will be used. + string description = desc; +} + +// Subclasses used to differentiate different constraint kinds. These are used +// as markers for the TableGen backend to handle different constraint kinds +// differently if needed. Constraints not deriving from the following subclasses +// are considered as uncategorized constraints. + +// Subclass for constraints on a type. +class TypeConstraint : + Constraint; + +// Subclass for constraints on an attribute. +class AttrConstraint : + Constraint; + +// How to use these constraint categories: +// +// * Use TypeConstraint to specify +// * Constraints on an op's operand/result definition +// * Further constraints to match an op's operand/result in source pattern +// +// * Use Attr (a subclass for AttrConstraint) for +// * Constraints on an op's attribute definition +// * Use AttrConstraint to specify +// * Further constraints to match an op's attribute in source pattern +// +// * Use uncategorized constraint to specify +// * Multi-entity constraints in rewrite rules + +//===----------------------------------------------------------------------===// +// Common predicates //===----------------------------------------------------------------------===// // Whether a type is a VectorType. @@ -89,23 +160,12 @@ def IsStaticShapeTensorTypePred : CPred<"{0}.cast().hasStaticShape()">; //===----------------------------------------------------------------------===// -// Type constraints and types. +// Type definitions //===----------------------------------------------------------------------===// -// A constraint on types. This can be used to check the validity of -// instruction arguments. -class TypeConstraint { - // The predicates that this type satisfies. - // Format: {0} will be expanded to the type. - Pred predicate = condition; - // User-readable description used, e.g., for error reporting. If empty, - // a generic message will be used instead. - string description = descr; -} - // A type, carries type constraints. -class Type - : TypeConstraint; +class Type : + TypeConstraint; // A variadic type constraint. It expands to zero or more of the base type. This // class is used for supporting variadic operands/results. An op can declare no @@ -262,16 +322,6 @@ def FloatLike : TypeConstraint { - // The predicates that this attribute satisfies. - // Format: {0} will be expanded to the attribute. - Pred predicate = condition; - // User-readable description used, e.g., for error reporting. - // If empty, a generic message will be used instead. - string description = descr; -} - // Base class for all attributes. class Attr : AttrConstraint { @@ -448,7 +498,7 @@ class ConstantAttr : AttrConstraint< class ConstF32Attr : ConstantAttr; //===----------------------------------------------------------------------===// -// Op Traits +// OpTrait definitions //===----------------------------------------------------------------------===// // OpTrait represents a trait regarding an op. @@ -484,7 +534,7 @@ def SameValueType : NativeOpTrait<"SameOperandsAndResultType">; def Terminator : NativeOpTrait<"IsTerminator">; //===----------------------------------------------------------------------===// -// Ops +// Op definitions //===----------------------------------------------------------------------===// // Marker used to identify the argument list for an op. @@ -626,14 +676,14 @@ class TCopVTEtIsSameAs : AllOf<[ CPred<"{0}.getOperand(" # i # ")->getType().cast().getElementType() == {0}.getOperand(" # j # ")->getType().cast().getElementType()">]>; //===----------------------------------------------------------------------===// -// Patterns +// Pattern definitions //===----------------------------------------------------------------------===// -// Base class for op+ -> op+ rewrite patterns. These allow declaratively -// specifying rewrite patterns. +// Base class for op+ -> op+ rewrite rules. These allow declaratively +// specifying rewrite rules. // -// A rewrite pattern contains two components: a source pattern and one or more -// result patterns. Each pattern is specified as a (recursive) DAG node (tree) +// A rewrite rule contains two components: a source pattern and one or more +// result rules. Each pattern is specified as a (recursive) DAG node (tree) // in the form of `(node arg0, arg1, ...)`. // The `node` are normally MLIR ops, but it can also be one of the directives // listed later in this section. @@ -643,8 +693,11 @@ class TCopVTEtIsSameAs : AllOf<[ // with potential transformations (e.g., using tAttr, etc.). `arg*` can itself // be nested DAG node. class Pattern results, list preds = []> { - dag patternToMatch = source; - list resultOps = results; + dag sourcePattern = source; + list resultPatterns = results; + // Multi-entity constraints. Each constraint here involves multiple entities + // matched in source pattern and places further constraints on them as a + // whole. list constraints = preds; } @@ -652,16 +705,6 @@ class Pattern results, list preds = []> { class Pat preds = []> : Pattern; -// Attribute matcher. This is the base class to specify a predicate -// that has to match. Used on the input attributes of a rewrite rule. -class mAttr : AttrConstraint; - -// Combine a list of attribute matchers into an attribute matcher that holds if -// any of the original matchers does. -class mAttrAnyOf attrs> : - mAttr, attrs, prev, attr, - !listconcat(prev, [attr.predicate]))>>; - // Attribute transformation. This is the base class to specify a transformation // of matched attributes. Used on the output attribute of a rewrite rule. class tAttr { @@ -698,15 +741,9 @@ class cOp { string function = f; } -// Pattern matching predicate specification to constrain when a pattern may be -// used. For example, -// def : Pat<(... $l, (... $r)), (...), [(mPat<"foo"> $l, $r)]; -// will result in this pattern being considered only if `foo(l, r)` holds where -// `foo` is a C++ function and `l` and `r` are the C++ bound variables of -// $l and $r. -class mPat { - string function = f; -} +//===----------------------------------------------------------------------===// +// Common directives +//===----------------------------------------------------------------------===// // Directive used in result pattern to indicate that no new result op are // generated, so to replace the matched DAG with an existing SSA value. diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index 324194dbf64..686c8c8b43a 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -24,7 +24,7 @@ #define MLIR_TABLEGEN_ATTRIBUTE_H_ #include "mlir/Support/LLVM.h" -#include "mlir/TableGen/Predicate.h" +#include "mlir/TableGen/Constraint.h" #include "llvm/ADT/StringRef.h" namespace llvm { @@ -35,29 +35,13 @@ class Record; namespace mlir { namespace tblgen { -// Wrapper class with helper methods for accessing Attribute constraints defined +// Wrapper class with helper methods for accessing attribute constraints defined // in TableGen. -class AttrConstraint { +class AttrConstraint : public Constraint { public: explicit AttrConstraint(const llvm::Record *record); - explicit AttrConstraint(const llvm::DefInit *init); - // Returns the predicate that can be used to check if a attribute satisfies - // this attribute constraint. - Pred getPredicate() const; - - // Returns the condition template that can be used to check if a attribute - // satisfies this attribute constraint. The template may contain "{0}" that - // must be substituted with an expression returning an mlir::Attribute. - std::string getConditionTemplate() const; - - // Returns the user-readable description of the constraint. If the description - // is not provided, returns the TableGen def name. - StringRef getDescription() const; - -protected: - // The TableGen definition of this attribute. - const llvm::Record *def; + static bool classof(const Constraint *c) { return c->getKind() == CK_Attr; } }; // Wrapper class providing helper methods for accessing MLIR Attribute defined diff --git a/mlir/include/mlir/TableGen/Constraint.h b/mlir/include/mlir/TableGen/Constraint.h new file mode 100644 index 00000000000..f8b12d9f6e7 --- /dev/null +++ b/mlir/include/mlir/TableGen/Constraint.h @@ -0,0 +1,86 @@ +//===- Constraint.h - Constraint class --------------------------*- C++ -*-===// +// +// Copyright 2019 The MLIR Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================= +// +// Constraint wrapper to simplify using TableGen Record for constraints. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_TABLEGEN_CONSTRAINT_H_ +#define MLIR_TABLEGEN_CONSTRAINT_H_ + +#include "mlir/Support/LLVM.h" +#include "mlir/TableGen/Predicate.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" + +namespace llvm { +class Record; +} // end namespace llvm + +namespace mlir { +namespace tblgen { + +// Wrapper class with helper methods for accessing Constraint defined in +// TableGen. +class Constraint { +public: + Constraint(const llvm::Record *record); + + bool operator==(const Constraint &that) { return def == that.def; } + bool operator!=(const Constraint &that) { return def != that.def; } + + // Returns the predicate for this constraint. + Pred getPredicate() const; + + // Returns the condition template that can be used to check if a type or + // attribute satisfies this constraint. The template may contain "{0}" that + // must be substituted with an expression returning an mlir::Type or + // mlir::Attribute. + std::string getConditionTemplate() const; + + // Returns the user-readable description of this constraint. If the + // description is not provided, returns the TableGen def name. + StringRef getDescription() const; + + // Constraint kind + enum Kind { CK_Type, CK_Attr, CK_Uncategorized }; + + Kind getKind() const { return kind; } + +protected: + Constraint(Kind kind, const llvm::Record *record); + + // The TableGen definition of this constraint. + const llvm::Record *def; + +private: + // What kind of constraint this is. + Kind kind; +}; + +// An constraint and the concrete entities to place the constraint on. +struct AppliedConstraint { + AppliedConstraint(Constraint &&c, std::vector &&e); + + Constraint constraint; + std::vector entities; +}; + +} // end namespace tblgen +} // end namespace mlir + +#endif // MLIR_TABLEGEN_CONSTRAINT_H_ diff --git a/mlir/include/mlir/TableGen/Pattern.h b/mlir/include/mlir/TableGen/Pattern.h index f8c6d838a97..51426480f15 100644 --- a/mlir/include/mlir/TableGen/Pattern.h +++ b/mlir/include/mlir/TableGen/Pattern.h @@ -29,13 +29,11 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringSet.h" -#include "llvm/TableGen/Error.h" namespace llvm { class DagInit; class Init; class Record; -class StringRef; } // end namespace llvm namespace mlir { @@ -79,11 +77,8 @@ public: // Returns true if this DAG leaf is specifying a constant attribute. bool isConstantAttr() const; - // Returns this DAG leaf as a type constraint. Asserts if fails. - TypeConstraint getAsTypeConstraint() const; - - // Returns this DAG leaf as an attribute constraint. Asserts if fails. - AttrConstraint getAsAttrConstraint() const; + // Returns this DAG leaf as a constraint. Asserts if fails. + Constraint getAsConstraint() const; // Returns this DAG leaf as an constant attribute. Asserts if fails. ConstantAttr getAsConstantAttr() const; @@ -180,33 +175,6 @@ private: const llvm::DagInit *node; // nullptr means null DagNode }; -class PatternConstraint { -public: - explicit PatternConstraint(const llvm::DagInit *node) : node(node) {} - - // Returns whether this is a type constraint. - bool isTypeConstraint() const; - - // Returns this DAG leaf as a type constraint. Asserts if fails. - TypeConstraint getAsTypeConstraint() const; - - // Returns whether this is a native pattern constraint. - bool isNativeConstraint() const; - - // Returns the C++ function invoked as part of native constraint. - StringRef getNativeConstraintFunction() const; - - // Argument names. - using const_name_iterator = - llvm::mapped_iterator::const_iterator, - std::string (*)(const llvm::StringInit *)>; - const_name_iterator name_begin() const; - const_name_iterator name_end() const; - -private: - const llvm::DagInit *node; -}; - // Wrapper class providing helper methods for accessing MLIR Pattern defined // in TableGen. This class should closely reflect what is defined as class // `Pattern` in TableGen. This class contains maps so it is not intended to be @@ -250,7 +218,7 @@ public: Operator &getDialectOp(DagNode node); // Returns the constraints. - std::vector getConstraints() const; + std::vector getConstraints() const; private: // The TableGen definition of this pattern. diff --git a/mlir/include/mlir/TableGen/Type.h b/mlir/include/mlir/TableGen/Type.h index 3bed9f50456..a4241ef0892 100644 --- a/mlir/include/mlir/TableGen/Type.h +++ b/mlir/include/mlir/TableGen/Type.h @@ -23,8 +23,7 @@ #define MLIR_TABLEGEN_TYPE_H_ #include "mlir/Support/LLVM.h" -#include "mlir/TableGen/Predicate.h" -#include "llvm/ADT/StringRef.h" +#include "mlir/TableGen/Constraint.h" namespace llvm { class DefInit; @@ -36,33 +35,15 @@ namespace tblgen { // Wrapper class with helper methods for accessing Type constraints defined in // TableGen. -class TypeConstraint { +class TypeConstraint : public Constraint { public: - explicit TypeConstraint(const llvm::Record &record); - explicit TypeConstraint(const llvm::DefInit &init); + explicit TypeConstraint(const llvm::Record *record); + explicit TypeConstraint(const llvm::DefInit *init); - bool operator==(const TypeConstraint &that) { return def == that.def; } - bool operator!=(const TypeConstraint &that) { return def != that.def; } - - // Returns the predicate that can be used to check if a type satisfies this - // type constraint. - Pred getPredicate() const; - - // Returns the condition template that can be used to check if a type - // satisfies this type constraint. The template may contain "{0}" that must - // be substituted with an expression returning an mlir::Type. - std::string getConditionTemplate() const; - - // Returns the user-readable description of the constraint. If the description - // is not provided, returns the TableGen def name. - StringRef getDescription() const; + static bool classof(const Constraint *c) { return c->getKind() == CK_Type; } // Returns true if this is a variadic type constraint. bool isVariadic() const; - -protected: - // The TableGen definition of this type. - const llvm::Record *def; }; // Wrapper class providing helper methods for accessing MLIR Type defined @@ -70,17 +51,15 @@ protected: // class Type in TableGen. class Type : public TypeConstraint { public: - explicit Type(const llvm::Record &record); - explicit Type(const llvm::Record *record) : Type(*record) {} + explicit Type(const llvm::Record *record); explicit Type(const llvm::DefInit *init); // Returns the TableGen def name for this type. StringRef getTableGenDefName() const; // Gets the base type of this variadic type constraint. - // Precondition: This type constraint is a variadic type constraint. + // Precondition: isVariadic() is true. Type getVariadicBaseType() const; - }; } // end namespace tblgen diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index 071cd61a4f4..808e2113196 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -37,36 +37,11 @@ static StringRef getValueAsString(const llvm::Init *init) { } tblgen::AttrConstraint::AttrConstraint(const llvm::Record *record) - : def(record) { + : Constraint(Constraint::CK_Attr, record) { assert(def->isSubClassOf("AttrConstraint") && "must be subclass of TableGen 'AttrConstraint' class"); } -tblgen::AttrConstraint::AttrConstraint(const llvm::DefInit *init) - : AttrConstraint(init->getDef()) {} - -tblgen::Pred tblgen::AttrConstraint::getPredicate() const { - auto *val = def->getValue("predicate"); - // If no predicate is specified, then return the null predicate (which - // corresponds to true). - if (!val) - return Pred(); - - const auto *pred = dyn_cast(val->getValue()); - return Pred(pred); -} - -std::string tblgen::AttrConstraint::getConditionTemplate() const { - return getPredicate().getCondition(); -} - -StringRef tblgen::AttrConstraint::getDescription() const { - auto doc = def->getValueAsString("description"); - if (doc.empty()) - return def->getName(); - return doc; -} - tblgen::Attribute::Attribute(const llvm::Record *record) : AttrConstraint(record) { assert(record->isSubClassOf("Attr") && @@ -74,7 +49,7 @@ tblgen::Attribute::Attribute(const llvm::Record *record) } tblgen::Attribute::Attribute(const llvm::DefInit *init) - : AttrConstraint(init->getDef()) {} + : Attribute(init->getDef()) {} bool tblgen::Attribute::isDerivedAttr() const { return def->isSubClassOf("DerivedAttr"); diff --git a/mlir/lib/TableGen/Constraint.cpp b/mlir/lib/TableGen/Constraint.cpp new file mode 100644 index 00000000000..2656f4cfa05 --- /dev/null +++ b/mlir/lib/TableGen/Constraint.cpp @@ -0,0 +1,66 @@ +//===- Constraint.cpp - Constraint class ----------------------------------===// +// +// Copyright 2019 The MLIR Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================= +// +// Constraint wrapper to simplify using TableGen Record for constraints. +// +//===----------------------------------------------------------------------===// + +#include "mlir/TableGen/Constraint.h" +#include "llvm/TableGen/Record.h" + +using namespace mlir::tblgen; + +Constraint::Constraint(const llvm::Record *record) + : def(record), kind(CK_Uncategorized) { + if (record->isSubClassOf("TypeConstraint")) { + kind = CK_Type; + } else if (record->isSubClassOf("AttrConstraint")) { + kind = CK_Attr; + } else { + assert(record->isSubClassOf("Constraint")); + } +} + +Constraint::Constraint(Kind kind, const llvm::Record *record) + : def(record), kind(kind) {} + +Pred Constraint::getPredicate() const { + auto *val = def->getValue("predicate"); + + // If no predicate is specified, then return the null predicate (which + // corresponds to true). + if (!val) + return Pred(); + + const auto *pred = dyn_cast(val->getValue()); + return Pred(pred); +} + +std::string Constraint::getConditionTemplate() const { + return getPredicate().getCondition(); +} + +llvm::StringRef Constraint::getDescription() const { + auto doc = def->getValueAsString("description"); + if (doc.empty()) + return def->getName(); + return doc; +} + +AppliedConstraint::AppliedConstraint(Constraint &&c, + std::vector &&e) + : constraint(c), entities(std::move(e)) {} diff --git a/mlir/lib/TableGen/Operator.cpp b/mlir/lib/TableGen/Operator.cpp index 13ac756b631..fc87eb25d8b 100644 --- a/mlir/lib/TableGen/Operator.cpp +++ b/mlir/lib/TableGen/Operator.cpp @@ -66,7 +66,7 @@ int tblgen::Operator::getNumResults() const { tblgen::TypeConstraint tblgen::Operator::getResultTypeConstraint(int index) const { DagInit *results = def.getValueAsDag("results"); - return TypeConstraint(*cast(results->getArg(index))); + return TypeConstraint(cast(results->getArg(index))); } StringRef tblgen::Operator::getResultName(int index) const { @@ -167,7 +167,7 @@ void tblgen::Operator::populateOpStructure() { if (argDef->isSubClassOf(typeConstraintClass)) { operands.push_back( - NamedTypeConstraint{givenName, TypeConstraint(*argDefInit)}); + NamedTypeConstraint{givenName, TypeConstraint(argDefInit)}); arguments.emplace_back(&operands.back()); } else if (argDef->isSubClassOf(attrClass)) { if (givenName.empty()) @@ -225,7 +225,7 @@ void tblgen::Operator::populateOpStructure() { PrintFatalError(def.getLoc(), Twine("undefined type for result #") + Twine(i)); } - results.push_back({name, TypeConstraint(*resultDef)}); + results.push_back({name, TypeConstraint(resultDef)}); } // Verify that only the last result can be variadic. diff --git a/mlir/lib/TableGen/Pattern.cpp b/mlir/lib/TableGen/Pattern.cpp index fb338593e6e..0cb06e180b3 100644 --- a/mlir/lib/TableGen/Pattern.cpp +++ b/mlir/lib/TableGen/Pattern.cpp @@ -22,6 +22,7 @@ #include "mlir/TableGen/Pattern.h" #include "llvm/ADT/Twine.h" +#include "llvm/TableGen/Error.h" #include "llvm/TableGen/Record.h" using namespace mlir; @@ -58,14 +59,10 @@ bool tblgen::DagLeaf::isConstantAttr() const { return cast(def)->getDef()->isSubClassOf("ConstantAttr"); } -tblgen::TypeConstraint tblgen::DagLeaf::getAsTypeConstraint() const { - assert(isOperandMatcher() && "the DAG leaf must be operand"); - return TypeConstraint(*cast(def)->getDef()); -} - -tblgen::AttrConstraint tblgen::DagLeaf::getAsAttrConstraint() const { - assert(isAttrMatcher() && "the DAG leaf must be attribute"); - return AttrConstraint(cast(def)->getDef()); +tblgen::Constraint tblgen::DagLeaf::getAsConstraint() const { + assert((isOperandMatcher() || isAttrMatcher()) && + "the DAG leaf must be operand or attribute"); + return Constraint(cast(def)->getDef()); } tblgen::ConstantAttr tblgen::DagLeaf::getAsConstantAttr() const { @@ -74,12 +71,7 @@ tblgen::ConstantAttr tblgen::DagLeaf::getAsConstantAttr() const { } std::string tblgen::DagLeaf::getConditionTemplate() const { - assert((isOperandMatcher() || isAttrMatcher()) && - "the DAG leaf must be operand/attribute matcher"); - if (isOperandMatcher()) { - return getAsTypeConstraint().getConditionTemplate(); - } - return getAsAttrConstraint().getConditionTemplate(); + return getAsConstraint().getConditionTemplate(); } std::string tblgen::DagLeaf::getTransformationTemplate() const { @@ -193,72 +185,22 @@ llvm::StringRef tblgen::DagNode::getNativeCodeBuilder() const { return dagOpDef->getValueAsString("function"); } -// Returns whether this is a type constraint. -bool tblgen::PatternConstraint::isTypeConstraint() const { - if (!node) - return false; - auto op = node->getOperator(); - if (!op || !isa(op)) - return false; - // Operand matchers specify a type constraint. - return cast(op)->getDef()->isSubClassOf("TypeConstraint"); -} - -// Returns this constraint as a TypeConstraint. Asserts if fails. -tblgen::TypeConstraint tblgen::PatternConstraint::getAsTypeConstraint() const { - assert(isTypeConstraint()); - // Constraint specify a type constraint. - return TypeConstraint(*cast(node->getOperator())->getDef()); -} - -static std::string toStringRef(const llvm::StringInit *si) { - return si->getAsUnquotedString(); -} - -tblgen::PatternConstraint::const_name_iterator -tblgen::PatternConstraint::name_begin() const { - return const_name_iterator(node->getArgNames().begin(), &toStringRef); -} -tblgen::PatternConstraint::const_name_iterator -tblgen::PatternConstraint::name_end() const { - return const_name_iterator(node->getArgNames().end(), &toStringRef); -} - -// Returns whether this is a native pattern constraint. -bool tblgen::PatternConstraint::isNativeConstraint() const { - if (!node) - return false; - auto op = node->getOperator(); - if (!op || !isa(op)) - return false; - // Operand matchers specify a type constraint. - return cast(op)->getDef()->isSubClassOf("mPat"); -} - -// Returns the C++ function invoked as part of native constraint. -llvm::StringRef tblgen::PatternConstraint::getNativeConstraintFunction() const { - assert(isNativeConstraint()); - return cast(node->getOperator()) - ->getDef() - ->getValueAsString("function"); -} - tblgen::Pattern::Pattern(const llvm::Record *def, RecordOperatorMap *mapper) : def(*def), recordOpMap(mapper) { getSourcePattern().collectBoundArguments(this); } tblgen::DagNode tblgen::Pattern::getSourcePattern() const { - return tblgen::DagNode(def.getValueAsDag("patternToMatch")); + return tblgen::DagNode(def.getValueAsDag("sourcePattern")); } unsigned tblgen::Pattern::getNumResults() const { - auto *results = def.getValueAsListInit("resultOps"); + auto *results = def.getValueAsListInit("resultPatterns"); return results->size(); } tblgen::DagNode tblgen::Pattern::getResultPattern(unsigned index) const { - auto *results = def.getValueAsListInit("resultOps"); + auto *results = def.getValueAsListInit("resultPatterns"); return tblgen::DagNode(cast(results->getElement(index))); } @@ -294,13 +236,24 @@ tblgen::Operator &tblgen::Pattern::getDialectOp(DagNode node) { return node.getDialectOp(recordOpMap); } -std::vector tblgen::Pattern::getConstraints() const { +std::vector tblgen::Pattern::getConstraints() const { auto *listInit = def.getValueAsListInit("constraints"); - std::vector ret; + std::vector ret; ret.reserve(listInit->size()); + for (auto it : *listInit) { - auto *dagInit = cast(it); - ret.emplace_back(dagInit); + auto *dagInit = dyn_cast(it); + if (!dagInit) + PrintFatalError(def.getLoc(), "all elemements in Pattern multi-entity " + "constraints should be DAG nodes"); + + std::vector entities; + entities.reserve(dagInit->arg_size()); + for (auto *argName : dagInit->getArgNames()) + entities.push_back(argName->getValue()); + + ret.emplace_back(cast(dagInit->getOperator())->getDef(), + std::move(entities)); } return ret; } diff --git a/mlir/lib/TableGen/Predicate.cpp b/mlir/lib/TableGen/Predicate.cpp index c8f4066e4de..18b6422a2b3 100644 --- a/mlir/lib/TableGen/Predicate.cpp +++ b/mlir/lib/TableGen/Predicate.cpp @@ -69,7 +69,7 @@ tblgen::CPred::CPred(const llvm::Init *init) : Pred(init) { // Get condition of the C Predicate. std::string tblgen::CPred::getConditionImpl() const { assert(!isNull() && "null predicate does not have a condition"); - return def->getValueAsString("predCall"); + return def->getValueAsString("predExpr"); } tblgen::CombinedPred::CombinedPred(const llvm::Record *record) : Pred(record) { diff --git a/mlir/lib/TableGen/Type.cpp b/mlir/lib/TableGen/Type.cpp index 8aebe79681c..1d7505af343 100644 --- a/mlir/lib/TableGen/Type.cpp +++ b/mlir/lib/TableGen/Type.cpp @@ -1,4 +1,4 @@ -//===- Type.cpp - Type class ------------------------------------*- C++ -*-===// +//===- Type.cpp - Type class ----------------------------------------------===// // // Copyright 2019 The MLIR Authors. // @@ -24,49 +24,29 @@ using namespace mlir; -tblgen::TypeConstraint::TypeConstraint(const llvm::Record &record) - : def(&record) { +tblgen::TypeConstraint::TypeConstraint(const llvm::Record *record) + : Constraint(Constraint::CK_Type, record) { assert(def->isSubClassOf("TypeConstraint") && "must be subclass of TableGen 'TypeConstraint' class"); } -tblgen::Pred tblgen::TypeConstraint::getPredicate() const { - auto *val = def->getValue("predicate"); - assert(val && - "TableGen 'TypeConstraint' class should have 'predicate' field"); - - const auto *pred = dyn_cast(val->getValue()); - return Pred(pred); -} - -std::string tblgen::TypeConstraint::getConditionTemplate() const { - return getPredicate().getCondition(); -} - -llvm::StringRef tblgen::TypeConstraint::getDescription() const { - auto doc = def->getValueAsString("description"); - if (doc.empty()) - return def->getName(); - return doc; -} - -tblgen::TypeConstraint::TypeConstraint(const llvm::DefInit &init) - : TypeConstraint(*init.getDef()) {} +tblgen::TypeConstraint::TypeConstraint(const llvm::DefInit *init) + : TypeConstraint(init->getDef()) {} bool tblgen::TypeConstraint::isVariadic() const { return def->isSubClassOf("Variadic"); } -tblgen::Type::Type(const llvm::Record &record) : TypeConstraint(record) { +tblgen::Type::Type(const llvm::Record *record) : TypeConstraint(record) { assert(def->isSubClassOf("Type") && "must be subclass of TableGen 'Type' class"); } -tblgen::Type::Type(const llvm::DefInit *init) : Type(*init->getDef()) {} +tblgen::Type::Type(const llvm::DefInit *init) : Type(init->getDef()) {} StringRef tblgen::Type::getTableGenDefName() const { return def->getName(); } tblgen::Type tblgen::Type::getVariadicBaseType() const { assert(isVariadic() && "must be variadic type constraint"); - return Type(*def->getValueAsDef("baseType")); + return Type(def->getValueAsDef("baseType")); } diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp index 6a7af8005a8..775f090c23f 100644 --- a/mlir/tools/mlir-tblgen/RewriterGen.cpp +++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp @@ -39,13 +39,7 @@ using namespace llvm; using namespace mlir; - -using mlir::tblgen::DagLeaf; -using mlir::tblgen::DagNode; -using mlir::tblgen::NamedAttribute; -using mlir::tblgen::NamedTypeConstraint; -using mlir::tblgen::Operator; -using mlir::tblgen::RecordOperatorMap; +using namespace mlir::tblgen; namespace { class PatternEmitter { @@ -105,7 +99,7 @@ private: std::string emitOpCreate(DagNode tree, int resultIndex, int depth); // Returns the string value of constant attribute as an argument. - std::string handleConstantAttr(tblgen::ConstantAttr constAttr); + std::string handleConstantAttr(ConstantAttr constAttr); // Returns the C++ expression to build an argument from the given DAG `leaf`. // `patArgName` is used to bound the argument to the source pattern. @@ -122,7 +116,7 @@ private: // Op's TableGen Record to wrapper object RecordOperatorMap *opMap; // Handy wrapper for pattern being emitted - tblgen::Pattern pattern; + Pattern pattern; // The next unused ID for newly created values unsigned nextValueId; raw_ostream &os; @@ -134,7 +128,7 @@ PatternEmitter::PatternEmitter(Record *pat, RecordOperatorMap *mapper, : loc(pat->getLoc()), opMap(mapper), pattern(pat, mapper), nextValueId(0), os(os) {} -std::string PatternEmitter::handleConstantAttr(tblgen::ConstantAttr constAttr) { +std::string PatternEmitter::handleConstantAttr(ConstantAttr constAttr) { auto attr = constAttr.getAttribute(); if (!attr.isConstBuildable()) @@ -226,7 +220,7 @@ void PatternEmitter::emitOperandMatch(DagNode tree, int index, int depth, // Only need to verify if the matcher's type is different from the one // of op definition. - if (operand->constraint != matcher.getAsTypeConstraint()) { + if (operand->constraint != matcher.getAsConstraint()) { os.indent(indent) << "if (!(" << formatv(matcher.getConditionTemplate().c_str(), formatv("op{0}->getOperand({1})->getType()", @@ -307,27 +301,35 @@ void PatternEmitter::emitMatchMethod(DagNode tree) { PrintFatalError(loc, formatv("referencing unbound variable '{0}'", name)); }; - for (auto constraint : pattern.getConstraints()) { - if (constraint.isTypeConstraint()) { - auto cmd = "if (!{0}) return matchFailure();\n"; - // TODO(jpienaar): Use the op definition here to simplify this. - auto condition = constraint.getAsTypeConstraint().getConditionTemplate(); + for (auto &appliedConstraint : pattern.getConstraints()) { + auto &constraint = appliedConstraint.constraint; + auto &entities = appliedConstraint.entities; + + auto condition = constraint.getConditionTemplate(); + auto cmd = "if (!{0}) return matchFailure();\n"; + + if (isa(constraint)) { // TODO(jpienaar): Verify op only has one result. os.indent(4) << formatv( - cmd, formatv(condition.c_str(), - "(*" + deduceName(*constraint.name_begin()) + - "->result_type_begin())")); - } else if (constraint.isNativeConstraint()) { - os.indent(4) << "if (!" << constraint.getNativeConstraintFunction() - << "("; - interleave( - constraint.name_begin(), constraint.name_end(), - [&](const std::string &name) { os << deduceName(name); }, - [&]() { os << ", "; }); - os << ")) return matchFailure();\n"; + cmd, formatv(condition.c_str(), "(*" + deduceName(entities.front()) + + "->result_type_begin())")); + } else if (isa(constraint)) { + PrintFatalError( + loc, "cannot use AttrConstraint in Pattern multi-entity constraints"); } else { - llvm_unreachable( - "Pattern constraints have to be either a type or native constraint"); + // TODO(fengliuai): replace formatv arguments with the exact specified + // args. + if (entities.size() > 4) { + PrintFatalError(loc, "only support up to 4-entity constraints now"); + } + SmallVector names; + unsigned i = 0; + for (unsigned e = entities.size(); i < e; ++i) + names.push_back(deduceName(entities[i])); + for (; i < 4; ++i) + names.push_back(""); + os.indent(4) << formatv(cmd, formatv(condition.c_str(), names[0], + names[1], names[2], names[3])); } } -- cgit v1.2.3 From c489f50e6f8bf22f105f51eee8e2ea0dd6d6f30f Mon Sep 17 00:00:00 2001 From: Feng Liu Date: Tue, 26 Mar 2019 15:31:15 -0700 Subject: Add a trait to set the result type by attribute Before this CL, the result type of the pattern match results need to be as same as the first operand type, operand broadcast type or a generic tensor type. This CL adds a new trait to set the result type by attribute. For example, the TFL_ConstOp can use this to set the output type to its value attribute. PiperOrigin-RevId: 240441249 --- mlir/include/mlir/IR/OpBase.td | 11 ++++++++ mlir/include/mlir/TableGen/Attribute.h | 6 ++++- mlir/include/mlir/TableGen/OpTrait.h | 13 +++++++++ mlir/lib/TableGen/Attribute.cpp | 4 +++ mlir/lib/TableGen/OpTrait.cpp | 6 +++++ mlir/lib/TableGen/Operator.cpp | 6 ++++- mlir/test/mlir-tblgen/op-result.td | 19 +++++++++++++ mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | 41 ++++++++++++++++++++++------- mlir/tools/mlir-tblgen/RewriterGen.cpp | 3 ++- 9 files changed, 96 insertions(+), 13 deletions(-) (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index c4af30aea16..b921d91b170 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -524,6 +524,11 @@ class NativeOpTrait : OpTrait { string trait = prop; } +// Specify a trait to control op definition generator internals. +class OpGenInternalTrait : OpTrait { + string trait = prop; +} + // Specify a trait by way of a predicate on the operation. class PredOpTrait : OpTrait { string desc = d; @@ -545,6 +550,12 @@ def SameValueType : NativeOpTrait<"SameOperandsAndResultType">; // op is a terminator def Terminator : NativeOpTrait<"IsTerminator">; +// op result type is derived from the first attribute. If the attribute is an +// subclass of `TypeAttrBase`, its value is used, otherwise, the type of the +// attribute content is used. +def FirstAttrDerivedResultType : + OpGenInternalTrait<"FirstAttrDerivedResultType">; + //===----------------------------------------------------------------------===// // Op definitions //===----------------------------------------------------------------------===// diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index 686c8c8b43a..7cd518963dc 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -53,9 +53,13 @@ public: explicit Attribute(const llvm::DefInit *init); // Returns true if this attribute is a derived attribute (i.e., a subclass - // of `DrivedAttr`). + // of `DerivedAttr`). bool isDerivedAttr() const; + // Returns true if this attribute is a type attribute (i.e., a subclass + // of `TypeAttrBase`). + bool isTypeAttr() const; + // Returns true if this attribute has storage type set. bool hasStorageType() const; diff --git a/mlir/include/mlir/TableGen/OpTrait.h b/mlir/include/mlir/TableGen/OpTrait.h index e4b56e9415d..8a3463d257e 100644 --- a/mlir/include/mlir/TableGen/OpTrait.h +++ b/mlir/include/mlir/TableGen/OpTrait.h @@ -43,6 +43,8 @@ public: Native, // OpTrait corresponding to predicate on operation. Pred, + // OpTrait controlling op definition generator internals. + Internal }; explicit OpTrait(Kind kind, const llvm::Record *def); @@ -79,6 +81,17 @@ public: static bool classof(const OpTrait *t) { return t->getKind() == Kind::Pred; } }; +// OpTrait controlling op definition generator internals. +class InternalOpTrait : public OpTrait { +public: + // Returns the trait controlling op definition generator internals. + StringRef getTrait() const; + + static bool classof(const OpTrait *t) { + return t->getKind() == Kind::Internal; + } +}; + } // end namespace tblgen } // end namespace mlir diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index 808e2113196..3e9452875b4 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -55,6 +55,10 @@ bool tblgen::Attribute::isDerivedAttr() const { return def->isSubClassOf("DerivedAttr"); } +bool tblgen::Attribute::isTypeAttr() const { + return def->isSubClassOf("TypeAttrBase"); +} + bool tblgen::Attribute::hasStorageType() const { const auto *init = def->getValueInit("storageType"); return !getValueAsString(init).empty(); diff --git a/mlir/lib/TableGen/OpTrait.cpp b/mlir/lib/TableGen/OpTrait.cpp index 5758b25a1f7..2c821537b60 100644 --- a/mlir/lib/TableGen/OpTrait.cpp +++ b/mlir/lib/TableGen/OpTrait.cpp @@ -32,6 +32,8 @@ mlir::tblgen::OpTrait mlir::tblgen::OpTrait::create(const llvm::Init *init) { auto def = cast(init)->getDef(); if (def->isSubClassOf("PredOpTrait")) return OpTrait(Kind::Pred, def); + if (def->isSubClassOf("OpGenInternalTrait")) + return OpTrait(Kind::Internal, def); assert(def->isSubClassOf("NativeOpTrait")); return OpTrait(Kind::Native, def); } @@ -43,6 +45,10 @@ llvm::StringRef mlir::tblgen::NativeOpTrait::getTrait() const { return def->getValueAsString("trait"); } +llvm::StringRef mlir::tblgen::InternalOpTrait::getTrait() const { + return def->getValueAsString("trait"); +} + std::string mlir::tblgen::PredOpTrait::getPredTemplate() const { auto pred = tblgen::Pred(def->getValueInit("pred")); return pred.getCondition(); diff --git a/mlir/lib/TableGen/Operator.cpp b/mlir/lib/TableGen/Operator.cpp index fc87eb25d8b..e6453a55436 100644 --- a/mlir/lib/TableGen/Operator.cpp +++ b/mlir/lib/TableGen/Operator.cpp @@ -101,9 +101,13 @@ StringRef tblgen::Operator::getArgName(int index) const { bool tblgen::Operator::hasTrait(StringRef trait) const { for (auto t : getTraits()) { - if (auto opTrait = dyn_cast(&t)) + if (auto opTrait = dyn_cast(&t)) { if (opTrait->getTrait() == trait) return true; + } else if (auto opTrait = dyn_cast(&t)) { + if (opTrait->getTrait() == trait) + return true; + } } return false; } diff --git a/mlir/test/mlir-tblgen/op-result.td b/mlir/test/mlir-tblgen/op-result.td index 9856ad5efde..f98564c5d28 100644 --- a/mlir/test/mlir-tblgen/op-result.td +++ b/mlir/test/mlir-tblgen/op-result.td @@ -31,6 +31,25 @@ def ThreeResultOp : Op<"three_result_op", []> { // CHECK: void ThreeResultOp::build(Builder *builder, OperationState *result, Type x, Type resultType1, Type z) // CHECK: result->addTypes({x, resultType1, z}); +def IntegerTypeAttr : TypeAttrBase<"IntegerType", "Integer type attribute">; +def TypeAttrResultTypeOp : Op<"type_attr_as_result_type", [FirstAttrDerivedResultType]> { + let arguments = (ins I32:$x, IntegerTypeAttr:$attr, F32Attr:$f32); + let results = (outs Tensor:$y); +} + +// CHECK-LABEL: TypeAttrResultTypeOp definitions +// CHECK: void TypeAttrResultTypeOp::build(Builder *builder, OperationState *result, Value *x, TypeAttr attr, FloatAttr f32) +// CHECK: result->addTypes({attr.getValue()}); + +def ValueAttrResultTypeOp : Op<"value_attr_as_result_type", [FirstAttrDerivedResultType]> { + let arguments = (ins I32:$x, F32Attr:$attr); + let results = (outs Tensor:$y); +} + +// CHECK-LABEL: ValueAttrResultTypeOp definitions +// CHECK: void ValueAttrResultTypeOp::build(Builder *builder, OperationState *result, Value *x, FloatAttr attr) +// CHECK: result->addTypes({attr.getType()}); + def VariadicResultOp : Op<"variadic_op", []> { let results = (outs I32:$x, Variadic:$y); } diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp index 5ff4f222c71..0ce9719a414 100644 --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -379,8 +379,10 @@ private: // Generates the build() method that takes each result-type/operand/attribute // as a stand-alone parameter. Using the first operand's type as all result - // types if `isAllSameType` is true. - void genStandaloneParamBuilder(bool isAllSameType); + // types if `useOperandType` is true. Using the first attribute's type as all + // result types if `useAttrType` true. Don't set `useOperandType` and + // `useAttrType` at the same time. + void genStandaloneParamBuilder(bool useOperandType, bool useAttrType); void genOpNameGetter(); @@ -501,7 +503,14 @@ void OpEmitter::genNamedResultGetters() { } } -void OpEmitter::genStandaloneParamBuilder(bool isAllSameType) { +void OpEmitter::genStandaloneParamBuilder(bool useOperandType, + bool useAttrType) { + if (useOperandType && useAttrType) { + PrintFatalError(def.getLoc(), + "Op definition has both 'SameOperandsAndResultType' and " + "'FirstAttrIsResultType' trait specified."); + } + auto numResults = op.getNumResults(); llvm::SmallVector resultNames; resultNames.reserve(numResults); @@ -509,7 +518,7 @@ void OpEmitter::genStandaloneParamBuilder(bool isAllSameType) { std::string paramList = "Builder *builder, OperationState *result"; // Emit parameters for all return types - if (!isAllSameType) { + if (!useOperandType && !useAttrType) { for (unsigned i = 0; i != numResults; ++i) { std::string resultName = op.getResultName(i); if (resultName.empty()) @@ -556,7 +565,7 @@ void OpEmitter::genStandaloneParamBuilder(bool isAllSameType) { // Push all result types to the result if (numResults > 0) { - if (!isAllSameType) { + if (!useOperandType && !useAttrType) { bool hasVariadicResult = op.hasVariadicResult(); int numNonVariadicResults = numResults - static_cast(hasVariadicResult); @@ -573,10 +582,20 @@ void OpEmitter::genStandaloneParamBuilder(bool isAllSameType) { method.body() << " result->addTypes(" << resultNames.back() << ");\n"; } } else { - auto resultType = formatv("{0}->getType()", getArgumentName(op, 0)).str(); + std::string resultType; + if (useAttrType) { + const auto &namedAttr = op.getAttribute(0); + if (namedAttr.attr.isTypeAttr()) { + resultType = formatv("{0}.getValue()", namedAttr.name); + } else { + resultType = formatv("{0}.getType()", namedAttr.name); + } + } else { + resultType = formatv("{0}->getType()", getArgumentName(op, 0)).str(); + } method.body() << " result->addTypes({" << resultType; for (unsigned i = 1; i != numResults; ++i) - method.body() << resultType; + method.body() << ", " << resultType; method.body() << "});\n\n"; } } @@ -657,7 +676,7 @@ void OpEmitter::genBuilder() { // 1. Stand-alone parameters - genStandaloneParamBuilder(/*isAllSameType=*/false); + genStandaloneParamBuilder(/*useOperandType=*/false, /*useAttrType=*/false); // 2. Aggregated parameters @@ -695,8 +714,10 @@ void OpEmitter::genBuilder() { // 3. Deduced result types - if (!op.hasVariadicResult() && op.hasTrait("SameOperandsAndResultType")) - genStandaloneParamBuilder(/*isAllSameType=*/true); + bool useOperandType = op.hasTrait("SameOperandsAndResultType"); + bool useAttrType = op.hasTrait("FirstAttrDerivedResultType"); + if (!op.hasVariadicResult() && (useOperandType || useAttrType)) + genStandaloneParamBuilder(useOperandType, useAttrType); } void OpEmitter::genCanonicalizerDecls() { diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp index 775f090c23f..21276a9e4f9 100644 --- a/mlir/tools/mlir-tblgen/RewriterGen.cpp +++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp @@ -550,8 +550,9 @@ std::string PatternEmitter::emitOpCreate(DagNode tree, int resultIndex, bool isSameValueType = resultOp.hasTrait("SameOperandsAndResultType"); bool isBroadcastable = resultOp.hasTrait("BroadcastableTwoOperandsOneResult"); + bool useFirstAttr = resultOp.hasTrait("FirstAttrDerivedResultType"); - if (isConstOp || isSameValueType || isBroadcastable) { + if (isConstOp || isSameValueType || isBroadcastable || useFirstAttr) { os.indent(4) << formatv("auto {0} = rewriter.create<{1}>(loc", resultValue, resultOp.getQualCppClassName()); } else { -- cgit v1.2.3 From b9e38a7972e6312fb89d24a567449b78bb3259ce Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 1 Apr 2019 08:58:53 -0700 Subject: [TableGen] Add EnumAttrCase and EnumAttr This CL adds EnumAttr as a general mechanism for modelling enum attributes. Right now it is using StringAttr under the hood since MLIR does not have native support for enum attributes. -- PiperOrigin-RevId: 241334043 --- mlir/include/mlir/IR/OpBase.td | 20 ++++++++++++++++++ mlir/include/mlir/TableGen/Attribute.h | 26 +++++++++++++++++++++++ mlir/include/mlir/TableGen/Pattern.h | 11 ++++++++++ mlir/lib/TableGen/Attribute.cpp | 35 +++++++++++++++++++++++++++++++ mlir/lib/TableGen/Pattern.cpp | 33 +++++++++++++++++------------ mlir/test/mlir-tblgen/attr-enum.td | 38 ++++++++++++++++++++++++++++++++++ mlir/tools/mlir-tblgen/RewriterGen.cpp | 22 +++++++++++++------- 7 files changed, 164 insertions(+), 21 deletions(-) create mode 100644 mlir/test/mlir-tblgen/attr-enum.td (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index 590823f08f9..3259346727a 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -445,6 +445,26 @@ class StringBasedAttr : def StrAttr : StringBasedAttr, "string">; +// An enum attribute case. +class EnumAttrCase : StringBasedAttr< + CPred<"{0}.cast().getValue() == \"" # sym # "\"">, + "case " # sym> { + // The C++ enumerant symbol + string symbol = sym; +} + +// An enum attribute. Its value can only be one from the given list of `cases`. +// Enum attributes are emulated via mlir::StringAttr, plus extra verification +// on the string: only the symbols of the allowed cases are permitted as the +// string value. +class EnumAttr cases> : + StringBasedAttr, description> { + // The C++ enum class name + string className = name; + // List of all accepted cases + list enumerants = cases; +} + class ElementsAttrBase : Attr { let storageType = [{ ElementsAttr }]; diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index 7cd518963dc..635d714c21e 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -120,6 +120,32 @@ private: const llvm::Record *def; }; +// Wrapper class providing helper methods for accessing enum attribute cases +// defined in TableGen. This class should closely reflect what is defined as +// class `EnumAttrCase` in TableGen. +class EnumAttrCase : public Attribute { +public: + explicit EnumAttrCase(const llvm::DefInit *init); + + // Returns the symbol of this enum attribute case. + StringRef getSymbol() const; +}; + +// Wrapper class providing helper methods for accessing enum attributes defined +// in TableGen. This class should closely reflect what is defined as class +// `EnumAttr` in TableGen. +class EnumAttr : public Attribute { +public: + explicit EnumAttr(const llvm::Record *record); + explicit EnumAttr(const llvm::DefInit *init); + + // Returns the enum class name. + StringRef getEnumClassName() const; + + // Returns all allowed cases for this enum attribute. + std::vector getAllCases() const; +}; + } // end namespace tblgen } // end namespace mlir diff --git a/mlir/include/mlir/TableGen/Pattern.h b/mlir/include/mlir/TableGen/Pattern.h index 28800d3b88c..e7856e61503 100644 --- a/mlir/include/mlir/TableGen/Pattern.h +++ b/mlir/include/mlir/TableGen/Pattern.h @@ -77,12 +77,19 @@ public: // Returns true if this DAG leaf is specifying a constant attribute. bool isConstantAttr() const; + // Returns true if this DAG leaf is specifying an enum attribute case. + bool isEnumAttrCase() const; + // Returns this DAG leaf as a constraint. Asserts if fails. Constraint getAsConstraint() const; // Returns this DAG leaf as an constant attribute. Asserts if fails. ConstantAttr getAsConstantAttr() const; + // Returns this DAG leaf as an enum attribute case. + // Precondition: isEnumAttrCase() + EnumAttrCase getAsEnumAttrCase() const; + // Returns the matching condition template inside this DAG leaf. Assumes the // leaf is an operand/attribute matcher and asserts otherwise. std::string getConditionTemplate() const; @@ -92,6 +99,10 @@ public: std::string getTransformationTemplate() const; private: + // Returns true if the TableGen Init `def` in this DagLeaf is a DefInit and + // also a subclass of the given `superclass`. + bool isSubClassOf(StringRef superclass) const; + const llvm::Init *def; }; diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index 3e9452875b4..26c22041f52 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -130,3 +130,38 @@ tblgen::Attribute tblgen::ConstantAttr::getAttribute() const { StringRef tblgen::ConstantAttr::getConstantValue() const { return def->getValueAsString("value"); } + +tblgen::EnumAttrCase::EnumAttrCase(const llvm::DefInit *init) + : Attribute(init) { + assert(def->isSubClassOf("EnumAttrCase") && + "must be subclass of TableGen 'EnumAttrCase' class"); +} + +StringRef tblgen::EnumAttrCase::getSymbol() const { + return def->getValueAsString("symbol"); +} + +tblgen::EnumAttr::EnumAttr(const llvm::Record *record) : Attribute(record) { + assert(def->isSubClassOf("EnumAttr") && + "must be subclass of TableGen 'EnumAttr' class"); +} + +tblgen::EnumAttr::EnumAttr(const llvm::DefInit *init) + : EnumAttr(init->getDef()) {} + +StringRef tblgen::EnumAttr::getEnumClassName() const { + return def->getValueAsString("className"); +} + +std::vector tblgen::EnumAttr::getAllCases() const { + const auto *inits = def->getValueAsListInit("enumerants"); + + std::vector cases; + cases.reserve(inits->size()); + + for (const llvm::Init *init : *inits) { + cases.push_back(tblgen::EnumAttrCase(cast(init))); + } + + return cases; +} diff --git a/mlir/lib/TableGen/Pattern.cpp b/mlir/lib/TableGen/Pattern.cpp index a6c40956fa5..de620e1e260 100644 --- a/mlir/lib/TableGen/Pattern.cpp +++ b/mlir/lib/TableGen/Pattern.cpp @@ -30,33 +30,29 @@ using namespace mlir; using mlir::tblgen::Operator; bool tblgen::DagLeaf::isUnspecified() const { - return !def || isa(def); + return dyn_cast_or_null(def); } bool tblgen::DagLeaf::isOperandMatcher() const { - if (!def || !isa(def)) - return false; // Operand matchers specify a type constraint. - return cast(def)->getDef()->isSubClassOf("TypeConstraint"); + return isSubClassOf("TypeConstraint"); } bool tblgen::DagLeaf::isAttrMatcher() const { - if (!def || !isa(def)) - return false; // Attribute matchers specify an attribute constraint. - return cast(def)->getDef()->isSubClassOf("AttrConstraint"); + return isSubClassOf("AttrConstraint"); } bool tblgen::DagLeaf::isAttrTransformer() const { - if (!def || !isa(def)) - return false; - return cast(def)->getDef()->isSubClassOf("tAttr"); + return isSubClassOf("tAttr"); } bool tblgen::DagLeaf::isConstantAttr() const { - if (!def || !isa(def)) - return false; - return cast(def)->getDef()->isSubClassOf("ConstantAttr"); + return isSubClassOf("ConstantAttr"); +} + +bool tblgen::DagLeaf::isEnumAttrCase() const { + return isSubClassOf("EnumAttrCase"); } tblgen::Constraint tblgen::DagLeaf::getAsConstraint() const { @@ -70,6 +66,11 @@ tblgen::ConstantAttr tblgen::DagLeaf::getAsConstantAttr() const { return ConstantAttr(cast(def)); } +tblgen::EnumAttrCase tblgen::DagLeaf::getAsEnumAttrCase() const { + assert(isEnumAttrCase() && "the DAG leaf must be an enum attribute case"); + return EnumAttrCase(cast(def)); +} + std::string tblgen::DagLeaf::getConditionTemplate() const { return getAsConstraint().getConditionTemplate(); } @@ -82,6 +83,12 @@ std::string tblgen::DagLeaf::getTransformationTemplate() const { .str(); } +bool tblgen::DagLeaf::isSubClassOf(StringRef superclass) const { + if (auto *defInit = dyn_cast_or_null(def)) + return defInit->getDef()->isSubClassOf(superclass); + return false; +} + bool tblgen::DagNode::isAttrTransformer() const { auto op = node->getOperator(); if (!op || !isa(op)) diff --git a/mlir/test/mlir-tblgen/attr-enum.td b/mlir/test/mlir-tblgen/attr-enum.td new file mode 100644 index 00000000000..52b88cf44bd --- /dev/null +++ b/mlir/test/mlir-tblgen/attr-enum.td @@ -0,0 +1,38 @@ +// RUN: mlir-tblgen -gen-op-defs -I %S/../../include %s | FileCheck %s --check-prefix=DEF +// RUN: mlir-tblgen -gen-rewriters -I %S/../../include %s | FileCheck %s --check-prefix=PAT + +include "mlir/IR/OpBase.td" + +def NS_SomeEnum_A : EnumAttrCase<"A">; +def NS_SomeEnum_B : EnumAttrCase<"B">; +def NS_SomeEnum_C : EnumAttrCase<"C">; + +def NS_SomeEnum : EnumAttr< + "SomeEnum", "some enum", + [NS_SomeEnum_A, NS_SomeEnum_B, NS_SomeEnum_C]>; + +def NS_OpA : Op<"op_a_with_enum_attr", []> { + let arguments = (ins NS_SomeEnum:$attr); +} + +// DEF-LABEL: StringRef OpA::attr() +// DEF-NEXT: auto attr = this->getAttr("attr").dyn_cast_or_null(); +// DEF-NEXT: return attr.getValue(); + +// DEF-LABEL: OpA::verify() +// DEF: if (!(((this->getAttr("attr").cast().getValue() == "A")) || ((this->getAttr("attr").cast().getValue() == "B")) || ((this->getAttr("attr").cast().getValue() == "C")))) +// DEF-SAME: return emitOpError("attribute 'attr' failed to satisfy some enum attribute constraints"); + +def NS_OpB : Op<"op_b_with_enum_attr", []> { + let arguments = (ins NS_SomeEnum:$attr); +} + +def : Pat<(NS_OpA NS_SomeEnum_A:$attr), (NS_OpB NS_SomeEnum_B)>; + +// PAT-LABEL: struct GeneratedConvert0 +// PAT: PatternMatchResult match +// PAT: if (!((op0->getAttrOfType("attr").cast().getValue() == "A"))) return matchFailure(); +// PAT: void rewrite +// PAT: auto vOpB0 = rewriter.create(loc, +// PAT-NEXT: rewriter.getStringAttr("B") +// PAT-NEXT: ); diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp index 025ec91338f..d9d5f744b7d 100644 --- a/mlir/tools/mlir-tblgen/RewriterGen.cpp +++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp @@ -98,8 +98,9 @@ private: // result value name. std::string emitOpCreate(DagNode tree, int resultIndex, int depth); - // Returns the string value of constant attribute as an argument. - std::string handleConstantAttr(ConstantAttr constAttr); + // Returns the C++ expression to construct a constant attribute of the given + // `value` for the given attribute kind `attr`. + std::string handleConstantAttr(Attribute attr, StringRef value); // Returns the C++ expression to build an argument from the given DAG `leaf`. // `patArgName` is used to bound the argument to the source pattern. @@ -128,16 +129,15 @@ PatternEmitter::PatternEmitter(Record *pat, RecordOperatorMap *mapper, : loc(pat->getLoc()), opMap(mapper), pattern(pat, mapper), nextValueId(0), os(os) {} -std::string PatternEmitter::handleConstantAttr(ConstantAttr constAttr) { - auto attr = constAttr.getAttribute(); - +std::string PatternEmitter::handleConstantAttr(Attribute attr, + StringRef value) { if (!attr.isConstBuildable()) PrintFatalError(loc, "Attribute " + attr.getTableGenDefName() + " does not have the 'constBuilderCall' field"); // TODO(jpienaar): Verify the constants here return formatv(attr.getConstBuilderTemplate().str().c_str(), "rewriter", - constAttr.getConstantValue()); + value); } static Twine resultName(const StringRef &name) { return Twine("res_") + name; } @@ -448,7 +448,13 @@ void PatternEmitter::handleVerifyUnusedValue(DagNode tree, int index) { std::string PatternEmitter::handleOpArgument(DagLeaf leaf, llvm::StringRef argName) { if (leaf.isConstantAttr()) { - return handleConstantAttr(leaf.getAsConstantAttr()); + auto constAttr = leaf.getAsConstantAttr(); + return handleConstantAttr(constAttr.getAttribute(), + constAttr.getConstantValue()); + } + if (leaf.isEnumAttrCase()) { + auto enumCase = leaf.getAsEnumAttrCase(); + return handleConstantAttr(enumCase, enumCase.getSymbol()); } pattern.ensureArgBoundInSourcePattern(argName); std::string result = boundArgNameInRewrite(argName).str(); @@ -587,7 +593,7 @@ std::string PatternEmitter::emitOpCreate(DagNode tree, int resultIndex, auto leaf = tree.getArgAsLeaf(i); // The argument in the result DAG pattern. auto patArgName = tree.getArgName(i); - if (leaf.isConstantAttr()) { + if (leaf.isConstantAttr() || leaf.isEnumAttrCase()) { // TODO(jpienaar): Refactor out into map to avoid recomputing these. auto argument = resultOp.getArg(i); if (!argument.is()) -- cgit v1.2.3 From 4cda344e7b92d965525df15b1193eb6e7370ba7e Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 5 Apr 2019 12:19:22 -0700 Subject: Add methods for building array attributes in Builder I32/I64/F32/F64/Str array attributes are commonly used in ops. It helps to have handy methods for them. -- PiperOrigin-RevId: 242170569 --- mlir/include/mlir/IR/Builders.h | 6 ++++++ mlir/include/mlir/IR/OpBase.td | 19 +++++++++++++++---- mlir/lib/IR/Builders.cpp | 31 +++++++++++++++++++++++++++++++ mlir/lib/TableGen/Attribute.cpp | 10 ++++++++-- mlir/test/mlir-tblgen/op-attribute.td | 25 +++++++++++++++++++++++++ 5 files changed, 85 insertions(+), 6 deletions(-) (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h index 4cbf4ee37b6..a3f8ad53875 100644 --- a/mlir/include/mlir/IR/Builders.h +++ b/mlir/include/mlir/IR/Builders.h @@ -132,6 +132,12 @@ public: IntegerAttr getI32IntegerAttr(int32_t value); IntegerAttr getI64IntegerAttr(int64_t value); + ArrayAttr getI32ArrayAttr(ArrayRef values); + ArrayAttr getI64ArrayAttr(ArrayRef values); + ArrayAttr getF32ArrayAttr(ArrayRef values); + ArrayAttr getF64ArrayAttr(ArrayRef values); + ArrayAttr getStrArrayAttr(ArrayRef values); + // Affine expressions and affine maps. AffineExpr getAffineDimExpr(unsigned position); AffineExpr getAffineSymbolExpr(unsigned position); diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index 791e99cf69c..602d50cc408 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -550,11 +550,22 @@ class TypedArrayAttrBase: ArrayAttrBase< } def I32ArrayAttr : TypedArrayAttrBase; + "32-bit integer array attribute"> { + let constBuilderCall = "{0}.getI32ArrayAttr({1})"; +} def I64ArrayAttr : TypedArrayAttrBase; -def F32ArrayAttr : TypedArrayAttrBase; -def StrArrayAttr : TypedArrayAttrBase; + "64-bit integer array attribute"> { + let constBuilderCall = "{0}.getI64ArrayAttr({1})"; +} +def F32ArrayAttr : TypedArrayAttrBase { + let constBuilderCall = "{0}.getF32ArrayAttr({1})"; +} +def F64ArrayAttr : TypedArrayAttrBase { + let constBuilderCall = "{0}.getF64ArrayAttr({1})"; +} +def StrArrayAttr : TypedArrayAttrBase { + let constBuilderCall = "{0}.getStrArrayAttr({1})"; +} // Attributes containing functions. def FunctionAttr : Attr()">, diff --git a/mlir/lib/IR/Builders.cpp b/mlir/lib/IR/Builders.cpp index a0d9367fa5f..962fa345c66 100644 --- a/mlir/lib/IR/Builders.cpp +++ b/mlir/lib/IR/Builders.cpp @@ -23,6 +23,7 @@ #include "mlir/IR/Location.h" #include "mlir/IR/Module.h" #include "mlir/IR/StandardTypes.h" +#include "mlir/Support/Functional.h" using namespace mlir; Builder::Builder(Module *module) : context(module->getContext()) {} @@ -202,6 +203,36 @@ ElementsAttr Builder::getOpaqueElementsAttr(Dialect *dialect, return OpaqueElementsAttr::get(dialect, type, bytes); } +ArrayAttr Builder::getI32ArrayAttr(ArrayRef values) { + auto attrs = functional::map( + [this](int32_t v) -> Attribute { return getI32IntegerAttr(v); }, values); + return getArrayAttr(attrs); +} + +ArrayAttr Builder::getI64ArrayAttr(ArrayRef values) { + auto attrs = functional::map( + [this](int64_t v) -> Attribute { return getI64IntegerAttr(v); }, values); + return getArrayAttr(attrs); +} + +ArrayAttr Builder::getF32ArrayAttr(ArrayRef values) { + auto attrs = functional::map( + [this](float v) -> Attribute { return getF32FloatAttr(v); }, values); + return getArrayAttr(attrs); +} + +ArrayAttr Builder::getF64ArrayAttr(ArrayRef values) { + auto attrs = functional::map( + [this](double v) -> Attribute { return getF64FloatAttr(v); }, values); + return getArrayAttr(attrs); +} + +ArrayAttr Builder::getStrArrayAttr(ArrayRef values) { + auto attrs = functional::map( + [this](StringRef v) -> Attribute { return getStringAttr(v); }, values); + return getArrayAttr(attrs); +} + Attribute Builder::getZeroAttr(Type type) { switch (type.getKind()) { case StandardTypes::F32: diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index 26c22041f52..3791d2cb3cb 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -103,9 +103,15 @@ bool tblgen::Attribute::isOptional() const { std::string tblgen::Attribute::getDefaultValueTemplate() const { assert(isConstBuildable() && "requiers constBuilderCall"); - const auto *init = def->getValueInit("defaultValue"); + StringRef defaultValue = getValueAsString(def->getValueInit("defaultValue")); + // TODO(antiagainst): This is a temporary hack to support array initializers + // because '{' is the special marker for placeholders for formatv. Remove this + // after switching to our own formatting utility and $-placeholders. + bool needsEscape = + defaultValue.startswith("{") && !defaultValue.startswith("{{"); + return llvm::formatv(getConstBuilderTemplate().str().c_str(), "{0}", - getValueAsString(init)); + needsEscape ? "{" + defaultValue : defaultValue); } StringRef tblgen::Attribute::getTableGenDefName() const { diff --git a/mlir/test/mlir-tblgen/op-attribute.td b/mlir/test/mlir-tblgen/op-attribute.td index 17c88dcecff..4b8a8818e6c 100644 --- a/mlir/test/mlir-tblgen/op-attribute.td +++ b/mlir/test/mlir-tblgen/op-attribute.td @@ -9,6 +9,9 @@ def SomeAttr : Attr, "some attribute kind"> { let constBuilderCall = "some-const-builder-call({0}, {1})"; } +// Test required, optional, default-valued attributes +// --- + def AOp : Op<"a_op", []> { let arguments = (ins SomeAttr:$aAttr, @@ -100,6 +103,28 @@ def BOp : Op<"b_op", []> { // CHECK: if (!((tblgen_array_attr.isa()))) // CHECK: if (!(((tblgen_some_attr_array.isa())) && (llvm::all_of(tblgen_some_attr_array.cast(), [](Attribute attr) { return (some-condition); })))) +// Test building constant values for array attribute kinds +// --- + +def COp : Op<"c_op", []> { + let arguments = (ins + DefaultValuedAttr:$i32_array_attr, + DefaultValuedAttr:$i64_array_attr, + DefaultValuedAttr:$f32_array_attr, + DefaultValuedAttr:$f64_array_attr, + DefaultValuedAttr:$str_array_attr + ); +} + +// CHECK-LABEL: COp definitions +// CHECK: mlir::Builder(this->getContext()).getI32ArrayAttr({1, 2}) +// CHECK: mlir::Builder(this->getContext()).getI64ArrayAttr({3, 4}) +// CHECK: mlir::Builder(this->getContext()).getF32ArrayAttr({5.f, 6.f}) +// CHECK: mlir::Builder(this->getContext()).getF64ArrayAttr({7., 8.}) +// CHECK: mlir::Builder(this->getContext()).getStrArrayAttr({"a", "b"}) + +// Test mixing operands and attributes in arbitrary order +// --- def MixOperandsAndAttrs : Op<"mix_operands_and_attrs", []> { let arguments = (ins F32Attr:$attr, F32:$operand, F32Attr:$otherAttr, F32:$otherArg); -- cgit v1.2.3 From 138c972d11b4afe583dd9038968c6530f8bb7be4 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 12 Apr 2019 06:05:49 -0700 Subject: [TableGen] Use `tgfmt` to format various predicates and rewrite rules This CL changes various predicates and rewrite rules to use $-placeholders and `tgfmt` as the driver for substitution. This will make the predicates and rewrite rules more consistent regarding their arguments and more readable. -- PiperOrigin-RevId: 243250739 --- mlir/include/mlir/IR/OpBase.td | 207 ++++++++++++---------- mlir/include/mlir/LLVMIR/LLVMOps.td | 2 +- mlir/include/mlir/Quantization/QuantPredicates.td | 6 +- mlir/include/mlir/TableGen/Attribute.h | 11 +- mlir/lib/TableGen/Attribute.cpp | 45 +++-- mlir/test/mlir-tblgen/op-attribute.td | 4 +- mlir/test/mlir-tblgen/pattern-bound-symbol.td | 2 +- mlir/test/mlir-tblgen/pattern-tAttr.td | 2 +- mlir/test/mlir-tblgen/predicate.td | 2 +- mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | 89 +++++----- mlir/tools/mlir-tblgen/RewriterGen.cpp | 52 +++--- 11 files changed, 219 insertions(+), 203 deletions(-) (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index 8fd2e00aafd..0295e37de89 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -44,6 +44,24 @@ class Pred; // predicate from the perspective of TableGen and the "interface" between // TableGen and C++. What is inside is already C++ code, which will be treated // as opaque strings with special placeholders to be substituted. +// +// ## Special placeholders +// +// Special placeholders can be used to refer to entities in the context where +// this predicate is used. They serve as "hooks" to the enclosing environment. +// The following special placeholders are supported in constraints for an op: +// +// * `$_builder` will be replaced by a mlir::Builder instance. +// * `$_op` will be replaced by the current operation. +// * `$_self` will be replaced with the entity this predicate is attached to. +// E.g., `BoolAttr` is an attribute constraint that wraps a +// `CPred<"$_self.isa()">` (see the following sections for details). +// Then for `F32:$attr`,`$_self` will be replaced by `$attr`. +// For type constraints, it's a little bit special since we want the +// constraints on each type definition reads naturally and we want to attach +// type constraints directly to an operand/result, $_self will be replaced +// by the operand/result's type. E.g., for `F32` in `F32:$operand`, its +// `$_self` will be expanded as `getOperand(...)->getType()`. class CPred : Pred { code predExpr = "(" # pred # ")"; } @@ -118,7 +136,6 @@ class Concat : // provide nice error messages, etc. class Constraint { // The predicates that this constraint requires. - // Format: {0} will be expanded to the op operand/result's type or attribute. Pred predicate = pred; // User-readable description used in error reporting messages. If empty, a // generic message will be used. @@ -157,23 +174,23 @@ class AttrConstraint : //===----------------------------------------------------------------------===// // Whether a type is a VectorType. -def IsVectorTypePred : CPred<"{0}.isa()">; +def IsVectorTypePred : CPred<"$_self.isa()">; // Whether a type is a TensorType. -def IsTensorTypePred : CPred<"{0}.isa()">; +def IsTensorTypePred : CPred<"$_self.isa()">; // Whether a type is a VectorOrTensorType. -def IsVectorOrTensorTypePred : CPred<"{0}.isa()">; +def IsVectorOrTensorTypePred : CPred<"$_self.isa()">; // Whether a type is a TupleType. -def IsTupleTypePred : CPred<"{0}.isa()">; +def IsTupleTypePred : CPred<"$_self.isa()">; // Whether a type is a MemRefType. -def IsMemRefTypePred : CPred<"{0}.isa()">; +def IsMemRefTypePred : CPred<"$_self.isa()">; // For a TensorType, verify that it is a statically shaped tensor. def IsStaticShapeTensorTypePred : - CPred<"{0}.cast().hasStaticShape()">; + CPred<"$_self.cast().hasStaticShape()">; //===----------------------------------------------------------------------===// // Type definitions @@ -224,14 +241,14 @@ class AnyTypeOf allowedTypes, string description> : Type< class IntegerBase : Type; // Any integer type irrespective of its width. -def Integer : IntegerBase()">, "integer">; +def Integer : IntegerBase()">, "integer">; // Index type. -def Index : IntegerBase()">, "index">; +def Index : IntegerBase()">, "index">; // Integer type of a specific width. class I - : IntegerBase, + : IntegerBase, width # "-bit integer">, BuildableType<"getIntegerType(" # width # ")"> { int bitwidth = width; @@ -246,11 +263,11 @@ def I64 : I<64>; class FloatBase : Type; // Any float type irrespective of its width. -def Float : FloatBase()">, "floating-point">; +def Float : FloatBase()">, "floating-point">; // Float type of a specific width. class F - : FloatBase, + : FloatBase, width # "-bit float">, BuildableType<"getF" # width # "Type()"> { int bitwidth = width; @@ -260,7 +277,7 @@ def F16 : F<16>; def F32 : F<32>; def F64 : F<64>; -def BF16 : Type, "bfloat16 type">, +def BF16 : Type, "bfloat16 type">, BuildableType<"getBF16Type()">; // A container type is a type that has another type embedded within it. @@ -269,7 +286,7 @@ class ContainerType(elementTypeCall), + SubstLeaves<"$_self", !cast(elementTypeCall), etype.predicate>]>, descr # " of " # etype.description # " values"> { // The type of elements in the container. @@ -281,16 +298,16 @@ class ContainerType : ContainerType().getElementType()", "vector">; + "$_self.cast().getElementType()", "vector">; class Vector dims> : ContainerType().getShape() == ArrayRef{{" # + CPred<"$_self.cast().getShape() == ArrayRef{{" # !foldl("", dims, sum, element, sum # !if(!empty(sum), "", ",") # !cast(element)) # "}">]>, - "{0}.cast().getElementType()", + "$_self.cast().getElementType()", "vector"> { list dimensions = dims; } @@ -312,7 +329,7 @@ def StaticShapeTensor // For typed tensors. class TypedTensor : ContainerType().getElementType()", + "$_self.cast().getElementType()", "tensor">; class TypedStaticShapeTensor @@ -340,7 +357,7 @@ def Tuple : Type; // Memrefs are blocks of data with fixed type and rank. class MemRef : ContainerType().getElementType()", "memref">; + "$_self.cast().getElementType()", "memref">; // Memref declarations handle any memref, independent of rank, size, (static or // dynamic), layout, or memory space. @@ -385,20 +402,19 @@ class Attr : // type. For example, an enum can be stored as an int but returned as an // enum class. // - // Format: {0} will be expanded to the attribute. + // Format: $_self will be expanded to the attribute. // - // For example, `{0}.getValue().getSExtValue()` for `IntegerAttr val` will + // For example, `$_self.getValue().getSExtValue()` for `IntegerAttr val` will // expand to `getAttrOfType("val").getValue().getSExtValue()`. - code convertFromStorage = "{0}.getValue()"; + code convertFromStorage = "$_self.getValue()"; // The call expression to build an attribute from a constant value. // - // Format: {0} will be expanded to an instance of mlir::Builder, - // {1} will be expanded to the constant value of the attribute. + // Format: $0 will be expanded to the constant value of the attribute. // - // For example, `{0}.getStringAttr("{1}")` for `StringAttr:"foo"` will expand - // to `builder.getStringAttr("foo")`. - code constBuilderCall = ?; + // For example, `$_builder.getStringAttr("$0")` for `StringAttr:"foo"` will + // expand to `builder.getStringAttr("foo")`. + string constBuilderCall = ?; // Default value for attribute. // Requires a constBuilderCall defined. @@ -430,7 +446,7 @@ class OptionalAttr : Attr { // Note: this has to be kept up to date with Attr above. let storageType = attr.storageType; let returnType = "Optional<" # attr.returnType #">"; - let convertFromStorage = "{0} ? " # returnType # "(" # + let convertFromStorage = "$_self ? " # returnType # "(" # attr.convertFromStorage # ") : (llvm::None)"; let isOptional = 0b1; } @@ -440,8 +456,8 @@ class OptionalAttr : Attr { class TypedAttrBase : Attr { - let constBuilderCall = "{0}.get" # attrKind # "({0}." # - attrValType.builderCall # ", {1})"; + let constBuilderCall = "$_builder.get" # attrKind # "($_builder." # + attrValType.builderCall # ", $0)"; let storageType = attrKind; } @@ -449,21 +465,21 @@ class TypedAttrBase, "any attribute"> { let storageType = "Attribute"; let returnType = "Attribute"; - let convertFromStorage = "{0}"; - let constBuilderCall = "{1}"; + let convertFromStorage = "$_self"; + let constBuilderCall = "$0"; } -def BoolAttr : Attr()">, "bool attribute"> { +def BoolAttr : Attr()">, "bool attribute"> { let storageType = [{ BoolAttr }]; let returnType = [{ bool }]; - let constBuilderCall = [{ {0}.getBoolAttr({1}) }]; + let constBuilderCall = "$_builder.getBoolAttr($0)"; } // Base class for integer attributes of fixed width. class IntegerAttrBase : TypedAttrBase()">, - CPred<"{0}.cast().getType()." + AllOf<[CPred<"$_self.isa()">, + CPred<"$_self.cast().getType()." "isInteger(" # attrValType.bitwidth # ")">]>, descr> { let returnType = [{ APInt }]; @@ -475,8 +491,8 @@ def I64Attr : IntegerAttrBase; // Base class for float attributes of fixed width. class FloatAttrBase : TypedAttrBase()">, - CPred<"{0}.cast().getType().isF" # + AllOf<[CPred<"$_self.isa()">, + CPred<"$_self.cast().getType().isF" # attrValType.bitwidth # "()">]>, descr> { let returnType = [{ APFloat }]; @@ -487,17 +503,17 @@ def F64Attr : FloatAttrBase; // An attribute backed by a string type. class StringBasedAttr : Attr { - let constBuilderCall = [{ {0}.getStringAttr("{1}") }]; + let constBuilderCall = "$_builder.getStringAttr(\"$0\")"; let storageType = [{ StringAttr }]; let returnType = [{ StringRef }]; } -def StrAttr : StringBasedAttr()">, +def StrAttr : StringBasedAttr()">, "string attribute">; // An enum attribute case. class EnumAttrCase : StringBasedAttr< - CPred<"{0}.cast().getValue() == \"" # sym # "\"">, + CPred<"$_self.cast().getValue() == \"" # sym # "\"">, "case " # sym> { // The C++ enumerant symbol string symbol = sym; @@ -521,10 +537,10 @@ class ElementsAttrBase : Attr { let storageType = [{ ElementsAttr }]; let returnType = [{ ElementsAttr }]; - let convertFromStorage = "{0}"; + let convertFromStorage = "$_self"; } -def ElementsAttr: ElementsAttrBase()">, +def ElementsAttr: ElementsAttrBase()">, "constant vector/tensor attribute">; // Base class for array attributes. @@ -532,10 +548,10 @@ class ArrayAttrBase : Attr { let storageType = [{ ArrayAttr }]; let returnType = [{ ArrayAttr }]; - let convertFromStorage = "{0}"; + let convertFromStorage = "$_self"; } -def ArrayAttr : ArrayAttrBase()">, +def ArrayAttr : ArrayAttrBase()">, "array attribute">; // Base class for array attributes whose elements are of the same kind. @@ -543,41 +559,40 @@ def ArrayAttr : ArrayAttrBase()">, class TypedArrayAttrBase: ArrayAttrBase< AllOf<[ // Guranatee this is an ArrayAttr first - CPred<"{0}.isa()">, + CPred<"$_self.isa()">, // Guarantee all elements satisfy the constraints from `element` - Concat<"llvm::all_of({0}.cast(), " - "[](Attribute attr) {{ return ", - SubstLeaves<"{0}", "attr", element.predicate>, + Concat<"llvm::all_of($_self.cast(), " + "[](Attribute attr) { return ", + SubstLeaves<"$_self", "attr", element.predicate>, "; })">]>, description> { - let constBuilderCall = [{ {0}.getArrayAttr({1}) }]; + let constBuilderCall = "$_builder.getArrayAttr($0)"; } def I32ArrayAttr : TypedArrayAttrBase { - let constBuilderCall = "{0}.getI32ArrayAttr({1})"; + let constBuilderCall = "$_builder.getI32ArrayAttr($0)"; } def I64ArrayAttr : TypedArrayAttrBase { - let constBuilderCall = "{0}.getI64ArrayAttr({1})"; + let constBuilderCall = "$_builder.getI64ArrayAttr($0)"; } def F32ArrayAttr : TypedArrayAttrBase { - let constBuilderCall = "{0}.getF32ArrayAttr({1})"; + let constBuilderCall = "$_builder.getF32ArrayAttr($0)"; } def F64ArrayAttr : TypedArrayAttrBase { - let constBuilderCall = "{0}.getF64ArrayAttr({1})"; + let constBuilderCall = "$_builder.getF64ArrayAttr($0)"; } def StrArrayAttr : TypedArrayAttrBase { - let constBuilderCall = "{0}.getStrArrayAttr({1})"; + let constBuilderCall = "$_builder.getStrArrayAttr($0)"; } // Attributes containing functions. -def FunctionAttr : Attr()">, +def FunctionAttr : Attr()">, "function attribute"> { let storageType = [{ FunctionAttr }]; let returnType = [{ Function * }]; - let convertFromStorage = [{ {0}.getValue() }]; - let constBuilderCall = [{ {0}.getFunctionAttr({1}) }]; + let constBuilderCall = "$_builder.getFunctionAttr($0)"; } // Base class for attributes containing types. Example: @@ -585,12 +600,12 @@ def FunctionAttr : Attr()">, // defines a type attribute containing an integer type. class TypeAttrBase : Attr()">, - CPred<"{0}.cast().getValue().isa<" # retType # ">()">]>, + CPred<"$_self.isa()">, + CPred<"$_self.cast().getValue().isa<" # retType # ">()">]>, description> { let storageType = [{ TypeAttr }]; let returnType = retType; - let convertFromStorage = "{0}.getValue().cast<" # retType # ">()"; + let convertFromStorage = "$_self.getValue().cast<" # retType # ">()"; } // DerivedAttr are attributes whose value is computed from properties @@ -611,9 +626,7 @@ class DerivedTypeAttr : DerivedAttr<"Type", body>; // If used as a constraint, it generates a matcher on a constant attribute by // using the constant value builder of the attribute and the value. class ConstantAttr : AttrConstraint< - CPred<"{0} == " # - !subst("{0}", "mlir::Builder(ctx)", !subst("{1}", val, - !cast(attribute.constBuilderCall)))>, + CPred<"$_self == " # !subst("$0", val, attribute.constBuilderCall)>, "constant attribute " # val> { Attr attr = attribute; string value = val; @@ -651,25 +664,25 @@ class AllAttrConstraintsOf constraints> : AttrConstraint< } class IntMinValue : AttrConstraint< - CPred<"{0}.cast().getInt() >= " # n>, + CPred<"$_self.cast().getInt() >= " # n>, "whose minimal value is " # n>; class ArrayMinCount : AttrConstraint< - CPred<"{0}.cast().size() >= " # n>, + CPred<"$_self.cast().size() >= " # n>, "with at least " # n # " elements">; class IntArrayNthElemEq : AttrConstraint< AllOf<[ - CPred<"{0}.cast().size() > " # index>, - CPred<"{0}.cast().getValue()[" # index # "]" + CPred<"$_self.cast().size() > " # index>, + CPred<"$_self.cast().getValue()[" # index # "]" ".cast().getInt() == " # value> ]>, "whose " # index # "-th element must be " # value>; class IntArrayNthElemMinValue : AttrConstraint< AllOf<[ - CPred<"{0}.cast().size() > " # index>, - CPred<"{0}.cast().getValue()[" # index # "]" + CPred<"$_self.cast().size() > " # index>, + CPred<"$_self.cast().getValue()[" # index # "]" ".cast().getInt() >= " # min> ]>, "whose " # index # "-th element must be at least " # min>; @@ -843,10 +856,10 @@ class Results { // Type Constraint operand `idx`'s Vector or Tensor Element type is `type`. class TCopVTEtIs : AllOf<[ - CPred<"{0}.getNumOperands() > " # idx>, - SubstLeaves<"{0}", "{0}.getOperand(" # idx # ")->getType()", + CPred<"$_op.getNumOperands() > " # idx>, + SubstLeaves<"$_self", "$_op.getOperand(" # idx # ")->getType()", IsVectorOrTensorTypePred>, - SubstLeaves<"{0}", "{0}.getOperand(" # idx # + SubstLeaves<"$_self", "$_op.getOperand(" # idx # ")->getType().cast().getElementType()", type.predicate>]>; @@ -855,14 +868,14 @@ class TCopVTEtIs : AllOf<[ // Type Constraint operand `i`'s Vector or Tensor Element type is Same As // operand `j`'s element type. class TCopVTEtIsSameAs : AllOf<[ - CPred<"{0}.getNumOperands() > std::max(" # i # "," # j # ")">, - SubstLeaves<"{0}", "{0}.getOperand(" # i # ")->getType()", + CPred<"$_op.getNumOperands() > std::max(" # i # "," # j # ")">, + SubstLeaves<"$_self", "$_op.getOperand(" # i # ")->getType()", IsVectorOrTensorTypePred>, - SubstLeaves<"{0}", "{0}.getOperand(" # j # ")->getType()", + SubstLeaves<"$_self", "$_op.getOperand(" # j # ")->getType()", IsVectorOrTensorTypePred>, // TODO: This could be made into C++ function instead. - CPred<"{0}.getOperand(" # i # ")->getType().cast()." - "getElementType() == {0}.getOperand(" # j # ")->getType()." + CPred<"$_op.getOperand(" # i # ")->getType().cast()." + "getElementType() == $_op.getOperand(" # j # ")->getType()." "cast().getElementType()">]>; // Predicate to verify that the i'th result and the j'th operand have the same @@ -870,15 +883,15 @@ class TCopVTEtIsSameAs : AllOf<[ // Type Constraint result`i`'s Vector or Tensor Element type is Same As // Type Constraint Operand `j`'s Vector or Tensor Element type. class TCresVTEtIsSameAsOp : AllOf<[ - CPred<"{0}.getNumResults() > " # i>, - CPred<"{0}.getNumOperands() > " # j>, - SubstLeaves<"{0}", "{0}.getResult(" # i # ")->getType()", + CPred<"$_op.getNumResults() > " # i>, + CPred<"$_op.getNumOperands() > " # j>, + SubstLeaves<"$_self", "$_op.getResult(" # i # ")->getType()", IsVectorOrTensorTypePred>, - SubstLeaves<"{0}", "{0}.getOperand(" # j # ")->getType()", + SubstLeaves<"$_self", "$_op.getOperand(" # j # ")->getType()", IsVectorOrTensorTypePred>, // TODO: This could be made into C++ function instead. - CPred<"{0}.getResult(" # i # ")->getType().cast()." - "getElementType() == {0}.getOperand(" # j # ")->getType()." + CPred<"$_op.getResult(" # i # ")->getType().cast()." + "getElementType() == $_op.getOperand(" # j # ")->getType()." "cast().getElementType()">]>; //===----------------------------------------------------------------------===// @@ -949,19 +962,20 @@ class Pat preds = [], // Attribute transformation. This is the base class to specify a transformation // of matched attributes. Used on the output attribute of a rewrite rule. +// +// ## Placeholders +// +// The following special placeholders are supported +// +// * `$_builder` will be replaced by the current `mlir::PatternRewriter`. +// * `$_self` will be replaced with the entity this transformer is attached to. +// E.g., with the definition `def transform : tAttr<$_self...>`, `$_self` in +// `transform:$attr` will be replaced by the value for `$att`. + +// Besides, if this is used as a DAG node, i.e., `(tAttr , ..., )`, +// then positional placeholders are supported and placholder `$N` will be +// replaced by ``. class tAttr { - // Code to transform the attributes. - // Format: - // - When it is used as a dag node, {0} represents the builder, {i} - // represents the (i-1)-th attribute argument when i >= 1. For example: - // def attr: tAttr<"{0}.compose({{{1}, {2}})"> for '(attr $a, $b)' will - // expand to '(builder.compose({foo, bar}))'. - // - When it is used as a dag leaf, {0} represents the attribute. - // For example: - // def attr: tAttr<"{0}.cast()"> for 'attr:$a' will expand to - // 'foo.cast()'. - // In both examples, `foo` and `bar` are the C++ bounded attribute variables - // of $a and $b. code attrTransform = transform; } @@ -976,6 +990,7 @@ class tAttr { // the DAG specified. It is the responsibility of this function to replace the // matched op(s) using the rewriter. This is intended for the long tail op // creation and replacement. +// TODO(antiagainst): Unify this and tAttr into a single creation mechanism. class cOp { // Function to invoke with the given arguments to construct a new op. The // operands will be passed to the function first followed by the attributes diff --git a/mlir/include/mlir/LLVMIR/LLVMOps.td b/mlir/include/mlir/LLVMIR/LLVMOps.td index 7ab76e82b43..85a9cb96fac 100644 --- a/mlir/include/mlir/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/LLVMIR/LLVMOps.td @@ -29,7 +29,7 @@ include "mlir/IR/OpBase.td" #endif // OP_BASE // LLVM IR type wrapped in MLIR. -def LLVM_Type : Type()">, +def LLVM_Type : Type()">, "LLVM dialect type">; // Base class for LLVM operations. All operations get an "llvm." prefix in diff --git a/mlir/include/mlir/Quantization/QuantPredicates.td b/mlir/include/mlir/Quantization/QuantPredicates.td index 62a1e50568b..af0135173b4 100644 --- a/mlir/include/mlir/Quantization/QuantPredicates.td +++ b/mlir/include/mlir/Quantization/QuantPredicates.td @@ -34,7 +34,7 @@ class quant_TypedPrimitiveOrContainer : // An implementation of QuantizedType. def quant_QuantizedType : - Type()">, "QuantizedType">; + Type()">, "QuantizedType">; // A primitive type that can represent a real value. This is either a // floating point value or a quantized type. @@ -63,10 +63,10 @@ def quant_RealOrStorageValueType : // An implementation of UniformQuantizedType. def quant_UniformQuantizedType : - Type()">, "UniformQuantizedType">; + Type()">, "UniformQuantizedType">; // Predicate for detecting a container or primitive of UniformQuantizedType. def quant_UniformQuantizedValueType : quant_TypedPrimitiveOrContainer; -#endif // QUANTIZATION_PREDICATES_ \ No newline at end of file +#endif // QUANTIZATION_PREDICATES_ diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index 635d714c21e..f8de36d753e 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -84,17 +84,14 @@ public: // the constant value. StringRef getConstBuilderTemplate() const; - // Returns whether this attribute has a default value. - bool hasDefaultValue() const; + // Returns whether this attribute has a default value's initializer. + bool hasDefaultValueInitializer() const; + // Returns the default value's initializer for this attribute. + StringRef getDefaultValueInitializer() const; // Returns whether this attribute is optional. bool isOptional() const; - // Returns the template that can be used to produce the default value of - // the attribute. - // Syntax: {0} should be replaced with a builder. - std::string getDefaultValueTemplate() const; - StringRef getTableGenDefName() const; // Returns the code body for derived attribute. Aborts if this is not a diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index 3791d2cb3cb..a165ba8be4f 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -20,36 +20,40 @@ // //===----------------------------------------------------------------------===// +#include "mlir/TableGen/Format.h" #include "mlir/TableGen/Operator.h" -#include "llvm/Support/FormatVariadic.h" #include "llvm/TableGen/Record.h" using namespace mlir; +using llvm::CodeInit; +using llvm::DefInit; +using llvm::Init; +using llvm::Record; +using llvm::StringInit; + // Returns the initializer's value as string if the given TableGen initializer // is a code or string initializer. Returns the empty StringRef otherwise. -static StringRef getValueAsString(const llvm::Init *init) { - if (const auto *code = dyn_cast(init)) +static StringRef getValueAsString(const Init *init) { + if (const auto *code = dyn_cast(init)) return code->getValue().trim(); - else if (const auto *str = dyn_cast(init)) + else if (const auto *str = dyn_cast(init)) return str->getValue().trim(); return {}; } -tblgen::AttrConstraint::AttrConstraint(const llvm::Record *record) +tblgen::AttrConstraint::AttrConstraint(const Record *record) : Constraint(Constraint::CK_Attr, record) { assert(def->isSubClassOf("AttrConstraint") && "must be subclass of TableGen 'AttrConstraint' class"); } -tblgen::Attribute::Attribute(const llvm::Record *record) - : AttrConstraint(record) { +tblgen::Attribute::Attribute(const Record *record) : AttrConstraint(record) { assert(record->isSubClassOf("Attr") && "must be subclass of TableGen 'Attr' class"); } -tblgen::Attribute::Attribute(const llvm::DefInit *init) - : Attribute(init->getDef()) {} +tblgen::Attribute::Attribute(const DefInit *init) : Attribute(init->getDef()) {} bool tblgen::Attribute::isDerivedAttr() const { return def->isSubClassOf("DerivedAttr"); @@ -92,26 +96,18 @@ StringRef tblgen::Attribute::getConstBuilderTemplate() const { return getValueAsString(init); } -bool tblgen::Attribute::hasDefaultValue() const { +bool tblgen::Attribute::hasDefaultValueInitializer() const { const auto *init = def->getValueInit("defaultValue"); return !getValueAsString(init).empty(); } -bool tblgen::Attribute::isOptional() const { - return def->getValueAsBit("isOptional"); +StringRef tblgen::Attribute::getDefaultValueInitializer() const { + const auto *init = def->getValueInit("defaultValue"); + return getValueAsString(init); } -std::string tblgen::Attribute::getDefaultValueTemplate() const { - assert(isConstBuildable() && "requiers constBuilderCall"); - StringRef defaultValue = getValueAsString(def->getValueInit("defaultValue")); - // TODO(antiagainst): This is a temporary hack to support array initializers - // because '{' is the special marker for placeholders for formatv. Remove this - // after switching to our own formatting utility and $-placeholders. - bool needsEscape = - defaultValue.startswith("{") && !defaultValue.startswith("{{"); - - return llvm::formatv(getConstBuilderTemplate().str().c_str(), "{0}", - needsEscape ? "{" + defaultValue : defaultValue); +bool tblgen::Attribute::isOptional() const { + return def->getValueAsBit("isOptional"); } StringRef tblgen::Attribute::getTableGenDefName() const { @@ -123,8 +119,7 @@ StringRef tblgen::Attribute::getDerivedCodeBody() const { return def->getValueAsString("body"); } -tblgen::ConstantAttr::ConstantAttr(const llvm::DefInit *init) - : def(init->getDef()) { +tblgen::ConstantAttr::ConstantAttr(const DefInit *init) : def(init->getDef()) { assert(def->isSubClassOf("ConstantAttr") && "must be subclass of TableGen 'ConstantAttr' class"); } diff --git a/mlir/test/mlir-tblgen/op-attribute.td b/mlir/test/mlir-tblgen/op-attribute.td index 4b8a8818e6c..32b9b6ca95a 100644 --- a/mlir/test/mlir-tblgen/op-attribute.td +++ b/mlir/test/mlir-tblgen/op-attribute.td @@ -5,8 +5,8 @@ include "mlir/IR/OpBase.td" def SomeAttr : Attr, "some attribute kind"> { let storageType = "some-attr-kind"; let returnType = "some-return-type"; - let convertFromStorage = "{0}.some-convert-from-storage()"; - let constBuilderCall = "some-const-builder-call({0}, {1})"; + let convertFromStorage = "$_self.some-convert-from-storage()"; + let constBuilderCall = "some-const-builder-call($_builder, $0)"; } // Test required, optional, default-valued attributes diff --git a/mlir/test/mlir-tblgen/pattern-bound-symbol.td b/mlir/test/mlir-tblgen/pattern-bound-symbol.td index 46cf2e28a42..7c2897e560c 100644 --- a/mlir/test/mlir-tblgen/pattern-bound-symbol.td +++ b/mlir/test/mlir-tblgen/pattern-bound-symbol.td @@ -22,7 +22,7 @@ def OpD : Op<"op_d", []> { let results = (outs I32:$result); } -def hasOneUse: ConstrainthasOneUse()">, "has one use">; +def hasOneUse: ConstrainthasOneUse()">, "has one use">; def : Pattern<(OpA:$res_a $operand, $attr), [(OpC:$res_c (OpB:$res_b $operand)), diff --git a/mlir/test/mlir-tblgen/pattern-tAttr.td b/mlir/test/mlir-tblgen/pattern-tAttr.td index 32008d95819..02a12567617 100644 --- a/mlir/test/mlir-tblgen/pattern-tAttr.td +++ b/mlir/test/mlir-tblgen/pattern-tAttr.td @@ -6,7 +6,7 @@ include "mlir/IR/OpBase.td" def T : BuildableType<"buildT()">; def T_Attr : TypedAttrBase, "attribute of T type">; def T_Const_Attr : ConstantAttr; -def T_Compose_Attr : tAttr<"{0}.getArrayAttr({{{1}, {2}})">; +def T_Compose_Attr : tAttr<"$_builder.getArrayAttr({$0, $1})">; // Define ops to rewrite. def Y_Op : Op<"y.op"> { diff --git a/mlir/test/mlir-tblgen/predicate.td b/mlir/test/mlir-tblgen/predicate.td index 6a9442a2696..3c05604fbea 100644 --- a/mlir/test/mlir-tblgen/predicate.td +++ b/mlir/test/mlir-tblgen/predicate.td @@ -2,7 +2,7 @@ include "mlir/IR/OpBase.td" -def I32OrF32 : Type, +def I32OrF32 : Type, "32-bit integer or floating-point type">; def OpA : Op<"op_for_CPred_containing_multiple_same_placeholder", []> { diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp index 122e579e130..dc015d12b3b 100644 --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -21,11 +21,11 @@ //===----------------------------------------------------------------------===// #include "mlir/Support/STLExtras.h" +#include "mlir/TableGen/Format.h" #include "mlir/TableGen/GenInfo.h" #include "mlir/TableGen/OpTrait.h" #include "mlir/TableGen/Operator.h" #include "llvm/ADT/StringExtras.h" -#include "llvm/Support/FormatVariadic.h" #include "llvm/Support/Signals.h" #include "llvm/TableGen/Error.h" #include "llvm/TableGen/Record.h" @@ -33,8 +33,7 @@ using namespace llvm; using namespace mlir; - -using mlir::tblgen::Operator; +using namespace mlir::tblgen; static const char *const tblgenNamePrefix = "tblgen_"; static const char *const generatedArgName = "tblgen_arg"; @@ -51,18 +50,6 @@ static const char *const opCommentHeader = R"( // Utility structs and functions //===----------------------------------------------------------------------===// -// Variation of method in FormatVariadic.h which takes a StringRef as input -// instead. -template -inline auto formatv(StringRef fmt, Ts &&... vals) -> formatv_object(vals))...))> { - using ParamTuple = decltype( - std::make_tuple(detail::build_format_adapter(std::forward(vals))...)); - return llvm::formatv_object( - fmt, - std::make_tuple(detail::build_format_adapter(std::forward(vals))...)); -} - // Returns whether the record has a value of the given name that can be returned // via getValueAsString. static inline bool hasStringAttribute(const Record &record, @@ -145,6 +132,7 @@ public: OpMethodBody &operator<<(Twine content); OpMethodBody &operator<<(int content); + OpMethodBody &operator<<(const FmtObjectBase &content); void writeTo(raw_ostream &os) const; @@ -263,6 +251,12 @@ OpMethodBody &OpMethodBody::operator<<(int content) { return *this; } +OpMethodBody &OpMethodBody::operator<<(const FmtObjectBase &content) { + if (isEffective) + body.append(content.str()); + return *this; +} + void OpMethodBody::writeTo(raw_ostream &os) const { os << body; if (body.empty() || body.back() != '\n') @@ -429,6 +423,8 @@ void OpEmitter::emitDecl(raw_ostream &os) { opClass.writeDeclTo(os); } void OpEmitter::emitDef(raw_ostream &os) { opClass.writeDefTo(os); } void OpEmitter::genAttrGetters() { + FmtContext fctx; + fctx.withBuilder("mlir::Builder(this->getContext())"); for (auto &namedAttr : op.getAttributes()) { auto name = namedAttr.getName(); const auto &attr = namedAttr.attr; @@ -440,35 +436,35 @@ void OpEmitter::genAttrGetters() { if (!it.second.empty()) getter = it.second; - auto &method = opClass.newMethod(attr.getReturnType(), getter, - /*params=*/""); + auto &method = opClass.newMethod(attr.getReturnType(), getter); + auto &body = method.body(); // Emit the derived attribute body. if (attr.isDerivedAttr()) { - method.body() << " " << attr.getDerivedCodeBody() << "\n"; + body << " " << attr.getDerivedCodeBody() << "\n"; continue; } // Emit normal emitter. // Return the queried attribute with the correct return type. - std::string attrVal = - formatv("this->getAttr(\"{1}\").dyn_cast_or_null<{0}>()", - attr.getStorageType(), name); - method.body() << " auto attr = " << attrVal << ";\n"; - if (attr.hasDefaultValue()) { + auto attrVal = formatv("this->getAttr(\"{0}\").dyn_cast_or_null<{1}>()", + name, attr.getStorageType()); + body << " auto attr = " << attrVal << ";\n"; + if (attr.hasDefaultValueInitializer()) { // Returns the default value if not set. // TODO: this is inefficient, we are recreating the attribute for every // call. This should be set instead. - method.body() << " if (!attr)\n" - " return " - << formatv(attr.getConvertFromStorageCall(), - formatv(attr.getDefaultValueTemplate(), - "mlir::Builder(this->getContext())")) - << ";\n"; + std::string defaultValue = tgfmt(attr.getConstBuilderTemplate(), &fctx, + attr.getDefaultValueInitializer()); + body << " if (!attr)\n return " + << tgfmt(attr.getConvertFromStorageCall(), + &fctx.withSelf(defaultValue)) + << ";\n"; } - method.body() << " return " - << formatv(attr.getConvertFromStorageCall(), "attr") << ";\n"; + body << " return " + << tgfmt(attr.getConvertFromStorageCall(), &fctx.withSelf("attr")) + << ";\n"; } } @@ -794,6 +790,8 @@ void OpEmitter::genVerifier() { auto &method = opClass.newMethod("LogicalResult", "verify", /*params=*/""); auto &body = method.body(); + FmtContext fctx; + fctx.withOp("(*this->getOperation())"); // Verify the attributes have the correct type. for (const auto &namedAttr : op.getAttributes()) { @@ -808,7 +806,8 @@ void OpEmitter::genVerifier() { body << formatv(" auto {0} = this->getAttr(\"{1}\");\n", varName, attrName); - bool allowMissingAttr = attr.hasDefaultValue() || attr.isOptional(); + bool allowMissingAttr = + attr.hasDefaultValueInitializer() || attr.isOptional(); if (allowMissingAttr) { // If the attribute has a default value, then only verify the predicate if // set. This does effectively assume that the default value is valid. @@ -822,10 +821,11 @@ void OpEmitter::genVerifier() { auto attrPred = attr.getPredicate(); if (!attrPred.isNull()) { - body << formatv(" if (!({0})) return emitOpError(\"attribute '{1}' " - "failed to satisfy constraint: {2}\");\n", - formatv(attrPred.getCondition(), varName), attrName, - attr.getDescription()); + body << tgfmt(" if (!($0)) return emitOpError(\"attribute '$1' " + "failed to satisfy constraint: $2\");\n", + /*ctx=*/nullptr, + tgfmt(attrPred.getCondition(), &fctx.withSelf(varName)), + attrName, attr.getDescription()); } body << " }\n"; @@ -843,10 +843,10 @@ void OpEmitter::genVerifier() { if (value.hasPredicate()) { auto description = value.constraint.getDescription(); body << " if (!(" - << formatv(value.constraint.getConditionTemplate(), - "this->getOperation()->get" + - Twine(isOperand ? "Operand" : "Result") + "(" + - Twine(index) + ")->getType()") + << tgfmt(value.constraint.getConditionTemplate(), + &fctx.withSelf("this->getOperation()->get" + + Twine(isOperand ? "Operand" : "Result") + + "(" + Twine(index) + ")->getType()")) << "))\n"; body << " return emitOpError(\"" << (isOperand ? "operand" : "result") << " #" << index @@ -866,11 +866,10 @@ void OpEmitter::genVerifier() { for (auto &trait : op.getTraits()) { if (auto t = dyn_cast(&trait)) { - body << " if (!(" - << formatv(t->getPredTemplate().c_str(), "(*this->getOperation())") - << "))\n"; - body << " return emitOpError(\"failed to verify that " - << t->getDescription() << "\");\n"; + body << tgfmt(" if (!($0))\n return emitOpError(\"" + "failed to verify that $1\");\n", + &fctx, tgfmt(t->getPredTemplate(), &fctx), + t->getDescription()); } } diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp index ae99a0589aa..c23db32cb05 100644 --- a/mlir/tools/mlir-tblgen/RewriterGen.cpp +++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp @@ -21,6 +21,7 @@ #include "mlir/Support/STLExtras.h" #include "mlir/TableGen/Attribute.h" +#include "mlir/TableGen/Format.h" #include "mlir/TableGen/GenInfo.h" #include "mlir/TableGen/Operator.h" #include "mlir/TableGen/Pattern.h" @@ -29,7 +30,6 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSet.h" #include "llvm/Support/CommandLine.h" -#include "llvm/Support/FormatVariadic.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Signals.h" #include "llvm/TableGen/Error.h" @@ -223,6 +223,11 @@ private: // The next unused ID for newly created values unsigned nextValueId; raw_ostream &os; + + // Format contexts containing placeholder substitutations for match(). + FmtContext matchCtx; + // Format contexts containing placeholder substitutations for rewrite(). + FmtContext rewriteCtx; }; } // end anonymous namespace @@ -231,7 +236,10 @@ PatternEmitter::PatternEmitter(Record *pat, RecordOperatorMap *mapper, : loc(pat->getLoc()), opMap(mapper), pattern(pat, mapper), symbolResolver(pattern.getSourcePatternBoundArgs(), pattern.getSourcePatternBoundResults()), - nextValueId(0), os(os) {} + nextValueId(0), os(os) { + matchCtx.withBuilder("mlir::Builder(ctx)"); + rewriteCtx.withBuilder("rewriter"); +} std::string PatternEmitter::handleConstantAttr(Attribute attr, StringRef value) { @@ -240,8 +248,8 @@ std::string PatternEmitter::handleConstantAttr(Attribute attr, " does not have the 'constBuilderCall' field"); // TODO(jpienaar): Verify the constants here - return formatv(attr.getConstBuilderTemplate().str().c_str(), "rewriter", - value); + return tgfmt(attr.getConstBuilderTemplate(), + &rewriteCtx.withBuilder("rewriter"), value); } // Helper function to match patterns. @@ -311,10 +319,10 @@ void PatternEmitter::emitOperandMatch(DagNode tree, int index, int depth, // Only need to verify if the matcher's type is different from the one // of op definition. if (operand->constraint != matcher.getAsConstraint()) { + auto self = formatv("op{0}->getOperand({1})->getType()", depth, index); os.indent(indent) << "if (!(" - << formatv(matcher.getConditionTemplate().c_str(), - formatv("op{0}->getOperand({1})->getType()", - depth, index)) + << tgfmt(matcher.getConditionTemplate(), + &matchCtx.withSelf(self)) << ")) return matchFailure();\n"; } } @@ -340,10 +348,10 @@ void PatternEmitter::emitAttributeMatch(DagNode tree, int index, int depth, attr.getStorageType(), namedAttr->getName()); // TODO(antiagainst): This should use getter method to avoid duplication. - if (attr.hasDefaultValue()) { + if (attr.hasDefaultValueInitializer()) { os.indent(indent) << "if (!attr) attr = " - << formatv(attr.getDefaultValueTemplate().c_str(), - "mlir::Builder(ctx)") + << tgfmt(attr.getConstBuilderTemplate(), &matchCtx, + attr.getDefaultValueInitializer()) << ";\n"; } else if (attr.isOptional()) { // For a missing attribut that is optional according to definition, we @@ -364,7 +372,8 @@ void PatternEmitter::emitAttributeMatch(DagNode tree, int index, int depth, // If a constraint is specified, we need to generate C++ statements to // check the constraint. os.indent(indent) << "if (!(" - << formatv(matcher.getConditionTemplate().c_str(), "attr") + << tgfmt(matcher.getConditionTemplate(), + &matchCtx.withSelf("attr")) << ")) return matchFailure();\n"; } @@ -410,11 +419,11 @@ void PatternEmitter::emitMatchMethod(DagNode tree) { auto cmd = "if (!{0}) return matchFailure();\n"; if (isa(constraint)) { + auto self = formatv("(*{0}->result_type_begin())", + resolveSymbol(entities.front())); // TODO(jpienaar): Verify op only has one result. - os.indent(4) << formatv( - cmd, - formatv(condition.c_str(), "(*" + resolveSymbol(entities.front()) + - "->result_type_begin())")); + os.indent(4) << formatv(cmd, + tgfmt(condition, &matchCtx.withSelf(self.str()))); } else if (isa(constraint)) { PrintFatalError( loc, "cannot use AttrConstraint in Pattern multi-entity constraints"); @@ -430,8 +439,8 @@ void PatternEmitter::emitMatchMethod(DagNode tree) { names.push_back(resolveSymbol(entities[i])); for (; i < 4; ++i) names.push_back(""); - os.indent(4) << formatv(cmd, formatv(condition.c_str(), names[0], - names[1], names[2], names[3])); + os.indent(4) << formatv(cmd, tgfmt(condition, &matchCtx, names[0], + names[1], names[2], names[3])); } } @@ -584,7 +593,8 @@ std::string PatternEmitter::handleOpArgument(DagLeaf leaf, return result; } if (leaf.isAttrTransformer()) { - return formatv(leaf.getTransformationTemplate().c_str(), result); + return tgfmt(leaf.getTransformationTemplate(), + &rewriteCtx.withSelf(result)); } PrintFatalError(loc, "unhandled case when rewriting op"); } @@ -593,7 +603,7 @@ std::string PatternEmitter::handleOpArgument(DagNode tree) { if (!tree.isAttrTransformer()) { PrintFatalError(loc, "only tAttr is supported in nested dag attribute"); } - auto tempStr = tree.getTransformationTemplate(); + auto fmt = tree.getTransformationTemplate(); // TODO(fengliuai): replace formatv arguments with the exact specified args. SmallVector attrs(8); if (tree.getNumArgs() > 8) { @@ -603,8 +613,8 @@ std::string PatternEmitter::handleOpArgument(DagNode tree) { for (unsigned i = 0, e = tree.getNumArgs(); i != e; ++i) { attrs[i] = handleOpArgument(tree.getArgAsLeaf(i), tree.getArgName(i)); } - return formatv(tempStr.c_str(), "rewriter", attrs[0], attrs[1], attrs[2], - attrs[3], attrs[4], attrs[5], attrs[6], attrs[7]); + return tgfmt(fmt, &rewriteCtx, attrs[0], attrs[1], attrs[2], attrs[3], + attrs[4], attrs[5], attrs[6], attrs[7]); } void PatternEmitter::addSymbol(DagNode node) { -- cgit v1.2.3 From df5000fd314a55b3bf0f11d7a7f955863ffee3f7 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 10 May 2019 16:11:02 -0700 Subject: [TableGen] Return base attribute's name for anonymous OptionalAttr/DefaultValuedAttr -- PiperOrigin-RevId: 247693280 --- mlir/include/mlir/IR/OpBase.td | 8 ++++++++ mlir/include/mlir/TableGen/Attribute.h | 5 ++++- mlir/lib/TableGen/Attribute.cpp | 4 +++- mlir/tools/mlir-tblgen/RewriterGen.cpp | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index 5b186ddb155..58e6867f547 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -495,6 +495,10 @@ class DefaultValuedAttr : let convertFromStorage = attr.convertFromStorage; let constBuilderCall = attr.constBuilderCall; let defaultValue = val; + + // Remember `attr`'s def name. + // TOOD(b/132458159): consider embedding Attr as a field. + string baseAttr = !cast(attr); } // Decorates an attribute as optional. The return type of the generated @@ -507,6 +511,10 @@ class OptionalAttr : Attr { let convertFromStorage = "$_self ? " # returnType # "(" # attr.convertFromStorage # ") : (llvm::None)"; let isOptional = 0b1; + + // Remember `attr`'s def name. + // TOOD(b/132458159): consider embedding Attr as a field. + string baseAttr = !cast(attr); } // A generic attribute that must be constructed around a specific type diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index f8de36d753e..f9216055d20 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -92,7 +92,10 @@ public: // Returns whether this attribute is optional. bool isOptional() const; - StringRef getTableGenDefName() const; + // Returns this attribute's TableGen def name. If this is an `OptionalAttr` + // or `DefaultValuedAttr` without explicit name, returns the base attribute's + // name. + StringRef getAttrDefName() const; // Returns the code body for derived attribute. Aborts if this is not a // derived attribute. diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index a165ba8be4f..6e4083c6e58 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -110,7 +110,9 @@ bool tblgen::Attribute::isOptional() const { return def->getValueAsBit("isOptional"); } -StringRef tblgen::Attribute::getTableGenDefName() const { +StringRef tblgen::Attribute::getAttrDefName() const { + if (def->isAnonymous() && (isOptional() || hasDefaultValueInitializer())) + return getValueAsString(def->getValueInit("baseAttr")); return def->getName(); } diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp index 26a8f8e5b49..9cf85079ec9 100644 --- a/mlir/tools/mlir-tblgen/RewriterGen.cpp +++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp @@ -234,7 +234,7 @@ PatternEmitter::PatternEmitter(Record *pat, RecordOperatorMap *mapper, std::string PatternEmitter::handleConstantAttr(Attribute attr, StringRef value) { if (!attr.isConstBuildable()) - PrintFatalError(loc, "Attribute " + attr.getTableGenDefName() + + PrintFatalError(loc, "Attribute " + attr.getAttrDefName() + " does not have the 'constBuilderCall' field"); // TODO(jpienaar): Verify the constants here -- cgit v1.2.3 From cde4d5a6d902b3288ee5faf00975340ce5e2d05a Mon Sep 17 00:00:00 2001 From: Jacques Pienaar Date: Tue, 14 May 2019 15:03:48 -0700 Subject: Remove unnecessary C++ specifier in CPP files. NFC. These are only required in .h files to disambiguate between C and C++ header files. -- PiperOrigin-RevId: 248219135 --- mlir/lib/Analysis/AffineStructures.cpp | 2 +- mlir/lib/Analysis/MemRefBoundCheck.cpp | 2 +- mlir/lib/Analysis/NestedMatcher.cpp | 2 +- mlir/lib/EDSC/Builders.cpp | 2 +- mlir/lib/EDSC/Helpers.cpp | 2 +- mlir/lib/EDSC/Intrinsics.cpp | 2 +- mlir/lib/Support/FileUtilities.cpp | 2 +- mlir/lib/Support/StorageUniquer.cpp | 2 +- mlir/lib/TableGen/Argument.cpp | 2 +- mlir/lib/TableGen/Attribute.cpp | 2 +- mlir/lib/TableGen/Pattern.cpp | 2 +- mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp | 2 +- mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp | 2 +- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | 2 +- mlir/lib/Transforms/LowerVectorTransfers.cpp | 2 +- mlir/lib/Transforms/MaterializeVectors.cpp | 2 +- mlir/lib/Transforms/Vectorize.cpp | 2 +- mlir/lib/Translation/Translation.cpp | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/lib/Analysis/AffineStructures.cpp b/mlir/lib/Analysis/AffineStructures.cpp index 70d5fcb7850..c10533193bc 100644 --- a/mlir/lib/Analysis/AffineStructures.cpp +++ b/mlir/lib/Analysis/AffineStructures.cpp @@ -1,4 +1,4 @@ -//===- AffineStructures.cpp - MLIR Affine Structures Class-------*- C++ -*-===// +//===- AffineStructures.cpp - MLIR Affine Structures Class-----------------===// // // Copyright 2019 The MLIR Authors. // diff --git a/mlir/lib/Analysis/MemRefBoundCheck.cpp b/mlir/lib/Analysis/MemRefBoundCheck.cpp index 4e23441d5a5..0f5edc7b25a 100644 --- a/mlir/lib/Analysis/MemRefBoundCheck.cpp +++ b/mlir/lib/Analysis/MemRefBoundCheck.cpp @@ -1,4 +1,4 @@ -//===- MemRefBoundCheck.cpp - MLIR Affine Structures Class-----*- C++ -*-===// +//===- MemRefBoundCheck.cpp - MLIR Affine Structures Class ----------------===// // // Copyright 2019 The MLIR Authors. // diff --git a/mlir/lib/Analysis/NestedMatcher.cpp b/mlir/lib/Analysis/NestedMatcher.cpp index f08f66df506..dc6f939a59c 100644 --- a/mlir/lib/Analysis/NestedMatcher.cpp +++ b/mlir/lib/Analysis/NestedMatcher.cpp @@ -1,4 +1,4 @@ -//===- NestedMatcher.cpp - NestedMatcher Impl ------------------*- C++ -*-===// +//===- NestedMatcher.cpp - NestedMatcher Impl ----------------------------===// // // Copyright 2019 The MLIR Authors. // diff --git a/mlir/lib/EDSC/Builders.cpp b/mlir/lib/EDSC/Builders.cpp index 2c9117736ae..a4691e89cda 100644 --- a/mlir/lib/EDSC/Builders.cpp +++ b/mlir/lib/EDSC/Builders.cpp @@ -1,4 +1,4 @@ -//===- Builders.cpp - MLIR Declarative Builder Classes ----------*- C++ -*-===// +//===- Builders.cpp - MLIR Declarative Builder Classes --------------------===// // // Copyright 2019 The MLIR Authors. // diff --git a/mlir/lib/EDSC/Helpers.cpp b/mlir/lib/EDSC/Helpers.cpp index c33086e151c..e6266d373e6 100644 --- a/mlir/lib/EDSC/Helpers.cpp +++ b/mlir/lib/EDSC/Helpers.cpp @@ -1,4 +1,4 @@ -//===- Helpers.cpp - MLIR Declarative Helper Functionality ------*- C++ -*-===// +//===- Helpers.cpp - MLIR Declarative Helper Functionality ----------------===// // // Copyright 2019 The MLIR Authors. // diff --git a/mlir/lib/EDSC/Intrinsics.cpp b/mlir/lib/EDSC/Intrinsics.cpp index 254a0d2e7d6..c6811ded0a6 100644 --- a/mlir/lib/EDSC/Intrinsics.cpp +++ b/mlir/lib/EDSC/Intrinsics.cpp @@ -1,4 +1,4 @@ -//===- Intrinsics.cpp - MLIR Operations for Declarative Builders *- C++ -*-===// +//===- Intrinsics.cpp - MLIR Operations for Declarative Builders ----------===// // // Copyright 2019 The MLIR Authors. // diff --git a/mlir/lib/Support/FileUtilities.cpp b/mlir/lib/Support/FileUtilities.cpp index e5eba800179..fb9f5cf86da 100644 --- a/mlir/lib/Support/FileUtilities.cpp +++ b/mlir/lib/Support/FileUtilities.cpp @@ -1,4 +1,4 @@ -//===- FileUtilities.cpp - utilities for working with files -----*- C++ -*-===// +//===- FileUtilities.cpp - utilities for working with files ---------------===// // // Copyright 2019 The MLIR Authors. // diff --git a/mlir/lib/Support/StorageUniquer.cpp b/mlir/lib/Support/StorageUniquer.cpp index 6fd55e77777..7100b17611b 100644 --- a/mlir/lib/Support/StorageUniquer.cpp +++ b/mlir/lib/Support/StorageUniquer.cpp @@ -1,4 +1,4 @@ -//===- StorageUniquer.cpp - Common Storage Class Uniquer --------*- C++ -*-===// +//===- StorageUniquer.cpp - Common Storage Class Uniquer ------------------===// // // Copyright 2019 The MLIR Authors. // diff --git a/mlir/lib/TableGen/Argument.cpp b/mlir/lib/TableGen/Argument.cpp index 7432e0fc48f..17dba054e4f 100644 --- a/mlir/lib/TableGen/Argument.cpp +++ b/mlir/lib/TableGen/Argument.cpp @@ -1,4 +1,4 @@ -//===- Argument.cpp - Argument definitions ----------------------*- C++ -*-===// +//===- Argument.cpp - Argument definitions --------------------------------===// // // Copyright 2019 The MLIR Authors. // diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index 6e4083c6e58..9de95efadbb 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -1,4 +1,4 @@ -//===- Attribute.cpp - Attribute wrapper class ------------------*- C++ -*-===// +//===- Attribute.cpp - Attribute wrapper class ----------------------------===// // // Copyright 2019 The MLIR Authors. // diff --git a/mlir/lib/TableGen/Pattern.cpp b/mlir/lib/TableGen/Pattern.cpp index d4ba6cdf292..285f1c9bd53 100644 --- a/mlir/lib/TableGen/Pattern.cpp +++ b/mlir/lib/TableGen/Pattern.cpp @@ -1,4 +1,4 @@ -//===- Pattern.cpp - Pattern wrapper class ----------------------*- C++ -*-===// +//===- Pattern.cpp - Pattern wrapper class --------------------------------===// // // Copyright 2019 The MLIR Authors. // diff --git a/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp index ff9aa993aef..34dd374e9d7 100644 --- a/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp @@ -1,4 +1,4 @@ -//===- ConvertToLLVMIR.cpp - MLIR to LLVM IR conversion ---------*- C++ -*-===// +//===- ConvertToLLVMIR.cpp - MLIR to LLVM IR conversion -------------------===// // // Copyright 2019 The MLIR Authors. // diff --git a/mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp index 2f7ce413f41..2bd58baa049 100644 --- a/mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp @@ -1,4 +1,4 @@ -//===- ConvertToNVVMIR.cpp - MLIR to LLVM IR conversion ---------*- C++ -*-===// +//===- ConvertToNVVMIR.cpp - MLIR to LLVM IR conversion -------------------===// // // Copyright 2019 The MLIR Authors. // diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp index 9c7e50410ff..631005bc32d 100644 --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -1,4 +1,4 @@ -//===- ModuleTranslation.cpp - MLIR to LLVM conversion ----------*- C++ -*-===// +//===- ModuleTranslation.cpp - MLIR to LLVM conversion --------------------===// // // Copyright 2019 The MLIR Authors. // diff --git a/mlir/lib/Transforms/LowerVectorTransfers.cpp b/mlir/lib/Transforms/LowerVectorTransfers.cpp index 657169ad81e..53c97cf2b96 100644 --- a/mlir/lib/Transforms/LowerVectorTransfers.cpp +++ b/mlir/lib/Transforms/LowerVectorTransfers.cpp @@ -1,4 +1,4 @@ -//===- LowerVectorTransfers.cpp - LowerVectorTransfers Pass Impl *- C++ -*-===// +//===- LowerVectorTransfers.cpp - LowerVectorTransfers Pass Impl ----------===// // // Copyright 2019 The MLIR Authors. // diff --git a/mlir/lib/Transforms/MaterializeVectors.cpp b/mlir/lib/Transforms/MaterializeVectors.cpp index f81fabb2965..8094ff2f986 100644 --- a/mlir/lib/Transforms/MaterializeVectors.cpp +++ b/mlir/lib/Transforms/MaterializeVectors.cpp @@ -1,4 +1,4 @@ -//===- MaterializeVectors.cpp - MaterializeVectors Pass Impl ----*- C++ -*-===// +//===- MaterializeVectors.cpp - MaterializeVectors Pass Impl --------------===// // // Copyright 2019 The MLIR Authors. // diff --git a/mlir/lib/Transforms/Vectorize.cpp b/mlir/lib/Transforms/Vectorize.cpp index a5bb23fc559..4b66a77b3a3 100644 --- a/mlir/lib/Transforms/Vectorize.cpp +++ b/mlir/lib/Transforms/Vectorize.cpp @@ -1,4 +1,4 @@ -//===- Vectorize.cpp - Vectorize Pass Impl ----------------------*- C++ -*-===// +//===- Vectorize.cpp - Vectorize Pass Impl --------------------------------===// // // Copyright 2019 The MLIR Authors. // diff --git a/mlir/lib/Translation/Translation.cpp b/mlir/lib/Translation/Translation.cpp index c1a9f9d11fc..be2fc35d605 100644 --- a/mlir/lib/Translation/Translation.cpp +++ b/mlir/lib/Translation/Translation.cpp @@ -1,4 +1,4 @@ -//===- Translation.cpp - Translation registry -------------------*- C++ -*-===// +//===- Translation.cpp - Translation registry -----------------------------===// // // Copyright 2019 The MLIR Authors. // -- cgit v1.2.3 From 1be9fc66115de245f469e3b09114a06603258ce0 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Sat, 8 Jun 2019 08:39:07 -0700 Subject: [TableGen] Generating enum definitions and utility functions Enum attributes can be defined using `EnumAttr`, which requires all its cases to be defined with `EnumAttrCase`. To facilitate the interaction between `EnumAttr`s and their C++ consumers, add a new EnumsGen TableGen backend to generate a few common utilities, including an enum class, `llvm::DenseMapInfo` for the enum class, conversion functions from/to strings. This is controlled via the `-gen-enum-decls` and `-gen-enum-defs` command-line options of `mlir-tblgen`. PiperOrigin-RevId: 252209623 --- mlir/g3doc/OpDefinitions.md | 90 +++++++++++++- mlir/include/mlir/IR/OpBase.td | 39 +++++- mlir/include/mlir/TableGen/Attribute.h | 18 +++ mlir/lib/TableGen/Attribute.cpp | 22 ++++ mlir/tools/mlir-tblgen/CMakeLists.txt | 1 + mlir/tools/mlir-tblgen/EnumsGen.cpp | 198 +++++++++++++++++++++++++++++++ mlir/unittests/TableGen/CMakeLists.txt | 9 ++ mlir/unittests/TableGen/EnumsGenTest.cpp | 66 +++++++++++ mlir/unittests/TableGen/enums.td | 31 +++++ 9 files changed, 472 insertions(+), 2 deletions(-) create mode 100644 mlir/tools/mlir-tblgen/EnumsGen.cpp create mode 100644 mlir/unittests/TableGen/EnumsGenTest.cpp create mode 100644 mlir/unittests/TableGen/enums.td (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/g3doc/OpDefinitions.md b/mlir/g3doc/OpDefinitions.md index 810dd347894..8146fce6e58 100644 --- a/mlir/g3doc/OpDefinitions.md +++ b/mlir/g3doc/OpDefinitions.md @@ -618,7 +618,94 @@ duplication, which is being worked on right now. ## Attribute Definition -TODO: This section is outdated. Update it. +### Enum attributes + +Enum attributes can be defined using `EnumAttr`, which requires all its cases to +be defined with `EnumAttrCase`. To facilitate the interaction between +`EnumAttr`s and their C++ consumers, the [`EnumsGen`][EnumsGen] TableGen backend +can generate a few common utilities, including an enum class, +`llvm::DenseMapInfo` for the enum class, conversion functions from/to strings. +This is controlled via the `-gen-enum-decls` and `-gen-enum-defs` command-line +options of `mlir-tblgen`. + +For example, given the following `EnumAttr`: + +```tablegen +def CaseA: EnumAttrCase<"caseA", 0>; +def CaseB: EnumAttrCase<"caseB", 10>; + +def MyEnum: EnumAttr<"MyEnum", "An example enum", [CaseA, CaseB]> { + let cppNamespace = "Outer::Inner"; + let underlyingType = "uint64_t"; + let stringToSymbolFnName = "ConvertToEnum"; + let symbolToStringFnName = "ConvertToString"; +} +``` + +The following will be generated via `mlir-tblgen -gen-enum-decls`: + +```c++ +namespace Outer { +namespace Inner { +// An example enum +enum class MyEnum : uint64_t { + caseA = 0, + caseB = 10, +}; + +llvm::StringRef ConvertToString(MyEnum); +llvm::Optional ConvertToEnum(llvm::StringRef); +} // namespace Inner +} // namespace Outer + +namespace llvm { +template<> struct DenseMapInfo { + using StorageInfo = llvm::DenseMapInfo; + + static inline Outer::Inner::MyEnum getEmptyKey() { + return static_cast(StorageInfo::getEmptyKey()); + } + + static inline Outer::Inner::MyEnum getTombstoneKey() { + return static_cast(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const Outer::Inner::MyEnum &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const Outer::Inner::MyEnum &lhs, + const Outer::Inner::MyEnum &rhs) { + return lhs == rhs; + } +}; +} +``` + +The following will be generated via `mlir-tblgen -gen-enum-defs`: + +```c++ +namespace Outer { +namespace Inner { +llvm::StringRef ConvertToString(MyEnum val) { + switch (val) { + case MyEnum::caseA: return "caseA"; + case MyEnum::caseB: return "caseB"; + default: return ""; + } +} + +llvm::Optional ConvertToEnum(llvm::StringRef str) { + return llvm::StringSwitch>(str) + .Case("caseA", MyEnum::caseA) + .Case("caseB", MyEnum::caseB) + .Default(llvm::None); +} +} // namespace Inner +} // namespace Outer +``` + +TODO(b/132506080): This following is outdated. Update it. An attribute is a compile time known constant of an operation. Attributes are required to be known to construct an operation (e.g., the padding behavior is @@ -829,3 +916,4 @@ TODO: Describe the generation of benefit metric given pattern. [TableGenBackend]: https://llvm.org/docs/TableGen/BackEnds.html#introduction [OpBase]: https://github.com/tensorflow/mlir/blob/master/include/mlir/IR/OpBase.td [OpDefinitionsGen]: https://github.com/tensorflow/mlir/blob/master/tools/mlir-tblgen/OpDefinitionsGen.cpp +[EnumsGen]: https://github.com/tensorflow/mlir/blob/master/tools/mlir-tblgen/EnumsGen.cpp diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index a170069ed41..ac8c6528be0 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -634,11 +634,14 @@ class TypeAttrBase : def TypeAttr : TypeAttrBase<"Type", "any type attribute">; // An enum attribute case. -class EnumAttrCase : StringBasedAttr< +class EnumAttrCase : StringBasedAttr< CPred<"$_self.cast().getValue() == \"" # sym # "\"">, "case " # sym> { // The C++ enumerant symbol string symbol = sym; + // The C++ enumerant value + // A non-negative value must be provided if to use EnumsGen backend. + int value = val; } // An enum attribute. Its value can only be one from the given list of `cases`. @@ -651,8 +654,42 @@ class EnumAttr cases> : description> { // The C++ enum class name string className = name; + // List of all accepted cases list enumerants = cases; + + // The following fields are only used by the EnumsGen backend to generate + // an enum class definition and conversion utility functions. + + // The underlying type for the C++ enum class. An empty string mean the + // underlying type is not explicitly specified. + string underlyingType = ""; + + // The C++ namespaces that the enum class definition and utility functions + // should be placed into. + // + // Normally you want to place the full namespace path here. If it is nested, + // use "::" as the delimiter, e.g., given "A::B", generated code will be + // placed in `namespace A { namespace B { ... } }`. To avoid placing in any + // namespace, use "". + // TODO(b/134741431): use dialect to provide the namespace. + string cppNamespace = ""; + + // The name of the utility function that converts a string to the + // corresponding symbol. It will have the following signature: + // + // ```c++ + // llvm::Optional<> (llvm::StringRef); + // ``` + string stringToSymbolFnName = "symbolize" # name; + + // The name of the utility function that converts a symbol to the + // corresponding string. It will have the following signature: + // + // ```c++ + // llvm::StringRef (); + // ``` + string symbolToStringFnName = "stringify" # name; } class ElementsAttrBase : diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index f9216055d20..f69961ad8e6 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -129,6 +129,9 @@ public: // Returns the symbol of this enum attribute case. StringRef getSymbol() const; + + // Returns the value of this enum attribute case. + int64_t getValue() const; }; // Wrapper class providing helper methods for accessing enum attributes defined @@ -137,11 +140,26 @@ public: class EnumAttr : public Attribute { public: explicit EnumAttr(const llvm::Record *record); + explicit EnumAttr(const llvm::Record &record); explicit EnumAttr(const llvm::DefInit *init); // Returns the enum class name. StringRef getEnumClassName() const; + // Returns the C++ namespaces this enum class should be placed in. + StringRef getCppNamespace() const; + + // Returns the underlying type. + StringRef getUnderlyingType() const; + + // Returns the name of the utility function that converts a string to the + // corresponding symbol. + StringRef getStringToSymbolFnName() const; + + // Returns the name of the utility function that converts a symbol to the + // corresponding string. + StringRef getSymbolToStringFnName() const; + // Returns all allowed cases for this enum attribute. std::vector getAllCases() const; }; diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index 9de95efadbb..29259bec69a 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -144,11 +144,17 @@ StringRef tblgen::EnumAttrCase::getSymbol() const { return def->getValueAsString("symbol"); } +int64_t tblgen::EnumAttrCase::getValue() const { + return def->getValueAsInt("value"); +} + tblgen::EnumAttr::EnumAttr(const llvm::Record *record) : Attribute(record) { assert(def->isSubClassOf("EnumAttr") && "must be subclass of TableGen 'EnumAttr' class"); } +tblgen::EnumAttr::EnumAttr(const llvm::Record &record) : Attribute(&record) {} + tblgen::EnumAttr::EnumAttr(const llvm::DefInit *init) : EnumAttr(init->getDef()) {} @@ -156,6 +162,22 @@ StringRef tblgen::EnumAttr::getEnumClassName() const { return def->getValueAsString("className"); } +StringRef tblgen::EnumAttr::getCppNamespace() const { + return def->getValueAsString("cppNamespace"); +} + +StringRef tblgen::EnumAttr::getUnderlyingType() const { + return def->getValueAsString("underlyingType"); +} + +StringRef tblgen::EnumAttr::getStringToSymbolFnName() const { + return def->getValueAsString("stringToSymbolFnName"); +} + +StringRef tblgen::EnumAttr::getSymbolToStringFnName() const { + return def->getValueAsString("symbolToStringFnName"); +} + std::vector tblgen::EnumAttr::getAllCases() const { const auto *inits = def->getValueAsListInit("enumerants"); diff --git a/mlir/tools/mlir-tblgen/CMakeLists.txt b/mlir/tools/mlir-tblgen/CMakeLists.txt index d341cabb65a..65c5e91c85f 100644 --- a/mlir/tools/mlir-tblgen/CMakeLists.txt +++ b/mlir/tools/mlir-tblgen/CMakeLists.txt @@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS ) add_tablegen(mlir-tblgen MLIR + EnumsGen.cpp LLVMIRConversionGen.cpp mlir-tblgen.cpp OpDefinitionsGen.cpp diff --git a/mlir/tools/mlir-tblgen/EnumsGen.cpp b/mlir/tools/mlir-tblgen/EnumsGen.cpp new file mode 100644 index 00000000000..ab86c9dd8cc --- /dev/null +++ b/mlir/tools/mlir-tblgen/EnumsGen.cpp @@ -0,0 +1,198 @@ +//===- EnumsGen.cpp - MLIR enum utility generator -------------------------===// +// +// Copyright 2019 The MLIR Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================= +// +// EnumsGen generates common utility functions for enums. +// +//===----------------------------------------------------------------------===// + +#include "mlir/TableGen/Attribute.h" +#include "mlir/TableGen/GenInfo.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/TableGen/Error.h" +#include "llvm/TableGen/Record.h" +#include "llvm/TableGen/TableGenBackend.h" + +using llvm::formatv; +using llvm::raw_ostream; +using llvm::Record; +using llvm::RecordKeeper; +using llvm::StringRef; +using mlir::tblgen::EnumAttr; +using mlir::tblgen::EnumAttrCase; + +static void emitEnumClass(const Record &enumDef, StringRef enumName, + StringRef underlyingType, StringRef description, + const std::vector &enumerants, + raw_ostream &os) { + os << "// " << description << "\n"; + os << "enum class " << enumName; + + if (!underlyingType.empty()) + os << " : " << underlyingType; + os << " {\n"; + + for (const auto &enumerant : enumerants) { + auto symbol = enumerant.getSymbol(); + auto value = enumerant.getValue(); + if (value < 0) { + llvm::PrintFatalError(enumDef.getLoc(), + "all enumerants must have a non-negative value"); + } + os << formatv(" {0} = {1},\n", symbol, value); + } + os << "};\n\n"; +} + +static void emitDenseMapInfo(StringRef enumName, std::string underlyingType, + StringRef cppNamespace, raw_ostream &os) { + std::string qualName = formatv("{0}::{1}", cppNamespace, enumName); + if (underlyingType.empty()) + underlyingType = formatv("std::underlying_type<{0}>::type", qualName); + + const char *const mapInfo = R"( +namespace llvm { +template<> struct DenseMapInfo<{0}> {{ + using StorageInfo = llvm::DenseMapInfo<{1}>; + + static inline {0} getEmptyKey() {{ + return static_cast<{0}>(StorageInfo::getEmptyKey()); + } + + static inline {0} getTombstoneKey() {{ + return static_cast<{0}>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const {0} &val) {{ + return StorageInfo::getHashValue(static_cast<{1}>(val)); + } + + static bool isEqual(const {0} &lhs, const {0} &rhs) {{ + return lhs == rhs; + } +}; +})"; + os << formatv(mapInfo, qualName, underlyingType); + os << "\n\n"; +} + +static void emitEnumDecl(const Record &enumDef, raw_ostream &os) { + EnumAttr enumAttr(enumDef); + StringRef enumName = enumAttr.getEnumClassName(); + StringRef cppNamespace = enumAttr.getCppNamespace(); + std::string underlyingType = enumAttr.getUnderlyingType(); + StringRef description = enumAttr.getDescription(); + StringRef strToSymFnName = enumAttr.getStringToSymbolFnName(); + StringRef symToStrFnName = enumAttr.getSymbolToStringFnName(); + auto enumerants = enumAttr.getAllCases(); + + llvm::SmallVector namespaces; + llvm::SplitString(cppNamespace, namespaces, "::"); + + for (auto ns : namespaces) + os << "namespace " << ns << " {\n"; + + // Emit the enum class definition + emitEnumClass(enumDef, enumName, underlyingType, description, enumerants, os); + + // Emit coversion function declarations + os << formatv("llvm::StringRef {1}({0});\n", enumName, symToStrFnName); + os << formatv("llvm::Optional<{0}> {1}(llvm::StringRef);\n", enumName, + strToSymFnName); + + for (auto ns : llvm::reverse(namespaces)) + os << "} // namespace " << ns << "\n"; + + // Emit DenseMapInfo for this enum class + emitDenseMapInfo(enumName, underlyingType, cppNamespace, os); +} + +static bool emitEnumDecls(const RecordKeeper &recordKeeper, raw_ostream &os) { + llvm::emitSourceFileHeader("Enum Utility Declarations", os); + + auto defs = recordKeeper.getAllDerivedDefinitions("EnumAttr"); + for (const auto *def : defs) + emitEnumDecl(*def, os); + + return false; +} + +static void emitEnumDef(const Record &enumDef, raw_ostream &os) { + EnumAttr enumAttr(enumDef); + StringRef enumName = enumAttr.getEnumClassName(); + StringRef cppNamespace = enumAttr.getCppNamespace(); + StringRef strToSymFnName = enumAttr.getStringToSymbolFnName(); + StringRef symToStrFnName = enumAttr.getSymbolToStringFnName(); + auto enumerants = enumAttr.getAllCases(); + + llvm::SmallVector namespaces; + llvm::SplitString(cppNamespace, namespaces, "::"); + + for (auto ns : namespaces) + os << "namespace " << ns << " {\n"; + + os << formatv("llvm::StringRef {1}({0} val) {{\n", enumName, symToStrFnName); + os << " switch (val) {\n"; + for (const auto &enumerant : enumerants) { + auto symbol = enumerant.getSymbol(); + os << formatv(" case {0}::{1}: return \"{1}\";\n", enumName, symbol); + } + os << " }\n"; + os << " return \"\";\n"; + os << "}\n\n"; + + os << formatv("llvm::Optional<{0}> {1}(llvm::StringRef str) {{\n", enumName, + strToSymFnName); + os << formatv(" return llvm::StringSwitch>(str)\n", + enumName); + for (const auto &enumerant : enumerants) { + auto symbol = enumerant.getSymbol(); + os << formatv(" .Case(\"{1}\", {0}::{1})\n", enumName, symbol); + } + os << " .Default(llvm::None);\n"; + os << "}\n"; + + for (auto ns : llvm::reverse(namespaces)) + os << "} // namespace " << ns << "\n"; + os << "\n"; +} + +static bool emitEnumDefs(const RecordKeeper &recordKeeper, raw_ostream &os) { + llvm::emitSourceFileHeader("Enum Utility Definitions", os); + + auto defs = recordKeeper.getAllDerivedDefinitions("EnumAttr"); + for (const auto *def : defs) + emitEnumDef(*def, os); + + return false; +} + +// Registers the enum utility generator to mlir-tblgen. +static mlir::GenRegistration + genEnumDecls("gen-enum-decls", "Generate enum utility declarations", + [](const RecordKeeper &records, raw_ostream &os) { + return emitEnumDecls(records, os); + }); + +// Registers the enum utility generator to mlir-tblgen. +static mlir::GenRegistration + genEnumDefs("gen-enum-defs", "Generate enum utility definitions", + [](const RecordKeeper &records, raw_ostream &os) { + return emitEnumDefs(records, os); + }); diff --git a/mlir/unittests/TableGen/CMakeLists.txt b/mlir/unittests/TableGen/CMakeLists.txt index e40059075e2..aa55adbdae8 100644 --- a/mlir/unittests/TableGen/CMakeLists.txt +++ b/mlir/unittests/TableGen/CMakeLists.txt @@ -1,5 +1,14 @@ +set(LLVM_TARGET_DEFINITIONS enums.td) +mlir_tablegen(EnumsGenTest.h.inc -gen-enum-decls) +mlir_tablegen(EnumsGenTest.cpp.inc -gen-enum-defs) +add_public_tablegen_target(MLIRTableGenEnumsIncGen) + add_mlir_unittest(MLIRTableGenTests + EnumsGenTest.cpp FormatTest.cpp ) + +add_dependencies(MLIRTableGenTests MLIRTableGenEnumsIncGen) + target_link_libraries(MLIRTableGenTests PRIVATE LLVMMLIRTableGen) diff --git a/mlir/unittests/TableGen/EnumsGenTest.cpp b/mlir/unittests/TableGen/EnumsGenTest.cpp new file mode 100644 index 00000000000..b9a98a4504c --- /dev/null +++ b/mlir/unittests/TableGen/EnumsGenTest.cpp @@ -0,0 +1,66 @@ +//===- EnumsGenTest.cpp - TableGen EnumsGen Tests -------------------------===// +// +// Copyright 2019 The MLIR Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================= + +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/StringSwitch.h" +#include "gmock/gmock.h" +#include + +// Pull in generated enum utility declarations +#include "EnumsGenTest.h.inc" +// And definitions +#include "EnumsGenTest.cpp.inc" + +using ::testing::StrEq; + +// Test namespaces and enum class/utility names +using Outer::Inner::ConvertToEnum; +using Outer::Inner::ConvertToString; +using Outer::Inner::MyEnum; + +TEST(EnumsGenTest, GeneratedEnumDefinition) { + EXPECT_EQ(0u, static_cast(MyEnum::CaseA)); + EXPECT_EQ(10u, static_cast(MyEnum::CaseB)); +} + +TEST(EnumsGenTest, GeneratedDenseMapInfo) { + llvm::DenseMap myMap; + + myMap[MyEnum::CaseA] = "zero"; + myMap[MyEnum::CaseB] = "ten"; + + EXPECT_THAT(myMap[MyEnum::CaseA], StrEq("zero")); + EXPECT_THAT(myMap[MyEnum::CaseB], StrEq("ten")); +} + +TEST(EnumsGenTest, GeneratedSymbolToStringFn) { + EXPECT_THAT(ConvertToString(MyEnum::CaseA), StrEq("CaseA")); + EXPECT_THAT(ConvertToString(MyEnum::CaseB), StrEq("CaseB")); +} + +TEST(EnumsGenTest, GeneratedStringToSymbolFn) { + EXPECT_EQ(llvm::Optional(MyEnum::CaseA), ConvertToEnum("CaseA")); + EXPECT_EQ(llvm::Optional(MyEnum::CaseB), ConvertToEnum("CaseB")); + EXPECT_EQ(llvm::None, ConvertToEnum("X")); +} + +TEST(EnumsGenTest, GeneratedUnderlyingType) { + bool v = + std::is_same::type>::value; + EXPECT_TRUE(v); +} diff --git a/mlir/unittests/TableGen/enums.td b/mlir/unittests/TableGen/enums.td new file mode 100644 index 00000000000..289829552c3 --- /dev/null +++ b/mlir/unittests/TableGen/enums.td @@ -0,0 +1,31 @@ +//===-- enums.td - EnumsGen test definition file -----------*- tablegen -*-===// +// +// Copyright 2019 The MLIR Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================= + +include "mlir/IR/OpBase.td" + +def CaseA: EnumAttrCase<"CaseA", 0>; +def CaseB: EnumAttrCase<"CaseB", 10>; + +def MyEnum: EnumAttr<"MyEnum", "A test enum", [CaseA, CaseB]> { + let cppNamespace = "Outer::Inner"; + let stringToSymbolFnName = "ConvertToEnum"; + let symbolToStringFnName = "ConvertToString"; +} + +def Uint64Enum : EnumAttr<"Uint64Enum", "A test enum", [CaseA, CaseB]> { + let underlyingType = "uint64_t"; +} -- cgit v1.2.3 From d7ba69e811c51f2f732aed374cc964cdc741defb Mon Sep 17 00:00:00 2001 From: Mahesh Ravishankar Date: Wed, 19 Jun 2019 16:09:57 -0700 Subject: Add SPIRV Image Type according to the spec described here : https://www.khronos.org/registry/spir-v/specs/1.0/SPIRV.html#OpTypeImage. Add new enums to describe Image dimensionality, Image Depth, Arrayed information, Sampling, Sampler User information, and Image format. Doesn's support the Optional Access qualifier at this stage Fix Enum generator for tblgen to add "_" at the beginning if the enum starts with a number. PiperOrigin-RevId: 254091423 --- mlir/g3doc/Dialects/SPIR-V.md | 31 ++++- mlir/include/mlir/IR/OpBase.td | 8 ++ mlir/include/mlir/SPIRV/SPIRVBase.td | 118 +++++++++++++++++++ mlir/include/mlir/SPIRV/SPIRVDialect.h | 3 + mlir/include/mlir/SPIRV/SPIRVTypes.h | 40 +++++++ mlir/include/mlir/TableGen/Attribute.h | 4 + mlir/lib/SPIRV/SPIRVDialect.cpp | 207 ++++++++++++++++++++++++++++++++- mlir/lib/SPIRV/SPIRVTypes.cpp | 179 ++++++++++++++++++++++++++++ mlir/lib/TableGen/Attribute.cpp | 4 + mlir/test/SPIRV/types.mlir | 70 +++++++++++ mlir/tools/mlir-tblgen/EnumsGen.cpp | 29 ++++- 11 files changed, 684 insertions(+), 9 deletions(-) (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/g3doc/Dialects/SPIR-V.md b/mlir/g3doc/Dialects/SPIR-V.md index 58400ef58bb..19442f27ed0 100644 --- a/mlir/g3doc/Dialects/SPIR-V.md +++ b/mlir/g3doc/Dialects/SPIR-V.md @@ -87,6 +87,35 @@ For example, !spv.array<16 x vector<4 x f32>> ``` +### Image type + +This corresponds to SPIR-V [image_type][ImageType]. Its syntax is + +``` {.ebnf} +dim ::= `1D` | `2D` | `3D` | `Cube` | + +depth-info ::= `NoDepth` | `IsDepth` | `DepthUnknown` + +arrayed-info ::= `NonArrayed` | `Arrayed` + +sampling-info ::= `SingleSampled` | `MultiSampled` + +sampler-use-info ::= `SamplerUnknown` | `NeedSampler` | `NoSampler` + +format ::= `Unknown` | `Rgba32f` | + +image-type ::= `!spv.image<` element-type `,` dim `,` depth-info `,` + arrayed-info `,` sampling-info `,` + sampler-use-info `,` format `>` +``` + +For example, + +``` {.mlir} +!spv.image +!spv.image +``` + ### Pointer type This corresponds to SPIR-V [pointer type][PointerType]. Its syntax is @@ -122,8 +151,8 @@ For example, !spv.rtarray> ``` - [SPIR-V]: https://www.khronos.org/registry/spir-v/ [ArrayType]: https://www.khronos.org/registry/spir-v/specs/unified1/SPIRV.html#OpTypeArray [PointerType]: https://www.khronos.org/registry/spir-v/specs/unified1/SPIRV.html#OpTypePointer [RuntimeArrayType]: https://www.khronos.org/registry/spir-v/specs/unified1/SPIRV.html#OpTypeRuntimeArray +[ImageType]: https://www.khronos.org/registry/spir-v/specs/unified1/SPIRV.html#OpTypeImage diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index 7f4b261af4a..6f199123b0f 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -688,6 +688,14 @@ class EnumAttr cases> : // llvm::StringRef (); // ``` string symbolToStringFnName = "stringify" # name; + + // The name of the utility function that returns the max enum value used + // within the enum class. It will have the following signature: + // + // ```c++ + // static constexpr unsigned (); + // ``` + string maxEnumValFnName = "getMaxEnumValFor" # name; } class ElementsAttrBase : diff --git a/mlir/include/mlir/SPIRV/SPIRVBase.td b/mlir/include/mlir/SPIRV/SPIRVBase.td index 50ac64af2f0..0a8b576743a 100644 --- a/mlir/include/mlir/SPIRV/SPIRVBase.td +++ b/mlir/include/mlir/SPIRV/SPIRVBase.td @@ -116,6 +116,80 @@ def SPV_AddressingModelAttr : let underlyingType = "uint32_t"; } +def SPV_D_1D : EnumAttrCase<"1D", 0>; +def SPV_D_2D : EnumAttrCase<"2D", 1>; +def SPV_D_3D : EnumAttrCase<"3D", 2>; +def SPV_D_Cube : EnumAttrCase<"Cube", 3>; +def SPV_D_Rect : EnumAttrCase<"Rect", 4>; +def SPV_D_Buffer : EnumAttrCase<"Buffer", 5>; +def SPV_D_SubpassData : EnumAttrCase<"SubpassData", 6>; + +def SPV_DimAttr : + EnumAttr<"Dim", "valid SPIR-V Dim", [ + SPV_D_1D, SPV_D_2D, SPV_D_3D, SPV_D_Cube, SPV_D_Rect, SPV_D_Buffer, + SPV_D_SubpassData + ]> { + let cppNamespace = "::mlir::spirv"; + let underlyingType = "uint32_t"; +} + +def SPV_IF_Unknown : EnumAttrCase<"Unknown", 0>; +def SPV_IF_Rgba32f : EnumAttrCase<"Rgba32f", 1>; +def SPV_IF_Rgba16f : EnumAttrCase<"Rgba16f", 2>; +def SPV_IF_R32f : EnumAttrCase<"R32f", 3>; +def SPV_IF_Rgba8 : EnumAttrCase<"Rgba8", 4>; +def SPV_IF_Rgba8Snorm : EnumAttrCase<"Rgba8Snorm", 5>; +def SPV_IF_Rg32f : EnumAttrCase<"Rg32f", 6>; +def SPV_IF_Rg16f : EnumAttrCase<"Rg16f", 7>; +def SPV_IF_R11fG11fB10f : EnumAttrCase<"R11fG11fB10f", 8>; +def SPV_IF_R16f : EnumAttrCase<"R16f", 9>; +def SPV_IF_Rgba16 : EnumAttrCase<"Rgba16", 10>; +def SPV_IF_Rgb10A2 : EnumAttrCase<"Rgb10A2", 11>; +def SPV_IF_Rg16 : EnumAttrCase<"Rg16", 12>; +def SPV_IF_Rg8 : EnumAttrCase<"Rg8", 13>; +def SPV_IF_R16 : EnumAttrCase<"R16", 14>; +def SPV_IF_R8 : EnumAttrCase<"R8", 15>; +def SPV_IF_Rgba16Snorm : EnumAttrCase<"Rgba16Snorm", 16>; +def SPV_IF_Rg16Snorm : EnumAttrCase<"Rg16Snorm", 17>; +def SPV_IF_Rg8Snorm : EnumAttrCase<"Rg8Snorm", 18>; +def SPV_IF_R16Snorm : EnumAttrCase<"R16Snorm", 19>; +def SPV_IF_R8Snorm : EnumAttrCase<"R8Snorm", 20>; +def SPV_IF_Rgba32i : EnumAttrCase<"Rgba32i", 21>; +def SPV_IF_Rgba16i : EnumAttrCase<"Rgba16i", 22>; +def SPV_IF_Rgba8i : EnumAttrCase<"Rgba8i", 23>; +def SPV_IF_R32i : EnumAttrCase<"R32i", 24>; +def SPV_IF_Rg32i : EnumAttrCase<"Rg32i", 25>; +def SPV_IF_Rg16i : EnumAttrCase<"Rg16i", 26>; +def SPV_IF_Rg8i : EnumAttrCase<"Rg8i", 27>; +def SPV_IF_R16i : EnumAttrCase<"R16i", 28>; +def SPV_IF_R8i : EnumAttrCase<"R8i", 29>; +def SPV_IF_Rgba32ui : EnumAttrCase<"Rgba32ui", 30>; +def SPV_IF_Rgba16ui : EnumAttrCase<"Rgba16ui", 31>; +def SPV_IF_Rgba8ui : EnumAttrCase<"Rgba8ui", 32>; +def SPV_IF_R32ui : EnumAttrCase<"R32ui", 33>; +def SPV_IF_Rgb10a2ui : EnumAttrCase<"Rgb10a2ui", 34>; +def SPV_IF_Rg32ui : EnumAttrCase<"Rg32ui", 35>; +def SPV_IF_Rg16ui : EnumAttrCase<"Rg16ui", 36>; +def SPV_IF_Rg8ui : EnumAttrCase<"Rg8ui", 37>; +def SPV_IF_R16ui : EnumAttrCase<"R16ui", 38>; +def SPV_IF_R8ui : EnumAttrCase<"R8ui", 39>; + +def SPV_ImageFormatAttr : + EnumAttr<"ImageFormat", "valid SPIR-V ImageFormat", [ + SPV_IF_Unknown, SPV_IF_Rgba32f, SPV_IF_Rgba16f, SPV_IF_R32f, SPV_IF_Rgba8, + SPV_IF_Rgba8Snorm, SPV_IF_Rg32f, SPV_IF_Rg16f, SPV_IF_R11fG11fB10f, + SPV_IF_R16f, SPV_IF_Rgba16, SPV_IF_Rgb10A2, SPV_IF_Rg16, SPV_IF_Rg8, + SPV_IF_R16, SPV_IF_R8, SPV_IF_Rgba16Snorm, SPV_IF_Rg16Snorm, SPV_IF_Rg8Snorm, + SPV_IF_R16Snorm, SPV_IF_R8Snorm, SPV_IF_Rgba32i, SPV_IF_Rgba16i, SPV_IF_Rgba8i, + SPV_IF_R32i, SPV_IF_Rg32i, SPV_IF_Rg16i, SPV_IF_Rg8i, SPV_IF_R16i, SPV_IF_R8i, + SPV_IF_Rgba32ui, SPV_IF_Rgba16ui, SPV_IF_Rgba8ui, SPV_IF_R32ui, + SPV_IF_Rgb10a2ui, SPV_IF_Rg32ui, SPV_IF_Rg16ui, SPV_IF_Rg8ui, SPV_IF_R16ui, + SPV_IF_R8ui + ]> { + let cppNamespace = "::mlir::spirv"; + let underlyingType = "uint32_t"; +} + def SPV_MM_Simple : EnumAttrCase<"Simple", 0>; def SPV_MM_GLSL450 : EnumAttrCase<"GLSL450", 1>; def SPV_MM_OpenCL : EnumAttrCase<"OpenCL", 2>; @@ -165,6 +239,50 @@ def SPV_StorageClassAttr : // End enum section. Generated from SPIR-V spec; DO NOT MODIFY! +// Enums added manually that are not part of SPIRV spec + +def SPV_IDI_NoDepth : EnumAttrCase<"NoDepth", 0>; +def SPV_IDI_IsDepth : EnumAttrCase<"IsDepth", 1>; +def SPV_IDI_DepthUnknown : EnumAttrCase<"DepthUnknown", 2>; + +def SPV_DepthAttr : + EnumAttr<"ImageDepthInfo", "valid SPIR-V Image Depth specification",[ + SPV_IDI_NoDepth, SPV_IDI_IsDepth, SPV_IDI_DepthUnknown]> { + let cppNamespace = "::mlir::spirv"; + let underlyingType = "uint32_t"; +} + +def SPV_IAI_NonArrayed : EnumAttrCase<"NonArrayed", 0>; +def SPV_IAI_Arrayed : EnumAttrCase<"Arrayed", 1>; + +def SPV_ArrayedAttr : + EnumAttr<"ImageArrayedInfo", "valid SPIR-V Image Arrayed specification", [ + SPV_IAI_NonArrayed, SPV_IAI_Arrayed]> { + let cppNamespace = "::mlir::spirv"; + let underlyingType = "uint32_t"; +} + +def SPV_ISI_SingleSampled : EnumAttrCase<"SingleSampled", 0>; +def SPV_ISI_MultiSampled : EnumAttrCase<"MultiSampled", 1>; + +def SPV_SamplingAttr: + EnumAttr<"ImageSamplingInfo", "valid SPIR-V Image Sampling specification", [ + SPV_ISI_SingleSampled, SPV_ISI_MultiSampled]> { + let cppNamespace = "::mlir::spirv"; + let underlyingType = "uint32_t"; +} + +def SPV_ISUI_SamplerUnknown : EnumAttrCase<"SamplerUnknown", 0>; +def SPV_ISUI_NeedSampler : EnumAttrCase<"NeedSampler", 1>; +def SPV_ISUI_NoSampler : EnumAttrCase<"NoSampler", 2>; + +def SPV_SamplerUseAttr: + EnumAttr<"ImageSamplerUseInfo", "valid SPIR-V Sampler Use specification", [ + SPV_ISUI_SamplerUnknown, SPV_ISUI_NeedSampler, SPV_ISUI_NoSampler]> { + let cppNamespace = "::mlir::spirv"; + let underlyingType = "uint32_t"; +} + //===----------------------------------------------------------------------===// // SPIR-V op definitions //===----------------------------------------------------------------------===// diff --git a/mlir/include/mlir/SPIRV/SPIRVDialect.h b/mlir/include/mlir/SPIRV/SPIRVDialect.h index 18667da374b..4272a722087 100644 --- a/mlir/include/mlir/SPIRV/SPIRVDialect.h +++ b/mlir/include/mlir/SPIRV/SPIRVDialect.h @@ -51,6 +51,9 @@ private: /// Parses `spec` as a SPIR-V run-time array type. Type parseRuntimeArrayType(StringRef spec, Location loc) const; + + /// Parses `spec` as a SPIR-V image type + Type parseImageType(StringRef spec, Location loc) const; }; } // end namespace spirv diff --git a/mlir/include/mlir/SPIRV/SPIRVTypes.h b/mlir/include/mlir/SPIRV/SPIRVTypes.h index ddab2de8494..80370e87bec 100644 --- a/mlir/include/mlir/SPIRV/SPIRVTypes.h +++ b/mlir/include/mlir/SPIRV/SPIRVTypes.h @@ -27,11 +27,14 @@ // Pull in all enum type definitions and utility function declarations #include "mlir/SPIRV/SPIRVEnums.h.inc" +#include + namespace mlir { namespace spirv { namespace detail { struct ArrayTypeStorage; +struct ImageTypeStorage; struct PointerTypeStorage; struct RuntimeArrayTypeStorage; } // namespace detail @@ -39,6 +42,7 @@ struct RuntimeArrayTypeStorage; namespace TypeKind { enum Kind { Array = Type::FIRST_SPIRV_TYPE, + ImageType, Pointer, RuntimeArray, }; @@ -89,6 +93,42 @@ public: Type getElementType(); }; +// SPIR-V image type +class ImageType + : public Type::TypeBase { +public: + using Base::Base; + + static bool kindof(unsigned kind) { return kind == TypeKind::ImageType; } + + static ImageType + get(Type elementType, Dim dim, + ImageDepthInfo depth = ImageDepthInfo::DepthUnknown, + ImageArrayedInfo arrayed = ImageArrayedInfo::NonArrayed, + ImageSamplingInfo samplingInfo = ImageSamplingInfo::SingleSampled, + ImageSamplerUseInfo samplerUse = ImageSamplerUseInfo::SamplerUnknown, + ImageFormat format = ImageFormat::Unknown) { + return ImageType::get( + std::tuple( + elementType, dim, depth, arrayed, samplingInfo, samplerUse, + format)); + } + + static ImageType + get(std::tuple); + + Type getElementType(); + Dim getDim(); + ImageDepthInfo getDepthInfo(); + ImageArrayedInfo getArrayedInfo(); + ImageSamplingInfo getSamplingInfo(); + ImageSamplerUseInfo getSamplerUseInfo(); + ImageFormat getImageFormat(); + // TODO(ravishankarm): Add support for Access qualifier +}; + } // end namespace spirv } // end namespace mlir diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index f69961ad8e6..f5a8764d11b 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -160,6 +160,10 @@ public: // corresponding string. StringRef getSymbolToStringFnName() const; + // Returns the name of the utilit function that returns the max enum value + // used within the enum class. + StringRef getMaxEnumValFnName() const; + // Returns all allowed cases for this enum attribute. std::vector getAllCases() const; }; diff --git a/mlir/lib/SPIRV/SPIRVDialect.cpp b/mlir/lib/SPIRV/SPIRVDialect.cpp index bca27b0b438..f2885d4ce7a 100644 --- a/mlir/lib/SPIRV/SPIRVDialect.cpp +++ b/mlir/lib/SPIRV/SPIRVDialect.cpp @@ -26,10 +26,14 @@ #include "mlir/Parser.h" #include "mlir/SPIRV/SPIRVOps.h" #include "mlir/SPIRV/SPIRVTypes.h" +#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/raw_ostream.h" +#include + using namespace mlir; using namespace mlir::spirv; @@ -39,7 +43,7 @@ using namespace mlir::spirv; SPIRVDialect::SPIRVDialect(MLIRContext *context) : Dialect(getDialectNamespace(), context) { - addTypes(); + addTypes(); addOperations< #define GET_OP_LIST @@ -73,8 +77,9 @@ static bool parseNumberX(StringRef &spec, int64_t &number) { return true; } -Type SPIRVDialect::parseAndVerifyType(StringRef spec, Location loc) const { - auto *context = getContext(); +static Type parseAndVerifyTypeImpl(SPIRVDialect const &dialect, Location loc, + StringRef spec) { + auto *context = dialect.getContext(); auto type = mlir::parseType(spec, context); if (!type) { context->emitError(loc, "cannot parse type: ") << spec; @@ -82,7 +87,7 @@ Type SPIRVDialect::parseAndVerifyType(StringRef spec, Location loc) const { } // Allow SPIR-V dialect types - if (&type.getDialect() == this) + if (&type.getDialect() == &dialect) return type; // Check other allowed types @@ -113,6 +118,10 @@ Type SPIRVDialect::parseAndVerifyType(StringRef spec, Location loc) const { return type; } +Type SPIRVDialect::parseAndVerifyType(StringRef spec, Location loc) const { + return parseAndVerifyTypeImpl(*this, loc, spec); +} + // element-type ::= integer-type // | floating-point-type // | vector-type @@ -209,10 +218,186 @@ Type SPIRVDialect::parseRuntimeArrayType(StringRef spec, Location loc) const { return RuntimeArrayType::get(elementType); } -Type SPIRVDialect::parseType(StringRef spec, Location loc) const { +// Specialize this function to parse each of the parameters that define an +// ImageType +template +Optional parseAndVerify(SPIRVDialect const &dialect, Location loc, + StringRef spec) { + auto *context = dialect.getContext(); + context->emitError(loc, "unexpected parameter while parsing '") + << spec << "'"; + return llvm::None; +} +template <> +Optional parseAndVerify(SPIRVDialect const &dialect, Location loc, + StringRef spec) { + // TODO(ravishankarm): Further verify that the element type can be sampled + return parseAndVerifyTypeImpl(dialect, loc, spec); +} + +template <> +Optional parseAndVerify(SPIRVDialect const &dialect, Location loc, + StringRef spec) { + auto dim = symbolizeDim(spec); + if (!dim) { + auto *context = dialect.getContext(); + context->emitError(loc, "unknown Dim in Image type: '") << spec << "'"; + } + return dim; +} + +template <> +Optional +parseAndVerify(SPIRVDialect const &dialect, Location loc, + StringRef spec) { + auto depth = symbolizeImageDepthInfo(spec); + if (!depth) { + auto *context = dialect.getContext(); + context->emitError(loc, "unknown ImageDepthInfo in Image type: '") + << spec << "'"; + } + return depth; +} + +template <> +Optional +parseAndVerify(SPIRVDialect const &dialect, Location loc, + StringRef spec) { + auto arrayedInfo = symbolizeImageArrayedInfo(spec); + if (!arrayedInfo) { + auto *context = dialect.getContext(); + context->emitError(loc, "unknown ImageArrayedInfo in Image type: '") + << spec << "'"; + } + return arrayedInfo; +} + +template <> +Optional +parseAndVerify(SPIRVDialect const &dialect, Location loc, + StringRef spec) { + auto samplingInfo = symbolizeImageSamplingInfo(spec); + if (!samplingInfo) { + auto *context = dialect.getContext(); + context->emitError(loc, "unknown ImageSamplingInfo in Image type: '") + << spec << "'"; + } + return samplingInfo; +} + +template <> +Optional +parseAndVerify(SPIRVDialect const &dialect, Location loc, + StringRef spec) { + auto samplerUseInfo = symbolizeImageSamplerUseInfo(spec); + if (!samplerUseInfo) { + auto *context = dialect.getContext(); + context->emitError(loc, "unknown ImageSamplerUseInfo in Image type: '") + << spec << "'"; + } + return samplerUseInfo; +} + +template <> +Optional parseAndVerify(SPIRVDialect const &dialect, + Location loc, + StringRef spec) { + auto format = symbolizeImageFormat(spec); + if (!format) { + auto *context = dialect.getContext(); + context->emitError(loc, "unknown ImageFormat in Image type: '") + << spec << "'"; + } + return format; +} + +// Functor object to parse a comma separated list of specs. The function +// parseAndVerify does the actual parsing and verification of individual +// elements. This is a functor since parsing the last element of the list +// (termination condition) needs partial specialization. +template struct parseCommaSeparatedList { + Optional> + operator()(SPIRVDialect const &dialect, Location loc, StringRef spec) const { + auto numArgs = std::tuple_size>::value; + StringRef parseSpec, restSpec; + auto *context = dialect.getContext(); + std::tie(parseSpec, restSpec) = spec.split(','); + + parseSpec = parseSpec.trim(); + if (numArgs != 0 && restSpec.empty()) { + context->emitError(loc, "expected more parameters for image type '") + << parseSpec << "'"; + return llvm::None; + } + + auto parseVal = parseAndVerify(dialect, loc, parseSpec); + if (!parseVal) { + return llvm::None; + } + + auto remainingValues = + parseCommaSeparatedList{}(dialect, loc, restSpec); + if (!remainingValues) { + return llvm::None; + } + return std::tuple_cat(std::tuple(parseVal.getValue()), + remainingValues.getValue()); + } +}; + +// Partial specialization of the function to parse a comma separated list of +// specs to parse the last element of the list. +template struct parseCommaSeparatedList { + Optional> + operator()(SPIRVDialect const &dialect, Location loc, StringRef spec) const { + spec = spec.trim(); + auto value = parseAndVerify(dialect, loc, spec); + if (!value) { + return llvm::None; + } + return std::tuple(value.getValue()); + } +}; + +// dim ::= `1D` | `2D` | `3D` | `Cube` | +// +// depth-info ::= `NoDepth` | `IsDepth` | `DepthUnknown` +// +// arrayed-info ::= `NonArrayed` | `Arrayed` +// +// sampling-info ::= `SingleSampled` | `MultiSampled` +// +// sampler-use-info ::= `SamplerUnknown` | `NeedSampler` | `NoSampler` +// +// format ::= `Unknown` | `Rgba32f` | +// +// image-type ::= `!spv.image<` element-type `,` dim `,` depth-info `,` +// arrayed-info `,` sampling-info `,` +// sampler-use-info `,` format `>` +Type SPIRVDialect::parseImageType(StringRef spec, Location loc) const { + auto *context = getContext(); + if (!spec.consume_front("image<") || !spec.consume_back(">")) { + context->emitError(loc, "spv.image delimiter <...> mismatch"); + return Type(); + } + + auto value = + parseCommaSeparatedList{}(*this, loc, spec); + if (!value) { + return Type(); + } + + return ImageType::get(value.getValue()); +} + +Type SPIRVDialect::parseType(StringRef spec, Location loc) const { if (spec.startswith("array")) return parseArrayType(spec, loc); + if (spec.startswith("image")) + return parseImageType(spec, loc); if (spec.startswith("ptr")) return parsePointerType(spec, loc); if (spec.startswith("rtarray")) @@ -240,6 +425,15 @@ static void print(PointerType type, llvm::raw_ostream &os) { << stringifyStorageClass(type.getStorageClass()) << ">"; } +static void print(ImageType type, llvm::raw_ostream &os) { + os << "image<" << type.getElementType() << ", " << stringifyDim(type.getDim()) + << ", " << stringifyImageDepthInfo(type.getDepthInfo()) << ", " + << stringifyImageArrayedInfo(type.getArrayedInfo()) << ", " + << stringifyImageSamplingInfo(type.getSamplingInfo()) << ", " + << stringifyImageSamplerUseInfo(type.getSamplerUseInfo()) << ", " + << stringifyImageFormat(type.getImageFormat()) << ">"; +} + void SPIRVDialect::printType(Type type, llvm::raw_ostream &os) const { switch (type.getKind()) { case TypeKind::Array: @@ -251,6 +445,9 @@ void SPIRVDialect::printType(Type type, llvm::raw_ostream &os) const { case TypeKind::RuntimeArray: print(type.cast(), os); return; + case TypeKind::ImageType: + print(type.cast(), os); + return; default: llvm_unreachable("unhandled SPIR-V type"); } diff --git a/mlir/lib/SPIRV/SPIRVTypes.cpp b/mlir/lib/SPIRV/SPIRVTypes.cpp index b273cdc99d5..d8c648be141 100644 --- a/mlir/lib/SPIRV/SPIRVTypes.cpp +++ b/mlir/lib/SPIRV/SPIRVTypes.cpp @@ -60,6 +60,185 @@ Type ArrayType::getElementType() { return getImpl()->elementType; } int64_t ArrayType::getElementCount() { return getImpl()->elementCount; } +//===----------------------------------------------------------------------===// +// ImageType +//===----------------------------------------------------------------------===// + +template static constexpr unsigned getNumBits() { return 0; } +template <> constexpr unsigned getNumBits() { + static_assert((1 << 3) > getMaxEnumValForDim(), + "Not enough bits to encode Dim value"); + return 3; +} +template <> constexpr unsigned getNumBits() { + static_assert((1 << 2) > getMaxEnumValForImageDepthInfo(), + "Not enough bits to encode ImageDepthInfo value"); + return 2; +} +template <> constexpr unsigned getNumBits() { + static_assert((1 << 1) > getMaxEnumValForImageArrayedInfo(), + "Not enough bits to encode ImageArrayedInfo value"); + return 1; +} +template <> constexpr unsigned getNumBits() { + static_assert((1 << 1) > getMaxEnumValForImageSamplingInfo(), + "Not enough bits to encode ImageSamplingInfo value"); + return 1; +} +template <> constexpr unsigned getNumBits() { + static_assert((1 << 2) > getMaxEnumValForImageSamplerUseInfo(), + "Not enough bits to encode ImageSamplerUseInfo value"); + return 2; +} +template <> constexpr unsigned getNumBits() { + static_assert((1 << 6) > getMaxEnumValForImageFormat(), + "Not enough bits to encode ImageFormat value"); + return 6; +} + +struct spirv::detail::ImageTypeStorage : public TypeStorage { +private: + /// Define a bit-field struct to pack the enum values + union EnumPack { + struct { + Dim dim : getNumBits(); + ImageDepthInfo depthInfo : getNumBits(); + ImageArrayedInfo arrayedInfo : getNumBits(); + ImageSamplingInfo samplingInfo : getNumBits(); + ImageSamplerUseInfo samplerUseInfo : getNumBits(); + ImageFormat format : getNumBits(); + } data; + unsigned storage; + }; + +public: + using KeyTy = std::tuple; + + static ImageTypeStorage *construct(TypeStorageAllocator &allocator, + const KeyTy &key) { + return new (allocator.allocate()) ImageTypeStorage(key); + } + + bool operator==(const KeyTy &key) const { + return key == KeyTy(elementType, getDim(), getDepthInfo(), getArrayedInfo(), + getSamplingInfo(), getSamplerUseInfo(), + getImageFormat()); + } + + Dim getDim() const { + EnumPack v; + v.storage = getSubclassData(); + return v.data.dim; + } + void setDim(Dim dim) { + EnumPack v; + v.storage = getSubclassData(); + v.data.dim = dim; + setSubclassData(v.storage); + } + + ImageDepthInfo getDepthInfo() const { + EnumPack v; + v.storage = getSubclassData(); + return v.data.depthInfo; + } + void setDepthInfo(ImageDepthInfo depthInfo) { + EnumPack v; + v.storage = getSubclassData(); + v.data.depthInfo = depthInfo; + setSubclassData(v.storage); + } + + ImageArrayedInfo getArrayedInfo() const { + EnumPack v; + v.storage = getSubclassData(); + return v.data.arrayedInfo; + } + void setArrayedInfo(ImageArrayedInfo arrayedInfo) { + EnumPack v; + v.storage = getSubclassData(); + v.data.arrayedInfo = arrayedInfo; + setSubclassData(v.storage); + } + + ImageSamplingInfo getSamplingInfo() const { + EnumPack v; + v.storage = getSubclassData(); + return v.data.samplingInfo; + } + void setSamplingInfo(ImageSamplingInfo samplingInfo) { + EnumPack v; + v.storage = getSubclassData(); + v.data.samplingInfo = samplingInfo; + setSubclassData(v.storage); + } + + ImageSamplerUseInfo getSamplerUseInfo() const { + EnumPack v; + v.storage = getSubclassData(); + return v.data.samplerUseInfo; + } + void setSamplerUseInfo(ImageSamplerUseInfo samplerUseInfo) { + EnumPack v; + v.storage = getSubclassData(); + v.data.samplerUseInfo = samplerUseInfo; + setSubclassData(v.storage); + } + + ImageFormat getImageFormat() const { + EnumPack v; + v.storage = getSubclassData(); + return v.data.format; + } + void setImageFormat(ImageFormat format) { + EnumPack v; + v.storage = getSubclassData(); + v.data.format = format; + setSubclassData(v.storage); + } + + ImageTypeStorage(const KeyTy &key) : elementType(std::get<0>(key)) { + static_assert(sizeof(EnumPack) <= sizeof(getSubclassData()), + "EnumPack size greater than subClassData type size"); + setDim(std::get<1>(key)); + setDepthInfo(std::get<2>(key)); + setArrayedInfo(std::get<3>(key)); + setSamplingInfo(std::get<4>(key)); + setSamplerUseInfo(std::get<5>(key)); + setImageFormat(std::get<6>(key)); + } + + Type elementType; +}; + +ImageType +ImageType::get(std::tuple + value) { + return Base::get(std::get<0>(value).getContext(), TypeKind::ImageType, value); +} + +Type ImageType::getElementType() { return getImpl()->elementType; } + +Dim ImageType::getDim() { return getImpl()->getDim(); } + +ImageDepthInfo ImageType::getDepthInfo() { return getImpl()->getDepthInfo(); } + +ImageArrayedInfo ImageType::getArrayedInfo() { + return getImpl()->getArrayedInfo(); +} + +ImageSamplingInfo ImageType::getSamplingInfo() { + return getImpl()->getSamplingInfo(); +} + +ImageSamplerUseInfo ImageType::getSamplerUseInfo() { + return getImpl()->getSamplerUseInfo(); +} + +ImageFormat ImageType::getImageFormat() { return getImpl()->getImageFormat(); } + //===----------------------------------------------------------------------===// // PointerType //===----------------------------------------------------------------------===// diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index 29259bec69a..0bd72ead67c 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -178,6 +178,10 @@ StringRef tblgen::EnumAttr::getSymbolToStringFnName() const { return def->getValueAsString("symbolToStringFnName"); } +StringRef tblgen::EnumAttr::getMaxEnumValFnName() const { + return def->getValueAsString("maxEnumValFnName"); +} + std::vector tblgen::EnumAttr::getAllCases() const { const auto *inits = def->getValueAsListInit("enumerants"); diff --git a/mlir/test/SPIRV/types.mlir b/mlir/test/SPIRV/types.mlir index 0e87d0b02be..857871a00d7 100644 --- a/mlir/test/SPIRV/types.mlir +++ b/mlir/test/SPIRV/types.mlir @@ -130,3 +130,73 @@ func @missing_element_type(!spv.rtarray<>) -> () // expected-error @+1 {{cannot parse type: 4xf32}} func @redundant_count(!spv.rtarray<4xf32>) -> () + +// ----- + +//===----------------------------------------------------------------------===// +// ImageType +//===----------------------------------------------------------------------===// + +// CHECK: func @image_parameters_1D(!spv.image) +func @image_parameters_1D(!spv.image) -> () + +// ----- + +// expected-error @+1 {{expected more parameters for image type 'f32'}} +func @image_parameters_one_element(!spv.image) -> () + +// ----- + +// expected-error @+1 {{expected more parameters for image type '1D'}} +func @image_parameters_two_elements(!spv.image) -> () + +// ----- + +// expected-error @+1 {{expected more parameters for image type 'NoDepth'}} +func @image_parameters_three_elements(!spv.image) -> () + +// ----- + +// expected-error @+1 {{expected more parameters for image type 'NonArrayed'}} +func @image_parameters_four_elements(!spv.image) -> () + +// ----- + +// expected-error @+1 {{expected more parameters for image type 'SingleSampled'}} +func @image_parameters_five_elements(!spv.image) -> () + +// ----- + +// expected-error @+1 {{expected more parameters for image type 'SamplerUnknown'}} +func @image_parameters_six_elements(!spv.image) -> () + +// ----- + +// expected-error @+1 {{spv.image delimiter <...> mismatch}} +func @image_parameters_delimiter(!spv.image f32, 1D, NoDepth, NonArrayed, SingleSampled, SamplerUnknown, Unkown>) -> () + +// ----- + +// expected-error @+1 {{unknown Dim in Image type: '1D NoDepth'}} +func @image_parameters_nocomma_1(!spv.image) -> () + +// ----- + +// expected-error @+1 {{unknown ImageDepthInfo in Image type: 'NoDepth NonArrayed'}} +func @image_parameters_nocomma_2(!spv.image) -> () + +// ----- + +// expected-error @+1 {{unknown ImageArrayedInfo in Image type: 'NonArrayed SingleSampled'}} +func @image_parameters_nocomma_3(!spv.image) -> () + +// ----- + +// expected-error @+1 {{unknown ImageSamplingInfo in Image type: 'SingleSampled SamplerUnknown'}} +func @image_parameters_nocomma_4(!spv.image) -> () + +// ----- + +// expected-error @+1 {{expected more parameters for image type 'SamplerUnknown Unknown'}} +func @image_parameters_nocomma_5(!spv.image) -> () + diff --git a/mlir/tools/mlir-tblgen/EnumsGen.cpp b/mlir/tools/mlir-tblgen/EnumsGen.cpp index ab86c9dd8cc..e9a70f3131e 100644 --- a/mlir/tools/mlir-tblgen/EnumsGen.cpp +++ b/mlir/tools/mlir-tblgen/EnumsGen.cpp @@ -30,6 +30,7 @@ #include "llvm/TableGen/TableGenBackend.h" using llvm::formatv; +using llvm::isDigit; using llvm::raw_ostream; using llvm::Record; using llvm::RecordKeeper; @@ -37,6 +38,14 @@ using llvm::StringRef; using mlir::tblgen::EnumAttr; using mlir::tblgen::EnumAttrCase; +static std::string makeIdentifier(StringRef str) { + if (!str.empty() && isDigit(static_cast(str.front()))) { + std::string newStr = std::string("_") + str.str(); + return newStr; + } + return str.str(); +} + static void emitEnumClass(const Record &enumDef, StringRef enumName, StringRef underlyingType, StringRef description, const std::vector &enumerants, @@ -49,7 +58,7 @@ static void emitEnumClass(const Record &enumDef, StringRef enumName, os << " {\n"; for (const auto &enumerant : enumerants) { - auto symbol = enumerant.getSymbol(); + auto symbol = makeIdentifier(enumerant.getSymbol()); auto value = enumerant.getValue(); if (value < 0) { llvm::PrintFatalError(enumDef.getLoc(), @@ -100,6 +109,7 @@ static void emitEnumDecl(const Record &enumDef, raw_ostream &os) { StringRef description = enumAttr.getDescription(); StringRef strToSymFnName = enumAttr.getStringToSymbolFnName(); StringRef symToStrFnName = enumAttr.getSymbolToStringFnName(); + StringRef maxEnumValFnName = enumAttr.getMaxEnumValFnName(); auto enumerants = enumAttr.getAllCases(); llvm::SmallVector namespaces; @@ -119,6 +129,17 @@ static void emitEnumDecl(const Record &enumDef, raw_ostream &os) { for (auto ns : llvm::reverse(namespaces)) os << "} // namespace " << ns << "\n"; + // Emit the function to return the max enum value + unsigned maxEnumVal = 0; + for (const auto &enumerant : enumerants) { + auto value = enumerant.getValue(); + // Already checked that the value is non-negetive. + maxEnumVal = std::max(maxEnumVal, static_cast(value)); + } + os << formatv("inline constexpr unsigned {0}() {{\n", maxEnumValFnName); + os << formatv(" return {0};\n", maxEnumVal); + os << "}\n\n"; + // Emit DenseMapInfo for this enum class emitDenseMapInfo(enumName, underlyingType, cppNamespace, os); } @@ -151,7 +172,8 @@ static void emitEnumDef(const Record &enumDef, raw_ostream &os) { os << " switch (val) {\n"; for (const auto &enumerant : enumerants) { auto symbol = enumerant.getSymbol(); - os << formatv(" case {0}::{1}: return \"{1}\";\n", enumName, symbol); + os << formatv(" case {0}::{1}: return \"{2}\";\n", enumName, + makeIdentifier(symbol), symbol); } os << " }\n"; os << " return \"\";\n"; @@ -163,7 +185,8 @@ static void emitEnumDef(const Record &enumDef, raw_ostream &os) { enumName); for (const auto &enumerant : enumerants) { auto symbol = enumerant.getSymbol(); - os << formatv(" .Case(\"{1}\", {0}::{1})\n", enumName, symbol); + os << formatv(" .Case(\"{1}\", {0}::{2})\n", enumName, symbol, + makeIdentifier(symbol)); } os << " .Default(llvm::None);\n"; os << "}\n"; -- cgit v1.2.3 From 8f77d2afedb0ed2f6b84fa5ddcff87c75528c088 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 21 Jun 2019 14:51:58 -0700 Subject: [spirv] Basic serializer and deserializer This CL adds the basic SPIR-V serializer and deserializer for converting SPIR-V module into the binary format and back. Right now only an empty module with addressing model and memory model is supported; (de)serialize other components will be added gradually with subsequent CLs. The purpose of this library is to enable importing SPIR-V binary modules to run transformations on them and exporting SPIR-V modules to be consumed by execution environments. The focus is transformations, which inevitably means changes to the binary module; so it is not designed to be a general tool for investigating the SPIR-V binary module and does not guarantee roundtrip equivalence (at least for now). PiperOrigin-RevId: 254473019 --- mlir/g3doc/Dialects/SPIR-V.md | 20 ++- mlir/include/mlir/IR/OpBase.td | 8 + mlir/include/mlir/SPIRV/CMakeLists.txt | 4 + mlir/include/mlir/SPIRV/SPIRVBase.td | 4 + mlir/include/mlir/SPIRV/SPIRVOps.td | 6 + mlir/include/mlir/SPIRV/SPIRVStructureOps.td | 2 + mlir/include/mlir/SPIRV/Serialization.h | 48 +++++ mlir/include/mlir/TableGen/Attribute.h | 4 + mlir/lib/SPIRV/CMakeLists.txt | 2 + mlir/lib/SPIRV/SPIRVOps.cpp | 4 + mlir/lib/SPIRV/Serialization/CMakeLists.txt | 17 ++ mlir/lib/SPIRV/Serialization/ConvertFromBinary.cpp | 98 ++++++++++ mlir/lib/SPIRV/Serialization/ConvertToBinary.cpp | 78 ++++++++ mlir/lib/SPIRV/Serialization/Deserializer.cpp | 197 +++++++++++++++++++++ mlir/lib/SPIRV/Serialization/SPIRVBinaryUtils.h | 42 +++++ mlir/lib/SPIRV/Serialization/Serializer.cpp | 168 ++++++++++++++++++ mlir/lib/TableGen/Attribute.cpp | 4 + mlir/test/SPIRV/Serialization/minimal-module.mlir | 13 ++ mlir/tools/mlir-tblgen/CMakeLists.txt | 1 + mlir/tools/mlir-tblgen/EnumsGen.cpp | 21 +++ mlir/tools/mlir-tblgen/SPIRVSerializationGen.cpp | 69 ++++++++ mlir/tools/mlir-translate/CMakeLists.txt | 2 + 22 files changed, 810 insertions(+), 2 deletions(-) create mode 100644 mlir/include/mlir/SPIRV/Serialization.h create mode 100644 mlir/lib/SPIRV/Serialization/CMakeLists.txt create mode 100644 mlir/lib/SPIRV/Serialization/ConvertFromBinary.cpp create mode 100644 mlir/lib/SPIRV/Serialization/ConvertToBinary.cpp create mode 100644 mlir/lib/SPIRV/Serialization/Deserializer.cpp create mode 100644 mlir/lib/SPIRV/Serialization/SPIRVBinaryUtils.h create mode 100644 mlir/lib/SPIRV/Serialization/Serializer.cpp create mode 100644 mlir/test/SPIRV/Serialization/minimal-module.mlir create mode 100644 mlir/tools/mlir-tblgen/SPIRVSerializationGen.cpp (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/g3doc/Dialects/SPIR-V.md b/mlir/g3doc/Dialects/SPIR-V.md index 19442f27ed0..6101d3b45b8 100644 --- a/mlir/g3doc/Dialects/SPIR-V.md +++ b/mlir/g3doc/Dialects/SPIR-V.md @@ -37,7 +37,8 @@ The SPIR-V dialect has the following conventions: A SPIR-V module is defined via the `spv.module` op, which has one region that contains one block. Model-level instructions, including function definitions, -are all placed inside the block. +are all placed inside the block. Functions are defined using the standard `func` +op. Compared to the binary format, we adjust how certain module-level SPIR-V instructions are represented in the SPIR-V dialect. Notably, @@ -89,7 +90,7 @@ For example, ### Image type -This corresponds to SPIR-V [image_type][ImageType]. Its syntax is +This corresponds to SPIR-V [image type][ImageType]. Its syntax is ``` {.ebnf} dim ::= `1D` | `2D` | `3D` | `Cube` | @@ -151,8 +152,23 @@ For example, !spv.rtarray> ``` +## Serialization + +The serialization library provides two entry points, `mlir::spirv::serialize()` +and `mlir::spirv::deserialize()`, for converting a MLIR SPIR-V module to binary +format and back. + +The purpose of this library is to enable importing SPIR-V binary modules to run +transformations on them and exporting SPIR-V modules to be consumed by execution +environments. The focus is transformations, which inevitably means changes to +the binary module; so it is not designed to be a general tool for investigating +the SPIR-V binary module and does not guarantee roundtrip equivalence (at least +for now). For the latter, please use the assembler/disassembler in the +[SPIRV-Tools][SPIRV-Tools] project. + [SPIR-V]: https://www.khronos.org/registry/spir-v/ [ArrayType]: https://www.khronos.org/registry/spir-v/specs/unified1/SPIRV.html#OpTypeArray [PointerType]: https://www.khronos.org/registry/spir-v/specs/unified1/SPIRV.html#OpTypePointer [RuntimeArrayType]: https://www.khronos.org/registry/spir-v/specs/unified1/SPIRV.html#OpTypeRuntimeArray [ImageType]: https://www.khronos.org/registry/spir-v/specs/unified1/SPIRV.html#OpTypeImage +[SPIRV-Tools]: https://github.com/KhronosGroup/SPIRV-Tools diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index 2598cc989d4..4fe05494615 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -673,6 +673,14 @@ class EnumAttr cases> : // TODO(b/134741431): use dialect to provide the namespace. string cppNamespace = ""; + // The name of the utility function that converts a value of the underlying + // type to the corresponding symbol. It will have the following signature: + // + // ```c++ + // llvm::Optional<> (); + // ``` + string underlyingToSymbolFnName = "symbolize" # name; + // The name of the utility function that converts a string to the // corresponding symbol. It will have the following signature: // diff --git a/mlir/include/mlir/SPIRV/CMakeLists.txt b/mlir/include/mlir/SPIRV/CMakeLists.txt index b646aa58c82..d4e5ba6a6f5 100644 --- a/mlir/include/mlir/SPIRV/CMakeLists.txt +++ b/mlir/include/mlir/SPIRV/CMakeLists.txt @@ -8,4 +8,8 @@ mlir_tablegen(SPIRVEnums.h.inc -gen-enum-decls) mlir_tablegen(SPIRVEnums.cpp.inc -gen-enum-defs) add_public_tablegen_target(MLIRSPIRVEnumsIncGen) +set(LLVM_TARGET_DEFINITIONS SPIRVOps.td) +mlir_tablegen(SPIRVSerialization.inc -gen-spirv-serial) +add_public_tablegen_target(MLIRSPIRVSerializationGen) + add_subdirectory(Transforms) diff --git a/mlir/include/mlir/SPIRV/SPIRVBase.td b/mlir/include/mlir/SPIRV/SPIRVBase.td index 0a8b576743a..c27a4cd47b5 100644 --- a/mlir/include/mlir/SPIRV/SPIRVBase.td +++ b/mlir/include/mlir/SPIRV/SPIRVBase.td @@ -290,6 +290,10 @@ def SPV_SamplerUseAttr: // Base class for all SPIR-V ops. class SPV_Op traits = []> : Op { + // Opcode for the binary format. Ops cannot be directly serialized will + // leave this field as unset. + int opcode = ?; + // For each SPIR-V op, the following static functions need to be defined // in SPVOps.cpp: // diff --git a/mlir/include/mlir/SPIRV/SPIRVOps.td b/mlir/include/mlir/SPIRV/SPIRVOps.td index 9fa9e176777..76853cbe18d 100644 --- a/mlir/include/mlir/SPIRV/SPIRVOps.td +++ b/mlir/include/mlir/SPIRV/SPIRVOps.td @@ -61,6 +61,8 @@ def SPV_FMulOp : SPV_Op<"FMul", [NoSideEffect, SameOperandsAndResultType]> { // No additional verification needed in addition to the ODS-generated ones. let verifier = [{ return success(); }]; + + let opcode = 133; } def SPV_ReturnOp : SPV_Op<"Return", [Terminator]> { @@ -78,6 +80,8 @@ def SPV_ReturnOp : SPV_Op<"Return", [Terminator]> { let printer = [{ printNoIOOp(getOperation(), p); }]; let verifier = [{ return verifyReturn(*this); }]; + + let opcode = 253; } def SPV_VariableOp : SPV_Op<"Variable"> { @@ -129,6 +133,8 @@ def SPV_VariableOp : SPV_Op<"Variable"> { let results = (outs SPV_AnyPtr:$pointer ); + + let opcode = 59; } #endif // SPIRV_OPS diff --git a/mlir/include/mlir/SPIRV/SPIRVStructureOps.td b/mlir/include/mlir/SPIRV/SPIRVStructureOps.td index 16faf49434a..fed417fcf7a 100644 --- a/mlir/include/mlir/SPIRV/SPIRVStructureOps.td +++ b/mlir/include/mlir/SPIRV/SPIRVStructureOps.td @@ -61,6 +61,8 @@ def SPV_ModuleOp : SPV_Op<"module", []> { let results = (outs); let regions = (region SizedRegion<1>:$body); + + let builders = [OpBuilder<"Builder *, OperationState *state">]; } def SPV_ModuleEndOp : SPV_Op<"_module_end", [Terminator]> { diff --git a/mlir/include/mlir/SPIRV/Serialization.h b/mlir/include/mlir/SPIRV/Serialization.h new file mode 100644 index 00000000000..80760c72232 --- /dev/null +++ b/mlir/include/mlir/SPIRV/Serialization.h @@ -0,0 +1,48 @@ +//===- Serialization.h - MLIR SPIR-V (De)serialization ----------*- C++ -*-===// +// +// Copyright 2019 The MLIR Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================= +// +// This file declares the entry points for serialize and deserialze SPIR-V +// binary modules. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_SPIRV_SERIALIZATION_H_ +#define MLIR_SPIRV_SERIALIZATION_H_ + +#include "mlir/Support/LLVM.h" + +namespace mlir { +class MLIRContext; + +namespace spirv { +class ModuleOp; + +/// Serializes the given SPIR-V `module` and writes to `binary`. Returns true on +/// success; otherwise, reports errors to the error handler registered with the +/// MLIR context for `module` and returns false. +bool serialize(ModuleOp module, SmallVectorImpl &binary); + +/// Deserializes the given SPIR-V `binary` module and creates a MLIR ModuleOp +/// in the given `context`. Returns the ModuleOp on success; otherwise, reports +/// errors to the error handler registered with `context` and returns +/// llvm::None. +Optional deserialize(ArrayRef binary, MLIRContext *context); + +} // end namespace spirv +} // end namespace mlir + +#endif // MLIR_SPIRV_SERIALIZATION_H_ diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index f5a8764d11b..d4914703c5b 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -152,6 +152,10 @@ public: // Returns the underlying type. StringRef getUnderlyingType() const; + // Returns the name of the utility function that converts a value of the + // underlying type to the corresponding symbol. + StringRef getUnderlyingToSymbolFnName() const; + // Returns the name of the utility function that converts a string to the // corresponding symbol. StringRef getStringToSymbolFnName() const; diff --git a/mlir/lib/SPIRV/CMakeLists.txt b/mlir/lib/SPIRV/CMakeLists.txt index 8101b17e202..e06195ff492 100644 --- a/mlir/lib/SPIRV/CMakeLists.txt +++ b/mlir/lib/SPIRV/CMakeLists.txt @@ -18,3 +18,5 @@ target_link_libraries(MLIRSPIRV MLIRIR MLIRParser MLIRSupport) + +add_subdirectory(Serialization) diff --git a/mlir/lib/SPIRV/SPIRVOps.cpp b/mlir/lib/SPIRV/SPIRVOps.cpp index 5d9602df998..fe024f9a4c5 100644 --- a/mlir/lib/SPIRV/SPIRVOps.cpp +++ b/mlir/lib/SPIRV/SPIRVOps.cpp @@ -139,6 +139,10 @@ static void ensureModuleEnd(Region *region, Builder builder, Location loc) { block.push_back(Operation::create(state)); } +void spirv::ModuleOp::build(Builder *builder, OperationState *state) { + ensureModuleEnd(state->addRegion(), *builder, state->location); +} + static ParseResult parseModuleOp(OpAsmParser *parser, OperationState *state) { Region *body = state->addRegion(); diff --git a/mlir/lib/SPIRV/Serialization/CMakeLists.txt b/mlir/lib/SPIRV/Serialization/CMakeLists.txt new file mode 100644 index 00000000000..a5420093b1f --- /dev/null +++ b/mlir/lib/SPIRV/Serialization/CMakeLists.txt @@ -0,0 +1,17 @@ +add_llvm_library(MLIRSPIRVSerialization + ConvertFromBinary.cpp + ConvertToBinary.cpp + Deserializer.cpp + Serializer.cpp + + ADDITIONAL_HEADER_DIRS + ${MLIR_MAIN_INCLUDE_DIR}/mlir/SPIRV + ) + +add_dependencies(MLIRSPIRVSerialization + MLIRSPIRVSerializationGen) + +target_link_libraries(MLIRSPIRVSerialization + MLIRIR + MLIRSPIRV + MLIRSupport) diff --git a/mlir/lib/SPIRV/Serialization/ConvertFromBinary.cpp b/mlir/lib/SPIRV/Serialization/ConvertFromBinary.cpp new file mode 100644 index 00000000000..e52992776b3 --- /dev/null +++ b/mlir/lib/SPIRV/Serialization/ConvertFromBinary.cpp @@ -0,0 +1,98 @@ +//===- ConvertFromBinary.cpp - MLIR SPIR-V binary to module conversion ----===// +// +// Copyright 2019 The MLIR Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================= +// +// This file implements a translation from SPIR-V binary module to MLIR SPIR-V +// ModuleOp. +// +//===----------------------------------------------------------------------===// + +#include "mlir/IR/Builders.h" +#include "mlir/IR/Module.h" +#include "mlir/SPIRV/SPIRVOps.h" +#include "mlir/SPIRV/Serialization.h" +#include "mlir/StandardOps/Ops.h" +#include "mlir/Support/FileUtilities.h" +#include "mlir/Translation.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/MemoryBuffer.h" + +using namespace mlir; + +// Adds a one-block function named as `spirv_module` to `module` and returns the +// block. The created block will be terminated by `std.return`. +Block *createOneBlockFunction(Builder builder, Module *module) { + auto fnType = builder.getFunctionType(/*inputs=*/{}, /*results=*/{}); + auto *fn = new Function(builder.getUnknownLoc(), "spirv_module", fnType); + module->getFunctions().push_back(fn); + + auto *block = new Block(); + fn->push_back(block); + + OperationState state(builder.getContext(), builder.getUnknownLoc(), + ReturnOp::getOperationName()); + ReturnOp::build(&builder, &state); + block->push_back(Operation::create(state)); + + return block; +} + +// Deserializes the SPIR-V binary module stored in the file named as +// `inputFilename` and returns a module containing the SPIR-V module. +std::unique_ptr deserializeModule(llvm::StringRef inputFilename, + MLIRContext *context) { + Builder builder(context); + + std::string errorMessage; + auto file = openInputFile(inputFilename, &errorMessage); + if (!file) { + context->emitError(builder.getUnknownLoc()) << errorMessage; + return {}; + } + + // Make sure the input stream can be treated as a stream of SPIR-V words + auto start = file->getBufferStart(); + auto end = file->getBufferEnd(); + if ((start - end) % sizeof(uint32_t) != 0) { + context->emitError(builder.getUnknownLoc()) + << "SPIR-V binary module must contain integral number of 32-bit words"; + return {}; + } + + auto binary = llvm::makeArrayRef(reinterpret_cast(start), + (end - start) / sizeof(uint32_t)); + + auto spirvModule = spirv::deserialize(binary, context); + if (!spirvModule) + return {}; + + // TODO(antiagainst): due to the restriction of the current translation + // infrastructure, we must return a MLIR module here. So we are wrapping the + // converted SPIR-V ModuleOp inside a MLIR module. This should be changed to + // return the SPIR-V ModuleOp directly after module and function are migrated + // to be general ops. + std::unique_ptr module(builder.createModule()); + Block *block = createOneBlockFunction(builder, module.get()); + block->push_front(spirvModule->getOperation()); + + return module; +} + +static TranslateToMLIRRegistration + registration("deserialize-spirv", + [](StringRef inputFilename, MLIRContext *context) { + return deserializeModule(inputFilename, context); + }); diff --git a/mlir/lib/SPIRV/Serialization/ConvertToBinary.cpp b/mlir/lib/SPIRV/Serialization/ConvertToBinary.cpp new file mode 100644 index 00000000000..ebdcaf73717 --- /dev/null +++ b/mlir/lib/SPIRV/Serialization/ConvertToBinary.cpp @@ -0,0 +1,78 @@ +//===- ConvertToBinary.cpp - MLIR SPIR-V module to binary conversion ------===// +// +// Copyright 2019 The MLIR Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================= +// +// This file implements a translation from MLIR SPIR-V ModuleOp to SPIR-V +// binary module. +// +//===----------------------------------------------------------------------===// + +#include "mlir/IR/Module.h" +#include "mlir/SPIRV/SPIRVOps.h" +#include "mlir/SPIRV/Serialization.h" +#include "mlir/Support/FileUtilities.h" +#include "mlir/Support/LogicalResult.h" +#include "mlir/Translation.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/ToolOutputFile.h" + +using namespace mlir; + +LogicalResult serializeModule(Module *module, StringRef outputFilename) { + if (!module) + return failure(); + + SmallVector binary; + bool done = false; + bool success = false; + + // TODO(antiagainst): we are checking there is only one SPIR-V ModuleOp in + // this module and serialize it. This is due to the restriction of the current + // translation infrastructure; we must take in a MLIR module here. So we are + // wrapping the SPIR-V ModuleOp inside a MLIR module. This should be changed + // to take in the SPIR-V ModuleOp directly after module and function are + // migrated to be general ops. + for (auto &fn : *module) { + fn.walk([&](spirv::ModuleOp spirvModule) { + if (done) { + spirvModule.emitError("found more than one 'spv.module' op"); + return; + } + + done = true; + success = spirv::serialize(spirvModule, binary); + }); + } + + if (!success) + return failure(); + + auto file = openOutputFile(outputFilename); + if (!file) + return failure(); + + file->os().write(reinterpret_cast(binary.data()), + binary.size() * sizeof(uint32_t)); + file->keep(); + + return mlir::success(); +} + +static TranslateFromMLIRRegistration + registration("serialize-spirv", + [](Module *module, StringRef outputFilename) { + return failed(serializeModule(module, outputFilename)); + }); diff --git a/mlir/lib/SPIRV/Serialization/Deserializer.cpp b/mlir/lib/SPIRV/Serialization/Deserializer.cpp new file mode 100644 index 00000000000..9c6d00e1bcd --- /dev/null +++ b/mlir/lib/SPIRV/Serialization/Deserializer.cpp @@ -0,0 +1,197 @@ +//===- Deserializer.cpp - MLIR SPIR-V Deserialization ---------------------===// +// +// Copyright 2019 The MLIR Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================= +// +// This file defines the SPIR-V binary to MLIR SPIR-V module deseralization. +// +//===----------------------------------------------------------------------===// + +#include "mlir/SPIRV/Serialization.h" + +#include "SPIRVBinaryUtils.h" +#include "mlir/IR/Builders.h" +#include "mlir/IR/Location.h" +#include "mlir/SPIRV/SPIRVOps.h" +#include "mlir/SPIRV/SPIRVTypes.h" +#include "mlir/Support/LogicalResult.h" +#include "llvm/ADT/SmallVector.h" + +using namespace mlir; + +namespace { +/// A SPIR-V module serializer. +/// +/// A SPIR-V binary module is a single linear stream of instructions; each +/// instruction is composed of 32-bit words. The first word of an instruction +/// records the total number of words of that instruction using the 16 +/// higher-order bits. So this deserializer uses that to get instruction +/// boundary and parse instructions and build a SPIR-V ModuleOp gradually. +/// +// TODO(antiagainst): clean up created ops on errors +class Deserializer { +public: + /// Creates a deserializer for the given SPIR-V `binary` module. + /// The SPIR-V ModuleOp will be created into `context. + explicit Deserializer(ArrayRef binary, MLIRContext *context); + + /// Deserializes the remembered SPIR-V binary module. + LogicalResult deserialize(); + + /// Collects the final SPIR-V ModuleOp. + Optional collect(); + +private: + /// Processes SPIR-V module header. + LogicalResult processHeader(); + + /// Processes a SPIR-V instruction with the given `opcode` and `operands`. + LogicalResult processInstruction(uint32_t opcode, + ArrayRef operands); + + LogicalResult processMemoryModel(ArrayRef operands); + + /// Initializes the `module` ModuleOp in this deserializer instance. + spirv::ModuleOp createModuleOp(); + +private: + /// The SPIR-V binary module. + ArrayRef binary; + + /// The current word offset into the binary module. + unsigned curOffset = 0; + + /// MLIRContext to create SPIR-V ModuleOp into. + MLIRContext *context; + + // TODO(antiagainst): create Location subclass for binary blob + UnknownLoc unknownLoc; + + /// The SPIR-V ModuleOp. + Optional module; + + OpBuilder opBuilder; +}; +} // namespace + +Deserializer::Deserializer(ArrayRef binary, MLIRContext *context) + : binary(binary), context(context), unknownLoc(UnknownLoc::get(context)), + module(createModuleOp()), + opBuilder(module->getOperation()->getRegion(0)) {} + +LogicalResult Deserializer::deserialize() { + if (failed(processHeader())) + return failure(); + + auto binarySize = binary.size(); + curOffset = spirv::kHeaderWordCount; + + while (curOffset < binarySize) { + // For each instruction, get its word count from the first word to slice it + // from the stream properly, and then dispatch to the instruction handler. + + uint32_t wordCount = binary[curOffset] >> 16; + uint32_t opcode = binary[curOffset] & 0xffff; + + if (wordCount == 0) + return context->emitError(unknownLoc, "word count cannot be zero"); + + uint32_t nextOffset = curOffset + wordCount; + if (nextOffset > binarySize) + return context->emitError(unknownLoc, + "insufficient words for the last instruction"); + + auto operands = binary.slice(curOffset + 1, wordCount - 1); + if (failed(processInstruction(opcode, operands))) + return failure(); + + curOffset = nextOffset; + } + + return success(); +} + +Optional Deserializer::collect() { return module; } + +LogicalResult Deserializer::processHeader() { + if (binary.size() < spirv::kHeaderWordCount) + return context->emitError(unknownLoc, + "SPIR-V binary module must have a 5-word header"); + + if (binary[0] != spirv::kMagicNumber) + return context->emitError(unknownLoc, "incorrect magic number"); + + // TODO(antiagainst): generator number, bound, schema + return success(); +} + +LogicalResult Deserializer::processInstruction(uint32_t opcode, + ArrayRef operands) { + switch (opcode) { + case spirv::kOpMemoryModelOpcode: + return processMemoryModel(operands); + default: + break; + } + return context->emitError(unknownLoc, "NYI: opcode ") << opcode; +} + +LogicalResult Deserializer::processMemoryModel(ArrayRef operands) { + if (operands.size() != 2) + return context->emitError(unknownLoc, + "OpMemoryModel must have two operands"); + + // TODO(antiagainst): use IntegerAttr-backed enum attributes to avoid the + // excessive string conversions here. + + auto am = spirv::symbolizeAddressingModel(operands.front()); + if (!am) + return context->emitError(unknownLoc, + "unknown addressing model for OpMemoryModel"); + + auto mm = spirv::symbolizeMemoryModel(operands.back()); + if (!mm) + return context->emitError(unknownLoc, + "unknown memory model for OpMemoryModel"); + + module->setAttr( + "addressing_model", + opBuilder.getStringAttr(spirv::stringifyAddressingModel(*am))); + module->setAttr("memory_model", + opBuilder.getStringAttr(spirv::stringifyMemoryModel(*mm))); + + return success(); +} + +spirv::ModuleOp Deserializer::createModuleOp() { + Builder builder(context); + OperationState state(context, unknownLoc, + spirv::ModuleOp::getOperationName()); + // TODO(antiagainst): use target environment to select the version + state.addAttribute("major_version", builder.getI32IntegerAttr(1)); + state.addAttribute("minor_version", builder.getI32IntegerAttr(0)); + spirv::ModuleOp::build(&builder, &state); + return llvm::cast(Operation::create(state)); +} + +Optional spirv::deserialize(ArrayRef binary, + MLIRContext *context) { + Deserializer deserializer(binary, context); + + if (failed(deserializer.deserialize())) + return llvm::None; + + return deserializer.collect(); +} diff --git a/mlir/lib/SPIRV/Serialization/SPIRVBinaryUtils.h b/mlir/lib/SPIRV/Serialization/SPIRVBinaryUtils.h new file mode 100644 index 00000000000..157b68c7399 --- /dev/null +++ b/mlir/lib/SPIRV/Serialization/SPIRVBinaryUtils.h @@ -0,0 +1,42 @@ +//===- SPIRVBinaryUtils.cpp - SPIR-V Binary Module Utils --------*- C++ -*-===// +// +// Copyright 2019 The MLIR Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================= +// +// This file defines common utilities for SPIR-V binary module. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_SPIRV_SERIALIZATION_SPIRV_BINARY_UTILS_H_ +#define MLIR_SPIRV_SERIALIZATION_SPIRV_BINARY_UTILS_H_ + +#include + +namespace mlir { +namespace spirv { + +/// SPIR-V binary header word count +constexpr unsigned kHeaderWordCount = 5; + +/// SPIR-V magic number +constexpr uint32_t kMagicNumber = 0x07230203; + +/// Opcode for SPIR-V OpMemoryModel +constexpr uint32_t kOpMemoryModelOpcode = 14; + +} // end namespace spirv +} // end namespace mlir + +#endif // MLIR_SPIRV_SERIALIZATION_SPIRV_BINARY_UTILS_H_ diff --git a/mlir/lib/SPIRV/Serialization/Serializer.cpp b/mlir/lib/SPIRV/Serialization/Serializer.cpp new file mode 100644 index 00000000000..93bd464f6ee --- /dev/null +++ b/mlir/lib/SPIRV/Serialization/Serializer.cpp @@ -0,0 +1,168 @@ +//===- Serializer.cpp - MLIR SPIR-V Serialization -------------------------===// +// +// Copyright 2019 The MLIR Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================= +// +// This file defines the MLIR SPIR-V module to SPIR-V binary seralization. +// +//===----------------------------------------------------------------------===// + +#include "mlir/SPIRV/Serialization.h" + +#include "SPIRVBinaryUtils.h" +#include "mlir/SPIRV/SPIRVOps.h" +#include "mlir/SPIRV/SPIRVTypes.h" +#include "mlir/Support/LogicalResult.h" +#include "llvm/ADT/SmallVector.h" + +using namespace mlir; + +static inline uint32_t getPrefixedOpcode(uint32_t wordCount, uint32_t opcode) { + assert(((wordCount >> 16) == 0) && "word count out of range!"); + return (wordCount << 16) | opcode; +} + +namespace { +/// A SPIR-V module serializer. +/// +/// A SPIR-V binary module is a single linear stream of instructions; each +/// instruction is composed of 32-bit words with the layout: +/// +/// | | | | | ... | +/// | <------ word -------> | <-- word --> | <-- word --> | ... | +/// +/// For the first word, the 16 high-order bits are the word count of the +/// instruction, the 16 low-order bits are the opcode enumerant. The +/// instructions then belong to different sections, which must be laid out in +/// the particular order as specified in "2.4 Logical Layout of a Module" of +/// the SPIR-V spec. +class Serializer { +public: + /// Creates a serializer for the given SPIR-V `module`. + explicit Serializer(spirv::ModuleOp module) : module(module) {} + + /// Serializes the remembered SPIR-V module. + LogicalResult serialize(); + + /// Collects the final SPIR-V `binary`. + void collect(SmallVectorImpl &binary); + +private: + /// Creates SPIR-V module header in the given `header`. + void processHeader(SmallVectorImpl &header); + + void processMemoryModel(); + +private: + /// The SPIR-V module to be serialized. + spirv::ModuleOp module; + + /// The next available result . + uint32_t nextID = 0; + + // The following are for different SPIR-V instruction sections. They follow + // the logical layout of a SPIR-V module. + + SmallVector capabilities; + SmallVector extensions; + SmallVector extendedSets; + SmallVector memoryModel; + SmallVector entryPoints; + SmallVector executionModes; + // TODO(antiagainst): debug instructions + SmallVector decorations; + SmallVector typesGlobalValues; + SmallVector functions; +}; +} // namespace + +namespace { +#include "mlir/SPIRV/SPIRVSerialization.inc" +} + +LogicalResult Serializer::serialize() { + if (failed(module.verify())) + return failure(); + + // TODO(antiagainst): handle the other sections + processMemoryModel(); + + return success(); +} + +void Serializer::collect(SmallVectorImpl &binary) { + // The number of words in the SPIR-V module header + + auto moduleSize = spirv::kHeaderWordCount + capabilities.size() + + extensions.size() + extendedSets.size() + + memoryModel.size() + entryPoints.size() + + executionModes.size() + decorations.size() + + typesGlobalValues.size() + functions.size(); + + binary.clear(); + binary.reserve(moduleSize); + + processHeader(binary); + binary.append(capabilities.begin(), capabilities.end()); + binary.append(extensions.begin(), extensions.end()); + binary.append(extendedSets.begin(), extendedSets.end()); + binary.append(memoryModel.begin(), memoryModel.end()); + binary.append(entryPoints.begin(), entryPoints.end()); + binary.append(executionModes.begin(), executionModes.end()); + binary.append(decorations.begin(), decorations.end()); + binary.append(typesGlobalValues.begin(), typesGlobalValues.end()); + binary.append(functions.begin(), functions.end()); +} + +void Serializer::processHeader(SmallVectorImpl &header) { + // The serializer tool ID registered to the Khronos Group + constexpr uint32_t kGeneratorNumber = 22; + // The major and minor version number for the generated SPIR-V binary. + // TODO(antiagainst): use target environment to select the version + constexpr uint8_t kMajorVersion = 1; + constexpr uint8_t kMinorVersion = 0; + + header.push_back(spirv::kMagicNumber); + header.push_back((kMajorVersion << 16) | (kMinorVersion << 8)); + header.push_back(kGeneratorNumber); + header.push_back(nextID); // ID bound + header.push_back(0); // Schema (reserved word) +} + +void Serializer::processMemoryModel() { + // TODO(antiagainst): use IntegerAttr-backed enum attributes to avoid the + // excessive string conversions here. + auto mm = static_cast(*spirv::symbolizeMemoryModel( + module.getAttrOfType("memory_model").getValue())); + auto am = static_cast(*spirv::symbolizeAddressingModel( + module.getAttrOfType("addressing_model").getValue())); + + constexpr uint32_t kNumWords = 3; + + memoryModel.reserve(kNumWords); + memoryModel.assign( + {getPrefixedOpcode(kNumWords, spirv::kOpMemoryModelOpcode), am, mm}); +} + +bool spirv::serialize(spirv::ModuleOp module, + SmallVectorImpl &binary) { + Serializer serializer(module); + + if (failed(serializer.serialize())) + return false; + + serializer.collect(binary); + return true; +} diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index 0bd72ead67c..1107048bb88 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -170,6 +170,10 @@ StringRef tblgen::EnumAttr::getUnderlyingType() const { return def->getValueAsString("underlyingType"); } +StringRef tblgen::EnumAttr::getUnderlyingToSymbolFnName() const { + return def->getValueAsString("underlyingToSymbolFnName"); +} + StringRef tblgen::EnumAttr::getStringToSymbolFnName() const { return def->getValueAsString("stringToSymbolFnName"); } diff --git a/mlir/test/SPIRV/Serialization/minimal-module.mlir b/mlir/test/SPIRV/Serialization/minimal-module.mlir new file mode 100644 index 00000000000..31ac451d135 --- /dev/null +++ b/mlir/test/SPIRV/Serialization/minimal-module.mlir @@ -0,0 +1,13 @@ +// RUN: mlir-translate -serialize-spirv %s | mlir-translate -deserialize-spirv | FileCheck %s + +// CHECK: spv.module { +// CHECK-NEXT: } attributes {addressing_model: "Logical", major_version: 1 : i32, memory_model: "VulkanKHR", minor_version: 0 : i32} + +func @spirv_module() -> () { + spv.module { + } attributes { + addressing_model: "Logical", + memory_model: "VulkanKHR" + } + return +} diff --git a/mlir/tools/mlir-tblgen/CMakeLists.txt b/mlir/tools/mlir-tblgen/CMakeLists.txt index 65c5e91c85f..9231fe9a1ea 100644 --- a/mlir/tools/mlir-tblgen/CMakeLists.txt +++ b/mlir/tools/mlir-tblgen/CMakeLists.txt @@ -11,5 +11,6 @@ add_tablegen(mlir-tblgen MLIR OpDocGen.cpp ReferenceImplGen.cpp RewriterGen.cpp + SPIRVSerializationGen.cpp ) set_target_properties(mlir-tblgen PROPERTIES FOLDER "Tablegenning") diff --git a/mlir/tools/mlir-tblgen/EnumsGen.cpp b/mlir/tools/mlir-tblgen/EnumsGen.cpp index e9a70f3131e..f85fa138be1 100644 --- a/mlir/tools/mlir-tblgen/EnumsGen.cpp +++ b/mlir/tools/mlir-tblgen/EnumsGen.cpp @@ -109,6 +109,7 @@ static void emitEnumDecl(const Record &enumDef, raw_ostream &os) { StringRef description = enumAttr.getDescription(); StringRef strToSymFnName = enumAttr.getStringToSymbolFnName(); StringRef symToStrFnName = enumAttr.getSymbolToStringFnName(); + StringRef underlyingToSymFnName = enumAttr.getUnderlyingToSymbolFnName(); StringRef maxEnumValFnName = enumAttr.getMaxEnumValFnName(); auto enumerants = enumAttr.getAllCases(); @@ -122,6 +123,9 @@ static void emitEnumDecl(const Record &enumDef, raw_ostream &os) { emitEnumClass(enumDef, enumName, underlyingType, description, enumerants, os); // Emit coversion function declarations + os << formatv( + "llvm::Optional<{0}> {1}({2});\n", enumName, underlyingToSymFnName, + underlyingType.empty() ? std::string("unsigned") : underlyingType); os << formatv("llvm::StringRef {1}({0});\n", enumName, symToStrFnName); os << formatv("llvm::Optional<{0}> {1}(llvm::StringRef);\n", enumName, strToSymFnName); @@ -158,8 +162,10 @@ static void emitEnumDef(const Record &enumDef, raw_ostream &os) { EnumAttr enumAttr(enumDef); StringRef enumName = enumAttr.getEnumClassName(); StringRef cppNamespace = enumAttr.getCppNamespace(); + std::string underlyingType = enumAttr.getUnderlyingType(); StringRef strToSymFnName = enumAttr.getStringToSymbolFnName(); StringRef symToStrFnName = enumAttr.getSymbolToStringFnName(); + StringRef underlyingToSymFnName = enumAttr.getUnderlyingToSymbolFnName(); auto enumerants = enumAttr.getAllCases(); llvm::SmallVector namespaces; @@ -179,6 +185,21 @@ static void emitEnumDef(const Record &enumDef, raw_ostream &os) { os << " return \"\";\n"; os << "}\n\n"; + os << formatv("llvm::Optional<{0}> {1}({2} value) {{\n", enumName, + underlyingToSymFnName, + underlyingType.empty() ? std::string("unsigned") + : underlyingType) + << " switch (value) {\n"; + for (const auto &enumerant : enumerants) { + auto symbol = enumerant.getSymbol(); + auto value = enumerant.getValue(); + os << formatv(" case {0}: return {1}::{2};\n", value, enumName, + makeIdentifier(symbol)); + } + os << " default: return llvm::None;\n" + << " }\n" + << "}\n\n"; + os << formatv("llvm::Optional<{0}> {1}(llvm::StringRef str) {{\n", enumName, strToSymFnName); os << formatv(" return llvm::StringSwitch>(str)\n", diff --git a/mlir/tools/mlir-tblgen/SPIRVSerializationGen.cpp b/mlir/tools/mlir-tblgen/SPIRVSerializationGen.cpp new file mode 100644 index 00000000000..48c39d94302 --- /dev/null +++ b/mlir/tools/mlir-tblgen/SPIRVSerializationGen.cpp @@ -0,0 +1,69 @@ +//===- SPIRVSerializationGen.cpp - SPIR-V serialization utility generator -===// +// +// Copyright 2019 The MLIR Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================= +// +// SPIRVSerializationGen generates common utility functions for SPIR-V +// serialization. +// +//===----------------------------------------------------------------------===// + +#include "mlir/TableGen/GenInfo.h" +#include "mlir/TableGen/Operator.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/TableGen/Error.h" +#include "llvm/TableGen/Record.h" +#include "llvm/TableGen/TableGenBackend.h" + +using llvm::formatv; +using llvm::raw_ostream; +using llvm::Record; +using llvm::RecordKeeper; +using mlir::tblgen::Operator; + +// Writes the following function to `os`: +// inline uint32_t getOpcode() { return ; } +static void emitGetOpcodeFunction(const llvm::Record &record, + const Operator &op, raw_ostream &os) { + if (llvm::isa(record.getValueInit("opcode"))) + return; + + os << formatv("inline uint32_t getOpcode({0}) {{ return {1}u; }\n", + op.getQualCppClassName(), record.getValueAsInt("opcode")); +} + +static bool emitSerializationUtils(const RecordKeeper &recordKeeper, + raw_ostream &os) { + llvm::emitSourceFileHeader("SPIR-V Serialization Utilities", os); + + auto defs = recordKeeper.getAllDerivedDefinitions("SPV_Op"); + for (const auto *def : defs) { + Operator op(def); + emitGetOpcodeFunction(*def, op, os); + } + + return false; +} + +// Registers the enum utility generator to mlir-tblgen. +static mlir::GenRegistration + genEnumDefs("gen-spirv-serial", + "Generate SPIR-V serialization utility definitions", + [](const RecordKeeper &records, raw_ostream &os) { + return emitSerializationUtils(records, os); + }); diff --git a/mlir/tools/mlir-translate/CMakeLists.txt b/mlir/tools/mlir-translate/CMakeLists.txt index 66199f93cb6..be29c6c46f3 100644 --- a/mlir/tools/mlir-translate/CMakeLists.txt +++ b/mlir/tools/mlir-translate/CMakeLists.txt @@ -4,6 +4,8 @@ set(LIBS MLIREDSC MLIRParser MLIRPass + MLIRSPIRV + MLIRSPIRVSerialization MLIRStandardOps MLIRTargetLLVMIR MLIRTargetNVVMIR -- cgit v1.2.3 From 9dd182e0fa3aeb178d274dc0d64b5891436fba47 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 1 Jul 2019 05:26:14 -0700 Subject: [ODS] Introduce IntEnumAttr In ODS, right now we use StringAttrs to emulate enum attributes. It is suboptimal if the op actually can and wants to store the enum as a single integer value; we are paying extra cost on storing and comparing the attribute value. This CL introduces a new enum attribute subclass that are backed by IntegerAttr. The downside with IntegerAttr-backed enum attributes is that the assembly form now uses integer values, which is less obvious than the StringAttr-backed ones. However, that can be remedied by defining custom assembly form with the help of the conversion utility functions generated via EnumsGen. Choices are given to the dialect writers to decide which one to use for their enum attributes. PiperOrigin-RevId: 255935542 --- mlir/include/mlir/IR/OpBase.td | 104 ++++++++++++++++++--- mlir/include/mlir/TableGen/Attribute.h | 14 ++- mlir/lib/TableGen/Attribute.cpp | 15 ++- mlir/lib/TableGen/Pattern.cpp | 2 +- mlir/test/IR/attribute.mlir | 85 +++++++++++++++++ mlir/test/lib/TestDialect/TestOps.td | 39 ++++++++ mlir/test/mlir-tblgen/attr-enum.td | 69 -------------- mlir/test/mlir-tblgen/pattern.mlir | 23 ++++- mlir/tools/mlir-tblgen/EnumsGen.cpp | 154 +++++++++++++++++++------------ mlir/tools/mlir-tblgen/RewriterGen.cpp | 7 +- mlir/unittests/TableGen/EnumsGenTest.cpp | 34 ++++--- mlir/unittests/TableGen/enums.td | 11 ++- 12 files changed, 383 insertions(+), 174 deletions(-) delete mode 100644 mlir/test/mlir-tblgen/attr-enum.td (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index 269c09a030e..802ae2c6335 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -483,6 +483,9 @@ def FloatLike : TypeConstraint : AttrConstraint { @@ -517,6 +520,9 @@ class Attr : bit isOptional = 0; } +//===----------------------------------------------------------------------===// +// Attribute modifier definition + // Decorates an attribute to have an (unvalidated) default value if not present. class DefaultValuedAttr : Attr { @@ -550,6 +556,9 @@ class OptionalAttr : Attr { string baseAttr = !cast(attr); } +//===----------------------------------------------------------------------===// +// Primitive attribute kinds + // A generic attribute that must be constructed around a specific type // `attrValType`. Backed by MLIR attribute kind `attrKind`. class TypedAttrBase : def TypeAttr : TypeAttrBase<"Type", "any type attribute">; -// An enum attribute case. -class EnumAttrCase : StringBasedAttr< - CPred<"$_self.cast().getValue() == \"" # sym # "\"">, - "case " # sym> { +//===----------------------------------------------------------------------===// +// Enum attribute kinds + +// Additional information for an enum attribute case. +class EnumAttrCaseInfo { // The C++ enumerant symbol string symbol = sym; + // The C++ enumerant value - // A non-negative value must be provided if to use EnumsGen backend. + // If less than zero, there will be no explicit discriminator values assigned + // to enumerators in the generated enum class. int value = val; } -// An enum attribute. Its value can only be one from the given list of `cases`. -// Enum attributes are emulated via mlir::StringAttr, plus extra verification -// on the string: only the symbols of the allowed cases are permitted as the -// string value. -class EnumAttr cases> : - StringBasedAttr]>, - description> { +// An enum attribute case stored with StringAttr. +// TODO(antiagainst): rename this to StrEnumAttrCase to be consistent +class EnumAttrCase : + EnumAttrCaseInfo, + StringBasedAttr< + CPred<"$_self.cast().getValue() == \"" # sym # "\"">, + "case " # sym>; + +// An enum attribute case stored with IntegerAttr. +class IntEnumAttrCaseBase : + EnumAttrCaseInfo, + IntegerAttrBase { + let predicate = + CPred<"$_self.cast().getInt() == " # val>; +} + +class I32EnumAttrCase : IntEnumAttrCaseBase; +class I64EnumAttrCase : IntEnumAttrCaseBase; + +// Additional information for an enum attribute. +class EnumAttrInfo cases> { // The C++ enum class name string className = name; // List of all accepted cases - list enumerants = cases; + list enumerants = cases; // The following fields are only used by the EnumsGen backend to generate // an enum class definition and conversion utility functions. @@ -706,6 +731,51 @@ class EnumAttr cases> : string maxEnumValFnName = "getMaxEnumValFor" # name; } +// An enum attribute backed by StringAttr. +// +// Op attributes of this kind are stored as StringAttr. Extra verification will +// be generated on the string though: only the symbols of the allowed cases are +// permitted as the string value. +// TODO(antiagainst): rename this to StrEnumAttr to be consistent +class EnumAttr cases> : + EnumAttrInfo, + StringBasedAttr< + And<[StrAttr.predicate, Or]>, + !if(!empty(description), "allowed string cases: " # + StrJoin.result, + description)>; + +// An enum attribute backed by IntegerAttr. +// +// Op attributes of this kind are stored as IntegerAttr. Extra verification will +// be generated on the integer though: only the values of the allowed cases are +// permitted as the integer value. +class IntEnumAttr cases> : + EnumAttrInfo, + IntegerAttrBase.result, description)> { + let predicate = And<[ + IntegerAttrBase.predicate, + Or]>; +} + +class I32EnumAttr cases> : + IntEnumAttr { + let underlyingType = "uint32_t"; +} +class I64EnumAttr cases> : + IntEnumAttr { + let underlyingType = "uint64_t"; +} + +//===----------------------------------------------------------------------===// +// Composite attribute kinds + class ElementsAttrBase : Attr { let storageType = [{ ElementsAttr }]; @@ -771,6 +841,9 @@ def FunctionAttr : Attr()">, let constBuilderCall = "$_builder.getFunctionAttr($0)"; } +//===----------------------------------------------------------------------===// +// Derive attribute kinds + // DerivedAttr are attributes whose value is computed from properties // of the operation. They do not require additional storage and are // materialized as needed. @@ -782,6 +855,9 @@ class DerivedAttr : Attr, "derived attribute"> { // Derived attribute that returns a mlir::Type. class DerivedTypeAttr : DerivedAttr<"Type", body>; +//===----------------------------------------------------------------------===// +// Constant attribute kinds + // Represents a constant attribute of specific Attr type. A constant // attribute can be specified only of attributes that have a constant // builder call defined. The constant value is specified as a string. diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index d4914703c5b..a3fbf6dcf4b 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -121,12 +121,15 @@ private: }; // Wrapper class providing helper methods for accessing enum attribute cases -// defined in TableGen. This class should closely reflect what is defined as -// class `EnumAttrCase` in TableGen. +// defined in TableGen. This is used for enum attribute case backed by both +// StringAttr and IntegerAttr. class EnumAttrCase : public Attribute { public: explicit EnumAttrCase(const llvm::DefInit *init); + // Returns true if this EnumAttrCase is backed by a StringAttr. + bool isStrCase() const; + // Returns the symbol of this enum attribute case. StringRef getSymbol() const; @@ -135,14 +138,17 @@ public: }; // Wrapper class providing helper methods for accessing enum attributes defined -// in TableGen. This class should closely reflect what is defined as class -// `EnumAttr` in TableGen. +// in TableGen.This is used for enum attribute case backed by both StringAttr +// and IntegerAttr. class EnumAttr : public Attribute { public: explicit EnumAttr(const llvm::Record *record); explicit EnumAttr(const llvm::Record &record); explicit EnumAttr(const llvm::DefInit *init); + // Returns true if this EnumAttr is backed by a StringAttr. + bool isStrEnum() const; + // Returns the enum class name. StringRef getEnumClassName() const; diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index 1107048bb88..d292f2bdac6 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -136,8 +136,12 @@ StringRef tblgen::ConstantAttr::getConstantValue() const { tblgen::EnumAttrCase::EnumAttrCase(const llvm::DefInit *init) : Attribute(init) { - assert(def->isSubClassOf("EnumAttrCase") && - "must be subclass of TableGen 'EnumAttrCase' class"); + assert(def->isSubClassOf("EnumAttrCaseInfo") && + "must be subclass of TableGen 'EnumAttrInfo' class"); +} + +bool tblgen::EnumAttrCase::isStrCase() const { + return def->isSubClassOf("EnumAttrCase"); } StringRef tblgen::EnumAttrCase::getSymbol() const { @@ -145,11 +149,12 @@ StringRef tblgen::EnumAttrCase::getSymbol() const { } int64_t tblgen::EnumAttrCase::getValue() const { + assert(isStrCase() && "cannot get value for EnumAttrCase"); return def->getValueAsInt("value"); } tblgen::EnumAttr::EnumAttr(const llvm::Record *record) : Attribute(record) { - assert(def->isSubClassOf("EnumAttr") && + assert(def->isSubClassOf("EnumAttrInfo") && "must be subclass of TableGen 'EnumAttr' class"); } @@ -158,6 +163,10 @@ tblgen::EnumAttr::EnumAttr(const llvm::Record &record) : Attribute(&record) {} tblgen::EnumAttr::EnumAttr(const llvm::DefInit *init) : EnumAttr(init->getDef()) {} +bool tblgen::EnumAttr::isStrEnum() const { + return def->isSubClassOf("EnumAttr"); +} + StringRef tblgen::EnumAttr::getEnumClassName() const { return def->getValueAsString("className"); } diff --git a/mlir/lib/TableGen/Pattern.cpp b/mlir/lib/TableGen/Pattern.cpp index e2ddcbae076..467c3d5c177 100644 --- a/mlir/lib/TableGen/Pattern.cpp +++ b/mlir/lib/TableGen/Pattern.cpp @@ -54,7 +54,7 @@ bool tblgen::DagLeaf::isConstantAttr() const { } bool tblgen::DagLeaf::isEnumAttrCase() const { - return isSubClassOf("EnumAttrCase"); + return isSubClassOf("EnumAttrCaseInfo"); } tblgen::Constraint tblgen::DagLeaf::getAsConstraint() const { diff --git a/mlir/test/IR/attribute.mlir b/mlir/test/IR/attribute.mlir index f7149145eac..9c47bcec80b 100644 --- a/mlir/test/IR/attribute.mlir +++ b/mlir/test/IR/attribute.mlir @@ -30,3 +30,88 @@ func @string_attr_custom_type() { test.string_attr_with_type "string_data" return } + +// ----- + +//===----------------------------------------------------------------------===// +// Test StrEnumAttr +//===----------------------------------------------------------------------===// + +// CHECK-LABEL: func @allowed_cases_pass +func @allowed_cases_pass() { + // CHECK: test.str_enum_attr + %0 = "test.str_enum_attr"() {attr = "A"} : () -> i32 + // CHECK: test.str_enum_attr + %1 = "test.str_enum_attr"() {attr = "B"} : () -> i32 + return +} + +// ----- + +func @disallowed_case_fail() { + // expected-error @+1 {{allowed string cases: 'A', 'B'}} + %0 = "test.str_enum_attr"() {attr = 7: i32} : () -> i32 + return +} + +// ----- + +//===----------------------------------------------------------------------===// +// Test I32EnumAttr +//===----------------------------------------------------------------------===// + +// CHECK-LABEL: func @allowed_cases_pass +func @allowed_cases_pass() { + // CHECK: test.i32_enum_attr + %0 = "test.i32_enum_attr"() {attr = 5: i32} : () -> i32 + // CHECK: test.i32_enum_attr + %1 = "test.i32_enum_attr"() {attr = 10: i32} : () -> i32 + return +} + +// ----- + +func @disallowed_case7_fail() { + // expected-error @+1 {{allowed 32-bit integer cases: 5, 10}} + %0 = "test.i32_enum_attr"() {attr = 7: i32} : () -> i32 + return +} + +// ----- + +func @disallowed_case7_fail() { + // expected-error @+1 {{allowed 32-bit integer cases: 5, 10}} + %0 = "test.i32_enum_attr"() {attr = 5: i64} : () -> i32 + return +} + +// ----- + +//===----------------------------------------------------------------------===// +// Test I64EnumAttr +//===----------------------------------------------------------------------===// + +// CHECK-LABEL: func @allowed_cases_pass +func @allowed_cases_pass() { + // CHECK: test.i64_enum_attr + %0 = "test.i64_enum_attr"() {attr = 5: i64} : () -> i32 + // CHECK: test.i64_enum_attr + %1 = "test.i64_enum_attr"() {attr = 10: i64} : () -> i32 + return +} + +// ----- + +func @disallowed_case7_fail() { + // expected-error @+1 {{allowed 64-bit integer cases: 5, 10}} + %0 = "test.i64_enum_attr"() {attr = 7: i64} : () -> i32 + return +} + +// ----- + +func @disallowed_case7_fail() { + // expected-error @+1 {{allowed 64-bit integer cases: 5, 10}} + %0 = "test.i64_enum_attr"() {attr = 5: i32} : () -> i32 + return +} diff --git a/mlir/test/lib/TestDialect/TestOps.td b/mlir/test/lib/TestDialect/TestOps.td index ba5362b9985..d64af5b0a97 100644 --- a/mlir/test/lib/TestDialect/TestOps.td +++ b/mlir/test/lib/TestDialect/TestOps.td @@ -104,6 +104,39 @@ def TypeStringAttrWithTypeOp : TEST_Op<"string_attr_with_type"> { }]; } +def StrCaseA: EnumAttrCase<"A">; +def StrCaseB: EnumAttrCase<"B">; + +def SomeStrEnum: EnumAttr< + "SomeStrEnum", "", [StrCaseA, StrCaseB]>; + +def StrEnumAttrOp : TEST_Op<"str_enum_attr"> { + let arguments = (ins SomeStrEnum:$attr); + let results = (outs I32:$val); +} + +def I32Case5: I32EnumAttrCase<"case5", 5>; +def I32Case10: I32EnumAttrCase<"case10", 10>; + +def SomeI32Enum: I32EnumAttr< + "SomeI32Enum", "", [I32Case5, I32Case10]>; + +def I32EnumAttrOp : TEST_Op<"i32_enum_attr"> { + let arguments = (ins SomeI32Enum:$attr); + let results = (outs I32:$val); +} + +def I64Case5: I64EnumAttrCase<"case5", 5>; +def I64Case10: I64EnumAttrCase<"case10", 10>; + +def SomeI64Enum: I64EnumAttr< + "SomeI64Enum", "", [I64Case5, I64Case10]>; + +def I64EnumAttrOp : TEST_Op<"i64_enum_attr"> { + let arguments = (ins SomeI64Enum:$attr); + let results = (outs I32:$val); +} + //===----------------------------------------------------------------------===// // Test Traits //===----------------------------------------------------------------------===// @@ -192,6 +225,12 @@ def : Pat<(OpD $input), (OpF $input), [], (addBenefit 10)>; def : Pat<(OpG $input), (OpB $input, ConstantAttr:$attr)>; def : Pat<(OpG (OpG $input)), (OpB $input, ConstantAttr:$attr)>; +// Test string enum attribute in rewrites. +def : Pat<(StrEnumAttrOp StrCaseA), (StrEnumAttrOp StrCaseB)>; +// Test integer enum attribute in rewrites. +def : Pat<(I32EnumAttrOp I32Case5), (I32EnumAttrOp I32Case10)>; +def : Pat<(I64EnumAttrOp I64Case5), (I64EnumAttrOp I64Case10)>; + //===----------------------------------------------------------------------===// // Test op regions //===----------------------------------------------------------------------===// diff --git a/mlir/test/mlir-tblgen/attr-enum.td b/mlir/test/mlir-tblgen/attr-enum.td deleted file mode 100644 index a86829c5dd1..00000000000 --- a/mlir/test/mlir-tblgen/attr-enum.td +++ /dev/null @@ -1,69 +0,0 @@ -// RUN: mlir-tblgen -gen-op-defs -I %S/../../include %s | FileCheck %s --check-prefix=DEF -// RUN: mlir-tblgen -gen-rewriters -I %S/../../include %s | FileCheck %s --check-prefix=PAT - -include "mlir/IR/OpBase.td" - -def NS_SomeEnum_A : EnumAttrCase<"A">; -def NS_SomeEnum_B : EnumAttrCase<"B">; - -def NS_SomeEnum : EnumAttr< - "SomeEnum", "some enum", [NS_SomeEnum_A, NS_SomeEnum_B]>; - -def Test_Dialect : Dialect { - let name = "test"; - let cppNamespace = "NS"; -} -class NS_Op traits> : - Op; - -def NS_OpA : NS_Op<"op_a_with_enum_attr", []> { - let arguments = (ins NS_SomeEnum:$attr); - let results = (outs I32:$result); -} - -// Test enum attribute getter method and verification -// --- - -// DEF-LABEL: StringRef OpA::attr() -// DEF-NEXT: auto attr = this->getAttr("attr").cast(); -// DEF-NEXT: return attr.getValue(); - -// DEF-LABEL: OpA::verify() -// DEF: auto tblgen_attr = this->getAttr("attr"); -// DEF: if (!(((tblgen_attr.isa())) && (((tblgen_attr.cast().getValue() == "A")) || ((tblgen_attr.cast().getValue() == "B"))))) -// DEF-SAME: return emitOpError("attribute 'attr' failed to satisfy constraint: some enum"); - -def NS_OpB : NS_Op<"op_b_with_enum_attr", []> { - let arguments = (ins NS_SomeEnum:$attr); - let results = (outs I32:$result); -} - -def : Pat<(NS_OpA NS_SomeEnum_A:$attr), (NS_OpB NS_SomeEnum_B)>; - -// Test enum attribute match and rewrite -// --- - -// PAT-LABEL: struct GeneratedConvert0 - -// PAT: PatternMatchResult match -// PAT: auto attr = op0->getAttrOfType("attr"); -// PAT-NEXT: if (!attr) return matchFailure(); -// PAT-NEXT: if (!((attr.cast().getValue() == "A"))) return matchFailure(); - -// PAT: void rewrite -// PAT: auto vOpB0 = rewriter.create(loc, -// PAT-NEXT: rewriter.getStringAttr("B") -// PAT-NEXT: ); - -def NS_SomeEnum_Array : TypedArrayAttrBase; - -def NS_OpC : NS_Op<"op_b_with_enum_array_attr", []> { - let arguments = (ins NS_SomeEnum_Array:$attr); - let results = (outs I32:$result); -} - -// Test enum array attribute verification -// --- - -// DEF-LABEL: OpC::verify() -// DEF: [](Attribute attr) { return ((attr.isa())) && (((attr.cast().getValue() == "A")) || ((attr.cast().getValue() == "B"))); } diff --git a/mlir/test/mlir-tblgen/pattern.mlir b/mlir/test/mlir-tblgen/pattern.mlir index cf7026b43ed..557c340fd63 100644 --- a/mlir/test/mlir-tblgen/pattern.mlir +++ b/mlir/test/mlir-tblgen/pattern.mlir @@ -27,4 +27,25 @@ func @verifyBenefit(%arg0 : i32) -> i32 { // CHECK: "test.op_f"(%arg0) // CHECK: "test.op_b"(%arg0) {attr = 34 : i32} return %0 : i32 -} \ No newline at end of file +} + +// CHECK-LABEL: verifyStrEnumAttr +func @verifyStrEnumAttr() -> i32 { + // CHECK: "test.str_enum_attr"() {attr = "B"} + %0 = "test.str_enum_attr"() {attr = "A"} : () -> i32 + return %0 : i32 +} + +// CHECK-LABEL: verifyI32EnumAttr +func @verifyI32EnumAttr() -> i32 { + // CHECK: "test.i32_enum_attr"() {attr = 10 : i32} + %0 = "test.i32_enum_attr"() {attr = 5: i32} : () -> i32 + return %0 : i32 +} + +// CHECK-LABEL: verifyI64EnumAttr +func @verifyI64EnumAttr() -> i32 { + // CHECK: "test.i64_enum_attr"() {attr = 10 : i64} + %0 = "test.i64_enum_attr"() {attr = 5: i64} : () -> i32 + return %0 : i32 +} diff --git a/mlir/tools/mlir-tblgen/EnumsGen.cpp b/mlir/tools/mlir-tblgen/EnumsGen.cpp index f85fa138be1..962a7eafaf4 100644 --- a/mlir/tools/mlir-tblgen/EnumsGen.cpp +++ b/mlir/tools/mlir-tblgen/EnumsGen.cpp @@ -60,11 +60,11 @@ static void emitEnumClass(const Record &enumDef, StringRef enumName, for (const auto &enumerant : enumerants) { auto symbol = makeIdentifier(enumerant.getSymbol()); auto value = enumerant.getValue(); - if (value < 0) { - llvm::PrintFatalError(enumDef.getLoc(), - "all enumerants must have a non-negative value"); + if (value >= 0) { + os << formatv(" {0} = {1},\n", symbol, value); + } else { + os << formatv(" {0},\n", symbol); } - os << formatv(" {0} = {1},\n", symbol, value); } os << "};\n\n"; } @@ -101,6 +101,88 @@ template<> struct DenseMapInfo<{0}> {{ os << "\n\n"; } +static void emitMaxValueFn(const Record &enumDef, raw_ostream &os) { + EnumAttr enumAttr(enumDef); + StringRef maxEnumValFnName = enumAttr.getMaxEnumValFnName(); + auto enumerants = enumAttr.getAllCases(); + + unsigned maxEnumVal = 0; + for (const auto &enumerant : enumerants) { + int64_t value = enumerant.getValue(); + // Avoid generating the max value function if there is an enumerant without + // explicit value. + if (value < 0) + return; + + maxEnumVal = std::max(maxEnumVal, static_cast(value)); + } + + // Emit the function to return the max enum value + os << formatv("inline constexpr unsigned {0}() {{\n", maxEnumValFnName); + os << formatv(" return {0};\n", maxEnumVal); + os << "}\n\n"; +} + +static void emitSymToStrFn(const Record &enumDef, raw_ostream &os) { + EnumAttr enumAttr(enumDef); + StringRef enumName = enumAttr.getEnumClassName(); + StringRef symToStrFnName = enumAttr.getSymbolToStringFnName(); + auto enumerants = enumAttr.getAllCases(); + + os << formatv("llvm::StringRef {1}({0} val) {{\n", enumName, symToStrFnName); + os << " switch (val) {\n"; + for (const auto &enumerant : enumerants) { + auto symbol = enumerant.getSymbol(); + os << formatv(" case {0}::{1}: return \"{2}\";\n", enumName, + makeIdentifier(symbol), symbol); + } + os << " }\n"; + os << " return \"\";\n"; + os << "}\n\n"; +} + +static void emitStrToSymFn(const Record &enumDef, raw_ostream &os) { + EnumAttr enumAttr(enumDef); + StringRef enumName = enumAttr.getEnumClassName(); + StringRef strToSymFnName = enumAttr.getStringToSymbolFnName(); + auto enumerants = enumAttr.getAllCases(); + + os << formatv("llvm::Optional<{0}> {1}(llvm::StringRef str) {{\n", enumName, + strToSymFnName); + os << formatv(" return llvm::StringSwitch>(str)\n", + enumName); + for (const auto &enumerant : enumerants) { + auto symbol = enumerant.getSymbol(); + os << formatv(" .Case(\"{1}\", {0}::{2})\n", enumName, symbol, + makeIdentifier(symbol)); + } + os << " .Default(llvm::None);\n"; + os << "}\n"; +} + +static void emitUnderlyingToSymFn(const Record &enumDef, raw_ostream &os) { + EnumAttr enumAttr(enumDef); + StringRef enumName = enumAttr.getEnumClassName(); + std::string underlyingType = enumAttr.getUnderlyingType(); + StringRef underlyingToSymFnName = enumAttr.getUnderlyingToSymbolFnName(); + auto enumerants = enumAttr.getAllCases(); + + os << formatv("llvm::Optional<{0}> {1}({2} value) {{\n", enumName, + underlyingToSymFnName, + underlyingType.empty() ? std::string("unsigned") + : underlyingType) + << " switch (value) {\n"; + for (const auto &enumerant : enumerants) { + auto symbol = enumerant.getSymbol(); + auto value = enumerant.getValue(); + os << formatv(" case {0}: return {1}::{2};\n", value, enumName, + makeIdentifier(symbol)); + } + os << " default: return llvm::None;\n" + << " }\n" + << "}\n\n"; +} + static void emitEnumDecl(const Record &enumDef, raw_ostream &os) { EnumAttr enumAttr(enumDef); StringRef enumName = enumAttr.getEnumClassName(); @@ -110,7 +192,6 @@ static void emitEnumDecl(const Record &enumDef, raw_ostream &os) { StringRef strToSymFnName = enumAttr.getStringToSymbolFnName(); StringRef symToStrFnName = enumAttr.getSymbolToStringFnName(); StringRef underlyingToSymFnName = enumAttr.getUnderlyingToSymbolFnName(); - StringRef maxEnumValFnName = enumAttr.getMaxEnumValFnName(); auto enumerants = enumAttr.getAllCases(); llvm::SmallVector namespaces; @@ -130,20 +211,11 @@ static void emitEnumDecl(const Record &enumDef, raw_ostream &os) { os << formatv("llvm::Optional<{0}> {1}(llvm::StringRef);\n", enumName, strToSymFnName); + emitMaxValueFn(enumDef, os); + for (auto ns : llvm::reverse(namespaces)) os << "} // namespace " << ns << "\n"; - // Emit the function to return the max enum value - unsigned maxEnumVal = 0; - for (const auto &enumerant : enumerants) { - auto value = enumerant.getValue(); - // Already checked that the value is non-negetive. - maxEnumVal = std::max(maxEnumVal, static_cast(value)); - } - os << formatv("inline constexpr unsigned {0}() {{\n", maxEnumValFnName); - os << formatv(" return {0};\n", maxEnumVal); - os << "}\n\n"; - // Emit DenseMapInfo for this enum class emitDenseMapInfo(enumName, underlyingType, cppNamespace, os); } @@ -151,7 +223,7 @@ static void emitEnumDecl(const Record &enumDef, raw_ostream &os) { static bool emitEnumDecls(const RecordKeeper &recordKeeper, raw_ostream &os) { llvm::emitSourceFileHeader("Enum Utility Declarations", os); - auto defs = recordKeeper.getAllDerivedDefinitions("EnumAttr"); + auto defs = recordKeeper.getAllDerivedDefinitions("EnumAttrInfo"); for (const auto *def : defs) emitEnumDecl(*def, os); @@ -160,13 +232,7 @@ static bool emitEnumDecls(const RecordKeeper &recordKeeper, raw_ostream &os) { static void emitEnumDef(const Record &enumDef, raw_ostream &os) { EnumAttr enumAttr(enumDef); - StringRef enumName = enumAttr.getEnumClassName(); StringRef cppNamespace = enumAttr.getCppNamespace(); - std::string underlyingType = enumAttr.getUnderlyingType(); - StringRef strToSymFnName = enumAttr.getStringToSymbolFnName(); - StringRef symToStrFnName = enumAttr.getSymbolToStringFnName(); - StringRef underlyingToSymFnName = enumAttr.getUnderlyingToSymbolFnName(); - auto enumerants = enumAttr.getAllCases(); llvm::SmallVector namespaces; llvm::SplitString(cppNamespace, namespaces, "::"); @@ -174,43 +240,9 @@ static void emitEnumDef(const Record &enumDef, raw_ostream &os) { for (auto ns : namespaces) os << "namespace " << ns << " {\n"; - os << formatv("llvm::StringRef {1}({0} val) {{\n", enumName, symToStrFnName); - os << " switch (val) {\n"; - for (const auto &enumerant : enumerants) { - auto symbol = enumerant.getSymbol(); - os << formatv(" case {0}::{1}: return \"{2}\";\n", enumName, - makeIdentifier(symbol), symbol); - } - os << " }\n"; - os << " return \"\";\n"; - os << "}\n\n"; - - os << formatv("llvm::Optional<{0}> {1}({2} value) {{\n", enumName, - underlyingToSymFnName, - underlyingType.empty() ? std::string("unsigned") - : underlyingType) - << " switch (value) {\n"; - for (const auto &enumerant : enumerants) { - auto symbol = enumerant.getSymbol(); - auto value = enumerant.getValue(); - os << formatv(" case {0}: return {1}::{2};\n", value, enumName, - makeIdentifier(symbol)); - } - os << " default: return llvm::None;\n" - << " }\n" - << "}\n\n"; - - os << formatv("llvm::Optional<{0}> {1}(llvm::StringRef str) {{\n", enumName, - strToSymFnName); - os << formatv(" return llvm::StringSwitch>(str)\n", - enumName); - for (const auto &enumerant : enumerants) { - auto symbol = enumerant.getSymbol(); - os << formatv(" .Case(\"{1}\", {0}::{2})\n", enumName, symbol, - makeIdentifier(symbol)); - } - os << " .Default(llvm::None);\n"; - os << "}\n"; + emitSymToStrFn(enumDef, os); + emitStrToSymFn(enumDef, os); + emitUnderlyingToSymFn(enumDef, os); for (auto ns : llvm::reverse(namespaces)) os << "} // namespace " << ns << "\n"; @@ -220,7 +252,7 @@ static void emitEnumDef(const Record &enumDef, raw_ostream &os) { static bool emitEnumDefs(const RecordKeeper &recordKeeper, raw_ostream &os) { llvm::emitSourceFileHeader("Enum Utility Definitions", os); - auto defs = recordKeeper.getAllDerivedDefinitions("EnumAttr"); + auto defs = recordKeeper.getAllDerivedDefinitions("EnumAttrInfo"); for (const auto *def : defs) emitEnumDef(*def, os); diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp index 203393b5caa..2419c31b170 100644 --- a/mlir/tools/mlir-tblgen/RewriterGen.cpp +++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp @@ -628,7 +628,12 @@ std::string PatternEmitter::handleOpArgument(DagLeaf leaf, } if (leaf.isEnumAttrCase()) { auto enumCase = leaf.getAsEnumAttrCase(); - return handleConstantAttr(enumCase, enumCase.getSymbol()); + if (enumCase.isStrCase()) + return handleConstantAttr(enumCase, enumCase.getSymbol()); + // This is an enum case backed by an IntegerAttr. We need to get its value + // to build the constant. + std::string val = std::to_string(enumCase.getValue()); + return handleConstantAttr(enumCase, val); } pattern.ensureBoundInSourcePattern(argName); std::string result = getBoundSymbol(argName).str(); diff --git a/mlir/unittests/TableGen/EnumsGenTest.cpp b/mlir/unittests/TableGen/EnumsGenTest.cpp index b9a98a4504c..f20ec0ca381 100644 --- a/mlir/unittests/TableGen/EnumsGenTest.cpp +++ b/mlir/unittests/TableGen/EnumsGenTest.cpp @@ -31,36 +31,40 @@ using ::testing::StrEq; // Test namespaces and enum class/utility names using Outer::Inner::ConvertToEnum; using Outer::Inner::ConvertToString; -using Outer::Inner::MyEnum; +using Outer::Inner::StrEnum; -TEST(EnumsGenTest, GeneratedEnumDefinition) { - EXPECT_EQ(0u, static_cast(MyEnum::CaseA)); - EXPECT_EQ(10u, static_cast(MyEnum::CaseB)); +TEST(EnumsGenTest, GeneratedStrEnumDefinition) { + EXPECT_EQ(0u, static_cast(StrEnum::CaseA)); + EXPECT_EQ(10u, static_cast(StrEnum::CaseB)); +} + +TEST(EnumsGenTest, GeneratedI32EnumDefinition) { + EXPECT_EQ(5u, static_cast(I32Enum::Case5)); + EXPECT_EQ(10u, static_cast(I32Enum::Case10)); } TEST(EnumsGenTest, GeneratedDenseMapInfo) { - llvm::DenseMap myMap; + llvm::DenseMap myMap; - myMap[MyEnum::CaseA] = "zero"; - myMap[MyEnum::CaseB] = "ten"; + myMap[StrEnum::CaseA] = "zero"; + myMap[StrEnum::CaseB] = "one"; - EXPECT_THAT(myMap[MyEnum::CaseA], StrEq("zero")); - EXPECT_THAT(myMap[MyEnum::CaseB], StrEq("ten")); + EXPECT_THAT(myMap[StrEnum::CaseA], StrEq("zero")); + EXPECT_THAT(myMap[StrEnum::CaseB], StrEq("one")); } TEST(EnumsGenTest, GeneratedSymbolToStringFn) { - EXPECT_THAT(ConvertToString(MyEnum::CaseA), StrEq("CaseA")); - EXPECT_THAT(ConvertToString(MyEnum::CaseB), StrEq("CaseB")); + EXPECT_THAT(ConvertToString(StrEnum::CaseA), StrEq("CaseA")); + EXPECT_THAT(ConvertToString(StrEnum::CaseB), StrEq("CaseB")); } TEST(EnumsGenTest, GeneratedStringToSymbolFn) { - EXPECT_EQ(llvm::Optional(MyEnum::CaseA), ConvertToEnum("CaseA")); - EXPECT_EQ(llvm::Optional(MyEnum::CaseB), ConvertToEnum("CaseB")); + EXPECT_EQ(llvm::Optional(StrEnum::CaseA), ConvertToEnum("CaseA")); + EXPECT_EQ(llvm::Optional(StrEnum::CaseB), ConvertToEnum("CaseB")); EXPECT_EQ(llvm::None, ConvertToEnum("X")); } TEST(EnumsGenTest, GeneratedUnderlyingType) { - bool v = - std::is_same::type>::value; + bool v = std::is_same::type>::value; EXPECT_TRUE(v); } diff --git a/mlir/unittests/TableGen/enums.td b/mlir/unittests/TableGen/enums.td index 289829552c3..bd830671841 100644 --- a/mlir/unittests/TableGen/enums.td +++ b/mlir/unittests/TableGen/enums.td @@ -17,15 +17,16 @@ include "mlir/IR/OpBase.td" -def CaseA: EnumAttrCase<"CaseA", 0>; +def CaseA: EnumAttrCase<"CaseA">; def CaseB: EnumAttrCase<"CaseB", 10>; -def MyEnum: EnumAttr<"MyEnum", "A test enum", [CaseA, CaseB]> { +def StrEnum: EnumAttr<"StrEnum", "A test enum", [CaseA, CaseB]> { let cppNamespace = "Outer::Inner"; let stringToSymbolFnName = "ConvertToEnum"; let symbolToStringFnName = "ConvertToString"; } -def Uint64Enum : EnumAttr<"Uint64Enum", "A test enum", [CaseA, CaseB]> { - let underlyingType = "uint64_t"; -} +def Case5: I32EnumAttrCase<"Case5", 5>; +def Case10: I32EnumAttrCase<"Case10", 10>; + +def I32Enum: I32EnumAttr<"I32Enum", "A test enum", [Case5, Case10]>; -- cgit v1.2.3 From 22883036cd2f24380a3426fd4c1de59281781bd1 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 1 Jul 2019 20:56:13 -0700 Subject: EnumsGen: remove dangling assertion StringAttr-backed enum attribute cases changed to allow explicit values, But this assertion was not deleted. Fixes https://github.com/tensorflow/mlir/issues/39 PiperOrigin-RevId: 256090793 --- mlir/lib/TableGen/Attribute.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index d292f2bdac6..c7dc002beef 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -149,7 +149,6 @@ StringRef tblgen::EnumAttrCase::getSymbol() const { } int64_t tblgen::EnumAttrCase::getValue() const { - assert(isStrCase() && "cannot get value for EnumAttrCase"); return def->getValueAsInt("value"); } -- cgit v1.2.3 From 509411c22998897f90f7b0db5e524af5530b77f5 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 2 Jul 2019 08:27:32 -0700 Subject: [ODS] NFC: Rename EnumAttr to StrEnumAttr to be consistent with IntEnumAttr PiperOrigin-RevId: 256169019 --- mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td | 16 ++++++++-------- mlir/include/mlir/IR/OpBase.td | 8 +++----- mlir/lib/TableGen/Attribute.cpp | 4 ++-- mlir/test/lib/TestDialect/TestOps.td | 12 ++++++------ mlir/unittests/TableGen/enums.td | 6 +++--- 5 files changed, 22 insertions(+), 24 deletions(-) (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td b/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td index 1cf74fccfb3..46b4293c1fd 100644 --- a/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td +++ b/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td @@ -67,14 +67,14 @@ def fxpmath_EwUnaryFn_Tanh : fxpmath_ConstEwUnaryFn<"TANH">; // Comparison functions (compares relative to zero on a subtraction result). //===----------------------------------------------------------------------===// -def fxpmath_CompareZ : EnumAttrCase<"CMPZ">; -def fxpmath_CompareNZ : EnumAttrCase<"CMPNZ">; -def fxpmath_CompareLZ : EnumAttrCase<"CMPLZ">; -def fxpmath_CompareLZE : EnumAttrCase<"CMPLZE">; -def fxpmath_CompareGZ : EnumAttrCase<"CMPGZ">; -def fxpmath_CompareGZE : EnumAttrCase<"CMPGZE">; - -def fxpmath_CompareFnAttr : EnumAttr<"ComparisonFn", +def fxpmath_CompareZ : StrEnumAttrCase<"CMPZ">; +def fxpmath_CompareNZ : StrEnumAttrCase<"CMPNZ">; +def fxpmath_CompareLZ : StrEnumAttrCase<"CMPLZ">; +def fxpmath_CompareLZE : StrEnumAttrCase<"CMPLZE">; +def fxpmath_CompareGZ : StrEnumAttrCase<"CMPGZ">; +def fxpmath_CompareGZE : StrEnumAttrCase<"CMPGZE">; + +def fxpmath_CompareFnAttr : StrEnumAttr<"ComparisonFn", "Type of subtraction-result comparison to perform.", [ fxpmath_CompareZ, diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index 802ae2c6335..40ef9e4915b 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -655,8 +655,7 @@ class EnumAttrCaseInfo { } // An enum attribute case stored with StringAttr. -// TODO(antiagainst): rename this to StrEnumAttrCase to be consistent -class EnumAttrCase : +class StrEnumAttrCase : EnumAttrCaseInfo, StringBasedAttr< CPred<"$_self.cast().getValue() == \"" # sym # "\"">, @@ -736,9 +735,8 @@ class EnumAttrInfo cases> { // Op attributes of this kind are stored as StringAttr. Extra verification will // be generated on the string though: only the symbols of the allowed cases are // permitted as the string value. -// TODO(antiagainst): rename this to StrEnumAttr to be consistent -class EnumAttr cases> : +class StrEnumAttr cases> : EnumAttrInfo, StringBasedAttr< And<[StrAttr.predicate, Or]>, diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index c7dc002beef..f5eb6d3bd9a 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -141,7 +141,7 @@ tblgen::EnumAttrCase::EnumAttrCase(const llvm::DefInit *init) } bool tblgen::EnumAttrCase::isStrCase() const { - return def->isSubClassOf("EnumAttrCase"); + return def->isSubClassOf("StrEnumAttrCase"); } StringRef tblgen::EnumAttrCase::getSymbol() const { @@ -163,7 +163,7 @@ tblgen::EnumAttr::EnumAttr(const llvm::DefInit *init) : EnumAttr(init->getDef()) {} bool tblgen::EnumAttr::isStrEnum() const { - return def->isSubClassOf("EnumAttr"); + return def->isSubClassOf("StrEnumAttr"); } StringRef tblgen::EnumAttr::getEnumClassName() const { diff --git a/mlir/test/lib/TestDialect/TestOps.td b/mlir/test/lib/TestDialect/TestOps.td index d64af5b0a97..ba9b6429ec2 100644 --- a/mlir/test/lib/TestDialect/TestOps.td +++ b/mlir/test/lib/TestDialect/TestOps.td @@ -104,10 +104,10 @@ def TypeStringAttrWithTypeOp : TEST_Op<"string_attr_with_type"> { }]; } -def StrCaseA: EnumAttrCase<"A">; -def StrCaseB: EnumAttrCase<"B">; +def StrCaseA: StrEnumAttrCase<"A">; +def StrCaseB: StrEnumAttrCase<"B">; -def SomeStrEnum: EnumAttr< +def SomeStrEnum: StrEnumAttr< "SomeStrEnum", "", [StrCaseA, StrCaseB]>; def StrEnumAttrOp : TEST_Op<"str_enum_attr"> { @@ -247,10 +247,10 @@ def SizedRegionOp : TEST_Op<"sized_region_op", []> { // Test Legalization //===----------------------------------------------------------------------===// -def Test_LegalizerEnum_Success : EnumAttrCase<"Success">; -def Test_LegalizerEnum_Failure : EnumAttrCase<"Failure">; +def Test_LegalizerEnum_Success : StrEnumAttrCase<"Success">; +def Test_LegalizerEnum_Failure : StrEnumAttrCase<"Failure">; -def Test_LegalizerEnum : EnumAttr<"Success", "Failure", +def Test_LegalizerEnum : StrEnumAttr<"Success", "Failure", [Test_LegalizerEnum_Success, Test_LegalizerEnum_Failure]>; def ILLegalOpA : TEST_Op<"illegal_op_a">, Results<(outs I32:$res)>; diff --git a/mlir/unittests/TableGen/enums.td b/mlir/unittests/TableGen/enums.td index bd830671841..a623e1e56cc 100644 --- a/mlir/unittests/TableGen/enums.td +++ b/mlir/unittests/TableGen/enums.td @@ -17,10 +17,10 @@ include "mlir/IR/OpBase.td" -def CaseA: EnumAttrCase<"CaseA">; -def CaseB: EnumAttrCase<"CaseB", 10>; +def CaseA: StrEnumAttrCase<"CaseA">; +def CaseB: StrEnumAttrCase<"CaseB", 10>; -def StrEnum: EnumAttr<"StrEnum", "A test enum", [CaseA, CaseB]> { +def StrEnum: StrEnumAttr<"StrEnum", "A test enum", [CaseA, CaseB]> { let cppNamespace = "Outer::Inner"; let stringToSymbolFnName = "ConvertToEnum"; let symbolToStringFnName = "ConvertToString"; -- cgit v1.2.3 From 765b77cc70943759f8ee28d55cf19841b713ac5c Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 16 Jul 2019 04:33:54 -0700 Subject: Better support for attribute wrapper classes when getting def name Unless we explicitly name a template instantiation in .td file, its def name will be "anonymous_". We typically give base-level Attr template instantiation a name by writing `def AnAttr : Attr<...>`. But when `AnAttr` is further wrapped in classes like OptionalAttr, the name is lost unless explicitly def'ed again. These implicit-named template instantiation is fairly common when writing op definitions. Those wrapper classes are just essentially attaching more information to the attribute. Without a proper way to trace back to the original attribute def name can cause problems for consumers wanting to handle attributes according to their types. Previously we handled OptionalAttr and DefaultValuedAttr specifically, but Confined was not supported. And they can compose together to have Confined, [...]>. So this CL moves the baseAttr field to main Attr class (like isOptional) and set it only on the innermost wrapper class. PiperOrigin-RevId: 258341646 --- mlir/include/mlir/IR/OpBase.td | 21 +++++++++++++++------ mlir/include/mlir/TableGen/Attribute.h | 20 ++++++++++++-------- mlir/lib/TableGen/Attribute.cpp | 13 +++++++++++-- 3 files changed, 38 insertions(+), 16 deletions(-) (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index 2af48e777a9..5ccd2a3e8e5 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -518,6 +518,17 @@ class Attr : // convertFromStorage method to handle the case where the attribute is // not present. bit isOptional = 0; + + // What is the base-level Attr instantiation that this Attr is built upon. + // Unset means this is a base-level Attr. + // + // This field is used by attribute wrapper classes (DefaultValuedAttr, + // OptionalAttr, etc.) to retrive the base-level attribute definition. + // This can be used for getting its name; otherwise, we will see + // "anonymous_" as the attribute def name because of template + // instantiation. + // TOOD(b/132458159): deduplicate the fields in attribute wrapper classes. + Attr baseAttr = ?; } //===----------------------------------------------------------------------===// @@ -535,9 +546,7 @@ class DefaultValuedAttr : let constBuilderCall = attr.constBuilderCall; let defaultValue = val; - // Remember `attr`'s def name. - // TOOD(b/132458159): consider embedding Attr as a field. - string baseAttr = !cast(attr); + let baseAttr = attr; } // Decorates an attribute as optional. The return type of the generated @@ -551,9 +560,7 @@ class OptionalAttr : Attr { attr.convertFromStorage # ") : (llvm::None)"; let isOptional = 1; - // Remember `attr`'s def name. - // TOOD(b/132458159): consider embedding Attr as a field. - string baseAttr = !cast(attr); + let baseAttr = attr; } //===----------------------------------------------------------------------===// @@ -891,6 +898,8 @@ class Confined constraints> : Attr< let constBuilderCall = attr.constBuilderCall; let defaultValue = attr.defaultValue; let isOptional = attr.isOptional; + + let baseAttr = attr; } // An AttrConstraint that holds if all attr constraints specified in diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index a3fbf6dcf4b..6950510f51d 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -52,14 +52,6 @@ public: explicit Attribute(const llvm::Record *record); explicit Attribute(const llvm::DefInit *init); - // Returns true if this attribute is a derived attribute (i.e., a subclass - // of `DerivedAttr`). - bool isDerivedAttr() const; - - // Returns true if this attribute is a type attribute (i.e., a subclass - // of `TypeAttrBase`). - bool isTypeAttr() const; - // Returns true if this attribute has storage type set. bool hasStorageType() const; @@ -84,6 +76,10 @@ public: // the constant value. StringRef getConstBuilderTemplate() const; + // Returns the base-level attribute that this attribute constraint is + // built upon. + Attribute getBaseAttr() const; + // Returns whether this attribute has a default value's initializer. bool hasDefaultValueInitializer() const; // Returns the default value's initializer for this attribute. @@ -92,6 +88,14 @@ public: // Returns whether this attribute is optional. bool isOptional() const; + // Returns true if this attribute is a derived attribute (i.e., a subclass + // of `DerivedAttr`). + bool isDerivedAttr() const; + + // Returns true if this attribute is a type attribute (i.e., a subclass + // of `TypeAttrBase`). + bool isTypeAttr() const; + // Returns this attribute's TableGen def name. If this is an `OptionalAttr` // or `DefaultValuedAttr` without explicit name, returns the base attribute's // name. diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index f5eb6d3bd9a..2daccc8e23f 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -96,6 +96,14 @@ StringRef tblgen::Attribute::getConstBuilderTemplate() const { return getValueAsString(init); } +tblgen::Attribute tblgen::Attribute::getBaseAttr() const { + if (const auto *defInit = + llvm::dyn_cast(def->getValueInit("baseAttr"))) { + return Attribute(defInit).getBaseAttr(); + } + return *this; +} + bool tblgen::Attribute::hasDefaultValueInitializer() const { const auto *init = def->getValueInit("defaultValue"); return !getValueAsString(init).empty(); @@ -111,8 +119,9 @@ bool tblgen::Attribute::isOptional() const { } StringRef tblgen::Attribute::getAttrDefName() const { - if (def->isAnonymous() && (isOptional() || hasDefaultValueInitializer())) - return getValueAsString(def->getValueInit("baseAttr")); + if (def->isAnonymous()) { + return getBaseAttr().def->getName(); + } return def->getName(); } -- cgit v1.2.3 From c6cfebf1af5f37382314acec87332e19b0d6764a Mon Sep 17 00:00:00 2001 From: Mahesh Ravishankar Date: Wed, 17 Jul 2019 18:41:28 -0700 Subject: Automatically generate (de)serialization methods for SPIR-V ops For ops in SPIR-V dialect that are a direct mirror of SPIR-V operations, the serialization/deserialization methods can be automatically generated from the Op specification. To enable this an 'autogenSerialization' field is added to SPV_Ops. When set to non-zero, this will enable the automatic (de)serialization function generation Also adding tests that verify the spv.Load, spv.Store and spv.Variable ops are serialized and deserialized correctly. To fully support these tests also add serialization and deserialization of float types and spv.ptr types PiperOrigin-RevId: 258684764 --- mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt | 2 +- mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td | 49 +++- mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td | 3 +- mlir/include/mlir/TableGen/Attribute.h | 4 + mlir/include/mlir/TableGen/Operator.h | 2 +- .../Dialect/SPIRV/Serialization/Deserializer.cpp | 83 ++++-- .../Dialect/SPIRV/Serialization/SPIRVBinaryUtils.h | 1 + .../lib/Dialect/SPIRV/Serialization/Serializer.cpp | 72 ++++- mlir/lib/TableGen/Attribute.cpp | 4 + mlir/lib/TableGen/Operator.cpp | 2 +- mlir/test/SPIRV/Serialization/load_store.mlir | 16 + mlir/test/SPIRV/Serialization/variables.mlir | 11 + mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp | 322 +++++++++++++++++++-- 13 files changed, 493 insertions(+), 78 deletions(-) create mode 100644 mlir/test/SPIRV/Serialization/load_store.mlir create mode 100644 mlir/test/SPIRV/Serialization/variables.mlir (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt b/mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt index dd933fe6357..af4520df130 100644 --- a/mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt +++ b/mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt @@ -9,7 +9,7 @@ mlir_tablegen(SPIRVEnums.cpp.inc -gen-enum-defs) add_public_tablegen_target(MLIRSPIRVEnumsIncGen) set(LLVM_TARGET_DEFINITIONS SPIRVOps.td) -mlir_tablegen(SPIRVSerialization.inc -gen-spirv-serial) +mlir_tablegen(SPIRVSerialization.inc -gen-spirv-serialization) add_public_tablegen_target(MLIRSPIRVSerializationGen) set(LLVM_TARGET_DEFINITIONS SPIRVBase.td) diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td index d9281234821..83f474cd780 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td @@ -1,4 +1,4 @@ -//===-- SPIRVOps.td - MLIR SPIR-V Op Definitions Spec ------*- tablegen -*-===// +//===- SPIRVBase.td - MLIR SPIR-V Op Definitions Base file -*- tablegen -*-===// // // Copyright 2019 The MLIR Authors. // @@ -76,6 +76,8 @@ def SPV_OC_OpMemoryModel : I32EnumAttrCase<"OpMemoryModel", 14>; def SPV_OC_OpEntryPoint : I32EnumAttrCase<"OpEntryPoint", 15>; def SPV_OC_OpExecutionMode : I32EnumAttrCase<"OpExecutionMode", 16>; def SPV_OC_OpTypeVoid : I32EnumAttrCase<"OpTypeVoid", 19>; +def SPV_OC_OpTypeFloat : I32EnumAttrCase<"OpTypeFloat", 22>; +def SPV_OC_OpTypePointer : I32EnumAttrCase<"OpTypePointer", 32>; def SPV_OC_OpTypeFunction : I32EnumAttrCase<"OpTypeFunction", 33>; def SPV_OC_OpFunction : I32EnumAttrCase<"OpFunction", 54>; def SPV_OC_OpFunctionParameter : I32EnumAttrCase<"OpFunctionParameter", 55>; @@ -91,10 +93,10 @@ def SPV_OC_OpReturn : I32EnumAttrCase<"OpReturn", 253>; def SPV_OpcodeAttr : I32EnumAttr<"Opcode", "valid SPIR-V instructions", [ SPV_OC_OpMemoryModel, SPV_OC_OpEntryPoint, SPV_OC_OpExecutionMode, - SPV_OC_OpTypeVoid, SPV_OC_OpTypeFunction, SPV_OC_OpFunction, - SPV_OC_OpFunctionParameter, SPV_OC_OpFunctionEnd, SPV_OC_OpVariable, - SPV_OC_OpLoad, SPV_OC_OpStore, SPV_OC_OpDecorate, SPV_OC_OpCompositeExtract, - SPV_OC_OpFMul, SPV_OC_OpReturn + SPV_OC_OpTypeVoid, SPV_OC_OpTypeFloat, SPV_OC_OpTypePointer, + SPV_OC_OpTypeFunction, SPV_OC_OpFunction, SPV_OC_OpFunctionParameter, + SPV_OC_OpFunctionEnd, SPV_OC_OpVariable, SPV_OC_OpLoad, SPV_OC_OpStore, + SPV_OC_OpDecorate, SPV_OC_OpCompositeExtract, SPV_OC_OpFMul, SPV_OC_OpReturn ]> { let returnType = "::mlir::spirv::Opcode"; let convertFromStorage = "static_cast<::mlir::spirv::Opcode>($_self.getInt())"; @@ -514,8 +516,6 @@ def ModuleOnly : class SPV_Op traits = []> : Op { - string spirvOpName = "Op" # mnemonic; - // For each SPIR-V op, the following static functions need to be defined // in SPVOps.cpp: // @@ -527,13 +527,34 @@ class SPV_Op traits = []> : let printer = [{ return ::print(*this, p); }]; let verifier = [{ return ::verify(*this); }]; - // By default the opcode to use for (de)serialization is obtained - // automatically from the SPIR-V spec. It assume the SPIR-V op being defined - // is ('Op' # mnemonic). The opcode value can be obtained by calling - // getOpcode(). If invoking this method is invalid or custom - // processing is needed for the op, set hasOpcode = 0 and specialize the - // getOpcode method. - int hasOpcode = 1; + // Specifies if the SPIR-V op has a direct representation of an instruction in + // SPIR-V spec. When set to 1, the ODS generates the dispatch to the + // (de)serialization methods for the op, and also generates the implementation + // of these processing methods (if autogenSerialization is also set to 1). + bit hasOpcode = 1; + + // Name of the corresponding SPIR-V op. Only valid to use when hasOpcode is 1 + string spirvOpName = "Op" # mnemonic; + + // Controls whether the (de)serialization method is generated automatically or + // not. This results in generation of the following methods: + // + // template Serialization::processOp(OpTy op) + // template Deserialization::processOp(ArrayRef) + // + // If the auto generation is disabled (set to 0), then manual implementation + // of a specialization of these methods is required. + // + // Note : + // + // 1) If hasOpcode is 1 and autogenSerialization is 0, the ODS generated + // dispatch function call the above method for the (de)serialization of the + // operation + // + // 2) If hasOpcode is 0, then ODS doesn't generate the (de)serialization + // methods, neither does it handle the dispatch. Those need to be handled + // manually. + bit autogenSerialization = 1; } #endif // SPIRV_BASE diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td index 3c1f2434c7b..b638bc8afa0 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td @@ -143,6 +143,7 @@ def SPV_EntryPointOp : SPV_Op<"EntryPoint", [ModuleOnly]> { ); let results = (outs SPV_EntryPoint:$id); + let autogenSerialization = 0; } // ----- @@ -344,7 +345,7 @@ def SPV_StoreOp : SPV_Op<"Store", []> { SPV_AnyPtr:$ptr, SPV_Type:$value, OptionalAttr:$memory_access, - OptionalAttr:$alignment + OptionalAttr:$alignment ); let results = (outs); diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index 6950510f51d..a1a7d0c820d 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -96,6 +96,10 @@ public: // of `TypeAttrBase`). bool isTypeAttr() const; + // Returns true if this attribute is an enum attribute (i.e., a subclass of + // `EnumAttrInfo`) + bool isEnumAttr() const; + // Returns this attribute's TableGen def name. If this is an `OptionalAttr` // or `DefaultValuedAttr` without explicit name, returns the base attribute's // name. diff --git a/mlir/include/mlir/TableGen/Operator.h b/mlir/include/mlir/TableGen/Operator.h index 37e7bc4e6c3..7cad27a4300 100644 --- a/mlir/include/mlir/TableGen/Operator.h +++ b/mlir/include/mlir/TableGen/Operator.h @@ -132,7 +132,7 @@ public: int getNumArgs() const { return arguments.size(); } // Op argument (attribute or operand) accessors. - Argument getArg(int index); + Argument getArg(int index) const; StringRef getArgName(int index) const; // Returns the number of `PredOpTrait` traits. diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp index cdd95e768ea..676ef8ec871 100644 --- a/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp @@ -88,9 +88,24 @@ private: LogicalResult processType(spirv::Opcode opcode, ArrayRef operands); LogicalResult processFunctionType(ArrayRef operands); - /// Process SPIR-V instructions that dont have any operands + /// Method to dispatch to the specialized deserialization function for an + /// operation in SPIR-V dialect that is a mirror of an operation in the SPIR-V + /// spec. This is auto-generated from ODS. Dispatch is handled for all + /// operations in SPIR-V dialect that have hasOpcode == 1 + LogicalResult dispatchToAutogenDeserialization(spirv::Opcode opcode, + ArrayRef words); + + /// Method to deserialize an operation in the SPIR-V dialect that is a mirror + /// of an instruction in the SPIR-V spec. This is auto generated if hasOpcode + /// == 1 and autogenSerialization == 1 in ODS. + template LogicalResult processOp(ArrayRef words) { + return processOpImpl(words); + } template - LogicalResult processNullaryInstruction(ArrayRef operands); + LogicalResult processOpImpl(ArrayRef words) { + return emitError(unknownLoc, "unsupported deserialization for op '") + << OpTy::getOperationName() << "')"; + } /// Process function objects in binary LogicalResult processFunction(ArrayRef operands); @@ -232,6 +247,39 @@ LogicalResult Deserializer::processType(spirv::Opcode opcode, } typeMap[operands[0]] = NoneType::get(context); break; + case spirv::Opcode::OpTypeFloat: { + if (operands.size() != 2) { + return emitError(unknownLoc, "OpTypeFloat must have bitwidth parameter"); + } + Type floatTy; + switch (operands[1]) { + case 16: + floatTy = opBuilder.getF16Type(); + break; + case 32: + floatTy = opBuilder.getF32Type(); + break; + case 64: + floatTy = opBuilder.getF64Type(); + break; + default: + return emitError(unknownLoc, "unsupported bitwdith ") + << operands[1] << " with OpTypeFloat"; + } + typeMap[operands[0]] = floatTy; + } break; + case spirv::Opcode::OpTypePointer: { + if (operands.size() != 3) { + return emitError(unknownLoc, "OpTypePointer must have two parameters"); + } + auto pointeeType = getType(operands[2]); + if (!pointeeType) { + return emitError(unknownLoc, "unknown OpTypePointer pointee type : ") + << operands[2]; + } + auto storageClass = static_cast(operands[1]); + typeMap[operands[0]] = spirv::PointerType::get(pointeeType, storageClass); + } break; case spirv::Opcode::OpTypeFunction: return processFunctionType(operands); default: @@ -240,18 +288,6 @@ LogicalResult Deserializer::processType(spirv::Opcode opcode, return success(); } -template -LogicalResult -Deserializer::processNullaryInstruction(ArrayRef operands) { - if (!operands.empty()) { - return emitError(unknownLoc) << stringifyOpcode(spirv::getOpcode()) - << " must have no operands, but found " - << operands.size() << " operands"; - } - opBuilder.create(unknownLoc); - return success(); -} - LogicalResult Deserializer::processFunction(ArrayRef operands) { // Get the result type if (operands.size() != 4) { @@ -314,7 +350,7 @@ LogicalResult Deserializer::processFunction(ArrayRef operands) { "expected result type and result for OpFunctionParameter"); } auto argDefinedType = getType(operands[0]); - if (argDefinedType || argDefinedType != argType) { + if (!argDefinedType || argDefinedType != argType) { return emitError(unknownLoc, "mismatch in argument type between function type " "definition ") @@ -352,23 +388,26 @@ LogicalResult Deserializer::processFunction(ArrayRef operands) { return success(); } +#define GET_DESERIALIZATION_FNS +#include "mlir/Dialect/SPIRV/SPIRVSerialization.inc" + LogicalResult Deserializer::processInstruction(spirv::Opcode opcode, ArrayRef operands) { + // First dispatch all the instructions whose opcode does not correspond to + // those that have a direct mirror in the SPIR-V dialect switch (opcode) { case spirv::Opcode::OpMemoryModel: return processMemoryModel(operands); - case spirv::Opcode::OpTypeVoid: + case spirv::Opcode::OpTypeFloat: case spirv::Opcode::OpTypeFunction: + case spirv::Opcode::OpTypePointer: + case spirv::Opcode::OpTypeVoid: return processType(opcode, operands); - case spirv::Opcode::OpReturn: - return processNullaryInstruction(operands); case spirv::Opcode::OpFunction: return processFunction(operands); - default: - break; + default:; } - return emitError(unknownLoc, "NYI: opcode ") - << spirv::stringifyOpcode(opcode); + return dispatchToAutogenDeserialization(opcode, operands); } LogicalResult Deserializer::processMemoryModel(ArrayRef operands) { diff --git a/mlir/lib/Dialect/SPIRV/Serialization/SPIRVBinaryUtils.h b/mlir/lib/Dialect/SPIRV/Serialization/SPIRVBinaryUtils.h index c04c725aaf0..12fb3d00be2 100644 --- a/mlir/lib/Dialect/SPIRV/Serialization/SPIRVBinaryUtils.h +++ b/mlir/lib/Dialect/SPIRV/Serialization/SPIRVBinaryUtils.h @@ -35,6 +35,7 @@ constexpr unsigned kHeaderWordCount = 5; /// SPIR-V magic number constexpr uint32_t kMagicNumber = 0x07230203; +#define GET_SPIRV_SERIALIZATION_UTILS #include "mlir/Dialect/SPIRV/SPIRVSerialization.inc" } // end namespace spirv diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp index ab931cc8269..b1c5936ae1a 100644 --- a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp @@ -41,7 +41,9 @@ static inline void buildInstruction(spirv::Opcode op, SmallVectorImpl &binary) { uint32_t wordCount = 1 + operands.size(); binary.push_back(getPrefixedOpcode(wordCount, op)); - binary.append(operands.begin(), operands.end()); + if (!operands.empty()) { + binary.append(operands.begin(), operands.end()); + } } namespace { @@ -90,11 +92,24 @@ private: // Main method to dispatch operation serialization LogicalResult processOperation(Operation *op); + /// Method to dispatch to the serialization function for an operation in + /// SPIR-V dialect that is a mirror of an instruction in the SPIR-V spec. This + /// is auto-generated from ODS. Dispatch is handled for all operations in + /// SPIR-V dialect that have hasOpcode == 1 + LogicalResult dispatchToAutogenSerialization(Operation *op); + + /// Method to serialize an operation in the SPIR-V dialect that is a mirror of + /// an instruction in the SPIR-V spec. This is auto generated if hasOpcode == + /// 1 and autogenSerialization == 1 in ODS + template LogicalResult processOp(OpTy op) { + return processOpImpl(op); + } + template LogicalResult processOpImpl(OpTy op) { + return op.emitError("unsupported op serialization"); + } + // Methods to serialize individual operation types LogicalResult processFuncOp(FuncOp op); - // Serialize op that dont produce a value and have no operands, like - // spirv::ReturnOp - template LogicalResult processNullaryOp(OpType op); uint32_t getNextID() { return nextID++; } @@ -103,6 +118,16 @@ private: return (it != typeIDMap.end() ? it->second : Optional(None)); } + Optional findValueID(Value *val) const { + auto it = valueIDMap.find(val); + return (it != valueIDMap.end() ? it->second : Optional(None)); + } + + Optional findFunctionID(Operation *op) const { + auto it = funcIDMap.find(op); + return (it != funcIDMap.end() ? it->second : Optional(None)); + } + Type voidType() { return mlir::NoneType::get(module.getContext()); } bool isVoidType(Type type) const { return type.isa(); } @@ -133,6 +158,9 @@ private: // Map from FuncOps to IDs DenseMap funcIDMap; + + // Map from Value to Ids + DenseMap valueIDMap; }; } // namespace @@ -245,6 +273,20 @@ Serializer::processBasicType(Location loc, Type type, spirv::Opcode &typeEnum, if (isVoidType(type)) { typeEnum = spirv::Opcode::OpTypeVoid; return success(); + } else if (type.isa()) { + typeEnum = spirv::Opcode::OpTypeFloat; + operands.push_back(type.cast().getWidth()); + return success(); + } else if (type.isa()) { + auto ptrType = type.cast(); + uint32_t pointeeTypeID = 0; + if (failed(processType(loc, ptrType.getPointeeType(), pointeeTypeID))) { + return failure(); + } + typeEnum = spirv::Opcode::OpTypePointer; + operands.push_back(static_cast(ptrType.getStorageClass())); + operands.push_back(pointeeTypeID); + return success(); } /// TODO(ravishankarm) : Handle other types return emitError(loc, "unhandled type in serialization : ") << type; @@ -275,15 +317,14 @@ Serializer::processFunctionType(Location loc, FunctionType type, } LogicalResult Serializer::processOperation(Operation *op) { + // First dispatch the methods that do not directly mirror an operation from + // the SPIR-V spec if (isa(op)) { return processFuncOp(cast(op)); - } else if (isa(op)) { - return processNullaryOp(cast(op)); } else if (isa(op)) { return success(); } - /// TODO(ravishankarm) : Handle other ops - return op->emitError("unhandled operation serialization"); + return dispatchToAutogenSerialization(op); } LogicalResult Serializer::processFuncOp(FuncOp op) { @@ -314,13 +355,15 @@ LogicalResult Serializer::processFuncOp(FuncOp op) { buildInstruction(spirv::Opcode::OpFunction, operands, functions); // Declare the parameters - for (auto argType : op.getType().getInputs()) { + for (auto arg : op.getArguments()) { uint32_t argTypeID = 0; - if (failed(processType(op.getLoc(), argType, argTypeID))) { + if (failed(processType(op.getLoc(), arg->getType(), argTypeID))) { return failure(); } + auto argValueID = getNextID(); + valueIDMap[arg] = argValueID; buildInstruction(spirv::Opcode::OpFunctionParameter, - {argTypeID, getNextID()}, functions); + {argTypeID, argValueID}, functions); } // Process the body @@ -345,11 +388,8 @@ LogicalResult Serializer::processFuncOp(FuncOp op) { return success(); } -template -LogicalResult Serializer::processNullaryOp(OpType op) { - buildInstruction(spirv::getOpcode(), ArrayRef(), functions); - return success(); -} +#define GET_SERIALIZATION_FNS +#include "mlir/Dialect/SPIRV/SPIRVSerialization.inc" LogicalResult spirv::serialize(spirv::ModuleOp module, SmallVectorImpl &binary) { diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index 2daccc8e23f..abf0ef06f0c 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -63,6 +63,10 @@ bool tblgen::Attribute::isTypeAttr() const { return def->isSubClassOf("TypeAttrBase"); } +bool tblgen::Attribute::isEnumAttr() const { + return def->isSubClassOf("EnumAttrInfo"); +} + bool tblgen::Attribute::hasStorageType() const { const auto *init = def->getValueInit("storageType"); return !getValueAsString(init).empty(); diff --git a/mlir/lib/TableGen/Operator.cpp b/mlir/lib/TableGen/Operator.cpp index 0a921369d6b..ba919184efe 100644 --- a/mlir/lib/TableGen/Operator.cpp +++ b/mlir/lib/TableGen/Operator.cpp @@ -217,7 +217,7 @@ auto tblgen::Operator::getOperands() -> value_range { return {operand_begin(), operand_end()}; } -auto tblgen::Operator::getArg(int index) -> Argument { +auto tblgen::Operator::getArg(int index) const -> Argument { return arguments[index]; } diff --git a/mlir/test/SPIRV/Serialization/load_store.mlir b/mlir/test/SPIRV/Serialization/load_store.mlir new file mode 100644 index 00000000000..a6d66c744dc --- /dev/null +++ b/mlir/test/SPIRV/Serialization/load_store.mlir @@ -0,0 +1,16 @@ +// RUN: mlir-translate -serialize-spirv %s | mlir-translate -deserialize-spirv | FileCheck %s + +// CHECK: func {{@.*}}([[ARG1:%.*]]: !spv.ptr, [[ARG2:%.*]]: !spv.ptr) { +// CHECK-NEXT: [[VALUE:%.*]] = spv.Load "Input" [[ARG1]] : f32 +// CHECK-NEXT: spv.Store "Output" [[ARG2]], [[VALUE]] : f32 + +func @spirv_loadstore() -> () { + spv.module "Logical" "VulkanKHR" { + func @load_store(%arg0 : !spv.ptr, %arg1 : !spv.ptr) { + %1 = spv.Load "Input" %arg0 : f32 + spv.Store "Output" %arg1, %1 : f32 + spv.Return + } + } + return +} \ No newline at end of file diff --git a/mlir/test/SPIRV/Serialization/variables.mlir b/mlir/test/SPIRV/Serialization/variables.mlir new file mode 100644 index 00000000000..dbb1f7fd380 --- /dev/null +++ b/mlir/test/SPIRV/Serialization/variables.mlir @@ -0,0 +1,11 @@ +// RUN: mlir-translate -serialize-spirv %s | mlir-translate -deserialize-spirv | FileCheck %s + +// CHECK: {{%.*}} = spv.Variable : !spv.ptr +// CHECK-NEXT: {{%.*}} = spv.Variable : !spv.ptr +func @spirv_variables() -> () { + spv.module "Logical" "VulkanKHR" { + %2 = spv.Variable : !spv.ptr + %3 = spv.Variable : !spv.ptr + } + return +} \ No newline at end of file diff --git a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp index 1dcf40fda28..869fe1ad15b 100644 --- a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp +++ b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp @@ -32,39 +32,317 @@ #include "llvm/TableGen/Record.h" #include "llvm/TableGen/TableGenBackend.h" +using llvm::ArrayRef; using llvm::formatv; using llvm::raw_ostream; +using llvm::raw_string_ostream; using llvm::Record; using llvm::RecordKeeper; +using llvm::SMLoc; +using mlir::tblgen::Attribute; using mlir::tblgen::EnumAttr; +using mlir::tblgen::NamedAttribute; +using mlir::tblgen::NamedTypeConstraint; using mlir::tblgen::Operator; // Writes the following function to `os`: // inline uint32_t getOpcode() { return ; } -static void emitGetOpcodeFunction(const llvm::Record &record, - Operator const &op, raw_ostream &os) { - if (record.getValueAsInt("hasOpcode")) { - os << formatv("template <> constexpr inline ::mlir::spirv::Opcode " - "getOpcode<{0}>()", - op.getQualCppClassName()) - << " {\n " - << formatv("return ::mlir::spirv::Opcode::Op{0};\n}\n", - record.getValueAsString("opName")); - } +static void emitGetOpcodeFunction(const Record *record, Operator const &op, + raw_ostream &os) { + os << formatv("template <> constexpr inline ::mlir::spirv::Opcode " + "getOpcode<{0}>()", + op.getQualCppClassName()) + << " {\n " + << formatv("return ::mlir::spirv::Opcode::{0};\n}\n", + record->getValueAsString("spirvOpName")); } -static bool emitSerializationUtils(const RecordKeeper &recordKeeper, - raw_ostream &os) { - llvm::emitSourceFileHeader("SPIR-V Serialization Utilities", os); - - /// Define the function to get the opcode +static void declareOpcodeFn(raw_ostream &os) { os << "template inline constexpr ::mlir::spirv::Opcode " "getOpcode();\n"; +} + +static void emitAttributeSerialization(const Attribute &attr, + ArrayRef loc, llvm::StringRef op, + llvm::StringRef operandList, + llvm::StringRef attrName, + raw_ostream &os) { + os << " auto attr = " << op << ".getAttr(\"" << attrName << "\");\n"; + os << " if (attr) {\n"; + if (attr.getAttrDefName() == "I32ArrayAttr") { + // Serialize all the elements of the array + os << " for (auto attrElem : attr.cast()) {\n"; + os << " " << operandList + << ".push_back(static_cast(attrElem.cast()." + "getValue().getZExtValue()));\n"; + os << " }\n"; + } else if (attr.isEnumAttr() || attr.getAttrDefName() == "I32Attr") { + os << " " << operandList + << ".push_back(static_cast(attr.cast().getValue()" + ".getZExtValue()));\n"; + } else { + PrintFatalError( + loc, + llvm::Twine( + "unhandled attribute type in SPIR-V serialization generation : '") + + attr.getAttrDefName() + llvm::Twine("'")); + } + os << " }\n"; +} + +static void emitSerializationFunction(const Record *record, const Operator &op, + raw_ostream &os) { + // If the record has 'autogenSerialization' set to 0, nothing to do + if (!record->getValueAsBit("autogenSerialization")) { + return; + } + os << formatv("template <> LogicalResult\nSerializer::processOpImpl<{0}>(\n" + " {0} op)", + op.getQualCppClassName()) + << " {\n"; + os << " SmallVector operands;\n"; + + // Serialize result information + if (op.getNumResults() == 1) { + os << " {\n"; + os << " uint32_t typeID = 0;\n"; + os << " if (failed(processType(op.getLoc(), " + "op.getResult()->getType(), typeID))) {\n"; + os << " return failure();\n"; + os << " }\n"; + os << " operands.push_back(typeID);\n"; + /// Create an SSA result for the op + os << " auto resultID = getNextID();\n"; + os << " valueIDMap[op.getResult()] = resultID;\n"; + os << " operands.push_back(resultID);\n"; + os << " }\n"; + } else if (op.getNumResults() != 0) { + PrintFatalError(record->getLoc(), "SPIR-V ops can only zero or one result"); + } + + // Process arguments + auto operandNum = 0; + for (unsigned i = 0, e = op.getNumArgs(); i < e; ++i) { + auto argument = op.getArg(i); + os << " {\n"; + if (argument.is()) { + os << " if (" << operandNum + << " < op.getOperation()->getNumOperands()) {\n"; + os << " auto arg = findValueID(op.getOperation()->getOperand(" + << operandNum << "));\n"; + os << " if (!arg) {\n"; + os << " emitError(op.getLoc(), \"operand " << operandNum + << " has a use before def\");\n"; + os << " }\n"; + os << " operands.push_back(arg.getValue());\n"; + os << " }\n"; + operandNum++; + } else { + auto attr = argument.get(); + emitAttributeSerialization( + (attr->attr.isOptional() ? attr->attr.getBaseAttr() : attr->attr), + record->getLoc(), "op", "operands", attr->name, os); + } + os << " }\n"; + } + + os << formatv( + " buildInstruction(spirv::getOpcode<{0}>(), operands, functions);\n", + op.getQualCppClassName()); + os << " return success();\n"; + os << "}\n\n"; +} + +static void initDispatchSerializationFn(raw_ostream &os) { + os << "LogicalResult Serializer::dispatchToAutogenSerialization(Operation " + "*op) {\n "; +} + +static void emitSerializationDispatch(const Operator &op, raw_ostream &os) { + os << formatv(" if (isa<{0}>(op)) ", op.getQualCppClassName()) << "{\n"; + os << " "; + os << formatv("return processOp<{0}>(cast<{0}>(op));\n", + op.getQualCppClassName()); + os << " } else"; +} + +static void finalizeDispatchSerializationFn(raw_ostream &os) { + os << " {\n"; + os << " return op->emitError(\"unhandled operation serialization\");\n"; + os << " }\n"; + os << " return success();\n"; + os << "}\n\n"; +} + +static void emitAttributeDeserialization( + const Attribute &attr, ArrayRef loc, llvm::StringRef attrList, + llvm::StringRef attrName, llvm::StringRef operandsList, + llvm::StringRef wordIndex, llvm::StringRef wordCount, raw_ostream &os) { + if (attr.getAttrDefName() == "I32ArrayAttr") { + os << " SmallVector attrListElems;\n"; + os << " while (" << wordIndex << " < " << wordCount << ") {\n"; + os << " attrListElems.push_back(opBuilder.getI32IntegerAttr(" + << operandsList << "[" << wordIndex << "++]));\n"; + os << " }\n"; + os << " " << attrList << ".push_back(opBuilder.getNamedAttr(\"" + << attrName << "\", opBuilder.getArrayAttr(attrListElems)));\n"; + } else if (attr.isEnumAttr() || attr.getAttrDefName() == "I32Attr") { + os << " " << attrList << ".push_back(opBuilder.getNamedAttr(\"" + << attrName << "\", opBuilder.getI32IntegerAttr(" << operandsList << "[" + << wordIndex << "++])));\n"; + } else { + PrintFatalError( + loc, llvm::Twine( + "unhandled attribute type in deserialization generation : '") + + attr.getAttrDefName() + llvm::Twine("'")); + } +} + +static void emitDeserializationFunction(const Record *record, + const Operator &op, raw_ostream &os) { + // If the record has 'autogenSerialization' set to 0, nothing to do + if (!record->getValueAsBit("autogenSerialization")) { + return; + } + os << formatv("template <> " + "LogicalResult\nDeserializer::processOpImpl<{0}>(ArrayRef<" + "uint32_t> words)", + op.getQualCppClassName()); + os << " {\n"; + os << " SmallVector resultTypes;\n"; + os << " size_t wordIndex = 0;\n"; + + // Deserialize result information if it exists + bool hasResult = false; + if (op.getNumResults() == 1) { + os << " {\n"; + os << " if (wordIndex >= words.size()) {\n"; + os << " " + << formatv("return emitError(unknownLoc, \"expected result type " + "while deserializing {0}\");\n", + op.getQualCppClassName()); + os << " }\n"; + os << " auto ty = getType(words[wordIndex]);\n"; + os << " if (!ty) {\n"; + os << " return emitError(unknownLoc, \"unknown type result : " + "\") << words[wordIndex];\n"; + os << " }\n"; + os << " resultTypes.push_back(ty);\n"; + os << " wordIndex++;\n"; + os << " }\n"; + os << " if (wordIndex >= words.size()) {\n"; + os << " " + << formatv("return emitError(unknownLoc, \"expected result while " + "deserializing {0}\");\n", + op.getQualCppClassName()); + os << " }\n"; + os << " uint32_t valueID = words[wordIndex++];\n"; + hasResult = true; + } else if (op.getNumResults() != 0) { + PrintFatalError(record->getLoc(), + "SPIR-V ops can have only zero or one result"); + } + + // Process arguments/attributes + os << " SmallVector operands;\n"; + os << " SmallVector attributes;\n"; + unsigned operandNum = 0; + for (unsigned i = 0, e = op.getNumArgs(); i < e; ++i) { + auto argument = op.getArg(i); + os << " if (wordIndex < words.size()) {\n"; + if (argument.is()) { + os << " auto arg = getValue(words[wordIndex]);\n"; + os << " if (!arg) {\n"; + os << " return emitError(unknownLoc, \"unknown result : \") << " + "words[wordIndex];\n"; + os << " }\n"; + os << " operands.push_back(arg);\n"; + os << " wordIndex++;\n"; + operandNum++; + } else { + auto attr = argument.get(); + emitAttributeDeserialization( + (attr->attr.isOptional() ? attr->attr.getBaseAttr() : attr->attr), + record->getLoc(), "attributes", attr->name, "words", "wordIndex", + "words.size()", os); + } + os << " }\n"; + } + + os << formatv(" auto op = opBuilder.create<{0}>(unknownLoc, resultTypes, " + "operands, attributes);\n", + op.getQualCppClassName()); + if (hasResult) { + os << " valueMap[valueID] = op.getResult();\n"; + } + os << " return success();\n"; + os << "}\n\n"; +} + +static void initDispatchDeserializationFn(raw_ostream &os) { + os << "LogicalResult " + "Deserializer::dispatchToAutogenDeserialization(spirv::Opcode " + "opcode, ArrayRef words) {\n"; + os << " switch (opcode) {\n"; +} + +static void emitDeserializationDispatch(const Operator &op, const Record *def, + raw_ostream &os) { + os << formatv(" case spirv::Opcode::{0}:\n", + def->getValueAsString("spirvOpName")); + os << formatv(" return processOp<{0}>(words);\n", + op.getQualCppClassName()); +} + +static void finalizeDispatchDeserializationFn(raw_ostream &os) { + os << " default:\n"; + os << " ;\n"; + os << " }\n"; + os << " return emitError(unknownLoc, \"unhandled deserialization of \") << " + "spirv::stringifyOpcode(opcode);\n"; + os << "}\n"; +} + +static bool emitSerializationFns(const RecordKeeper &recordKeeper, + raw_ostream &os) { + llvm::emitSourceFileHeader("SPIR-V Serialization Utilities/Functions", os); + + std::string dSerFnString, dDesFnString, serFnString, deserFnString, + utilsString; + raw_string_ostream dSerFn(dSerFnString), dDesFn(dDesFnString), + serFn(serFnString), deserFn(deserFnString), utils(utilsString); + + declareOpcodeFn(utils); + initDispatchSerializationFn(dSerFn); + initDispatchDeserializationFn(dDesFn); auto defs = recordKeeper.getAllDerivedDefinitions("SPV_Op"); for (const auto *def : defs) { + if (!def->getValueAsBit("hasOpcode")) { + continue; + } Operator op(def); - emitGetOpcodeFunction(*def, op, os); + emitGetOpcodeFunction(def, op, utils); + emitSerializationFunction(def, op, serFn); + emitSerializationDispatch(op, dSerFn); + emitDeserializationFunction(def, op, deserFn); + emitDeserializationDispatch(op, def, dDesFn); } + finalizeDispatchSerializationFn(dSerFn); + finalizeDispatchDeserializationFn(dDesFn); + + os << "#ifdef GET_SPIRV_SERIALIZATION_UTILS\n"; + os << utils.str(); + os << "#endif // GET_SPIRV_SERIALIZATION_UTILS\n\n"; + + os << "#ifdef GET_SERIALIZATION_FNS\n\n"; + os << serFn.str(); + os << dSerFn.str(); + os << "#endif // GET_SERIALIZATION_FNS\n\n"; + + os << "#ifdef GET_DESERIALIZATION_FNS\n\n"; + os << deserFn.str(); + os << dDesFn.str(); + os << "#endif // GET_DESERIALIZATION_FNS\n\n"; return false; } @@ -134,12 +412,12 @@ static bool emitOpUtils(const RecordKeeper &recordKeeper, raw_ostream &os) { } // Registers the enum utility generator to mlir-tblgen. -static mlir::GenRegistration - genSerializationDefs("gen-spirv-serial", - "Generate SPIR-V serialization utility definitions", - [](const RecordKeeper &records, raw_ostream &os) { - return emitSerializationUtils(records, os); - }); +static mlir::GenRegistration genSerialization( + "gen-spirv-serialization", + "Generate SPIR-V (de)serialization utilities and functions", + [](const RecordKeeper &records, raw_ostream &os) { + return emitSerializationFns(records, os); + }); static mlir::GenRegistration genOpUtils("gen-spirv-op-utils", -- cgit v1.2.3 From 4be7e8627f58d701f3a6993c352819008cc12d4c Mon Sep 17 00:00:00 2001 From: Jacques Pienaar Date: Mon, 29 Jul 2019 14:52:51 -0700 Subject: Remove dead code. PiperOrigin-RevId: 260585594 --- mlir/include/mlir/TableGen/Attribute.h | 6 ------ mlir/include/mlir/TableGen/Operator.h | 15 --------------- mlir/include/mlir/TableGen/Type.h | 16 ---------------- mlir/lib/TableGen/Attribute.cpp | 9 --------- mlir/lib/TableGen/Operator.cpp | 35 ---------------------------------- mlir/lib/TableGen/Type.cpp | 14 -------------- 6 files changed, 95 deletions(-) (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index a1a7d0c820d..2f137a2aca4 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -52,9 +52,6 @@ public: explicit Attribute(const llvm::Record *record); explicit Attribute(const llvm::DefInit *init); - // Returns true if this attribute has storage type set. - bool hasStorageType() const; - // Returns the storage type if set. Returns the default storage type // ("Attribute") otherwise. StringRef getStorageType() const; @@ -154,9 +151,6 @@ public: explicit EnumAttr(const llvm::Record &record); explicit EnumAttr(const llvm::DefInit *init); - // Returns true if this EnumAttr is backed by a StringAttr. - bool isStrEnum() const; - // Returns the enum class name. StringRef getEnumClassName() const; diff --git a/mlir/include/mlir/TableGen/Operator.h b/mlir/include/mlir/TableGen/Operator.h index 7cad27a4300..d9b60d236fc 100644 --- a/mlir/include/mlir/TableGen/Operator.h +++ b/mlir/include/mlir/TableGen/Operator.h @@ -59,9 +59,6 @@ public: // format if its dialect name is not empty. std::string getOperationName() const; - // Returns this op's C++ namespaces. - StringRef getCppNamespaces() const; - // Returns this op's C++ class name. StringRef getCppClassName() const; @@ -106,13 +103,9 @@ public: llvm::iterator_range getAttributes() const; int getNumAttributes() const { return attributes.size(); } - // Returns the total number of native attributes. - int getNumNativeAttributes() const; - int getNumDerivedAttributes() const; // Op attribute accessors. NamedAttribute &getAttribute(int index) { return attributes[index]; } - const NamedAttribute &getAttribute(int index) const; // Op operand iterators. value_iterator operand_begin(); @@ -135,19 +128,11 @@ public: Argument getArg(int index) const; StringRef getArgName(int index) const; - // Returns the number of `PredOpTrait` traits. - int getNumPredOpTraits() const; - // Returns true if this op has the given MLIR C++ `trait`. // TODO: We should add a C++ wrapper class for TableGen OpTrait instead of // requiring the raw MLIR trait here. bool hasTrait(llvm::StringRef trait) const; - using const_region_iterator = const NamedRegion *; - const_region_iterator region_begin() const; - const_region_iterator region_end() const; - llvm::iterator_range getRegions() const; - // Returns the number of regions. unsigned getNumRegions() const; // Returns the `index`-th region. diff --git a/mlir/include/mlir/TableGen/Type.h b/mlir/include/mlir/TableGen/Type.h index a4241ef0892..c7f92e4b74b 100644 --- a/mlir/include/mlir/TableGen/Type.h +++ b/mlir/include/mlir/TableGen/Type.h @@ -46,22 +46,6 @@ public: bool isVariadic() const; }; -// Wrapper class providing helper methods for accessing MLIR Type defined -// in TableGen. This class should closely reflect what is defined as -// class Type in TableGen. -class Type : public TypeConstraint { -public: - explicit Type(const llvm::Record *record); - explicit Type(const llvm::DefInit *init); - - // Returns the TableGen def name for this type. - StringRef getTableGenDefName() const; - - // Gets the base type of this variadic type constraint. - // Precondition: isVariadic() is true. - Type getVariadicBaseType() const; -}; - } // end namespace tblgen } // end namespace mlir diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index abf0ef06f0c..b42bb94e3fc 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -67,11 +67,6 @@ bool tblgen::Attribute::isEnumAttr() const { return def->isSubClassOf("EnumAttrInfo"); } -bool tblgen::Attribute::hasStorageType() const { - const auto *init = def->getValueInit("storageType"); - return !getValueAsString(init).empty(); -} - StringRef tblgen::Attribute::getStorageType() const { const auto *init = def->getValueInit("storageType"); auto type = getValueAsString(init); @@ -175,10 +170,6 @@ tblgen::EnumAttr::EnumAttr(const llvm::Record &record) : Attribute(&record) {} tblgen::EnumAttr::EnumAttr(const llvm::DefInit *init) : EnumAttr(init->getDef()) {} -bool tblgen::EnumAttr::isStrEnum() const { - return def->isSubClassOf("StrEnumAttr"); -} - StringRef tblgen::EnumAttr::getEnumClassName() const { return def->getValueAsString("className"); } diff --git a/mlir/lib/TableGen/Operator.cpp b/mlir/lib/TableGen/Operator.cpp index ba919184efe..60fecf7cdde 100644 --- a/mlir/lib/TableGen/Operator.cpp +++ b/mlir/lib/TableGen/Operator.cpp @@ -62,10 +62,6 @@ std::string tblgen::Operator::getOperationName() const { StringRef tblgen::Operator::getDialectName() const { return dialect.getName(); } -StringRef tblgen::Operator::getCppNamespaces() const { - return dialect.getCppNamespace(); -} - StringRef tblgen::Operator::getCppClassName() const { return cppClassName; } std::string tblgen::Operator::getQualCppClassName() const { @@ -124,18 +120,6 @@ unsigned tblgen::Operator::getNumVariadicResults() const { [](const NamedTypeConstraint &c) { return c.constraint.isVariadic(); }); } -int tblgen::Operator::getNumNativeAttributes() const { - return numNativeAttributes; -} - -int tblgen::Operator::getNumDerivedAttributes() const { - return getNumAttributes() - getNumNativeAttributes(); -} - -const tblgen::NamedAttribute &tblgen::Operator::getAttribute(int index) const { - return attributes[index]; -} - unsigned tblgen::Operator::getNumVariadicOperands() const { return std::count_if( operands.begin(), operands.end(), @@ -147,12 +131,6 @@ StringRef tblgen::Operator::getArgName(int index) const { return argumentValues->getArgName(index)->getValue(); } -int tblgen::Operator::getNumPredOpTraits() const { - return std::count_if(traits.begin(), traits.end(), [](const OpTrait &trait) { - return isa(&trait); - }); -} - bool tblgen::Operator::hasTrait(StringRef trait) const { for (auto t : getTraits()) { if (auto opTrait = dyn_cast(&t)) { @@ -166,19 +144,6 @@ bool tblgen::Operator::hasTrait(StringRef trait) const { return false; } -tblgen::Operator::const_region_iterator tblgen::Operator::region_begin() const { - return regions.begin(); -} - -tblgen::Operator::const_region_iterator tblgen::Operator::region_end() const { - return regions.end(); -} - -llvm::iterator_range -tblgen::Operator::getRegions() const { - return {region_begin(), region_end()}; -} - unsigned tblgen::Operator::getNumRegions() const { return regions.size(); } const tblgen::NamedRegion &tblgen::Operator::getRegion(unsigned index) const { diff --git a/mlir/lib/TableGen/Type.cpp b/mlir/lib/TableGen/Type.cpp index 1d7505af343..340fb4b89f8 100644 --- a/mlir/lib/TableGen/Type.cpp +++ b/mlir/lib/TableGen/Type.cpp @@ -36,17 +36,3 @@ tblgen::TypeConstraint::TypeConstraint(const llvm::DefInit *init) bool tblgen::TypeConstraint::isVariadic() const { return def->isSubClassOf("Variadic"); } - -tblgen::Type::Type(const llvm::Record *record) : TypeConstraint(record) { - assert(def->isSubClassOf("Type") && - "must be subclass of TableGen 'Type' class"); -} - -tblgen::Type::Type(const llvm::DefInit *init) : Type(init->getDef()) {} - -StringRef tblgen::Type::getTableGenDefName() const { return def->getName(); } - -tblgen::Type tblgen::Type::getVariadicBaseType() const { - assert(isVariadic() && "must be variadic type constraint"); - return Type(def->getValueAsDef("baseType")); -} -- cgit v1.2.3 From 8f90a442c3e3d4b727b013a520a3e9520bbd2784 Mon Sep 17 00:00:00 2001 From: Rob Suderman Date: Fri, 30 Aug 2019 12:51:31 -0700 Subject: Added a TableGen generator for structured data Similar to enum, added a generator for structured data. This provide Dictionary that stores a fixed set of values and guarantees the values are valid. It is intended to store a fixed number of values by a given name. PiperOrigin-RevId: 266437460 --- mlir/include/mlir/IR/OpBase.td | 25 ++- mlir/include/mlir/TableGen/Attribute.h | 30 ++++ mlir/lib/TableGen/Attribute.cpp | 52 ++++++ mlir/tools/mlir-tblgen/CMakeLists.txt | 1 + mlir/tools/mlir-tblgen/StructsGen.cpp | 259 +++++++++++++++++++++++++++++ mlir/unittests/TableGen/CMakeLists.txt | 7 + mlir/unittests/TableGen/StructsGenTest.cpp | 146 ++++++++++++++++ mlir/unittests/TableGen/structs.td | 29 ++++ 8 files changed, 548 insertions(+), 1 deletion(-) create mode 100644 mlir/tools/mlir-tblgen/StructsGen.cpp create mode 100644 mlir/unittests/TableGen/StructsGenTest.cpp create mode 100644 mlir/unittests/TableGen/structs.td (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index dd9d4e29e4b..b4c921e6f52 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -838,7 +838,7 @@ class I64EnumAttr()">, +class DictionaryAttr : Attr()">, "dictionary of named attribute values"> { let storageType = [{ DictionaryAttr }]; let returnType = [{ DictionaryAttr }]; @@ -914,6 +914,29 @@ def I32ElementsAttr : Attr< "{$_builder.getI32IntegerAttr($0)})"; let convertFromStorage = "$_self"; } +// Attribute information for an Attribute field within a StructAttr. +class StructFieldAttr { + // Name of this field in the StructAttr. + string name = thisName; + + // Attribute type wrapped by the struct attr. + Attr type = thisType; +} + +// Structured attribute that wraps a DictionaryAttr and provides both a +// validation method and set of accessors for a fixed set of fields. This is +// useful when representing data that would normally be in a structure. +class StructAttr attributes> : DictionaryAttr { + // Name for this StructAttr. + string className = name; + + // The dialect this StructAttr belongs to. + Dialect structDialect = dialect; + + // List of fields that the StructAttr contains. + list fields = attributes; +} // Attributes containing symbol references. def SymbolRefAttr : Attr()">, diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index 2f137a2aca4..1cff9fdfa8b 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -180,6 +180,36 @@ public: std::vector getAllCases() const; }; +class StructFieldAttr { +public: + explicit StructFieldAttr(const llvm::Record *record); + explicit StructFieldAttr(const llvm::Record &record); + explicit StructFieldAttr(const llvm::DefInit *init); + + StringRef getName() const; + Attribute getType() const; + +private: + const llvm::Record *def; +}; + +// Wrapper class providing helper methods for accessing struct attributes +// defined in TableGen. +class StructAttr : public Attribute { +public: + explicit StructAttr(const llvm::Record *record); + explicit StructAttr(const llvm::Record &record) : StructAttr(&record){}; + explicit StructAttr(const llvm::DefInit *init); + + // Returns the struct class name. + StringRef getStructClassName() const; + + // Returns the C++ namespaces this struct class should be placed in. + StringRef getCppNamespace() const; + + std::vector getAllFields() const; +}; + } // end namespace tblgen } // end namespace mlir diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index b42bb94e3fc..3d19de24429 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -210,3 +210,55 @@ std::vector tblgen::EnumAttr::getAllCases() const { return cases; } + +tblgen::StructFieldAttr::StructFieldAttr(const llvm::Record *record) + : def(record) { + assert(def->isSubClassOf("StructFieldAttr") && + "must be subclass of TableGen 'StructFieldAttr' class"); +} + +tblgen::StructFieldAttr::StructFieldAttr(const llvm::Record &record) + : StructFieldAttr(&record) {} + +tblgen::StructFieldAttr::StructFieldAttr(const llvm::DefInit *init) + : StructFieldAttr(init->getDef()) {} + +StringRef tblgen::StructFieldAttr::getName() const { + return def->getValueAsString("name"); +} + +tblgen::Attribute tblgen::StructFieldAttr::getType() const { + auto init = def->getValueInit("type"); + return tblgen::Attribute(cast(init)); +} + +tblgen::StructAttr::StructAttr(const llvm::Record *record) : Attribute(record) { + assert(def->isSubClassOf("StructAttr") && + "must be subclass of TableGen 'StructAttr' class"); +} + +tblgen::StructAttr::StructAttr(const llvm::DefInit *init) + : StructAttr(init->getDef()) {} + +StringRef tblgen::StructAttr::getStructClassName() const { + return def->getValueAsString("className"); +} + +StringRef tblgen::StructAttr::getCppNamespace() const { + Dialect dialect(def->getValueAsDef("structDialect")); + return dialect.getCppNamespace(); +} + +std::vector +tblgen::StructAttr::getAllFields() const { + std::vector attributes; + + const auto *inits = def->getValueAsListInit("fields"); + attributes.reserve(inits->size()); + + for (const llvm::Init *init : *inits) { + attributes.emplace_back(cast(init)); + } + + return attributes; +} diff --git a/mlir/tools/mlir-tblgen/CMakeLists.txt b/mlir/tools/mlir-tblgen/CMakeLists.txt index 067e1725e24..31c23b8bd38 100644 --- a/mlir/tools/mlir-tblgen/CMakeLists.txt +++ b/mlir/tools/mlir-tblgen/CMakeLists.txt @@ -13,5 +13,6 @@ add_tablegen(mlir-tblgen MLIR ReferenceImplGen.cpp RewriterGen.cpp SPIRVUtilsGen.cpp + StructsGen.cpp ) set_target_properties(mlir-tblgen PROPERTIES FOLDER "Tablegenning") diff --git a/mlir/tools/mlir-tblgen/StructsGen.cpp b/mlir/tools/mlir-tblgen/StructsGen.cpp new file mode 100644 index 00000000000..d8844957ece --- /dev/null +++ b/mlir/tools/mlir-tblgen/StructsGen.cpp @@ -0,0 +1,259 @@ +//===- StructsGen.cpp - MLIR struct utility generator ---------------------===// +// +// Copyright 2019 The MLIR Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================= +// +// StructsGen generates common utility functions for grouping attributes into a +// set of structured data. +// +//===----------------------------------------------------------------------===// + +#include "mlir/TableGen/Attribute.h" +#include "mlir/TableGen/Format.h" +#include "mlir/TableGen/GenInfo.h" +#include "mlir/TableGen/Operator.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/TableGen/Error.h" +#include "llvm/TableGen/Record.h" +#include "llvm/TableGen/TableGenBackend.h" + +using llvm::raw_ostream; +using llvm::Record; +using llvm::RecordKeeper; +using llvm::StringRef; +using mlir::tblgen::StructAttr; + +static void +emitStructClass(const Record &structDef, StringRef structName, + llvm::ArrayRef fields, + StringRef description, raw_ostream &os) { + const char *structInfo = R"( +// {0} +class {1} : public mlir::DictionaryAttr)"; + const char *structInfoEnd = R"( { +public: + using DictionaryAttr::DictionaryAttr; + static bool classof(mlir::Attribute attr); +)"; + os << formatv(structInfo, description, structName) << structInfoEnd; + + // Declares a constructor function for the tablegen structure. + // TblgenStruct::get(MLIRContext context, Type1 Field1, Type2 Field2, ...); + const char *getInfoDecl = " static {0} get(\n"; + const char *getInfoDeclArg = " {0} {1},\n"; + const char *getInfoDeclEnd = " mlir::MLIRContext* context);\n\n"; + + os << llvm::formatv(getInfoDecl, structName); + + for (auto field : fields) { + auto name = field.getName(); + auto type = field.getType(); + auto storage = type.getStorageType(); + os << llvm::formatv(getInfoDeclArg, storage, name); + } + os << getInfoDeclEnd; + + // Declares an accessor for the fields owned by the tablegen structure. + // namespace::storage TblgenStruct::field1() const; + const char *fieldInfo = R"( {0} {1}() const; +)"; + for (const auto field : fields) { + auto name = field.getName(); + auto type = field.getType(); + auto storage = type.getStorageType(); + os << formatv(fieldInfo, storage, name); + } + + os << "};\n\n"; +} + +static void emitStructDecl(const Record &structDef, raw_ostream &os) { + StructAttr structAttr(&structDef); + StringRef structName = structAttr.getStructClassName(); + StringRef cppNamespace = structAttr.getCppNamespace(); + StringRef description = structAttr.getDescription(); + auto fields = structAttr.getAllFields(); + + // Wrap in the appropriate namespace. + llvm::SmallVector namespaces; + llvm::SplitString(cppNamespace, namespaces, "::"); + + for (auto ns : namespaces) + os << "namespace " << ns << " {\n"; + + // Emit the struct class definition + emitStructClass(structDef, structName, fields, description, os); + + // Close the declared namespace. + for (auto ns : namespaces) + os << "} // namespace " << ns << "\n"; +} + +static bool emitStructDecls(const RecordKeeper &recordKeeper, raw_ostream &os) { + llvm::emitSourceFileHeader("Struct Utility Declarations", os); + + auto defs = recordKeeper.getAllDerivedDefinitions("StructAttr"); + for (const auto *def : defs) { + emitStructDecl(*def, os); + } + + return false; +} + +static void emitFactoryDef(llvm::StringRef structName, + llvm::ArrayRef fields, + raw_ostream &os) { + const char *getInfoDecl = "{0} {0}::get(\n"; + const char *getInfoDeclArg = " {0} {1},\n"; + const char *getInfoDeclEnd = " mlir::MLIRContext* context) {"; + + os << llvm::formatv(getInfoDecl, structName); + + for (auto field : fields) { + auto name = field.getName(); + auto type = field.getType(); + auto storage = type.getStorageType(); + os << llvm::formatv(getInfoDeclArg, storage, name); + } + os << getInfoDeclEnd; + + const char *fieldStart = R"( + llvm::SmallVector fields; +)"; + os << llvm::formatv(fieldStart, fields.size()); + + const char *getFieldInfo = R"( + assert({0}); + auto {0}_id = mlir::Identifier::get("{0}", context); + fields.emplace_back({0}_id, {0}); +)"; + + for (auto field : fields) { + os << llvm::formatv(getFieldInfo, field.getName()); + } + + const char *getEndInfo = R"( + Attribute dict = mlir::DictionaryAttr::get(fields, context); + return dict.dyn_cast<{0}>(); +} +)"; + os << llvm::formatv(getEndInfo, structName); +} + +static void emitClassofDef(llvm::StringRef structName, + llvm::ArrayRef fields, + raw_ostream &os) { + const char *classofInfo = R"( +bool {0}::classof(mlir::Attribute attr))"; + + const char *classofInfoHeader = R"( + auto derived = attr.dyn_cast(); + if (!derived) + return false; + if (derived.size() != {0}) + return false; +)"; + + os << llvm::formatv(classofInfo, structName) << " {"; + os << llvm::formatv(classofInfoHeader, fields.size()); + + const char *classofArgInfo = R"( + auto {0} = derived.get("{0}"); + if (!{0} || !{0}.isa<{1}>()) + return false; +)"; + for (auto field : fields) { + auto name = field.getName(); + auto type = field.getType(); + auto storage = type.getStorageType(); + os << llvm::formatv(classofArgInfo, name, storage); + } + + const char *classofEndInfo = R"( + return true; +} +)"; + os << classofEndInfo; +} + +static void +emitAccessorDef(llvm::StringRef structName, + llvm::ArrayRef fields, + raw_ostream &os) { + const char *fieldInfo = R"( +{0} {2}::{1}() const { + auto derived = this->cast(); + auto {1} = derived.get("{1}"); + assert({1} && "attribute not found."); + assert({1}.isa<{0}>() && "incorrect Attribute type found."); + return {1}.cast<{0}>(); +} +)"; + for (auto field : fields) { + auto name = field.getName(); + auto type = field.getType(); + auto storage = type.getStorageType(); + os << llvm::formatv(fieldInfo, storage, name, structName); + } +} + +static void emitStructDef(const Record &structDef, raw_ostream &os) { + StructAttr structAttr(&structDef); + StringRef cppNamespace = structAttr.getCppNamespace(); + StringRef structName = structAttr.getStructClassName(); + mlir::tblgen::FmtContext ctx; + auto fields = structAttr.getAllFields(); + + llvm::SmallVector namespaces; + llvm::SplitString(cppNamespace, namespaces, "::"); + + for (auto ns : namespaces) + os << "namespace " << ns << " {\n"; + + emitFactoryDef(structName, fields, os); + emitClassofDef(structName, fields, os); + emitAccessorDef(structName, fields, os); + + for (auto ns : llvm::reverse(namespaces)) + os << "} // namespace " << ns << "\n"; +} + +static bool emitStructDefs(const RecordKeeper &recordKeeper, raw_ostream &os) { + llvm::emitSourceFileHeader("Struct Utility Definitions", os); + + auto defs = recordKeeper.getAllDerivedDefinitions("StructAttr"); + for (const auto *def : defs) + emitStructDef(*def, os); + + return false; +} + +// Registers the struct utility generator to mlir-tblgen. +static mlir::GenRegistration + genStructDecls("gen-struct-attr-decls", + "Generate struct utility declarations", + [](const RecordKeeper &records, raw_ostream &os) { + return emitStructDecls(records, os); + }); + +// Registers the struct utility generator to mlir-tblgen. +static mlir::GenRegistration + genStructDefs("gen-struct-attr-defs", "Generate struct utility definitions", + [](const RecordKeeper &records, raw_ostream &os) { + return emitStructDefs(records, os); + }); diff --git a/mlir/unittests/TableGen/CMakeLists.txt b/mlir/unittests/TableGen/CMakeLists.txt index aa55adbdae8..0c122746244 100644 --- a/mlir/unittests/TableGen/CMakeLists.txt +++ b/mlir/unittests/TableGen/CMakeLists.txt @@ -3,12 +3,19 @@ mlir_tablegen(EnumsGenTest.h.inc -gen-enum-decls) mlir_tablegen(EnumsGenTest.cpp.inc -gen-enum-defs) add_public_tablegen_target(MLIRTableGenEnumsIncGen) +set(LLVM_TARGET_DEFINITIONS structs.td) +mlir_tablegen(StructAttrGenTest.h.inc -gen-struct-attr-decls) +mlir_tablegen(StructAttrGenTest.cpp.inc -gen-struct-attr-defs) +add_public_tablegen_target(MLIRTableGenStructAttrIncGen) + add_mlir_unittest(MLIRTableGenTests EnumsGenTest.cpp + StructAttrGenTest.cpp FormatTest.cpp ) add_dependencies(MLIRTableGenTests MLIRTableGenEnumsIncGen) +add_dependencies(MLIRTableGenTests MLIRTableGenStructAttrIncGen) target_link_libraries(MLIRTableGenTests PRIVATE LLVMMLIRTableGen) diff --git a/mlir/unittests/TableGen/StructsGenTest.cpp b/mlir/unittests/TableGen/StructsGenTest.cpp new file mode 100644 index 00000000000..4457e6c495c --- /dev/null +++ b/mlir/unittests/TableGen/StructsGenTest.cpp @@ -0,0 +1,146 @@ +//===- StructsGenTest.cpp - TableGen StructsGen Tests ---------------------===// +// +// Copyright 2019 The MLIR Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================= + +#include "mlir/IR/Attributes.h" +#include "mlir/IR/Identifier.h" +#include "mlir/IR/StandardTypes.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/StringSwitch.h" +#include "gmock/gmock.h" +#include + +namespace mlir { + +// Pull in generated enum utility declarations +#include "StructAttrGenTest.h.inc" +// And definitions +#include "StructAttrGenTest.cpp.inc" +// Helper that returns an example test::TestStruct for testing its +// implementation. +static test::TestStruct getTestStruct(mlir::MLIRContext *context) { + auto integerType = mlir::IntegerType::get(32, context); + auto integerAttr = mlir::IntegerAttr::get(integerType, 127); + + auto floatType = mlir::FloatType::getF16(context); + auto floatAttr = mlir::FloatAttr::get(floatType, 0.25); + + auto elementsType = mlir::RankedTensorType::get({2, 3}, integerType); + auto elementsAttr = + mlir::DenseElementsAttr::get(elementsType, {1, 2, 3, 4, 5, 6}); + + return test::TestStruct::get(integerAttr, floatAttr, elementsAttr, context); +} + +// Validates that test::TestStruct::classof correctly identifies a valid +// test::TestStruct. +TEST(StructsGenTest, ClassofTrue) { + mlir::MLIRContext context; + auto structAttr = getTestStruct(&context); + ASSERT_TRUE(test::TestStruct::classof(structAttr)); +} + +// Validates that test::TestStruct::classof fails when an extra attribute is in +// the class. +TEST(StructsGenTest, ClassofExtraFalse) { + mlir::MLIRContext context; + mlir::DictionaryAttr structAttr = getTestStruct(&context); + auto expectedValues = structAttr.getValue(); + ASSERT_EQ(expectedValues.size(), 3); + + // Copy the set of named attributes. + llvm::SmallVector newValues(expectedValues.begin(), + expectedValues.end()); + + // Add an extra NamedAttribute. + auto wrongId = mlir::Identifier::get("wrong", &context); + auto wrongAttr = mlir::NamedAttribute(wrongId, expectedValues[0].second); + newValues.push_back(wrongAttr); + + // Make a new DictionaryAttr and validate. + auto badDictionary = mlir::DictionaryAttr::get(newValues, &context); + ASSERT_FALSE(test::TestStruct::classof(badDictionary)); +} + +// Validates that test::TestStruct::classof fails when a NamedAttribute has an +// incorrect name. +TEST(StructsGenTest, ClassofBadNameFalse) { + mlir::MLIRContext context; + mlir::DictionaryAttr structAttr = getTestStruct(&context); + auto expectedValues = structAttr.getValue(); + ASSERT_EQ(expectedValues.size(), 3); + + // Create a copy of all but the first NamedAttributes. + llvm::SmallVector newValues( + expectedValues.begin() + 1, expectedValues.end()); + + // Add a copy of the first attribute with the wrong Identifier. + auto wrongId = mlir::Identifier::get("wrong", &context); + auto wrongAttr = mlir::NamedAttribute(wrongId, expectedValues[0].second); + newValues.push_back(wrongAttr); + + auto badDictionary = mlir::DictionaryAttr::get(newValues, &context); + ASSERT_FALSE(test::TestStruct::classof(badDictionary)); +} + +// Validates that test::TestStruct::classof fails when a NamedAttribute is +// missing. +TEST(StructsGenTest, ClassofMissingFalse) { + mlir::MLIRContext context; + mlir::DictionaryAttr structAttr = getTestStruct(&context); + auto expectedValues = structAttr.getValue(); + ASSERT_EQ(expectedValues.size(), 3); + + // Copy a subset of the structures Named Attributes. + llvm::SmallVector newValues( + expectedValues.begin() + 1, expectedValues.end()); + + // Make a new DictionaryAttr and validate it is not a validte TestStruct. + auto badDictionary = mlir::DictionaryAttr::get(newValues, &context); + ASSERT_FALSE(test::TestStruct::classof(badDictionary)); +} + +// Validate the accessor for the FloatAttr value. +TEST(StructsGenTest, GetFloat) { + mlir::MLIRContext context; + auto structAttr = getTestStruct(&context); + auto returnedAttr = structAttr.sample_float(); + EXPECT_EQ(returnedAttr.getValueAsDouble(), 0.25); +} + +// Validate the accessor for the IntegerAttr value. +TEST(StructsGenTest, GetInteger) { + mlir::MLIRContext context; + auto structAttr = getTestStruct(&context); + auto returnedAttr = structAttr.sample_integer(); + EXPECT_EQ(returnedAttr.getInt(), 127); +} + +// Validate the accessor for the ElementsAttr value. +TEST(StructsGenTest, GetElements) { + mlir::MLIRContext context; + auto structAttr = getTestStruct(&context); + auto returnedAttr = structAttr.sample_elements(); + auto denseAttr = returnedAttr.dyn_cast(); + ASSERT_TRUE(denseAttr); + + for (const auto &valIndexIt : llvm::enumerate(denseAttr.getIntValues())) { + EXPECT_EQ(valIndexIt.value(), valIndexIt.index() + 1); + } +} + +} // namespace mlir diff --git a/mlir/unittests/TableGen/structs.td b/mlir/unittests/TableGen/structs.td new file mode 100644 index 00000000000..be847aeafd1 --- /dev/null +++ b/mlir/unittests/TableGen/structs.td @@ -0,0 +1,29 @@ +//===-- structss.td - StructsGen test definition file ------*- tablegen -*-===// +// +// Copyright 2019 The MLIR Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================= + +include "mlir/IR/OpBase.td" + +def Test_Dialect : Dialect { + let name = "test"; +} + +def Test_Struct : StructAttr<"TestStruct", Test_Dialect, [ + StructFieldAttr<"sample_integer", I32Attr>, + StructFieldAttr<"sample_float", F32Attr>, + StructFieldAttr<"sample_elements", ElementsAttr>] > { + let description = "Structure for test data"; +} -- cgit v1.2.3 From 6934a337f099f4ccb22625e1bf440b3356f8c09f Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 16 Sep 2019 09:22:43 -0700 Subject: [spirv] Add support for BitEnumAttr Certain enum classes in SPIR-V, like function/loop control and memory access, are bitmasks. This CL introduces a BitEnumAttr to properly model this and drive auto-generation of verification code and utility functions. We still store the attribute using an 32-bit IntegerAttr for minimal memory footprint and easy (de)serialization. But utility conversion functions are adjusted to inspect each bit and generate "|"-concatenated strings for the bits; vice versa. Each such enum class has a "None" case that means no bit is set. We need special handling for "None". Because of this, the logic is not general anymore. So right now the definition is placed in the SPIR-V dialect. If later this turns out to be useful for other dialects, then we can see how to properly adjust it and move to OpBase.td. Added tests for SPV_MemoryAccess to check and demonstrate. PiperOrigin-RevId: 269350620 --- mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt | 11 +- mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td | 94 +++++++++---- mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h | 3 +- mlir/include/mlir/IR/OpBase.td | 7 +- mlir/include/mlir/TableGen/Attribute.h | 7 + mlir/lib/Dialect/SPIRV/CMakeLists.txt | 3 +- mlir/lib/Dialect/SPIRV/SPIRVOps.cpp | 4 +- mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp | 4 +- mlir/lib/TableGen/Attribute.cpp | 8 ++ mlir/test/Dialect/SPIRV/ops.mlir | 84 ++++++++++- mlir/tools/mlir-tblgen/EnumsGen.cpp | 23 ++- mlir/tools/mlir-tblgen/EnumsGen.h | 48 +++++++ mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp | 188 ++++++++++++++++++++++++- mlir/utils/spirv/gen_spirv_dialect.py | 14 +- 14 files changed, 444 insertions(+), 54 deletions(-) create mode 100644 mlir/tools/mlir-tblgen/EnumsGen.h (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt b/mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt index ca08b682a1a..0c847f029b1 100644 --- a/mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt +++ b/mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt @@ -9,9 +9,14 @@ mlir_tablegen(SPIRVGLSLOps.cpp.inc -gen-op-defs) add_public_tablegen_target(MLIRSPIRVGLSLOpsIncGen) set(LLVM_TARGET_DEFINITIONS SPIRVBase.td) -mlir_tablegen(SPIRVEnums.h.inc -gen-enum-decls) -mlir_tablegen(SPIRVEnums.cpp.inc -gen-enum-defs) -add_public_tablegen_target(MLIRSPIRVEnumsIncGen) +mlir_tablegen(SPIRVIntEnums.h.inc -gen-enum-decls) +mlir_tablegen(SPIRVIntEnums.cpp.inc -gen-enum-defs) +add_public_tablegen_target(MLIRSPIRVIntEnumsIncGen) + +set(LLVM_TARGET_DEFINITIONS SPIRVBase.td) +mlir_tablegen(SPIRVBitEnums.h.inc -gen-spirv-enum-decls) +mlir_tablegen(SPIRVBitEnums.cpp.inc -gen-spirv-enum-defs) +add_public_tablegen_target(MLIRSPIRVBitEnumsIncGen) set(LLVM_TARGET_DEFINITIONS SPIRVOps.td) mlir_tablegen(SPIRVSerialization.inc -gen-spirv-serialization) diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td index f42edaf2ca5..8a49ae63b2a 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td @@ -185,7 +185,6 @@ def SPV_OpcodeAttr : // End opcode section. Generated from SPIR-V spec; DO NOT MODIFY! - //===----------------------------------------------------------------------===// // SPIR-V type definitions //===----------------------------------------------------------------------===// @@ -231,6 +230,49 @@ class SPV_Optional : Variadic; // TODO(ravishankarm): From 1.4, this should also include Composite type. def SPV_SelectType : AnyTypeOf<[SPV_Scalar, SPV_Vector, SPV_AnyPtr]>; +//===----------------------------------------------------------------------===// +// SPIR-V BitEnum definition +//===----------------------------------------------------------------------===// + +// A bit enum case stored with 32-bit IntegerAttr. `val` here is *not* the +// ordinal number of the bit that is set. It is the 32-bit integer with only +// one bit set. +class BitEnumAttrCase : + EnumAttrCaseInfo, + IntegerAttrBase { + let predicate = CPred< + "$_self.cast().getValue().getSExtValue() & " # val # "u">; +} + +// A bit enum stored with 32-bit IntegerAttr. +// +// Op attributes of this kind are stored as IntegerAttr. Extra verification will +// be generated on the integer to make sure only allowed bit are set. +class BitEnumAttr cases> : + EnumAttrInfo, IntegerAttrBase { + let predicate = And<[ + IntegerAttrBase.predicate, + // Make sure we don't have unknown bit set. + CPred<"!($_self.cast().getValue().getZExtValue() & (~(" # + StrJoin.result # + ")))"> + ]>; + + let underlyingType = "uint32_t"; + + // We need to return a string because we may concatenate symbols for multiple + // bits together. + let symbolToStringFnRetType = "std::string"; + + // The string used to separate bit enum cases in strings. + string separator = "|"; + + // Turn off the autogen with EnumsGen. SPIR-V needs custom logic here and + // we will use our own autogen logic. + let skipAutoGen = 1; +} + //===----------------------------------------------------------------------===// // SPIR-V extension definitions //===----------------------------------------------------------------------===// @@ -847,14 +889,14 @@ def SPV_ExecutionModelAttr : let cppNamespace = "::mlir::spirv"; } -def SPV_FC_None : I32EnumAttrCase<"None", 0x0000>; -def SPV_FC_Inline : I32EnumAttrCase<"Inline", 0x0001>; -def SPV_FC_DontInline : I32EnumAttrCase<"DontInline", 0x0002>; -def SPV_FC_Pure : I32EnumAttrCase<"Pure", 0x0004>; -def SPV_FC_Const : I32EnumAttrCase<"Const", 0x0008>; +def SPV_FC_None : BitEnumAttrCase<"None", 0x0000>; +def SPV_FC_Inline : BitEnumAttrCase<"Inline", 0x0001>; +def SPV_FC_DontInline : BitEnumAttrCase<"DontInline", 0x0002>; +def SPV_FC_Pure : BitEnumAttrCase<"Pure", 0x0004>; +def SPV_FC_Const : BitEnumAttrCase<"Const", 0x0008>; def SPV_FunctionControlAttr : - I32EnumAttr<"FunctionControl", "valid SPIR-V FunctionControl", [ + BitEnumAttr<"FunctionControl", "valid SPIR-V FunctionControl", [ SPV_FC_None, SPV_FC_Inline, SPV_FC_DontInline, SPV_FC_Pure, SPV_FC_Const ]> { let returnType = "::mlir::spirv::FunctionControl"; @@ -932,19 +974,19 @@ def SPV_LinkageTypeAttr : let cppNamespace = "::mlir::spirv"; } -def SPV_LC_None : I32EnumAttrCase<"None", 0x0000>; -def SPV_LC_Unroll : I32EnumAttrCase<"Unroll", 0x0001>; -def SPV_LC_DontUnroll : I32EnumAttrCase<"DontUnroll", 0x0002>; -def SPV_LC_DependencyInfinite : I32EnumAttrCase<"DependencyInfinite", 0x0004>; -def SPV_LC_DependencyLength : I32EnumAttrCase<"DependencyLength", 0x0008>; -def SPV_LC_MinIterations : I32EnumAttrCase<"MinIterations", 0x0010>; -def SPV_LC_MaxIterations : I32EnumAttrCase<"MaxIterations", 0x0020>; -def SPV_LC_IterationMultiple : I32EnumAttrCase<"IterationMultiple", 0x0040>; -def SPV_LC_PeelCount : I32EnumAttrCase<"PeelCount", 0x0080>; -def SPV_LC_PartialCount : I32EnumAttrCase<"PartialCount", 0x0100>; +def SPV_LC_None : BitEnumAttrCase<"None", 0x0000>; +def SPV_LC_Unroll : BitEnumAttrCase<"Unroll", 0x0001>; +def SPV_LC_DontUnroll : BitEnumAttrCase<"DontUnroll", 0x0002>; +def SPV_LC_DependencyInfinite : BitEnumAttrCase<"DependencyInfinite", 0x0004>; +def SPV_LC_DependencyLength : BitEnumAttrCase<"DependencyLength", 0x0008>; +def SPV_LC_MinIterations : BitEnumAttrCase<"MinIterations", 0x0010>; +def SPV_LC_MaxIterations : BitEnumAttrCase<"MaxIterations", 0x0020>; +def SPV_LC_IterationMultiple : BitEnumAttrCase<"IterationMultiple", 0x0040>; +def SPV_LC_PeelCount : BitEnumAttrCase<"PeelCount", 0x0080>; +def SPV_LC_PartialCount : BitEnumAttrCase<"PartialCount", 0x0100>; def SPV_LoopControlAttr : - I32EnumAttr<"LoopControl", "valid SPIR-V LoopControl", [ + BitEnumAttr<"LoopControl", "valid SPIR-V LoopControl", [ SPV_LC_None, SPV_LC_Unroll, SPV_LC_DontUnroll, SPV_LC_DependencyInfinite, SPV_LC_DependencyLength, SPV_LC_MinIterations, SPV_LC_MaxIterations, SPV_LC_IterationMultiple, SPV_LC_PeelCount, SPV_LC_PartialCount @@ -954,16 +996,16 @@ def SPV_LoopControlAttr : let cppNamespace = "::mlir::spirv"; } -def SPV_MA_None : I32EnumAttrCase<"None", 0x0000>; -def SPV_MA_Volatile : I32EnumAttrCase<"Volatile", 0x0001>; -def SPV_MA_Aligned : I32EnumAttrCase<"Aligned", 0x0002>; -def SPV_MA_Nontemporal : I32EnumAttrCase<"Nontemporal", 0x0004>; -def SPV_MA_MakePointerAvailable : I32EnumAttrCase<"MakePointerAvailable", 0x0008>; -def SPV_MA_MakePointerVisible : I32EnumAttrCase<"MakePointerVisible", 0x0010>; -def SPV_MA_NonPrivatePointer : I32EnumAttrCase<"NonPrivatePointer", 0x0020>; +def SPV_MA_None : BitEnumAttrCase<"None", 0x0000>; +def SPV_MA_Volatile : BitEnumAttrCase<"Volatile", 0x0001>; +def SPV_MA_Aligned : BitEnumAttrCase<"Aligned", 0x0002>; +def SPV_MA_Nontemporal : BitEnumAttrCase<"Nontemporal", 0x0004>; +def SPV_MA_MakePointerAvailable : BitEnumAttrCase<"MakePointerAvailable", 0x0008>; +def SPV_MA_MakePointerVisible : BitEnumAttrCase<"MakePointerVisible", 0x0010>; +def SPV_MA_NonPrivatePointer : BitEnumAttrCase<"NonPrivatePointer", 0x0020>; def SPV_MemoryAccessAttr : - I32EnumAttr<"MemoryAccess", "valid SPIR-V MemoryAccess", [ + BitEnumAttr<"MemoryAccess", "valid SPIR-V MemoryAccess", [ SPV_MA_None, SPV_MA_Volatile, SPV_MA_Aligned, SPV_MA_Nontemporal, SPV_MA_MakePointerAvailable, SPV_MA_MakePointerVisible, SPV_MA_NonPrivatePointer diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h b/mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h index d261dc2e3ca..679d37a7ad3 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h @@ -27,7 +27,8 @@ #include "mlir/IR/Types.h" // Pull in all enum type definitions and utility function declarations -#include "mlir/Dialect/SPIRV/SPIRVEnums.h.inc" +#include "mlir/Dialect/SPIRV/SPIRVBitEnums.h.inc" +#include "mlir/Dialect/SPIRV/SPIRVIntEnums.h.inc" #include diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index e2738d447f9..f1edb78948d 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -787,6 +787,10 @@ class EnumAttrInfo cases> { // List of all accepted cases list enumerants = cases; + // Whether to skip automatically generating C++ enum class and utility + // functions for this enum attribute with EnumsGen. + bit skipAutoGen = 0; + // The following fields are only used by the EnumsGen backend to generate // an enum class definition and conversion utility functions. @@ -824,9 +828,10 @@ class EnumAttrInfo cases> { // corresponding string. It will have the following signature: // // ```c++ - // llvm::StringRef (); + // (); // ``` string symbolToStringFnName = "stringify" # name; + string symbolToStringFnRetType = "llvm::StringRef"; // The name of the utility function that returns the max enum value used // within the enum class. It will have the following signature: diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index 1cff9fdfa8b..be688c9579c 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -151,6 +151,9 @@ public: explicit EnumAttr(const llvm::Record &record); explicit EnumAttr(const llvm::DefInit *init); + // Returns whether skipping auto-generation is requested. + bool skipAutoGen() const; + // Returns the enum class name. StringRef getEnumClassName() const; @@ -172,6 +175,10 @@ public: // corresponding string. StringRef getSymbolToStringFnName() const; + // Returns the return type of the utility function that converts a symbol to + // the corresponding string. + StringRef getSymbolToStringFnRetType() const; + // Returns the name of the utilit function that returns the max enum value // used within the enum class. StringRef getMaxEnumValFnName() const; diff --git a/mlir/lib/Dialect/SPIRV/CMakeLists.txt b/mlir/lib/Dialect/SPIRV/CMakeLists.txt index f044175c693..f4e89d1b7c5 100644 --- a/mlir/lib/Dialect/SPIRV/CMakeLists.txt +++ b/mlir/lib/Dialect/SPIRV/CMakeLists.txt @@ -11,7 +11,8 @@ add_llvm_library(MLIRSPIRV add_dependencies(MLIRSPIRV MLIRSPIRVOpsIncGen - MLIRSPIRVEnumsIncGen + MLIRSPIRVIntEnumsIncGen + MLIRSPIRVBitEnumsIncGen MLIRSPIRVOpUtilsGen) target_link_libraries(MLIRSPIRV diff --git a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp index 743065ca28e..81860e86b7a 100644 --- a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp @@ -141,7 +141,7 @@ static ParseResult parseMemoryAccessAttributes(OpAsmParser *parser, return failure(); } - if (memoryAccessAttr == spirv::MemoryAccess::Aligned) { + if (spirv::bitEnumContains(memoryAccessAttr, spirv::MemoryAccess::Aligned)) { // Parse integer attribute for alignment. Attribute alignmentAttr; Type i32Type = parser->getBuilder().getIntegerType(32); @@ -212,7 +212,7 @@ static LogicalResult verifyMemoryAccessAttribute(LoadStoreOpTy loadStoreOp) { << memAccessVal; } - if (*memAccess == spirv::MemoryAccess::Aligned) { + if (spirv::bitEnumContains(*memAccess, spirv::MemoryAccess::Aligned)) { if (!op->getAttr(kAlignmentAttrName)) { return loadStoreOp.emitOpError("missing alignment value"); } diff --git a/mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp b/mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp index f79db01998f..f18d313ea1e 100644 --- a/mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp @@ -21,13 +21,15 @@ #include "mlir/Dialect/SPIRV/SPIRVTypes.h" #include "mlir/IR/StandardTypes.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" using namespace mlir; using namespace mlir::spirv; // Pull in all enum utility function definitions -#include "mlir/Dialect/SPIRV/SPIRVEnums.cpp.inc" +#include "mlir/Dialect/SPIRV/SPIRVBitEnums.cpp.inc" +#include "mlir/Dialect/SPIRV/SPIRVIntEnums.cpp.inc" //===----------------------------------------------------------------------===// // ArrayType diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index 3d19de24429..46bbfff7137 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -170,6 +170,10 @@ tblgen::EnumAttr::EnumAttr(const llvm::Record &record) : Attribute(&record) {} tblgen::EnumAttr::EnumAttr(const llvm::DefInit *init) : EnumAttr(init->getDef()) {} +bool tblgen::EnumAttr::skipAutoGen() const { + return def->getValueAsBit("skipAutoGen"); +} + StringRef tblgen::EnumAttr::getEnumClassName() const { return def->getValueAsString("className"); } @@ -194,6 +198,10 @@ StringRef tblgen::EnumAttr::getSymbolToStringFnName() const { return def->getValueAsString("symbolToStringFnName"); } +StringRef tblgen::EnumAttr::getSymbolToStringFnRetType() const { + return def->getValueAsString("symbolToStringFnRetType"); +} + StringRef tblgen::EnumAttr::getMaxEnumValFnName() const { return def->getValueAsString("maxEnumValFnName"); } diff --git a/mlir/test/Dialect/SPIRV/ops.mlir b/mlir/test/Dialect/SPIRV/ops.mlir index 348a685bd8c..11385dbcc60 100644 --- a/mlir/test/Dialect/SPIRV/ops.mlir +++ b/mlir/test/Dialect/SPIRV/ops.mlir @@ -301,30 +301,84 @@ spv.module "Logical" "GLSL450" { // spv.LoadOp //===----------------------------------------------------------------------===// -// CHECK_LABEL: @simple_load +// CHECK-LABEL: @simple_load func @simple_load() -> () { %0 = spv.Variable : !spv.ptr - // CHECK: spv.Load "Function" %0 : f32 + // CHECK: spv.Load "Function" %{{.*}} : f32 %1 = spv.Load "Function" %0 : f32 return } -// CHECK_LABEL: @volatile_load +// CHECK-LABEL: @load_none_access +func @load_none_access() -> () { + %0 = spv.Variable : !spv.ptr + // CHECK: spv.Load "Function" %{{.*}} ["None"] : f32 + %1 = spv.Load "Function" %0 ["None"] : f32 + return +} + +// CHECK-LABEL: @volatile_load func @volatile_load() -> () { %0 = spv.Variable : !spv.ptr - // CHECK: spv.Load "Function" %0 ["Volatile"] : f32 + // CHECK: spv.Load "Function" %{{.*}} ["Volatile"] : f32 %1 = spv.Load "Function" %0 ["Volatile"] : f32 return } -// CHECK_LABEL: @aligned_load +// CHECK-LABEL: @aligned_load func @aligned_load() -> () { %0 = spv.Variable : !spv.ptr - // CHECK: spv.Load "Function" %0 ["Aligned", 4] : f32 + // CHECK: spv.Load "Function" %{{.*}} ["Aligned", 4] : f32 %1 = spv.Load "Function" %0 ["Aligned", 4] : f32 return } +// CHECK-LABEL: @volatile_aligned_load +func @volatile_aligned_load() -> () { + %0 = spv.Variable : !spv.ptr + // CHECK: spv.Load "Function" %{{.*}} ["Volatile|Aligned", 4] : f32 + %1 = spv.Load "Function" %0 ["Volatile|Aligned", 4] : f32 + return +} + +// ----- + +// CHECK-LABEL: load_none_access +func @load_none_access() -> () { + %0 = spv.Variable : !spv.ptr + // CHECK: spv.Load + // CHECK-SAME: ["None"] + %1 = "spv.Load"(%0) {memory_access = 0 : i32} : (!spv.ptr) -> (f32) + return +} + +// CHECK-LABEL: volatile_load +func @volatile_load() -> () { + %0 = spv.Variable : !spv.ptr + // CHECK: spv.Load + // CHECK-SAME: ["Volatile"] + %1 = "spv.Load"(%0) {memory_access = 1 : i32} : (!spv.ptr) -> (f32) + return +} + +// CHECK-LABEL: aligned_load +func @aligned_load() -> () { + %0 = spv.Variable : !spv.ptr + // CHECK: spv.Load + // CHECK-SAME: ["Aligned", 4] + %1 = "spv.Load"(%0) {memory_access = 2 : i32, alignment = 4 : i32} : (!spv.ptr) -> (f32) + return +} + +// CHECK-LABEL: volatile_aligned_load +func @volatile_aligned_load() -> () { + %0 = spv.Variable : !spv.ptr + // CHECK: spv.Load + // CHECK-SAME: ["Volatile|Aligned", 4] + %1 = "spv.Load"(%0) {memory_access = 3 : i32, alignment = 4 : i32} : (!spv.ptr) -> (f32) + return +} + // ----- func @simple_load_missing_storageclass() -> () { @@ -408,6 +462,24 @@ func @load_unknown_memory_access() -> () { // ----- +func @load_unknown_memory_access() -> () { + %0 = spv.Variable : !spv.ptr + // expected-error @+1 {{custom op 'spv.Load' invalid memory_access attribute specification: "Volatile|Something"}} + %1 = spv.Load "Function" %0 ["Volatile|Something"] : f32 + return +} + +// ----- + +func @load_unknown_memory_access() -> () { + %0 = spv.Variable : !spv.ptr + // expected-error @+1 {{failed to satisfy constraint: valid SPIR-V MemoryAccess}} + %1 = "spv.Load"(%0) {memory_access = 0x80000000 : i32} : (!spv.ptr) -> (f32) + return +} + +// ----- + func @aligned_load_incorrect_attributes() -> () { %0 = spv.Variable : !spv.ptr // expected-error @+1 {{expected ']'}} diff --git a/mlir/tools/mlir-tblgen/EnumsGen.cpp b/mlir/tools/mlir-tblgen/EnumsGen.cpp index 36f2e049641..a581130753c 100644 --- a/mlir/tools/mlir-tblgen/EnumsGen.cpp +++ b/mlir/tools/mlir-tblgen/EnumsGen.cpp @@ -19,6 +19,7 @@ // //===----------------------------------------------------------------------===// +#include "EnumsGen.h" #include "mlir/TableGen/Attribute.h" #include "mlir/TableGen/GenInfo.h" #include "llvm/ADT/SmallVector.h" @@ -127,9 +128,11 @@ static void emitSymToStrFn(const Record &enumDef, raw_ostream &os) { EnumAttr enumAttr(enumDef); StringRef enumName = enumAttr.getEnumClassName(); StringRef symToStrFnName = enumAttr.getSymbolToStringFnName(); + StringRef symToStrFnRetType = enumAttr.getSymbolToStringFnRetType(); auto enumerants = enumAttr.getAllCases(); - os << formatv("llvm::StringRef {1}({0} val) {{\n", enumName, symToStrFnName); + os << formatv("{2} {1}({0} val) {{\n", enumName, symToStrFnName, + symToStrFnRetType); os << " switch (val) {\n"; for (const auto &enumerant : enumerants) { auto symbol = enumerant.getSymbol(); @@ -190,7 +193,8 @@ static void emitUnderlyingToSymFn(const Record &enumDef, raw_ostream &os) { << "}\n\n"; } -static void emitEnumDecl(const Record &enumDef, raw_ostream &os) { +void mlir::tblgen::emitEnumDecl(const Record &enumDef, + ExtraFnEmitter emitExtraFns, raw_ostream &os) { EnumAttr enumAttr(enumDef); StringRef enumName = enumAttr.getEnumClassName(); StringRef cppNamespace = enumAttr.getCppNamespace(); @@ -198,6 +202,7 @@ static void emitEnumDecl(const Record &enumDef, raw_ostream &os) { StringRef description = enumAttr.getDescription(); StringRef strToSymFnName = enumAttr.getStringToSymbolFnName(); StringRef symToStrFnName = enumAttr.getSymbolToStringFnName(); + StringRef symToStrFnRetType = enumAttr.getSymbolToStringFnRetType(); StringRef underlyingToSymFnName = enumAttr.getUnderlyingToSymbolFnName(); auto enumerants = enumAttr.getAllCases(); @@ -218,11 +223,11 @@ static void emitEnumDecl(const Record &enumDef, raw_ostream &os) { "llvm::Optional<{0}> {1}({2});\n", enumName, underlyingToSymFnName, underlyingType.empty() ? std::string("unsigned") : underlyingType); } - os << formatv("llvm::StringRef {1}({0});\n", enumName, symToStrFnName); + os << formatv("{2} {1}({0});\n", enumName, symToStrFnName, symToStrFnRetType); os << formatv("llvm::Optional<{0}> {1}(llvm::StringRef);\n", enumName, strToSymFnName); - emitMaxValueFn(enumDef, os); + emitExtraFns(enumDef, os); for (auto ns : llvm::reverse(namespaces)) os << "} // namespace " << ns << "\n"; @@ -234,9 +239,14 @@ static void emitEnumDecl(const Record &enumDef, raw_ostream &os) { static bool emitEnumDecls(const RecordKeeper &recordKeeper, raw_ostream &os) { llvm::emitSourceFileHeader("Enum Utility Declarations", os); + auto extraFnEmitter = [](const Record &enumDef, raw_ostream &os) { + emitMaxValueFn(enumDef, os); + }; + auto defs = recordKeeper.getAllDerivedDefinitions("EnumAttrInfo"); for (const auto *def : defs) - emitEnumDecl(*def, os); + if (!EnumAttr(def).skipAutoGen()) + mlir::tblgen::emitEnumDecl(*def, extraFnEmitter, os); return false; } @@ -265,7 +275,8 @@ static bool emitEnumDefs(const RecordKeeper &recordKeeper, raw_ostream &os) { auto defs = recordKeeper.getAllDerivedDefinitions("EnumAttrInfo"); for (const auto *def : defs) - emitEnumDef(*def, os); + if (!EnumAttr(def).skipAutoGen()) + emitEnumDef(*def, os); return false; } diff --git a/mlir/tools/mlir-tblgen/EnumsGen.h b/mlir/tools/mlir-tblgen/EnumsGen.h new file mode 100644 index 00000000000..552d29e1f2e --- /dev/null +++ b/mlir/tools/mlir-tblgen/EnumsGen.h @@ -0,0 +1,48 @@ +//===- EnumsGen.h - MLIR enum utility generator -----------------*- C++ -*-===// +// +// Copyright 2019 The MLIR Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================= +// +// This file defines common utilities for enum generator. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_TOOLS_MLIR_TBLGEN_ENUMSGEN_H_ +#define MLIR_TOOLS_MLIR_TBLGEN_ENUMSGEN_H_ + +#include "mlir/Support/LLVM.h" + +namespace llvm { +class Record; +} + +namespace mlir { +namespace tblgen { + +using ExtraFnEmitter = llvm::function_ref; + +// Emits declarations for the given EnumAttr `enumDef` into `os`. +// +// This will emit a C++ enum class and string to symbol and symbol to string +// conversion utility declarations. Additional functions can be emitted via +// the `emitExtraFns` function. +void emitEnumDecl(const llvm::Record &enumDef, ExtraFnEmitter emitExtraFns, + llvm::raw_ostream &os); + +} // namespace tblgen +} // namespace mlir + +#endif // MLIR_TOOLS_MLIR_TBLGEN_ENUMSGEN_H_ diff --git a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp index d948ec501f1..ca650651af9 100644 --- a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp +++ b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp @@ -20,6 +20,7 @@ // //===----------------------------------------------------------------------===// +#include "EnumsGen.h" #include "mlir/Support/StringExtras.h" #include "mlir/TableGen/Attribute.h" #include "mlir/TableGen/GenInfo.h" @@ -49,6 +50,10 @@ using mlir::tblgen::NamedAttribute; using mlir::tblgen::NamedTypeConstraint; using mlir::tblgen::Operator; +//===----------------------------------------------------------------------===// +// Serialization AutoGen +//===----------------------------------------------------------------------===// + // Writes the following function to `os`: // inline uint32_t getOpcode() { return ; } static void emitGetOpcodeFunction(const Record *record, Operator const &op, @@ -397,6 +402,10 @@ static bool emitSerializationFns(const RecordKeeper &recordKeeper, return false; } +//===----------------------------------------------------------------------===// +// Op Utils AutoGen +//===----------------------------------------------------------------------===// + static void emitEnumGetAttrNameFnDecl(raw_ostream &os) { os << formatv("template inline constexpr StringRef " "attributeName();\n"); @@ -435,7 +444,7 @@ static void emitEnumGetSymbolizeFnDefn(const EnumAttr &enumAttr, static bool emitOpUtils(const RecordKeeper &recordKeeper, raw_ostream &os) { llvm::emitSourceFileHeader("SPIR-V Op Utilites", os); - auto defs = recordKeeper.getAllDerivedDefinitions("I32EnumAttr"); + auto defs = recordKeeper.getAllDerivedDefinitions("EnumAttrInfo"); os << "#ifndef SPIRV_OP_UTILS_H_\n"; os << "#define SPIRV_OP_UTILS_H_\n"; emitEnumGetAttrNameFnDecl(os); @@ -449,7 +458,168 @@ static bool emitOpUtils(const RecordKeeper &recordKeeper, raw_ostream &os) { return false; } -// Registers the enum utility generator to mlir-tblgen. +//===----------------------------------------------------------------------===// +// BitEnum AutoGen +//===----------------------------------------------------------------------===// + +// Emits the following inline function for bit enums: +// inline operator|( a, b); +// inline bitEnumContains( a, b); +static void emitOperators(const Record &enumDef, raw_ostream &os) { + EnumAttr enumAttr(enumDef); + StringRef enumName = enumAttr.getEnumClassName(); + std::string underlyingType = enumAttr.getUnderlyingType(); + os << formatv("inline {0} operator|({0} lhs, {0} rhs) {{\n", enumName) + << formatv(" return static_cast<{0}>(" + "static_cast<{1}>(lhs) | static_cast<{1}>(rhs));\n", + enumName, underlyingType) + << "}\n"; + os << formatv( + "inline bool bitEnumContains({0} bits, {0} bit) {{\n" + " return (static_cast<{1}>(bits) & static_cast<{1}>(bit)) != 0;\n", + enumName, underlyingType) + << "}\n"; +} + +static bool emitBitEnumDecls(const RecordKeeper &recordKeeper, + raw_ostream &os) { + llvm::emitSourceFileHeader("BitEnum Utility Declarations", os); + + auto operatorsEmitter = [](const Record &enumDef, llvm::raw_ostream &os) { + return emitOperators(enumDef, os); + }; + + auto defs = recordKeeper.getAllDerivedDefinitions("BitEnumAttr"); + for (const auto *def : defs) + mlir::tblgen::emitEnumDecl(*def, operatorsEmitter, os); + + return false; +} + +static void emitSymToStrFnForBitEnum(const Record &enumDef, raw_ostream &os) { + EnumAttr enumAttr(enumDef); + StringRef enumName = enumAttr.getEnumClassName(); + StringRef symToStrFnName = enumAttr.getSymbolToStringFnName(); + StringRef symToStrFnRetType = enumAttr.getSymbolToStringFnRetType(); + StringRef separator = enumDef.getValueAsString("separator"); + auto enumerants = enumAttr.getAllCases(); + + os << formatv("{2} {1}({0} symbol) {{\n", enumName, symToStrFnName, + symToStrFnRetType); + + os << formatv(" auto val = static_cast<{0}>(symbol);\n", + enumAttr.getUnderlyingType()); + os << " // Special case for all bits unset.\n"; + os << " if (val == 0) return \"None\";\n\n"; + os << " SmallVector strs;\n"; + for (const auto &enumerant : enumerants) { + // Skip the special enumerant for None. + if (auto val = enumerant.getValue()) + os << formatv(" if ({0}u & val) {{ strs.push_back(\"{1}\"); " + "val &= ~{0}u; }\n", + val, enumerant.getSymbol()); + } + // If we have unknown bit set, return an empty string to signal errors. + os << "\n if (val) return \"\";\n"; + os << formatv(" return llvm::join(strs, \"{0}\");\n", separator); + + os << "}\n\n"; +} + +static void emitStrToSymFnForBitEnum(const Record &enumDef, raw_ostream &os) { + EnumAttr enumAttr(enumDef); + StringRef enumName = enumAttr.getEnumClassName(); + std::string underlyingType = enumAttr.getUnderlyingType(); + StringRef strToSymFnName = enumAttr.getStringToSymbolFnName(); + StringRef separator = enumDef.getValueAsString("separator"); + auto enumerants = enumAttr.getAllCases(); + + os << formatv("llvm::Optional<{0}> {1}(llvm::StringRef str) {{\n", enumName, + strToSymFnName); + + os << formatv(" if (str == \"None\") return {0}::None;\n\n", enumName); + + // Split the string to get symbols for all the bits. + os << " SmallVector symbols;\n"; + os << formatv(" str.split(symbols, \"{0}\");\n\n", separator); + + os << formatv(" {0} val = 0;\n", underlyingType); + os << " for (auto symbol : symbols) {\n"; + + // Convert each symbol to the bit ordinal and set the corresponding bit. + os << formatv( + " auto bit = llvm::StringSwitch>(symbol)\n", + underlyingType); + for (const auto &enumerant : enumerants) { + // Skip the special enumerant for None. + if (auto val = enumerant.getValue()) + os.indent(6) << formatv(".Case(\"{0}\", {1})\n", enumerant.getSymbol(), + enumerant.getValue()); + } + os.indent(6) << ".Default(llvm::None);\n"; + + os << " if (bit) { val |= *bit; } else { return llvm::None; }\n"; + os << " }\n"; + + os << formatv(" return static_cast<{0}>(val);\n", enumName); + os << "}\n\n"; +} + +static void emitUnderlyingToSymFnForBitEnum(const Record &enumDef, + raw_ostream &os) { + EnumAttr enumAttr(enumDef); + StringRef enumName = enumAttr.getEnumClassName(); + std::string underlyingType = enumAttr.getUnderlyingType(); + StringRef underlyingToSymFnName = enumAttr.getUnderlyingToSymbolFnName(); + auto enumerants = enumAttr.getAllCases(); + + os << formatv("llvm::Optional<{0}> {1}({2} value) {{\n", enumName, + underlyingToSymFnName, underlyingType); + os << formatv(" if (value == 0) return {0}::None;\n", enumName); + llvm::SmallVector values; + for (const auto &enumerant : enumerants) { + if (auto val = enumerant.getValue()) + values.push_back(formatv("{0}u", val)); + } + os << formatv(" if (value & ~({0})) return llvm::None;\n", + llvm::join(values, " | ")); + os << formatv(" return static_cast<{0}>(value);\n", enumName); + os << "}\n"; +} + +static void emitBitEnumDef(const Record &enumDef, raw_ostream &os) { + EnumAttr enumAttr(enumDef); + StringRef cppNamespace = enumAttr.getCppNamespace(); + + llvm::SmallVector namespaces; + llvm::SplitString(cppNamespace, namespaces, "::"); + + for (auto ns : namespaces) + os << "namespace " << ns << " {\n"; + + emitSymToStrFnForBitEnum(enumDef, os); + emitStrToSymFnForBitEnum(enumDef, os); + emitUnderlyingToSymFnForBitEnum(enumDef, os); + + for (auto ns : llvm::reverse(namespaces)) + os << "} // namespace " << ns << "\n"; + os << "\n"; +} + +static bool emitBitEnumDefs(const RecordKeeper &recordKeeper, raw_ostream &os) { + llvm::emitSourceFileHeader("BitEnum Utility Definitions", os); + + auto defs = recordKeeper.getAllDerivedDefinitions("BitEnumAttr"); + for (const auto *def : defs) + emitBitEnumDef(*def, os); + + return false; +} + +//===----------------------------------------------------------------------===// +// Hook Registration +//===----------------------------------------------------------------------===// + static mlir::GenRegistration genSerialization( "gen-spirv-serialization", "Generate SPIR-V (de)serialization utilities and functions", @@ -463,3 +633,17 @@ static mlir::GenRegistration [](const RecordKeeper &records, raw_ostream &os) { return emitOpUtils(records, os); }); + +static mlir::GenRegistration + genEnumDecls("gen-spirv-enum-decls", + "Generate SPIR-V bit enum utility declarations", + [](const RecordKeeper &records, raw_ostream &os) { + return emitBitEnumDecls(records, os); + }); + +static mlir::GenRegistration + genEnumDefs("gen-spirv-enum-defs", + "Generate SPIR-V bit enum utility definitions", + [](const RecordKeeper &records, raw_ostream &os) { + return emitBitEnumDefs(records, os); + }); diff --git a/mlir/utils/spirv/gen_spirv_dialect.py b/mlir/utils/spirv/gen_spirv_dialect.py index cca152f7633..6595931eeed 100755 --- a/mlir/utils/spirv/gen_spirv_dialect.py +++ b/mlir/utils/spirv/gen_spirv_dialect.py @@ -132,16 +132,18 @@ def uniquify(lst, equality_fn): def gen_operand_kind_enum_attr(operand_kind): - """Generates the TableGen I32EnumAttr definition for the given operand kind. + """Generates the TableGen EnumAttr definition for the given operand kind. Returns: - The operand kind's name - - A string containing the TableGen I32EnumAttr definition + - A string containing the TableGen EnumAttr definition """ if 'enumerants' not in operand_kind: return '', '' kind_name = operand_kind['kind'] + is_bit_enum = operand_kind['category'] == 'BitEnum' + kind_category = 'Bit' if is_bit_enum else 'I32' kind_acronym = ''.join([c for c in kind_name if c >= 'A' and c <= 'Z']) kind_cases = [(case['enumerant'], case['value']) for case in operand_kind['enumerants']] @@ -150,9 +152,10 @@ def gen_operand_kind_enum_attr(operand_kind): # Generate the definition for each enum case fmt_str = 'def SPV_{acronym}_{symbol} {colon:>{offset}} '\ - 'I32EnumAttrCase<"{symbol}", {value}>;' + '{category}EnumAttrCase<"{symbol}", {value}>;' case_defs = [ fmt_str.format( + category=kind_category, acronym=kind_acronym, symbol=case[0], value=case[1], @@ -174,12 +177,13 @@ def gen_operand_kind_enum_attr(operand_kind): # Generate the enum attribute definition enum_attr = 'def SPV_{name}Attr :\n '\ - 'I32EnumAttr<"{name}", "valid SPIR-V {name}", [\n{cases}\n ]> {{\n'\ + '{category}EnumAttr<"{name}", "valid SPIR-V {name}", [\n{cases}\n'\ + ' ]> {{\n'\ ' let returnType = "::mlir::spirv::{name}";\n'\ ' let convertFromStorage = '\ '"static_cast<::mlir::spirv::{name}>($_self.getInt())";\n'\ ' let cppNamespace = "::mlir::spirv";\n}}'.format( - name=kind_name, cases=case_names) + name=kind_name, category=kind_category, cases=case_names) return kind_name, case_defs + '\n\n' + enum_attr -- cgit v1.2.3 From 2fa865719b1fdbb2319b9e38ea36f747642c4c83 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 1 Nov 2019 11:17:23 -0700 Subject: Move BitEnumAttr from SPIRVBase.td to OpBase.td BitEnumAttr is a mechanism for modelling attributes whose value is a bitfield. It should not be scoped to the SPIR-V dialect and can be used by other dialects too. This CL is mostly shuffling code around and adding tests and docs. Functionality changes are: * Fixed to use `getZExtValue()` instead of `getSExtValue()` when getting the value from the underlying IntegerAttr for a case. * Changed to auto-detect whether there is a case whose value is all bits unset (i.e., zero). If so handle it specially in all helper methods. PiperOrigin-RevId: 277964926 --- mlir/g3doc/OpDefinitions.md | 198 ++++++++++++++++++++----- mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt | 11 +- mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td | 43 ------ mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h | 3 +- mlir/include/mlir/IR/OpBase.td | 41 ++++- mlir/include/mlir/TableGen/Attribute.h | 4 +- mlir/lib/Dialect/SPIRV/CMakeLists.txt | 3 +- mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp | 3 +- mlir/lib/TableGen/Attribute.cpp | 4 +- mlir/tools/mlir-tblgen/EnumsGen.cpp | 182 ++++++++++++++++++++--- mlir/tools/mlir-tblgen/EnumsGen.h | 48 ------ mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp | 179 ---------------------- mlir/unittests/TableGen/EnumsGenTest.cpp | 37 +++++ mlir/unittests/TableGen/enums.td | 10 ++ 14 files changed, 420 insertions(+), 346 deletions(-) delete mode 100644 mlir/tools/mlir-tblgen/EnumsGen.h (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/g3doc/OpDefinitions.md b/mlir/g3doc/OpDefinitions.md index d0de56e4b0d..9967f65bac2 100644 --- a/mlir/g3doc/OpDefinitions.md +++ b/mlir/g3doc/OpDefinitions.md @@ -716,23 +716,35 @@ duplication, which is being worked on right now. ### Enum attributes -Enum attributes can be defined using `EnumAttr`, which requires all its cases to -be defined with `EnumAttrCase`. To facilitate the interaction between -`EnumAttr`s and their C++ consumers, the [`EnumsGen`][EnumsGen] TableGen backend -can generate a few common utilities, including an enum class, -`llvm::DenseMapInfo` for the enum class, conversion functions from/to strings. -This is controlled via the `-gen-enum-decls` and `-gen-enum-defs` command-line -options of `mlir-tblgen`. +Some attributes can only take values from an predefined enum, e.g., the +comparsion kind of a comparsion op. To define such attributes, ODS provides +several mechanisms: `StrEnumAttr`, `IntEnumAttr`, and `BitEnumAttr`. + +* `StrEnumAttr`: each enum case is a string, the attribute is stored as a + [`StringAttr`][StringAttr] in the op. +* `IntEnumAttr`: each enum case is an integer, the attribute is stored as a + [`IntegerAttr`][IntegerAttr] in the op. +* `BitEnumAttr`: each enum case is a bit, the attribute is stored as a + [`IntegerAttr`][IntegerAttr] in the op. + +All these `*EnumAttr` attributes require fully specifying all of the the allowed +cases via their corresponding `*EnumAttrCase`. With this, ODS is able to +generate additional verification to only accept allowed cases. To facilitate the +interaction between `*EnumAttr`s and their C++ consumers, the +[`EnumsGen`][EnumsGen] TableGen backend can generate a few common utilities: a +C++ enum class, `llvm::DenseMapInfo` for the enum class, conversion functions +from/to strings. This is controlled via the `-gen-enum-decls` and +`-gen-enum-defs` command-line options of `mlir-tblgen`. For example, given the following `EnumAttr`: ```tablegen -def CaseA: EnumAttrCase<"caseA", 0>; -def CaseB: EnumAttrCase<"caseB", 10>; +def Case15: I32EnumAttrCase<"Case15", 15>; +def Case20: I32EnumAttrCase<"Case20", 20>; -def MyEnum: EnumAttr<"MyEnum", "An example enum", [CaseA, CaseB]> { +def MyIntEnum: I32EnumAttr<"MyIntEnum", "An example int enum", + [Case15, Case20]> { let cppNamespace = "Outer::Inner"; - let underlyingType = "uint64_t"; let stringToSymbolFnName = "ConvertToEnum"; let symbolToStringFnName = "ConvertToString"; } @@ -743,35 +755,39 @@ The following will be generated via `mlir-tblgen -gen-enum-decls`: ```c++ namespace Outer { namespace Inner { -// An example enum -enum class MyEnum : uint64_t { - caseA = 0, - caseB = 10, +// An example int enum +enum class MyIntEnum : uint32_t { + Case15 = 15, + Case20 = 20, }; -llvm::StringRef ConvertToString(MyEnum); -llvm::Optional ConvertToEnum(llvm::StringRef); +llvm::Optional symbolizeMyIntEnum(uint32_t); +llvm::StringRef ConvertToString(MyIntEnum); +llvm::Optional ConvertToEnum(llvm::StringRef); +inline constexpr unsigned getMaxEnumValForMyIntEnum() { + return 20; +} + } // namespace Inner } // namespace Outer namespace llvm { -template<> struct DenseMapInfo { - using StorageInfo = llvm::DenseMapInfo; +template<> struct DenseMapInfo { + using StorageInfo = llvm::DenseMapInfo; - static inline Outer::Inner::MyEnum getEmptyKey() { - return static_cast(StorageInfo::getEmptyKey()); + static inline Outer::Inner::MyIntEnum getEmptyKey() { + return static_cast(StorageInfo::getEmptyKey()); } - static inline Outer::Inner::MyEnum getTombstoneKey() { - return static_cast(StorageInfo::getTombstoneKey()); + static inline Outer::Inner::MyIntEnum getTombstoneKey() { + return static_cast(StorageInfo::getTombstoneKey()); } - static unsigned getHashValue(const Outer::Inner::MyEnum &val) { - return StorageInfo::getHashValue(static_cast(val)); + static unsigned getHashValue(const Outer::Inner::MyIntEnum &val) { + return StorageInfo::getHashValue(static_cast(val)); } - static bool isEqual(const Outer::Inner::MyEnum &lhs, - const Outer::Inner::MyEnum &rhs) { + static bool isEqual(const Outer::Inner::MyIntEnum &lhs, const Outer::Inner::MyIntEnum &rhs) { return lhs == rhs; } }; @@ -783,24 +799,133 @@ The following will be generated via `mlir-tblgen -gen-enum-defs`: ```c++ namespace Outer { namespace Inner { -llvm::StringRef ConvertToString(MyEnum val) { +llvm::StringRef ConvertToString(MyIntEnum val) { switch (val) { - case MyEnum::caseA: return "caseA"; - case MyEnum::caseB: return "caseB"; - default: return ""; + case MyIntEnum::Case15: return "Case15"; + case MyIntEnum::Case20: return "Case20"; } + return ""; } -llvm::Optional ConvertToEnum(llvm::StringRef str) { - return llvm::StringSwitch>(str) - .Case("caseA", MyEnum::caseA) - .Case("caseB", MyEnum::caseB) +llvm::Optional ConvertToEnum(llvm::StringRef str) { + return llvm::StringSwitch>(str) + .Case("Case15", MyIntEnum::Case15) + .Case("Case20", MyIntEnum::Case20) .Default(llvm::None); } +llvm::Optional symbolizeMyIntEnum(uint32_t value) { + switch (value) { + case 15: return MyIntEnum::Case15; + case 20: return MyIntEnum::Case20; + default: return llvm::None; + } +} + } // namespace Inner } // namespace Outer ``` +Similarly for the following `BitEnumAttr` definition: + +```tablegen +def None: BitEnumAttrCase<"None", 0x0000>; +def Bit1: BitEnumAttrCase<"Bit1", 0x0001>; +def Bit2: BitEnumAttrCase<"Bit2", 0x0002>; +def Bit3: BitEnumAttrCase<"Bit3", 0x0004>; + +def MyBitEnum: BitEnumAttr<"MyBitEnum", "An example bit enum", + [None, Bit1, Bit2, Bit3]>; +``` + +We can have: + +```c++ +// An example bit enum +enum class MyBitEnum : uint32_t { + None = 0, + Bit1 = 1, + Bit2 = 2, + Bit3 = 4, +}; + +llvm::Optional symbolizeMyBitEnum(uint32_t); +std::string stringifyMyBitEnum(MyBitEnum); +llvm::Optional symbolizeMyBitEnum(llvm::StringRef); +inline MyBitEnum operator|(MyBitEnum lhs, MyBitEnum rhs) { + return static_cast(static_cast(lhs) | static_cast(rhs)); +} +inline MyBitEnum operator&(MyBitEnum lhs, MyBitEnum rhs) { + return static_cast(static_cast(lhs) & static_cast(rhs)); +} +inline bool bitEnumContains(MyBitEnum bits, MyBitEnum bit) { + return (static_cast(bits) & static_cast(bit)) != 0; +} + +namespace llvm { +template<> struct DenseMapInfo<::MyBitEnum> { + using StorageInfo = llvm::DenseMapInfo; + + static inline ::MyBitEnum getEmptyKey() { + return static_cast<::MyBitEnum>(StorageInfo::getEmptyKey()); + } + + static inline ::MyBitEnum getTombstoneKey() { + return static_cast<::MyBitEnum>(StorageInfo::getTombstoneKey()); + } + + static unsigned getHashValue(const ::MyBitEnum &val) { + return StorageInfo::getHashValue(static_cast(val)); + } + + static bool isEqual(const ::MyBitEnum &lhs, const ::MyBitEnum &rhs) { + return lhs == rhs; + } +}; +``` + +```c++ +std::string stringifyMyBitEnum(MyBitEnum symbol) { + auto val = static_cast(symbol); + // Special case for all bits unset. + if (val == 0) return "None"; + + llvm::SmallVector strs; + if (1u & val) { strs.push_back("Bit1"); val &= ~1u; } + if (2u & val) { strs.push_back("Bit2"); val &= ~2u; } + if (4u & val) { strs.push_back("Bit3"); val &= ~4u; } + + if (val) return ""; + return llvm::join(strs, "|"); +} + +llvm::Optional symbolizeMyBitEnum(llvm::StringRef str) { + // Special case for all bits unset. + if (str == "None") return MyBitEnum::None; + + llvm::SmallVector symbols; + str.split(symbols, "|"); + + uint32_t val = 0; + for (auto symbol : symbols) { + auto bit = llvm::StringSwitch>(symbol) + .Case("Bit1", 1) + .Case("Bit2", 2) + .Case("Bit3", 4) + .Default(llvm::None); + if (bit) { val |= *bit; } else { return llvm::None; } + } + return static_cast(val); +} + +llvm::Optional symbolizeMyBitEnum(uint32_t value) { + // Special case for all bits unset. + if (value == 0) return MyBitEnum::None; + + if (value & ~(1u | 2u | 4u)) return llvm::None; + return static_cast(value); +} +``` + TODO(b/132506080): This following is outdated. Update it. An attribute is a compile time known constant of an operation. Attributes are @@ -954,7 +1079,6 @@ function, the reference implementation of the operation will be used to derive the shape function. The reference implementation is general and can support the arbitrary computations needed to specify output shapes. - [TableGen]: https://llvm.org/docs/TableGen/index.html [TableGenIntro]: https://llvm.org/docs/TableGen/LangIntro.html [TableGenRef]: https://llvm.org/docs/TableGen/LangRef.html @@ -962,3 +1086,5 @@ arbitrary computations needed to specify output shapes. [OpBase]: https://github.com/tensorflow/mlir/blob/master/include/mlir/IR/OpBase.td [OpDefinitionsGen]: https://github.com/tensorflow/mlir/blob/master/tools/mlir-tblgen/OpDefinitionsGen.cpp [EnumsGen]: https://github.com/tensorflow/mlir/blob/master/tools/mlir-tblgen/EnumsGen.cpp +[StringAttr]: https://github.com/tensorflow/mlir/blob/master/g3doc/LangRef.md#string-attribute +[IntegerAttr]: https://github.com/tensorflow/mlir/blob/master/g3doc/LangRef.md#integer-attribute diff --git a/mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt b/mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt index f1d68036e35..af4520df130 100644 --- a/mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt +++ b/mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt @@ -4,14 +4,9 @@ mlir_tablegen(SPIRVOps.cpp.inc -gen-op-defs) add_public_tablegen_target(MLIRSPIRVOpsIncGen) set(LLVM_TARGET_DEFINITIONS SPIRVBase.td) -mlir_tablegen(SPIRVIntEnums.h.inc -gen-enum-decls) -mlir_tablegen(SPIRVIntEnums.cpp.inc -gen-enum-defs) -add_public_tablegen_target(MLIRSPIRVIntEnumsIncGen) - -set(LLVM_TARGET_DEFINITIONS SPIRVBase.td) -mlir_tablegen(SPIRVBitEnums.h.inc -gen-spirv-enum-decls) -mlir_tablegen(SPIRVBitEnums.cpp.inc -gen-spirv-enum-defs) -add_public_tablegen_target(MLIRSPIRVBitEnumsIncGen) +mlir_tablegen(SPIRVEnums.h.inc -gen-enum-decls) +mlir_tablegen(SPIRVEnums.cpp.inc -gen-enum-defs) +add_public_tablegen_target(MLIRSPIRVEnumsIncGen) set(LLVM_TARGET_DEFINITIONS SPIRVOps.td) mlir_tablegen(SPIRVSerialization.inc -gen-spirv-serialization) diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td index 253217bd678..ba8659c87c7 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td @@ -274,49 +274,6 @@ class SPV_Optional : Variadic; // TODO(ravishankarm): From 1.4, this should also include Composite type. def SPV_SelectType : AnyTypeOf<[SPV_Scalar, SPV_Vector, SPV_AnyPtr]>; -//===----------------------------------------------------------------------===// -// SPIR-V BitEnum definition -//===----------------------------------------------------------------------===// - -// A bit enum case stored with 32-bit IntegerAttr. `val` here is *not* the -// ordinal number of the bit that is set. It is the 32-bit integer with only -// one bit set. -class BitEnumAttrCase : - EnumAttrCaseInfo, - IntegerAttrBase { - let predicate = CPred< - "$_self.cast().getValue().getSExtValue() & " # val # "u">; -} - -// A bit enum stored with 32-bit IntegerAttr. -// -// Op attributes of this kind are stored as IntegerAttr. Extra verification will -// be generated on the integer to make sure only allowed bit are set. -class BitEnumAttr cases> : - EnumAttrInfo, IntegerAttrBase { - let predicate = And<[ - IntegerAttrBase.predicate, - // Make sure we don't have unknown bit set. - CPred<"!($_self.cast().getValue().getZExtValue() & (~(" # - StrJoin.result # - ")))"> - ]>; - - let underlyingType = "uint32_t"; - - // We need to return a string because we may concatenate symbols for multiple - // bits together. - let symbolToStringFnRetType = "std::string"; - - // The string used to separate bit enum cases in strings. - string separator = "|"; - - // Turn off the autogen with EnumsGen. SPIR-V needs custom logic here and - // we will use our own autogen logic. - let skipAutoGen = 1; -} - //===----------------------------------------------------------------------===// // SPIR-V extension definitions //===----------------------------------------------------------------------===// diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h b/mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h index 81d2a8bc38d..bc3083e8d7c 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h @@ -27,8 +27,7 @@ #include "mlir/IR/Types.h" // Pull in all enum type definitions and utility function declarations -#include "mlir/Dialect/SPIRV/SPIRVBitEnums.h.inc" -#include "mlir/Dialect/SPIRV/SPIRVIntEnums.h.inc" +#include "mlir/Dialect/SPIRV/SPIRVEnums.h.inc" #include diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index b57c549d205..1393a1dce58 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -836,6 +836,16 @@ class IntEnumAttrCaseBase : class I32EnumAttrCase : IntEnumAttrCaseBase; class I64EnumAttrCase : IntEnumAttrCaseBase; +// A bit enum case stored with 32-bit IntegerAttr. `val` here is *not* the +// ordinal number of the bit that is set. It is the 32-bit integer with only +// one bit set. +class BitEnumAttrCase : + EnumAttrCaseInfo, + IntegerAttrBase { + let predicate = CPred< + "$_self.cast().getValue().getZExtValue() & " # val # "u">; +} + // Additional information for an enum attribute. class EnumAttrInfo cases> { // The C++ enum class name @@ -844,10 +854,6 @@ class EnumAttrInfo cases> { // List of all accepted cases list enumerants = cases; - // Whether to skip automatically generating C++ enum class and utility - // functions for this enum attribute with EnumsGen. - bit skipAutoGen = 0; - // The following fields are only used by the EnumsGen backend to generate // an enum class definition and conversion utility functions. @@ -940,6 +946,33 @@ class I64EnumAttr cases> : + EnumAttrInfo, IntegerAttrBase { + let predicate = And<[ + IntegerAttrBase.predicate, + // Make sure we don't have unknown bit set. + CPred<"!($_self.cast().getValue().getZExtValue() & (~(" # + StrJoin.result # + ")))"> + ]>; + + let underlyingType = "uint32_t"; + + // We need to return a string because we may concatenate symbols for multiple + // bits together. + let symbolToStringFnRetType = "std::string"; + + // The delimiter used to separate bit enum cases in strings. + string separator = "|"; +} + //===----------------------------------------------------------------------===// // Composite attribute kinds diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index be688c9579c..9f221b9ed9b 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -151,8 +151,8 @@ public: explicit EnumAttr(const llvm::Record &record); explicit EnumAttr(const llvm::DefInit *init); - // Returns whether skipping auto-generation is requested. - bool skipAutoGen() const; + // Returns true if this is a bit enum attribute. + bool isBitEnum() const; // Returns the enum class name. StringRef getEnumClassName() const; diff --git a/mlir/lib/Dialect/SPIRV/CMakeLists.txt b/mlir/lib/Dialect/SPIRV/CMakeLists.txt index a6a36f4f11c..dd51f0aae7e 100644 --- a/mlir/lib/Dialect/SPIRV/CMakeLists.txt +++ b/mlir/lib/Dialect/SPIRV/CMakeLists.txt @@ -11,8 +11,7 @@ add_llvm_library(MLIRSPIRV add_dependencies(MLIRSPIRV MLIRSPIRVOpsIncGen - MLIRSPIRVIntEnumsIncGen - MLIRSPIRVBitEnumsIncGen + MLIRSPIRVEnumsIncGen MLIRSPIRVOpUtilsGen) target_link_libraries(MLIRSPIRV diff --git a/mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp b/mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp index 66765bec976..b4f49b75bfb 100644 --- a/mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp @@ -28,8 +28,7 @@ using namespace mlir; using namespace mlir::spirv; // Pull in all enum utility function definitions -#include "mlir/Dialect/SPIRV/SPIRVBitEnums.cpp.inc" -#include "mlir/Dialect/SPIRV/SPIRVIntEnums.cpp.inc" +#include "mlir/Dialect/SPIRV/SPIRVEnums.cpp.inc" //===----------------------------------------------------------------------===// // ArrayType diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index 46bbfff7137..b9432e5a729 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -170,8 +170,8 @@ tblgen::EnumAttr::EnumAttr(const llvm::Record &record) : Attribute(&record) {} tblgen::EnumAttr::EnumAttr(const llvm::DefInit *init) : EnumAttr(init->getDef()) {} -bool tblgen::EnumAttr::skipAutoGen() const { - return def->getValueAsBit("skipAutoGen"); +bool tblgen::EnumAttr::isBitEnum() const { + return def->isSubClassOf("BitEnumAttr"); } StringRef tblgen::EnumAttr::getEnumClassName() const { diff --git a/mlir/tools/mlir-tblgen/EnumsGen.cpp b/mlir/tools/mlir-tblgen/EnumsGen.cpp index b36672e26be..e278fdd80e8 100644 --- a/mlir/tools/mlir-tblgen/EnumsGen.cpp +++ b/mlir/tools/mlir-tblgen/EnumsGen.cpp @@ -19,7 +19,6 @@ // //===----------------------------------------------------------------------===// -#include "EnumsGen.h" #include "mlir/TableGen/Attribute.h" #include "mlir/TableGen/GenInfo.h" #include "llvm/ADT/SmallVector.h" @@ -124,7 +123,44 @@ static void emitMaxValueFn(const Record &enumDef, raw_ostream &os) { os << "}\n\n"; } -static void emitSymToStrFn(const Record &enumDef, raw_ostream &os) { +// Returns the EnumAttrCase whose value is zero if exists; returns llvm::None +// otherwise. +static llvm::Optional +getAllBitsUnsetCase(llvm::ArrayRef cases) { + for (auto attrCase : cases) { + if (attrCase.getValue() == 0) + return attrCase; + } + return llvm::None; +} + +// Emits the following inline function for bit enums: +// +// inline operator|( a, b); +// inline operator&( a, b); +// inline bitEnumContains( a, b); +static void emitOperators(const Record &enumDef, raw_ostream &os) { + EnumAttr enumAttr(enumDef); + StringRef enumName = enumAttr.getEnumClassName(); + std::string underlyingType = enumAttr.getUnderlyingType(); + os << formatv("inline {0} operator|({0} lhs, {0} rhs) {{\n", enumName) + << formatv(" return static_cast<{0}>(" + "static_cast<{1}>(lhs) | static_cast<{1}>(rhs));\n", + enumName, underlyingType) + << "}\n"; + os << formatv("inline {0} operator&({0} lhs, {0} rhs) {{\n", enumName) + << formatv(" return static_cast<{0}>(" + "static_cast<{1}>(lhs) & static_cast<{1}>(rhs));\n", + enumName, underlyingType) + << "}\n"; + os << formatv( + "inline bool bitEnumContains({0} bits, {0} bit) {{\n" + " return (static_cast<{1}>(bits) & static_cast<{1}>(bit)) != 0;\n", + enumName, underlyingType) + << "}\n"; +} + +static void emitSymToStrFnForIntEnum(const Record &enumDef, raw_ostream &os) { EnumAttr enumAttr(enumDef); StringRef enumName = enumAttr.getEnumClassName(); StringRef symToStrFnName = enumAttr.getSymbolToStringFnName(); @@ -144,7 +180,41 @@ static void emitSymToStrFn(const Record &enumDef, raw_ostream &os) { os << "}\n\n"; } -static void emitStrToSymFn(const Record &enumDef, raw_ostream &os) { +static void emitSymToStrFnForBitEnum(const Record &enumDef, raw_ostream &os) { + EnumAttr enumAttr(enumDef); + StringRef enumName = enumAttr.getEnumClassName(); + StringRef symToStrFnName = enumAttr.getSymbolToStringFnName(); + StringRef symToStrFnRetType = enumAttr.getSymbolToStringFnRetType(); + StringRef separator = enumDef.getValueAsString("separator"); + auto enumerants = enumAttr.getAllCases(); + auto allBitsUnsetCase = getAllBitsUnsetCase(enumerants); + + os << formatv("{2} {1}({0} symbol) {{\n", enumName, symToStrFnName, + symToStrFnRetType); + + os << formatv(" auto val = static_cast<{0}>(symbol);\n", + enumAttr.getUnderlyingType()); + if (allBitsUnsetCase) { + os << " // Special case for all bits unset.\n"; + os << formatv(" if (val == 0) return \"{0}\";\n\n", + allBitsUnsetCase->getSymbol()); + } + os << " llvm::SmallVector strs;\n"; + for (const auto &enumerant : enumerants) { + // Skip the special enumerant for None. + if (auto val = enumerant.getValue()) + os << formatv(" if ({0}u & val) {{ strs.push_back(\"{1}\"); " + "val &= ~{0}u; }\n", + val, enumerant.getSymbol()); + } + // If we have unknown bit set, return an empty string to signal errors. + os << "\n if (val) return \"\";\n"; + os << formatv(" return llvm::join(strs, \"{0}\");\n", separator); + + os << "}\n\n"; +} + +static void emitStrToSymFnForIntEnum(const Record &enumDef, raw_ostream &os) { EnumAttr enumAttr(enumDef); StringRef enumName = enumAttr.getEnumClassName(); StringRef strToSymFnName = enumAttr.getStringToSymbolFnName(); @@ -163,7 +233,53 @@ static void emitStrToSymFn(const Record &enumDef, raw_ostream &os) { os << "}\n"; } -static void emitUnderlyingToSymFn(const Record &enumDef, raw_ostream &os) { +static void emitStrToSymFnForBitEnum(const Record &enumDef, raw_ostream &os) { + EnumAttr enumAttr(enumDef); + StringRef enumName = enumAttr.getEnumClassName(); + std::string underlyingType = enumAttr.getUnderlyingType(); + StringRef strToSymFnName = enumAttr.getStringToSymbolFnName(); + StringRef separator = enumDef.getValueAsString("separator"); + auto enumerants = enumAttr.getAllCases(); + auto allBitsUnsetCase = getAllBitsUnsetCase(enumerants); + + os << formatv("llvm::Optional<{0}> {1}(llvm::StringRef str) {{\n", enumName, + strToSymFnName); + + if (allBitsUnsetCase) { + os << " // Special case for all bits unset.\n"; + StringRef caseSymbol = allBitsUnsetCase->getSymbol(); + os << formatv(" if (str == \"{1}\") return {0}::{2};\n\n", enumName, + caseSymbol, makeIdentifier(caseSymbol)); + } + + // Split the string to get symbols for all the bits. + os << " llvm::SmallVector symbols;\n"; + os << formatv(" str.split(symbols, \"{0}\");\n\n", separator); + + os << formatv(" {0} val = 0;\n", underlyingType); + os << " for (auto symbol : symbols) {\n"; + + // Convert each symbol to the bit ordinal and set the corresponding bit. + os << formatv( + " auto bit = llvm::StringSwitch>(symbol)\n", + underlyingType); + for (const auto &enumerant : enumerants) { + // Skip the special enumerant for None. + if (auto val = enumerant.getValue()) + os.indent(6) << formatv(".Case(\"{0}\", {1})\n", enumerant.getSymbol(), + val); + } + os.indent(6) << ".Default(llvm::None);\n"; + + os << " if (bit) { val |= *bit; } else { return llvm::None; }\n"; + os << " }\n"; + + os << formatv(" return static_cast<{0}>(val);\n", enumName); + os << "}\n\n"; +} + +static void emitUnderlyingToSymFnForIntEnum(const Record &enumDef, + raw_ostream &os) { EnumAttr enumAttr(enumDef); StringRef enumName = enumAttr.getEnumClassName(); std::string underlyingType = enumAttr.getUnderlyingType(); @@ -193,8 +309,34 @@ static void emitUnderlyingToSymFn(const Record &enumDef, raw_ostream &os) { << "}\n\n"; } -void mlir::tblgen::emitEnumDecl(const Record &enumDef, - ExtraFnEmitter emitExtraFns, raw_ostream &os) { +static void emitUnderlyingToSymFnForBitEnum(const Record &enumDef, + raw_ostream &os) { + EnumAttr enumAttr(enumDef); + StringRef enumName = enumAttr.getEnumClassName(); + std::string underlyingType = enumAttr.getUnderlyingType(); + StringRef underlyingToSymFnName = enumAttr.getUnderlyingToSymbolFnName(); + auto enumerants = enumAttr.getAllCases(); + auto allBitsUnsetCase = getAllBitsUnsetCase(enumerants); + + os << formatv("llvm::Optional<{0}> {1}({2} value) {{\n", enumName, + underlyingToSymFnName, underlyingType); + if (allBitsUnsetCase) { + os << " // Special case for all bits unset.\n"; + os << formatv(" if (value == 0) return {0}::{1};\n\n", enumName, + makeIdentifier(allBitsUnsetCase->getSymbol())); + } + llvm::SmallVector values; + for (const auto &enumerant : enumerants) { + if (auto val = enumerant.getValue()) + values.push_back(formatv("{0}u", val)); + } + os << formatv(" if (value & ~({0})) return llvm::None;\n", + llvm::join(values, " | ")); + os << formatv(" return static_cast<{0}>(value);\n", enumName); + os << "}\n"; +} + +static void emitEnumDecl(const Record &enumDef, raw_ostream &os) { EnumAttr enumAttr(enumDef); StringRef enumName = enumAttr.getEnumClassName(); StringRef cppNamespace = enumAttr.getCppNamespace(); @@ -227,7 +369,11 @@ void mlir::tblgen::emitEnumDecl(const Record &enumDef, os << formatv("llvm::Optional<{0}> {1}(llvm::StringRef);\n", enumName, strToSymFnName); - emitExtraFns(enumDef, os); + if (enumAttr.isBitEnum()) { + emitOperators(enumDef, os); + } else { + emitMaxValueFn(enumDef, os); + } for (auto ns : llvm::reverse(namespaces)) os << "} // namespace " << ns << "\n"; @@ -239,14 +385,9 @@ void mlir::tblgen::emitEnumDecl(const Record &enumDef, static bool emitEnumDecls(const RecordKeeper &recordKeeper, raw_ostream &os) { llvm::emitSourceFileHeader("Enum Utility Declarations", os); - auto extraFnEmitter = [](const Record &enumDef, raw_ostream &os) { - emitMaxValueFn(enumDef, os); - }; - auto defs = recordKeeper.getAllDerivedDefinitions("EnumAttrInfo"); for (const auto *def : defs) - if (!EnumAttr(def).skipAutoGen()) - mlir::tblgen::emitEnumDecl(*def, extraFnEmitter, os); + emitEnumDecl(*def, os); return false; } @@ -261,9 +402,15 @@ static void emitEnumDef(const Record &enumDef, raw_ostream &os) { for (auto ns : namespaces) os << "namespace " << ns << " {\n"; - emitSymToStrFn(enumDef, os); - emitStrToSymFn(enumDef, os); - emitUnderlyingToSymFn(enumDef, os); + if (enumAttr.isBitEnum()) { + emitSymToStrFnForBitEnum(enumDef, os); + emitStrToSymFnForBitEnum(enumDef, os); + emitUnderlyingToSymFnForBitEnum(enumDef, os); + } else { + emitSymToStrFnForIntEnum(enumDef, os); + emitStrToSymFnForIntEnum(enumDef, os); + emitUnderlyingToSymFnForIntEnum(enumDef, os); + } for (auto ns : llvm::reverse(namespaces)) os << "} // namespace " << ns << "\n"; @@ -275,8 +422,7 @@ static bool emitEnumDefs(const RecordKeeper &recordKeeper, raw_ostream &os) { auto defs = recordKeeper.getAllDerivedDefinitions("EnumAttrInfo"); for (const auto *def : defs) - if (!EnumAttr(def).skipAutoGen()) - emitEnumDef(*def, os); + emitEnumDef(*def, os); return false; } diff --git a/mlir/tools/mlir-tblgen/EnumsGen.h b/mlir/tools/mlir-tblgen/EnumsGen.h deleted file mode 100644 index 552d29e1f2e..00000000000 --- a/mlir/tools/mlir-tblgen/EnumsGen.h +++ /dev/null @@ -1,48 +0,0 @@ -//===- EnumsGen.h - MLIR enum utility generator -----------------*- C++ -*-===// -// -// Copyright 2019 The MLIR Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= -// -// This file defines common utilities for enum generator. -// -//===----------------------------------------------------------------------===// - -#ifndef MLIR_TOOLS_MLIR_TBLGEN_ENUMSGEN_H_ -#define MLIR_TOOLS_MLIR_TBLGEN_ENUMSGEN_H_ - -#include "mlir/Support/LLVM.h" - -namespace llvm { -class Record; -} - -namespace mlir { -namespace tblgen { - -using ExtraFnEmitter = llvm::function_ref; - -// Emits declarations for the given EnumAttr `enumDef` into `os`. -// -// This will emit a C++ enum class and string to symbol and symbol to string -// conversion utility declarations. Additional functions can be emitted via -// the `emitExtraFns` function. -void emitEnumDecl(const llvm::Record &enumDef, ExtraFnEmitter emitExtraFns, - llvm::raw_ostream &os); - -} // namespace tblgen -} // namespace mlir - -#endif // MLIR_TOOLS_MLIR_TBLGEN_ENUMSGEN_H_ diff --git a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp index 184c17f3431..25d0adea717 100644 --- a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp +++ b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp @@ -20,7 +20,6 @@ // //===----------------------------------------------------------------------===// -#include "EnumsGen.h" #include "mlir/Support/StringExtras.h" #include "mlir/TableGen/Attribute.h" #include "mlir/TableGen/GenInfo.h" @@ -705,170 +704,6 @@ static bool emitOpUtils(const RecordKeeper &recordKeeper, raw_ostream &os) { return false; } -//===----------------------------------------------------------------------===// -// BitEnum AutoGen -//===----------------------------------------------------------------------===// - -// Emits the following inline function for bit enums: -// inline operator|( a, b); -// inline operator&( a, b); -// inline bitEnumContains( a, b); -static void emitOperators(const Record &enumDef, raw_ostream &os) { - EnumAttr enumAttr(enumDef); - StringRef enumName = enumAttr.getEnumClassName(); - std::string underlyingType = enumAttr.getUnderlyingType(); - os << formatv("inline {0} operator|({0} lhs, {0} rhs) {{\n", enumName) - << formatv(" return static_cast<{0}>(" - "static_cast<{1}>(lhs) | static_cast<{1}>(rhs));\n", - enumName, underlyingType) - << "}\n"; - os << formatv("inline {0} operator&({0} lhs, {0} rhs) {{\n", enumName) - << formatv(" return static_cast<{0}>(" - "static_cast<{1}>(lhs) & static_cast<{1}>(rhs));\n", - enumName, underlyingType) - << "}\n"; - os << formatv( - "inline bool bitEnumContains({0} bits, {0} bit) {{\n" - " return (static_cast<{1}>(bits) & static_cast<{1}>(bit)) != 0;\n", - enumName, underlyingType) - << "}\n"; -} - -static bool emitBitEnumDecls(const RecordKeeper &recordKeeper, - raw_ostream &os) { - llvm::emitSourceFileHeader("BitEnum Utility Declarations", os); - - auto operatorsEmitter = [](const Record &enumDef, llvm::raw_ostream &os) { - return emitOperators(enumDef, os); - }; - - auto defs = recordKeeper.getAllDerivedDefinitions("BitEnumAttr"); - for (const auto *def : defs) - mlir::tblgen::emitEnumDecl(*def, operatorsEmitter, os); - - return false; -} - -static void emitSymToStrFnForBitEnum(const Record &enumDef, raw_ostream &os) { - EnumAttr enumAttr(enumDef); - StringRef enumName = enumAttr.getEnumClassName(); - StringRef symToStrFnName = enumAttr.getSymbolToStringFnName(); - StringRef symToStrFnRetType = enumAttr.getSymbolToStringFnRetType(); - StringRef separator = enumDef.getValueAsString("separator"); - auto enumerants = enumAttr.getAllCases(); - - os << formatv("{2} {1}({0} symbol) {{\n", enumName, symToStrFnName, - symToStrFnRetType); - - os << formatv(" auto val = static_cast<{0}>(symbol);\n", - enumAttr.getUnderlyingType()); - os << " // Special case for all bits unset.\n"; - os << " if (val == 0) return \"None\";\n\n"; - os << " SmallVector strs;\n"; - for (const auto &enumerant : enumerants) { - // Skip the special enumerant for None. - if (auto val = enumerant.getValue()) - os << formatv(" if ({0}u & val) {{ strs.push_back(\"{1}\"); " - "val &= ~{0}u; }\n", - val, enumerant.getSymbol()); - } - // If we have unknown bit set, return an empty string to signal errors. - os << "\n if (val) return \"\";\n"; - os << formatv(" return llvm::join(strs, \"{0}\");\n", separator); - - os << "}\n\n"; -} - -static void emitStrToSymFnForBitEnum(const Record &enumDef, raw_ostream &os) { - EnumAttr enumAttr(enumDef); - StringRef enumName = enumAttr.getEnumClassName(); - std::string underlyingType = enumAttr.getUnderlyingType(); - StringRef strToSymFnName = enumAttr.getStringToSymbolFnName(); - StringRef separator = enumDef.getValueAsString("separator"); - auto enumerants = enumAttr.getAllCases(); - - os << formatv("llvm::Optional<{0}> {1}(llvm::StringRef str) {{\n", enumName, - strToSymFnName); - - os << formatv(" if (str == \"None\") return {0}::None;\n\n", enumName); - - // Split the string to get symbols for all the bits. - os << " SmallVector symbols;\n"; - os << formatv(" str.split(symbols, \"{0}\");\n\n", separator); - - os << formatv(" {0} val = 0;\n", underlyingType); - os << " for (auto symbol : symbols) {\n"; - - // Convert each symbol to the bit ordinal and set the corresponding bit. - os << formatv( - " auto bit = llvm::StringSwitch>(symbol)\n", - underlyingType); - for (const auto &enumerant : enumerants) { - // Skip the special enumerant for None. - if (auto val = enumerant.getValue()) - os.indent(6) << formatv(".Case(\"{0}\", {1})\n", enumerant.getSymbol(), - val); - } - os.indent(6) << ".Default(llvm::None);\n"; - - os << " if (bit) { val |= *bit; } else { return llvm::None; }\n"; - os << " }\n"; - - os << formatv(" return static_cast<{0}>(val);\n", enumName); - os << "}\n\n"; -} - -static void emitUnderlyingToSymFnForBitEnum(const Record &enumDef, - raw_ostream &os) { - EnumAttr enumAttr(enumDef); - StringRef enumName = enumAttr.getEnumClassName(); - std::string underlyingType = enumAttr.getUnderlyingType(); - StringRef underlyingToSymFnName = enumAttr.getUnderlyingToSymbolFnName(); - auto enumerants = enumAttr.getAllCases(); - - os << formatv("llvm::Optional<{0}> {1}({2} value) {{\n", enumName, - underlyingToSymFnName, underlyingType); - os << formatv(" if (value == 0) return {0}::None;\n", enumName); - llvm::SmallVector values; - for (const auto &enumerant : enumerants) { - if (auto val = enumerant.getValue()) - values.push_back(formatv("{0}u", val)); - } - os << formatv(" if (value & ~({0})) return llvm::None;\n", - llvm::join(values, " | ")); - os << formatv(" return static_cast<{0}>(value);\n", enumName); - os << "}\n"; -} - -static void emitBitEnumDef(const Record &enumDef, raw_ostream &os) { - EnumAttr enumAttr(enumDef); - StringRef cppNamespace = enumAttr.getCppNamespace(); - - llvm::SmallVector namespaces; - llvm::SplitString(cppNamespace, namespaces, "::"); - - for (auto ns : namespaces) - os << "namespace " << ns << " {\n"; - - emitSymToStrFnForBitEnum(enumDef, os); - emitStrToSymFnForBitEnum(enumDef, os); - emitUnderlyingToSymFnForBitEnum(enumDef, os); - - for (auto ns : llvm::reverse(namespaces)) - os << "} // namespace " << ns << "\n"; - os << "\n"; -} - -static bool emitBitEnumDefs(const RecordKeeper &recordKeeper, raw_ostream &os) { - llvm::emitSourceFileHeader("BitEnum Utility Definitions", os); - - auto defs = recordKeeper.getAllDerivedDefinitions("BitEnumAttr"); - for (const auto *def : defs) - emitBitEnumDef(*def, os); - - return false; -} - //===----------------------------------------------------------------------===// // Hook Registration //===----------------------------------------------------------------------===// @@ -886,17 +721,3 @@ static mlir::GenRegistration [](const RecordKeeper &records, raw_ostream &os) { return emitOpUtils(records, os); }); - -static mlir::GenRegistration - genEnumDecls("gen-spirv-enum-decls", - "Generate SPIR-V bit enum utility declarations", - [](const RecordKeeper &records, raw_ostream &os) { - return emitBitEnumDecls(records, os); - }); - -static mlir::GenRegistration - genEnumDefs("gen-spirv-enum-defs", - "Generate SPIR-V bit enum utility definitions", - [](const RecordKeeper &records, raw_ostream &os) { - return emitBitEnumDefs(records, os); - }); diff --git a/mlir/unittests/TableGen/EnumsGenTest.cpp b/mlir/unittests/TableGen/EnumsGenTest.cpp index f20ec0ca381..3934e8b0ed2 100644 --- a/mlir/unittests/TableGen/EnumsGenTest.cpp +++ b/mlir/unittests/TableGen/EnumsGenTest.cpp @@ -17,6 +17,8 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/Optional.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" #include "gmock/gmock.h" #include @@ -68,3 +70,38 @@ TEST(EnumsGenTest, GeneratedUnderlyingType) { bool v = std::is_same::type>::value; EXPECT_TRUE(v); } + +TEST(EnumsGenTest, GeneratedBitEnumDefinition) { + EXPECT_EQ(0u, static_cast(BitEnumWithNone::None)); + EXPECT_EQ(1u, static_cast(BitEnumWithNone::Bit1)); + EXPECT_EQ(4u, static_cast(BitEnumWithNone::Bit3)); +} + +TEST(EnumsGenTest, GeneratedSymbolToStringFnForBitEnum) { + EXPECT_THAT(stringifyBitEnumWithNone(BitEnumWithNone::None), StrEq("None")); + EXPECT_THAT(stringifyBitEnumWithNone(BitEnumWithNone::Bit1), StrEq("Bit1")); + EXPECT_THAT(stringifyBitEnumWithNone(BitEnumWithNone::Bit3), StrEq("Bit3")); + EXPECT_THAT( + stringifyBitEnumWithNone(BitEnumWithNone::Bit1 | BitEnumWithNone::Bit3), + StrEq("Bit1|Bit3")); +} + +TEST(EnumsGenTest, GeneratedStringToSymbolForBitEnum) { + EXPECT_EQ(symbolizeBitEnumWithNone("None"), BitEnumWithNone::None); + EXPECT_EQ(symbolizeBitEnumWithNone("Bit1"), BitEnumWithNone::Bit1); + EXPECT_EQ(symbolizeBitEnumWithNone("Bit3"), BitEnumWithNone::Bit3); + EXPECT_EQ(symbolizeBitEnumWithNone("Bit3|Bit1"), + BitEnumWithNone::Bit3 | BitEnumWithNone::Bit1); + + EXPECT_EQ(symbolizeBitEnumWithNone("Bit2"), llvm::None); + EXPECT_EQ(symbolizeBitEnumWithNone("Bit3|Bit4"), llvm::None); + + EXPECT_EQ(symbolizeBitEnumWithoutNone("None"), llvm::None); +} + +TEST(EnumsGenTest, GeneratedOperator) { + EXPECT_TRUE(bitEnumContains(BitEnumWithNone::Bit1 | BitEnumWithNone::Bit3, + BitEnumWithNone::Bit1)); + EXPECT_FALSE(bitEnumContains(BitEnumWithNone::Bit1 & BitEnumWithNone::Bit3, + BitEnumWithNone::Bit1)); +} diff --git a/mlir/unittests/TableGen/enums.td b/mlir/unittests/TableGen/enums.td index a623e1e56cc..806d4a9d7b9 100644 --- a/mlir/unittests/TableGen/enums.td +++ b/mlir/unittests/TableGen/enums.td @@ -30,3 +30,13 @@ def Case5: I32EnumAttrCase<"Case5", 5>; def Case10: I32EnumAttrCase<"Case10", 10>; def I32Enum: I32EnumAttr<"I32Enum", "A test enum", [Case5, Case10]>; + +def Bit0 : BitEnumAttrCase<"None", 0x0000>; +def Bit1 : BitEnumAttrCase<"Bit1", 0x0001>; +def Bit3 : BitEnumAttrCase<"Bit3", 0x0004>; + +def BitEnumWithNone : BitEnumAttr<"BitEnumWithNone", "A test enum", + [Bit0, Bit1, Bit3]>; + +def BitEnumWithoutNone : BitEnumAttr<"BitEnumWithoutNone", "A test enum", + [Bit1, Bit3]>; -- cgit v1.2.3 From aa9dc9446e21b0de1389d460a41867ade7bc4683 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 12 Nov 2019 11:57:40 -0800 Subject: Expose an isSubclassOf() method on AttrConstraint PiperOrigin-RevId: 280021408 --- mlir/include/mlir/TableGen/Attribute.h | 4 ++++ mlir/lib/TableGen/Attribute.cpp | 24 +++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index 9f221b9ed9b..60f95156bb5 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -42,6 +42,10 @@ public: explicit AttrConstraint(const llvm::Record *record); static bool classof(const Constraint *c) { return c->getKind() == CK_Attr; } + + // Returns true if this constraint is a subclass of the given `className` + // class defined in TableGen. + bool isSubClassOf(StringRef className) const; }; // Wrapper class providing helper methods for accessing MLIR Attribute defined diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index b9432e5a729..c2b673a7c93 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -44,10 +44,14 @@ static StringRef getValueAsString(const Init *init) { tblgen::AttrConstraint::AttrConstraint(const Record *record) : Constraint(Constraint::CK_Attr, record) { - assert(def->isSubClassOf("AttrConstraint") && + assert(isSubClassOf("AttrConstraint") && "must be subclass of TableGen 'AttrConstraint' class"); } +bool tblgen::AttrConstraint::isSubClassOf(StringRef className) const { + return def->isSubClassOf(className); +} + tblgen::Attribute::Attribute(const Record *record) : AttrConstraint(record) { assert(record->isSubClassOf("Attr") && "must be subclass of TableGen 'Attr' class"); @@ -56,15 +60,15 @@ tblgen::Attribute::Attribute(const Record *record) : AttrConstraint(record) { tblgen::Attribute::Attribute(const DefInit *init) : Attribute(init->getDef()) {} bool tblgen::Attribute::isDerivedAttr() const { - return def->isSubClassOf("DerivedAttr"); + return isSubClassOf("DerivedAttr"); } bool tblgen::Attribute::isTypeAttr() const { - return def->isSubClassOf("TypeAttrBase"); + return isSubClassOf("TypeAttrBase"); } bool tblgen::Attribute::isEnumAttr() const { - return def->isSubClassOf("EnumAttrInfo"); + return isSubClassOf("EnumAttrInfo"); } StringRef tblgen::Attribute::getStorageType() const { @@ -144,12 +148,12 @@ StringRef tblgen::ConstantAttr::getConstantValue() const { tblgen::EnumAttrCase::EnumAttrCase(const llvm::DefInit *init) : Attribute(init) { - assert(def->isSubClassOf("EnumAttrCaseInfo") && + assert(isSubClassOf("EnumAttrCaseInfo") && "must be subclass of TableGen 'EnumAttrInfo' class"); } bool tblgen::EnumAttrCase::isStrCase() const { - return def->isSubClassOf("StrEnumAttrCase"); + return isSubClassOf("StrEnumAttrCase"); } StringRef tblgen::EnumAttrCase::getSymbol() const { @@ -161,7 +165,7 @@ int64_t tblgen::EnumAttrCase::getValue() const { } tblgen::EnumAttr::EnumAttr(const llvm::Record *record) : Attribute(record) { - assert(def->isSubClassOf("EnumAttrInfo") && + assert(isSubClassOf("EnumAttrInfo") && "must be subclass of TableGen 'EnumAttr' class"); } @@ -170,9 +174,7 @@ tblgen::EnumAttr::EnumAttr(const llvm::Record &record) : Attribute(&record) {} tblgen::EnumAttr::EnumAttr(const llvm::DefInit *init) : EnumAttr(init->getDef()) {} -bool tblgen::EnumAttr::isBitEnum() const { - return def->isSubClassOf("BitEnumAttr"); -} +bool tblgen::EnumAttr::isBitEnum() const { return isSubClassOf("BitEnumAttr"); } StringRef tblgen::EnumAttr::getEnumClassName() const { return def->getValueAsString("className"); @@ -241,7 +243,7 @@ tblgen::Attribute tblgen::StructFieldAttr::getType() const { } tblgen::StructAttr::StructAttr(const llvm::Record *record) : Attribute(record) { - assert(def->isSubClassOf("StructAttr") && + assert(isSubClassOf("StructAttr") && "must be subclass of TableGen 'StructAttr' class"); } -- cgit v1.2.3 From b41162b3af62668b36076baebf765044e21c04ba Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 2 Dec 2019 09:33:24 -0800 Subject: [ODS] Generate builders taking unwrapped value and defaults for attributes Existing builders generated by ODS require attributes to be passed in as mlir::Attribute or its subclasses. This is okay foraggregate- parameter builders, which is primarily to be used by programmatic C++ code generation; it is inconvenient for separate-parameter builders meant to be called in manually written C++ code because it requires developers to wrap raw values into mlir::Attribute by themselves. This CL extends to generate additional builder methods that take raw values for attributes and handles the wrapping in the builder implementation. Additionally, if an attribute appears late in the arguments list and has a default value, the default value is supplied in the declaration if possible. PiperOrigin-RevId: 283355919 --- mlir/g3doc/OpDefinitions.md | 79 +++++++++-- mlir/include/mlir/TableGen/Attribute.h | 8 +- mlir/include/mlir/TableGen/Operator.h | 1 + mlir/lib/TableGen/Attribute.cpp | 4 +- mlir/test/mlir-tblgen/op-attribute.td | 211 ++++++++++++++++++---------- mlir/test/mlir-tblgen/op-decl.td | 2 +- mlir/test/mlir-tblgen/op-result.td | 10 +- mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | 203 +++++++++++++++++++++----- mlir/tools/mlir-tblgen/RewriterGen.cpp | 4 +- 9 files changed, 386 insertions(+), 136 deletions(-) (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/g3doc/OpDefinitions.md b/mlir/g3doc/OpDefinitions.md index ea794964033..25865593800 100644 --- a/mlir/g3doc/OpDefinitions.md +++ b/mlir/g3doc/OpDefinitions.md @@ -382,27 +382,86 @@ def OpWithInferTypeInterfaceOp : Op<... [DeclareOpInterfaceMethods]> { ... } ``` -### Custom builder methods +### Builder methods -For each operation, there are two builders automatically generated based on the -arguments and returns types: +For each operation, there are a few builders automatically generated based on +the arguments and returns types. For example, given the following op definition: -```c++ -static void build(Builder *, OperationState &tblgen_state, - Type , Type , ..., - Value , Value , ..., - Attribute , Attribute , ...); +```tablegen +def MyOp : ... { + let arguments = (ins + I32:$i32_operand, + F32:$f32_operand, + ..., -static void build(Builder *, OperationState &tblgen_state, + I32Attr:$i32_attr, + F32Attr:$f32_attr, + ... + ); + + let results = (outs + I32:$i32_result, + F32:$f32_result, + ... + ); +} +``` + +The following builders are generated: + +```c++ +// All result-types/operands/attributes have one aggregate parameter. +static void build(Builder *tblgen_builder, OperationState &tblgen_state, ArrayRef resultTypes, ArrayRef operands, ArrayRef attributes); + +// Each result-type/operand/attribute has a separate parameter. The parameters +// for attributes are of mlir::Attribute types. +static void build(Builder *tblgen_builder, OperationState &tblgen_state, + Type i32_result, Type f32_result, ..., + Value *i32_operand, Value *f32_operand, ..., + IntegerAttr i32_attr, FloatAttr f32_attr, ...); + +// Each result-type/operand/attribute has a separate parameter. The parameters +// for attributes are raw values unwrapped with mlir::Attribute instances. +// (Note that this builder will not always be generated. See the following +// explanation for more details.) +static void build(Builder *tblgen_builder, OperationState &tblgen_state, + Type i32_result, Type f32_result, ..., + Value *i32_operand, Value *f32_operand, ..., + APInt i32_attr, StringRef f32_attr, ...); + +// (And potentially others depending on the specific op.) ``` -The above cases make sure basic uniformity so that we can create ops using the +The first form provides basic uniformity so that we can create ops using the same form regardless of the exact op. This is particularly useful for implementing declarative pattern rewrites. +The second and third forms are good for use in manually written code given that +they provide better guarantee via signatures. + +The third form will be generated if any of the op's attribute has different +`Attr.returnType` from `Attr.storageType` and we know how to build an attribute +from an unwrapped value (i.e., `Attr.constBuilderCall` is defined.) +Additionally, for the third form, if an attribute appearing later in the +`arguments` list has a default value, the default value will be supplied in the +declaration. This works for `BoolAttr`, `StrAttr`, `EnumAttr` for now and the +list can grow in the future. So if possible, default valued attribute should be +placed at the end of the `arguments` list to leverage this feature. (This +behavior is essentially due to C++ function parameter default value placement +restrictions.) Otherwise, the builder of the third form will still be generated +but default values for the attributes not at the end of the `arguments` list +will not be supplied in the builder's signature. + +And there may potentially exist other builders depending on the specific op; +please refer to the +[generated C++ file](#run-mlir-tblgen-to-see-the-generated-content) for the +complete list. + +#### Custom builder methods + However, if the above cases cannot satisfy all needs, you can define additional convenience build methods with `OpBuilder`. diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index 60f95156bb5..242376e24ff 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -81,10 +81,10 @@ public: // built upon. Attribute getBaseAttr() const; - // Returns whether this attribute has a default value's initializer. - bool hasDefaultValueInitializer() const; - // Returns the default value's initializer for this attribute. - StringRef getDefaultValueInitializer() const; + // Returns whether this attribute has a default value. + bool hasDefaultValue() const; + // Returns the default value for this attribute. + StringRef getDefaultValue() const; // Returns whether this attribute is optional. bool isOptional() const; diff --git a/mlir/include/mlir/TableGen/Operator.h b/mlir/include/mlir/TableGen/Operator.h index 7b636ddb79e..89fd4ed8d2e 100644 --- a/mlir/include/mlir/TableGen/Operator.h +++ b/mlir/include/mlir/TableGen/Operator.h @@ -103,6 +103,7 @@ public: llvm::iterator_range getAttributes() const; int getNumAttributes() const { return attributes.size(); } + int getNumNativeAttributes() const { return numNativeAttributes; } // Op attribute accessors. NamedAttribute &getAttribute(int index) { return attributes[index]; } diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index c2b673a7c93..ec946a855fc 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -107,12 +107,12 @@ tblgen::Attribute tblgen::Attribute::getBaseAttr() const { return *this; } -bool tblgen::Attribute::hasDefaultValueInitializer() const { +bool tblgen::Attribute::hasDefaultValue() const { const auto *init = def->getValueInit("defaultValue"); return !getValueAsString(init).empty(); } -StringRef tblgen::Attribute::getDefaultValueInitializer() const { +StringRef tblgen::Attribute::getDefaultValue() const { const auto *init = def->getValueInit("defaultValue"); return getValueAsString(init); } diff --git a/mlir/test/mlir-tblgen/op-attribute.td b/mlir/test/mlir-tblgen/op-attribute.td index 61fe70f8926..d5c6a4ae1f7 100644 --- a/mlir/test/mlir-tblgen/op-attribute.td +++ b/mlir/test/mlir-tblgen/op-attribute.td @@ -1,4 +1,5 @@ -// RUN: mlir-tblgen -gen-op-defs -I %S/../../include %s | FileCheck %s +// RUN: mlir-tblgen -gen-op-decls -I %S/../../include %s | FileCheck %s --check-prefix=DECL +// RUN: mlir-tblgen -gen-op-defs -I %S/../../include %s | FileCheck %s --check-prefix=DEF include "mlir/IR/OpBase.td" @@ -26,51 +27,55 @@ def AOp : NS_Op<"a_op", []> { ); } -// CHECK-LABEL: AOp definitions +// DEF-LABEL: AOp definitions // Test getter methods // --- -// CHECK: some-return-type AOp::aAttr() { -// CHECK-NEXT: auto attr = this->getAttr("aAttr").cast(); -// CHECK-NEXT: return attr.some-convert-from-storage(); +// DEF: some-return-type AOp::aAttr() { +// DEF-NEXT: auto attr = this->getAttr("aAttr").cast(); +// DEF-NEXT: return attr.some-convert-from-storage(); -// CHECK: some-return-type AOp::bAttr() { -// CHECK-NEXT: auto attr = this->getAttr("bAttr").dyn_cast_or_null(); -// CHECK-NEXT: if (!attr) -// CHECK-NEXT: return some-const-builder-call(mlir::Builder(this->getContext()), 4.2).some-convert-from-storage(); -// CHECK-NEXT: return attr.some-convert-from-storage(); +// DEF: some-return-type AOp::bAttr() { +// DEF-NEXT: auto attr = this->getAttr("bAttr").dyn_cast_or_null(); +// DEF-NEXT: if (!attr) +// DEF-NEXT: return some-const-builder-call(mlir::Builder(this->getContext()), 4.2).some-convert-from-storage(); +// DEF-NEXT: return attr.some-convert-from-storage(); -// CHECK: Optional AOp::cAttr() { -// CHECK-NEXT: auto attr = this->getAttr("cAttr").dyn_cast_or_null(); -// CHECK-NEXT: return attr ? Optional(attr.some-convert-from-storage()) : (llvm::None); +// DEF: Optional AOp::cAttr() { +// DEF-NEXT: auto attr = this->getAttr("cAttr").dyn_cast_or_null(); +// DEF-NEXT: return attr ? Optional(attr.some-convert-from-storage()) : (llvm::None); // Test build methods // --- -// CHECK: void AOp::build( -// CHECK: tblgen_state.addAttribute("aAttr", aAttr); -// CHECK: tblgen_state.addAttribute("bAttr", bAttr); -// CHECK: if (cAttr) { -// CHECK-NEXT: tblgen_state.addAttribute("cAttr", cAttr); +// DEF: void AOp::build( +// DEF: tblgen_state.addAttribute("aAttr", aAttr); +// DEF: tblgen_state.addAttribute("bAttr", bAttr); +// DEF: if (cAttr) { +// DEF-NEXT: tblgen_state.addAttribute("cAttr", cAttr); -// CHECK: void AOp::build( -// CHECK-SAME: ArrayRef attributes -// CHECK: tblgen_state.addAttributes(attributes); +// DEF: void AOp::build( +// DEF-SAME: some-return-type aAttr, some-return-type bAttr, /*optional*/some-attr-kind cAttr +// DEF: tblgen_state.addAttribute("aAttr", some-const-builder-call((*tblgen_builder), aAttr)); + +// DEF: void AOp::build( +// DEF-SAME: ArrayRef attributes +// DEF: tblgen_state.addAttributes(attributes); // Test verify method // --- -// CHECK: AOp::verify() -// CHECK: auto tblgen_aAttr = this->getAttr("aAttr"); -// CHECK-NEXT: if (!tblgen_aAttr) return emitOpError("requires attribute 'aAttr'"); -// CHECK: if (!((some-condition))) return emitOpError("attribute 'aAttr' failed to satisfy constraint: some attribute kind"); -// CHECK: auto tblgen_bAttr = this->getAttr("bAttr"); -// CHECK-NEXT: if (tblgen_bAttr) { -// CHECK-NEXT: if (!((some-condition))) return emitOpError("attribute 'bAttr' failed to satisfy constraint: some attribute kind"); -// CHECK: auto tblgen_cAttr = this->getAttr("cAttr"); -// CHECK-NEXT: if (tblgen_cAttr) { -// CHECK-NEXT: if (!((some-condition))) return emitOpError("attribute 'cAttr' failed to satisfy constraint: some attribute kind"); +// DEF: AOp::verify() +// DEF: auto tblgen_aAttr = this->getAttr("aAttr"); +// DEF-NEXT: if (!tblgen_aAttr) return emitOpError("requires attribute 'aAttr'"); +// DEF: if (!((some-condition))) return emitOpError("attribute 'aAttr' failed to satisfy constraint: some attribute kind"); +// DEF: auto tblgen_bAttr = this->getAttr("bAttr"); +// DEF-NEXT: if (tblgen_bAttr) { +// DEF-NEXT: if (!((some-condition))) return emitOpError("attribute 'bAttr' failed to satisfy constraint: some attribute kind"); +// DEF: auto tblgen_cAttr = this->getAttr("cAttr"); +// DEF-NEXT: if (tblgen_cAttr) { +// DEF-NEXT: if (!((some-condition))) return emitOpError("attribute 'cAttr' failed to satisfy constraint: some attribute kind"); def SomeTypeAttr : TypeAttrBase<"SomeType", "some type attribute">; @@ -95,37 +100,37 @@ def BOp : NS_Op<"b_op", []> { // Test common attribute kind getters' return types // --- -// CHECK: Attribute BOp::any_attr() -// CHECK: bool BOp::bool_attr() -// CHECK: APInt BOp::i32_attr() -// CHECK: APInt BOp::i64_attr() -// CHECK: APFloat BOp::f32_attr() -// CHECK: APFloat BOp::f64_attr() -// CHECK: StringRef BOp::str_attr() -// CHECK: ElementsAttr BOp::elements_attr() -// CHECK: StringRef BOp::function_attr() -// CHECK: SomeType BOp::type_attr() -// CHECK: ArrayAttr BOp::array_attr() -// CHECK: ArrayAttr BOp::some_attr_array() -// CHECK: Type BOp::type_attr() +// DEF: Attribute BOp::any_attr() +// DEF: bool BOp::bool_attr() +// DEF: APInt BOp::i32_attr() +// DEF: APInt BOp::i64_attr() +// DEF: APFloat BOp::f32_attr() +// DEF: APFloat BOp::f64_attr() +// DEF: StringRef BOp::str_attr() +// DEF: ElementsAttr BOp::elements_attr() +// DEF: StringRef BOp::function_attr() +// DEF: SomeType BOp::type_attr() +// DEF: ArrayAttr BOp::array_attr() +// DEF: ArrayAttr BOp::some_attr_array() +// DEF: Type BOp::type_attr() // Test common attribute kinds' constraints // --- -// CHECK-LABEL: BOp::verify -// CHECK: if (!((true))) -// CHECK: if (!((tblgen_bool_attr.isa()))) -// CHECK: if (!(((tblgen_i32_attr.isa())) && ((tblgen_i32_attr.cast().getType().isInteger(32))))) -// CHECK: if (!(((tblgen_i64_attr.isa())) && ((tblgen_i64_attr.cast().getType().isInteger(64))))) -// CHECK: if (!(((tblgen_f32_attr.isa())) && ((tblgen_f32_attr.cast().getType().isF32())))) -// CHECK: if (!(((tblgen_f64_attr.isa())) && ((tblgen_f64_attr.cast().getType().isF64())))) -// CHECK: if (!((tblgen_str_attr.isa()))) -// CHECK: if (!((tblgen_elements_attr.isa()))) -// CHECK: if (!((tblgen_function_attr.isa()))) -// CHECK: if (!(((tblgen_type_attr.isa())) && ((tblgen_type_attr.cast().getValue().isa())))) -// CHECK: if (!((tblgen_array_attr.isa()))) -// CHECK: if (!(((tblgen_some_attr_array.isa())) && (llvm::all_of(tblgen_some_attr_array.cast(), [](Attribute attr) { return (some-condition); })))) -// CHECK: if (!(((tblgen_type_attr.isa())) && ((tblgen_type_attr.cast().getValue().isa())))) +// DEF-LABEL: BOp::verify +// DEF: if (!((true))) +// DEF: if (!((tblgen_bool_attr.isa()))) +// DEF: if (!(((tblgen_i32_attr.isa())) && ((tblgen_i32_attr.cast().getType().isInteger(32))))) +// DEF: if (!(((tblgen_i64_attr.isa())) && ((tblgen_i64_attr.cast().getType().isInteger(64))))) +// DEF: if (!(((tblgen_f32_attr.isa())) && ((tblgen_f32_attr.cast().getType().isF32())))) +// DEF: if (!(((tblgen_f64_attr.isa())) && ((tblgen_f64_attr.cast().getType().isF64())))) +// DEF: if (!((tblgen_str_attr.isa()))) +// DEF: if (!((tblgen_elements_attr.isa()))) +// DEF: if (!((tblgen_function_attr.isa()))) +// DEF: if (!(((tblgen_type_attr.isa())) && ((tblgen_type_attr.cast().getValue().isa())))) +// DEF: if (!((tblgen_array_attr.isa()))) +// DEF: if (!(((tblgen_some_attr_array.isa())) && (llvm::all_of(tblgen_some_attr_array.cast(), [](Attribute attr) { return (some-condition); })))) +// DEF: if (!(((tblgen_type_attr.isa())) && ((tblgen_type_attr.cast().getValue().isa())))) // Test building constant values for array attribute kinds // --- @@ -140,12 +145,70 @@ def COp : NS_Op<"c_op", []> { ); } -// CHECK-LABEL: COp definitions -// CHECK: mlir::Builder(this->getContext()).getI32ArrayAttr({1, 2}) -// CHECK: mlir::Builder(this->getContext()).getI64ArrayAttr({3, 4}) -// CHECK: mlir::Builder(this->getContext()).getF32ArrayAttr({5.f, 6.f}) -// CHECK: mlir::Builder(this->getContext()).getF64ArrayAttr({7., 8.}) -// CHECK: mlir::Builder(this->getContext()).getStrArrayAttr({"a", "b"}) +// DEF-LABEL: COp definitions +// DEF: mlir::Builder(this->getContext()).getI32ArrayAttr({1, 2}) +// DEF: mlir::Builder(this->getContext()).getI64ArrayAttr({3, 4}) +// DEF: mlir::Builder(this->getContext()).getF32ArrayAttr({5.f, 6.f}) +// DEF: mlir::Builder(this->getContext()).getF64ArrayAttr({7., 8.}) +// DEF: mlir::Builder(this->getContext()).getStrArrayAttr({"a", "b"}) + + +// Test builder method which takes unwrapped values for attributes +// --- + +def I32Case5: I32EnumAttrCase<"case5", 5>; +def I32Case10: I32EnumAttrCase<"case10", 10>; + +def SomeI32Enum: I32EnumAttr< + "SomeI32Enum", "", [I32Case5, I32Case10]>; + +def DOp : NS_Op<"d_op", []> { + let arguments = (ins + I32Attr:$i32_attr, + F64Attr:$f64_attr, + StrAttr:$str_attr, + BoolAttr:$bool_attr, + SomeI32Enum:$enum_attr, + DefaultValuedAttr:$dv_i32_attr, + DefaultValuedAttr:$dv_f64_attr, + DefaultValuedAttr:$dv_str_attr, + DefaultValuedAttr:$dv_bool_attr, + DefaultValuedAttr:$dv_enum_attr + ); +} + +// DECL-LABEL: DOp declarations +// DECL: static void build({{.*}}, APInt i32_attr, APFloat f64_attr, +// DECL-SAME: StringRef str_attr, bool bool_attr, ::SomeI32Enum enum_attr, +// DECL-SAME: APInt dv_i32_attr, APFloat dv_f64_attr, +// DECL-SAME: StringRef dv_str_attr = "abc", bool dv_bool_attr = true, +// DECL-SAME: ::SomeI32Enum dv_enum_attr = ::SomeI32Enum::case5) + +// Test that only default valued attributes at the end of the arguments +// list get default values in the builder signature +// --- + +def EOp : NS_Op<"e_op", []> { + let arguments = (ins + I32Attr:$i32_attr, + DefaultValuedAttr:$dv_i32_attr, + F64Attr:$f64_attr, + DefaultValuedAttr:$dv_f64_attr, + StrAttr:$str_attr, + DefaultValuedAttr:$dv_str_attr, + BoolAttr:$bool_attr, + DefaultValuedAttr:$dv_bool_attr, + SomeI32Enum:$enum_attr, + DefaultValuedAttr:$dv_enum_attr + ); +} + +// DECL-LABEL: EOp declarations +// DECL: static void build({{.*}}, APInt i32_attr, APInt dv_i32_attr, +// DECL-SAME: APFloat f64_attr, APFloat dv_f64_attr, +// DECL-SAME: StringRef str_attr, StringRef dv_str_attr, +// DECL-SAME: bool bool_attr, bool dv_bool_attr, +// DECL-SAME: ::SomeI32Enum enum_attr, ::SomeI32Enum dv_enum_attr = ::SomeI32Enum::case5) // Test mixing operands and attributes in arbitrary order // --- @@ -154,12 +217,12 @@ def MixOperandsAndAttrs : NS_Op<"mix_operands_and_attrs", []> { let arguments = (ins F32Attr:$attr, F32:$operand, F32Attr:$otherAttr, F32:$otherArg); } -// CHECK-LABEL: MixOperandsAndAttrs definitions -// CHECK-DAG: Value *MixOperandsAndAttrs::operand() -// CHECK-DAG: Value *MixOperandsAndAttrs::otherArg() -// CHECK-DAG: void MixOperandsAndAttrs::build(Builder *, OperationState &tblgen_state, FloatAttr attr, Value *operand, FloatAttr otherAttr, Value *otherArg) -// CHECK-DAG: APFloat MixOperandsAndAttrs::attr() -// CHECK-DAG: APFloat MixOperandsAndAttrs::otherAttr() +// DEF-LABEL: MixOperandsAndAttrs definitions +// DEF-DAG: Value *MixOperandsAndAttrs::operand() +// DEF-DAG: Value *MixOperandsAndAttrs::otherArg() +// DEF-DAG: void MixOperandsAndAttrs::build(Builder *tblgen_builder, OperationState &tblgen_state, FloatAttr attr, Value *operand, FloatAttr otherAttr, Value *otherArg) +// DEF-DAG: APFloat MixOperandsAndAttrs::attr() +// DEF-DAG: APFloat MixOperandsAndAttrs::otherAttr() // Test unit attributes. // --- @@ -168,8 +231,8 @@ def UnitAttrOp : NS_Op<"unit_attr_op", []> { let arguments = (ins UnitAttr:$attr); } -// CHECK-LABEL: UnitAttrOp definitions -// CHECK: bool UnitAttrOp::attr() { -// CHECK: return {{.*}} != nullptr +// DEF-LABEL: UnitAttrOp definitions +// DEF: bool UnitAttrOp::attr() { +// DEF: return {{.*}} != nullptr -// CHECK: build(Builder *, OperationState &tblgen_state, /*optional*/UnitAttr attr) +// DEF: build(Builder *tblgen_builder, OperationState &tblgen_state, /*optional*/UnitAttr attr) diff --git a/mlir/test/mlir-tblgen/op-decl.td b/mlir/test/mlir-tblgen/op-decl.td index 672cfeffbfe..e66ea4320e7 100644 --- a/mlir/test/mlir-tblgen/op-decl.td +++ b/mlir/test/mlir-tblgen/op-decl.td @@ -66,7 +66,7 @@ def NS_AOp : NS_Op<"a_op", [NoSideEffect]> { // CHECK: APInt attr1(); // CHECK: Optional< APFloat > attr2(); // CHECK: static void build(Value *val); -// CHECK: static void build(Builder *, OperationState &tblgen_state, Type r, ArrayRef s, Value *a, ArrayRef b, IntegerAttr attr1, /*optional*/FloatAttr attr2); +// CHECK: static void build(Builder *tblgen_builder, OperationState &tblgen_state, Type r, ArrayRef s, Value *a, ArrayRef b, IntegerAttr attr1, /*optional*/FloatAttr attr2); // CHECK: static void build(Builder *, OperationState &tblgen_state, ArrayRef resultTypes, ArrayRef operands, ArrayRef attributes); // CHECK: static ParseResult parse(OpAsmParser &parser, OperationState &result); // CHECK: void print(OpAsmPrinter &p); diff --git a/mlir/test/mlir-tblgen/op-result.td b/mlir/test/mlir-tblgen/op-result.td index 9979480dc14..007d7472716 100644 --- a/mlir/test/mlir-tblgen/op-result.td +++ b/mlir/test/mlir-tblgen/op-result.td @@ -23,9 +23,9 @@ def OpB : NS_Op<"same_input_output_type_op", [SameOperandsAndResultType]> { } // CHECK-LABEL: OpB definitions -// CHECK: void OpB::build(Builder *, OperationState &tblgen_state, Type y, Value *x) +// CHECK: void OpB::build(Builder *tblgen_builder, OperationState &tblgen_state, Type y, Value *x) // CHECK: tblgen_state.addTypes(y); -// CHECK: void OpB::build(Builder *, OperationState &tblgen_state, Value *x) +// CHECK: void OpB::build(Builder *tblgen_builder, OperationState &tblgen_state, Value *x) // CHECK: tblgen_state.addTypes({x->getType()}); def OpC : NS_Op<"three_normal_result_op", []> { @@ -33,7 +33,7 @@ def OpC : NS_Op<"three_normal_result_op", []> { } // CHECK-LABEL: OpC definitions -// CHECK: void OpC::build(Builder *, OperationState &tblgen_state, Type x, Type resultType1, Type z) +// CHECK: void OpC::build(Builder *tblgen_builder, OperationState &tblgen_state, Type x, Type resultType1, Type z) // CHECK-NEXT: tblgen_state.addTypes(x) // CHECK-NEXT: tblgen_state.addTypes(resultType1) // CHECK-NEXT: tblgen_state.addTypes(z) @@ -73,7 +73,7 @@ def OpG : NS_Op<"one_normal_and_one_variadic_result_op", []> { // CHECK-LABEL: OpG definitions -// CHECK: void OpG::build(Builder *, OperationState &tblgen_state, Type x, ArrayRef y) +// CHECK: void OpG::build(Builder *tblgen_builder, OperationState &tblgen_state, Type x, ArrayRef y) // CHECK-NEXT: tblgen_state.addTypes(x); // CHECK-NEXT: tblgen_state.addTypes(y); @@ -105,5 +105,5 @@ def OpK : NS_Op<"only_input_is_variadic_with_same_value_type_op", [SameOperandsA let results = (outs AnyTensor:$result); } -// CHECK-LABEL: OpK::build(Builder *, OperationState &tblgen_state, ArrayRef input) +// CHECK-LABEL: OpK::build(Builder *tblgen_builder, OperationState &tblgen_state, ArrayRef input) // CHECK: tblgen_state.addTypes({input.front()->getType()}); diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp index 864f7734f8a..dcecd1c65be 100644 --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -32,6 +32,8 @@ #include "llvm/TableGen/Record.h" #include "llvm/TableGen/TableGenBackend.h" +#define DEBUG_TYPE "mlir-tblgen-opdefgen" + using namespace llvm; using namespace mlir; using namespace mlir::tblgen; @@ -113,6 +115,14 @@ static std::string getArgumentName(const Operator &op, int index) { return formatv("{0}_{1}", generatedArgName, index); } +// Returns true if we can use unwrapped value for the given `attr` in builders. +static bool canUseUnwrappedRawValue(const tblgen::Attribute &attr) { + return attr.getReturnType() != attr.getStorageType() && + // We need to wrap the raw value into an attribute in the builder impl + // so we need to make sure that the attribute specifies how to do that. + !attr.getConstBuilderTemplate().empty(); +} + namespace { // Simple RAII helper for defining ifdef-undef-endif scopes. class IfDefScope { @@ -506,46 +516,66 @@ private: void genBuilder(); // Generates the build() method that takes each result-type/operand/attribute - // as a stand-alone parameter. This build() method also requires specifying - // result types for all results. - void genSeparateParamBuilder(); + // as a stand-alone parameter. Attributes will take wrapped mlir::Attribute + // values. The generated build() method also requires specifying result types + // for all results. + void genSeparateParamWrappedAttrBuilder(); + + // Generates the build() method that takes each result-type/operand/attribute + // as a stand-alone parameter. Attributes will take raw values without + // mlir::Attribute wrapper. The generated build() method also requires + // specifying result types for all results. + void genSeparateParamUnwrappedAttrBuilder(); // Generates the build() method that takes a single parameter for all the // result types and a separate parameter for each operand/attribute. void genCollectiveTypeParamBuilder(); // Generates the build() method that takes each operand/attribute as a - // stand-alone parameter. This build() method uses first operand's type - // as all results' types. + // stand-alone parameter. The generated build() method uses first operand's + // type as all results' types. void genUseOperandAsResultTypeSeparateParamBuilder(); // Generates the build() method that takes all operands/attributes - // collectively as one parameter. This build() method uses first operand's - // type as all results' types. + // collectively as one parameter. The generated build() method uses first + // operand's type as all results' types. void genUseOperandAsResultTypeCollectiveParamBuilder(); // Generates the build() method that takes each operand/attribute as a - // stand-alone parameter. This build() method uses first attribute's type - // as all result's types. + // stand-alone parameter. The generated build() method uses first attribute's + // type as all result's types. void genUseAttrAsResultTypeBuilder(); // Generates the build() method that takes all result types collectively as // one parameter. Similarly for operands and attributes. void genCollectiveParamBuilder(); - enum class TypeParamKind { None, Separate, Collective }; + // The kind of parameter to generate for result types in builders. + enum class TypeParamKind { + None, // No result type in parameter list. + Separate, // A separate parameter for each result type. + Collective, // An ArrayRef for all result types. + }; + + // The kind of parameter to generate for attributes in builders. + enum class AttrParamKind { + WrappedAttr, // A wrapped MLIR Attribute instance. + UnwrappedValue, // A raw value without MLIR Attribute wrapper. + }; // Builds the parameter list for build() method of this op. This method writes - // to `paramList` the comma-separated parameter list. If `includeResultTypes` - // is true then `paramList` will also contain the parameters for all results - // and `resultTypeNames` will be populated with the parameter name for each - // result type. + // to `paramList` the comma-separated parameter list and updates + // `resultTypeNames` with the names for parameters for specifying result + // types. The given `typeParamKind` and `attrParamKind` controls how result + // types and attributes are placed in the parameter list. void buildParamList(std::string ¶mList, SmallVectorImpl &resultTypeNames, - TypeParamKind kind); + TypeParamKind typeParamKind, + AttrParamKind attrParamKind = AttrParamKind::WrappedAttr); // Adds op arguments and regions into operation state for build() methods. - void genCodeForAddingArgAndRegionForBuilder(OpMethodBody &body); + void genCodeForAddingArgAndRegionForBuilder(OpMethodBody &body, + bool isRawValueAttr = false); // Generates canonicalizer declaration for the operation. void genCanonicalizerDecls(); @@ -650,18 +680,18 @@ void OpEmitter::genAttrGetters() { // Return the queried attribute with the correct return type. auto attrVal = - (attr.hasDefaultValueInitializer() || attr.isOptional()) + (attr.hasDefaultValue() || attr.isOptional()) ? formatv("this->getAttr(\"{0}\").dyn_cast_or_null<{1}>()", name, attr.getStorageType()) : formatv("this->getAttr(\"{0}\").cast<{1}>()", name, attr.getStorageType()); body << " auto attr = " << attrVal << ";\n"; - if (attr.hasDefaultValueInitializer()) { + if (attr.hasDefaultValue()) { // Returns the default value if not set. // TODO: this is inefficient, we are recreating the attribute for every // call. This should be set instead. - std::string defaultValue = tgfmt(attr.getConstBuilderTemplate(), &fctx, - attr.getDefaultValueInitializer()); + std::string defaultValue = + tgfmt(attr.getConstBuilderTemplate(), &fctx, attr.getDefaultValue()); body << " if (!attr)\n return " << tgfmt(attr.getConvertFromStorageCall(), &fctx.withSelf(defaultValue)) @@ -847,7 +877,7 @@ void OpEmitter::genNamedRegionGetters() { } } -void OpEmitter::genSeparateParamBuilder() { +void OpEmitter::genSeparateParamWrappedAttrBuilder() { std::string paramList; llvm::SmallVector resultNames; buildParamList(paramList, resultNames, TypeParamKind::Separate); @@ -862,6 +892,42 @@ void OpEmitter::genSeparateParamBuilder() { } } +void OpEmitter::genSeparateParamUnwrappedAttrBuilder() { + // If this op does not have native attributes at all, return directly to avoid + // redefining builders. + if (op.getNumNativeAttributes() == 0) + return; + + bool canGenerate = false; + // We are generating builders that take raw values for attributes. We need to + // make sure the native attributes have a meaningful "unwrapped" value type + // different from the wrapped mlir::Attribute type to avoid redefining + // builders. This checks for the op has at least one such native attribute. + for (int i = 0, e = op.getNumNativeAttributes(); i < e; ++i) { + NamedAttribute &namedAttr = op.getAttribute(i); + if (canUseUnwrappedRawValue(namedAttr.attr)) { + canGenerate = true; + break; + } + } + if (!canGenerate) + return; + + std::string paramList; + llvm::SmallVector resultNames; + buildParamList(paramList, resultNames, TypeParamKind::Separate, + AttrParamKind::UnwrappedValue); + + auto &m = opClass.newMethod("void", "build", paramList, OpMethod::MP_Static); + genCodeForAddingArgAndRegionForBuilder(m.body(), /*isRawValueAttr=*/true); + + // Push all result types to the operation state. + for (int i = 0, e = op.getNumResults(); i < e; ++i) { + m.body() << " " << builderOpState << ".addTypes(" << resultNames[i] + << ");\n"; + } +} + void OpEmitter::genCollectiveTypeParamBuilder() { auto numResults = op.getNumResults(); @@ -1006,7 +1072,8 @@ void OpEmitter::genBuilder() { // We generate three builders here: // 1. one having a stand-alone parameter for each result type / operand / // attribute, and - genSeparateParamBuilder(); + genSeparateParamWrappedAttrBuilder(); + genSeparateParamUnwrappedAttrBuilder(); // 2. one having a stand-alone parameter for each operand / attribute and // an aggregated parameter for all result types, and genCollectiveTypeParamBuilder(); @@ -1069,15 +1136,16 @@ void OpEmitter::genCollectiveParamBuilder() { void OpEmitter::buildParamList(std::string ¶mList, SmallVectorImpl &resultTypeNames, - TypeParamKind kind) { + TypeParamKind typeParamKind, + AttrParamKind attrParamKind) { resultTypeNames.clear(); auto numResults = op.getNumResults(); resultTypeNames.reserve(numResults); - paramList = "Builder *, OperationState &"; + paramList = "Builder *tblgen_builder, OperationState &"; paramList.append(builderOpState); - switch (kind) { + switch (typeParamKind) { case TypeParamKind::None: break; case TypeParamKind::Separate: { @@ -1100,10 +1168,36 @@ void OpEmitter::buildParamList(std::string ¶mList, } break; } + // Add parameters for all arguments (operands and attributes). + int numOperands = 0; int numAttrs = 0; - // Add parameters for all arguments (operands and attributes). + int defaultValuedAttrStartIndex = op.getNumArgs(); + if (attrParamKind == AttrParamKind::UnwrappedValue) { + // Calculate the start index from which we can attach default values in the + // builder declaration. + for (int i = op.getNumArgs() - 1; i >= 0; --i) { + auto *namedAttr = op.getArg(i).dyn_cast(); + if (!namedAttr || !namedAttr->attr.hasDefaultValue()) + break; + + if (!canUseUnwrappedRawValue(namedAttr->attr)) + break; + + // Creating an APInt requires us to provide bitwidth, value, and + // signedness, which is complicated compared to others. Similarly + // for APFloat. + // TODO(b/144412160) Adjust the 'returnType' field of such attributes + // to support them. + StringRef retType = namedAttr->attr.getReturnType(); + if (retType == "APInt" || retType == "APFloat") + break; + + defaultValuedAttrStartIndex = i; + } + } + for (int i = 0, e = op.getNumArgs(); i < e; ++i) { auto argument = op.getArg(i); if (argument.is()) { @@ -1113,24 +1207,46 @@ void OpEmitter::buildParamList(std::string ¶mList, paramList.append(getArgumentName(op, numOperands)); ++numOperands; } else { - // TODO(antiagainst): Support default initializer for attributes const auto &namedAttr = op.getAttribute(numAttrs); const auto &attr = namedAttr.attr; paramList.append(", "); + if (attr.isOptional()) paramList.append("/*optional*/"); - paramList.append(attr.getStorageType()); + + switch (attrParamKind) { + case AttrParamKind::WrappedAttr: + paramList.append(attr.getStorageType()); + break; + case AttrParamKind::UnwrappedValue: + if (canUseUnwrappedRawValue(attr)) { + paramList.append(attr.getReturnType()); + } else { + paramList.append(attr.getStorageType()); + } + break; + } paramList.append(" "); paramList.append(namedAttr.name); + + // Attach default value if requested and possible. + if (attrParamKind == AttrParamKind::UnwrappedValue && + i >= defaultValuedAttrStartIndex) { + bool isString = attr.getReturnType() == "StringRef"; + paramList.append(" = "); + if (isString) + paramList.append("\""); + paramList.append(attr.getDefaultValue()); + if (isString) + paramList.append("\""); + } ++numAttrs; } } - - if (numOperands + numAttrs != op.getNumArgs()) - PrintFatalError("op arguments must be either operands or attributes"); } -void OpEmitter::genCodeForAddingArgAndRegionForBuilder(OpMethodBody &body) { +void OpEmitter::genCodeForAddingArgAndRegionForBuilder(OpMethodBody &body, + bool isRawValueAttr) { // Push all operands to the result for (int i = 0, e = op.getNumOperands(); i < e; ++i) { body << " " << builderOpState << ".addOperands(" << getArgumentName(op, i) @@ -1139,13 +1255,25 @@ void OpEmitter::genCodeForAddingArgAndRegionForBuilder(OpMethodBody &body) { // Push all attributes to the result for (const auto &namedAttr : op.getAttributes()) { - if (!namedAttr.attr.isDerivedAttr()) { - bool emitNotNullCheck = namedAttr.attr.isOptional(); + auto &attr = namedAttr.attr; + if (!attr.isDerivedAttr()) { + bool emitNotNullCheck = attr.isOptional(); if (emitNotNullCheck) { body << formatv(" if ({0}) ", namedAttr.name) << "{\n"; } - body << formatv(" {0}.addAttribute(\"{1}\", {1});\n", builderOpState, - namedAttr.name); + if (isRawValueAttr and canUseUnwrappedRawValue(attr)) { + // If this is a raw value, then we need to wrap it in an Attribute + // instance. + FmtContext fctx; + fctx.withBuilder("(*tblgen_builder)"); + std::string value = + tgfmt(attr.getConstBuilderTemplate(), &fctx, namedAttr.name); + body << formatv(" {0}.addAttribute(\"{1}\", {2});\n", builderOpState, + namedAttr.name, value); + } else { + body << formatv(" {0}.addAttribute(\"{1}\", {1});\n", builderOpState, + namedAttr.name); + } if (emitNotNullCheck) { body << " }\n"; } @@ -1282,8 +1410,7 @@ void OpEmitter::genVerifier() { body << formatv(" auto {0} = this->getAttr(\"{1}\");\n", varName, attrName); - bool allowMissingAttr = - attr.hasDefaultValueInitializer() || attr.isOptional(); + bool allowMissingAttr = attr.hasDefaultValue() || attr.isOptional(); if (allowMissingAttr) { // If the attribute has a default value, then only verify the predicate if // set. This does effectively assume that the default value is valid. diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp index a2cace7fb60..d321b204f4e 100644 --- a/mlir/tools/mlir-tblgen/RewriterGen.cpp +++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp @@ -342,10 +342,10 @@ void PatternEmitter::emitAttributeMatch(DagNode tree, int argIndex, int depth, attr.getStorageType(), namedAttr->name); // TODO(antiagainst): This should use getter method to avoid duplication. - if (attr.hasDefaultValueInitializer()) { + if (attr.hasDefaultValue()) { os.indent(indent) << "if (!tblgen_attr) tblgen_attr = " << tgfmt(attr.getConstBuilderTemplate(), &fmtCtx, - attr.getDefaultValueInitializer()) + attr.getDefaultValue()) << ";\n"; } else if (attr.isOptional()) { // For a missing attribute that is optional according to definition, we -- cgit v1.2.3 From 56222a0694e4caf35e892d70591417c39fef1185 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Mon, 23 Dec 2019 09:35:36 -0800 Subject: Adjust License.txt file to use the LLVM license PiperOrigin-RevId: 286906740 --- mlir/LICENSE.TXT | 128 ++++++++++++++++----- mlir/bindings/python/pybind.cpp | 17 +-- mlir/examples/toy/Ch1/include/toy/AST.h | 17 +-- mlir/examples/toy/Ch1/include/toy/Lexer.h | 17 +-- mlir/examples/toy/Ch1/include/toy/Parser.h | 17 +-- mlir/examples/toy/Ch1/parser/AST.cpp | 17 +-- mlir/examples/toy/Ch1/toyc.cpp | 17 +-- mlir/examples/toy/Ch2/include/toy/AST.h | 17 +-- mlir/examples/toy/Ch2/include/toy/Dialect.h | 17 +-- mlir/examples/toy/Ch2/include/toy/Lexer.h | 17 +-- mlir/examples/toy/Ch2/include/toy/MLIRGen.h | 17 +-- mlir/examples/toy/Ch2/include/toy/Ops.td | 17 +-- mlir/examples/toy/Ch2/include/toy/Parser.h | 17 +-- mlir/examples/toy/Ch2/mlir/Dialect.cpp | 17 +-- mlir/examples/toy/Ch2/mlir/MLIRGen.cpp | 17 +-- mlir/examples/toy/Ch2/parser/AST.cpp | 17 +-- mlir/examples/toy/Ch2/toyc.cpp | 17 +-- mlir/examples/toy/Ch3/include/toy/AST.h | 17 +-- mlir/examples/toy/Ch3/include/toy/Dialect.h | 17 +-- mlir/examples/toy/Ch3/include/toy/Lexer.h | 17 +-- mlir/examples/toy/Ch3/include/toy/MLIRGen.h | 17 +-- mlir/examples/toy/Ch3/include/toy/Ops.td | 17 +-- mlir/examples/toy/Ch3/include/toy/Parser.h | 17 +-- mlir/examples/toy/Ch3/mlir/Dialect.cpp | 17 +-- mlir/examples/toy/Ch3/mlir/MLIRGen.cpp | 17 +-- mlir/examples/toy/Ch3/mlir/ToyCombine.cpp | 17 +-- mlir/examples/toy/Ch3/mlir/ToyCombine.td | 17 +-- mlir/examples/toy/Ch3/parser/AST.cpp | 17 +-- mlir/examples/toy/Ch3/toyc.cpp | 17 +-- mlir/examples/toy/Ch4/include/toy/AST.h | 17 +-- mlir/examples/toy/Ch4/include/toy/Dialect.h | 17 +-- mlir/examples/toy/Ch4/include/toy/Lexer.h | 17 +-- mlir/examples/toy/Ch4/include/toy/MLIRGen.h | 17 +-- mlir/examples/toy/Ch4/include/toy/Ops.td | 17 +-- mlir/examples/toy/Ch4/include/toy/Parser.h | 17 +-- mlir/examples/toy/Ch4/include/toy/Passes.h | 17 +-- .../toy/Ch4/include/toy/ShapeInferenceInterface.h | 17 +-- .../toy/Ch4/include/toy/ShapeInferenceInterface.td | 17 +-- .../toy/Ch4/mlir/DeadFunctionEliminationPass.cpp | 17 +-- mlir/examples/toy/Ch4/mlir/Dialect.cpp | 17 +-- mlir/examples/toy/Ch4/mlir/MLIRGen.cpp | 17 +-- mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp | 17 +-- mlir/examples/toy/Ch4/mlir/ToyCombine.cpp | 17 +-- mlir/examples/toy/Ch4/mlir/ToyCombine.td | 17 +-- mlir/examples/toy/Ch4/parser/AST.cpp | 17 +-- mlir/examples/toy/Ch4/toyc.cpp | 17 +-- mlir/examples/toy/Ch5/include/toy/AST.h | 17 +-- mlir/examples/toy/Ch5/include/toy/Dialect.h | 17 +-- mlir/examples/toy/Ch5/include/toy/Lexer.h | 17 +-- mlir/examples/toy/Ch5/include/toy/MLIRGen.h | 17 +-- mlir/examples/toy/Ch5/include/toy/Ops.td | 17 +-- mlir/examples/toy/Ch5/include/toy/Parser.h | 17 +-- mlir/examples/toy/Ch5/include/toy/Passes.h | 17 +-- .../toy/Ch5/include/toy/ShapeInferenceInterface.h | 17 +-- .../toy/Ch5/include/toy/ShapeInferenceInterface.td | 17 +-- .../toy/Ch5/mlir/DeadFunctionEliminationPass.cpp | 17 +-- mlir/examples/toy/Ch5/mlir/Dialect.cpp | 17 +-- mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp | 17 +-- mlir/examples/toy/Ch5/mlir/MLIRGen.cpp | 17 +-- mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp | 17 +-- mlir/examples/toy/Ch5/mlir/ToyCombine.cpp | 17 +-- mlir/examples/toy/Ch5/mlir/ToyCombine.td | 17 +-- mlir/examples/toy/Ch5/parser/AST.cpp | 17 +-- mlir/examples/toy/Ch5/toyc.cpp | 17 +-- mlir/examples/toy/Ch6/include/toy/AST.h | 17 +-- mlir/examples/toy/Ch6/include/toy/Dialect.h | 17 +-- mlir/examples/toy/Ch6/include/toy/Lexer.h | 17 +-- mlir/examples/toy/Ch6/include/toy/MLIRGen.h | 17 +-- mlir/examples/toy/Ch6/include/toy/Ops.td | 17 +-- mlir/examples/toy/Ch6/include/toy/Parser.h | 17 +-- mlir/examples/toy/Ch6/include/toy/Passes.h | 17 +-- .../toy/Ch6/include/toy/ShapeInferenceInterface.h | 17 +-- .../toy/Ch6/include/toy/ShapeInferenceInterface.td | 17 +-- .../toy/Ch6/mlir/DeadFunctionEliminationPass.cpp | 17 +-- mlir/examples/toy/Ch6/mlir/Dialect.cpp | 17 +-- mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp | 17 +-- mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp | 17 +-- mlir/examples/toy/Ch6/mlir/MLIRGen.cpp | 17 +-- mlir/examples/toy/Ch6/mlir/ShapeInferencePass.cpp | 17 +-- mlir/examples/toy/Ch6/mlir/ToyCombine.cpp | 17 +-- mlir/examples/toy/Ch6/mlir/ToyCombine.td | 17 +-- mlir/examples/toy/Ch6/parser/AST.cpp | 17 +-- mlir/examples/toy/Ch6/toyc.cpp | 17 +-- mlir/examples/toy/Ch7/include/toy/AST.h | 17 +-- mlir/examples/toy/Ch7/include/toy/Dialect.h | 17 +-- mlir/examples/toy/Ch7/include/toy/Lexer.h | 17 +-- mlir/examples/toy/Ch7/include/toy/MLIRGen.h | 17 +-- mlir/examples/toy/Ch7/include/toy/Ops.td | 17 +-- mlir/examples/toy/Ch7/include/toy/Parser.h | 17 +-- mlir/examples/toy/Ch7/include/toy/Passes.h | 17 +-- .../toy/Ch7/include/toy/ShapeInferenceInterface.h | 17 +-- .../toy/Ch7/include/toy/ShapeInferenceInterface.td | 17 +-- .../toy/Ch7/mlir/DeadFunctionEliminationPass.cpp | 17 +-- mlir/examples/toy/Ch7/mlir/Dialect.cpp | 17 +-- mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp | 17 +-- mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp | 17 +-- mlir/examples/toy/Ch7/mlir/MLIRGen.cpp | 17 +-- mlir/examples/toy/Ch7/mlir/ShapeInferencePass.cpp | 17 +-- mlir/examples/toy/Ch7/mlir/ToyCombine.cpp | 17 +-- mlir/examples/toy/Ch7/mlir/ToyCombine.td | 17 +-- mlir/examples/toy/Ch7/parser/AST.cpp | 17 +-- mlir/examples/toy/Ch7/toyc.cpp | 17 +-- mlir/include/mlir-c/Core.h | 17 +-- mlir/include/mlir/ADT/TypeSwitch.h | 17 +-- mlir/include/mlir/Analysis/AffineAnalysis.h | 17 +-- mlir/include/mlir/Analysis/AffineStructures.h | 17 +-- mlir/include/mlir/Analysis/CallGraph.h | 17 +-- mlir/include/mlir/Analysis/CallInterfaces.h | 17 +-- mlir/include/mlir/Analysis/CallInterfaces.td | 17 +-- mlir/include/mlir/Analysis/Dominance.h | 17 +-- mlir/include/mlir/Analysis/InferTypeOpInterface.h | 17 +-- mlir/include/mlir/Analysis/InferTypeOpInterface.td | 17 +-- mlir/include/mlir/Analysis/Liveness.h | 17 +-- mlir/include/mlir/Analysis/LoopAnalysis.h | 17 +-- mlir/include/mlir/Analysis/NestedMatcher.h | 17 +-- mlir/include/mlir/Analysis/Passes.h | 17 +-- mlir/include/mlir/Analysis/SliceAnalysis.h | 17 +-- mlir/include/mlir/Analysis/Utils.h | 17 +-- mlir/include/mlir/Analysis/Verifier.h | 17 +-- .../Conversion/AffineToStandard/AffineToStandard.h | 17 +-- .../mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h | 17 +-- .../mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h | 17 +-- .../mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h | 17 +-- .../mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.h | 17 +-- .../Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.h | 17 +-- .../mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h | 17 +-- .../LoopToStandard/ConvertLoopToStandard.h | 17 +-- .../mlir/Conversion/LoopsToGPU/LoopsToGPU.h | 17 +-- .../mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h | 17 +-- .../StandardToLLVM/ConvertStandardToLLVM.h | 17 +-- .../StandardToLLVM/ConvertStandardToLLVMPass.h | 17 +-- .../StandardToSPIRV/ConvertStandardToSPIRV.h | 17 +-- .../StandardToSPIRV/ConvertStandardToSPIRVPass.h | 17 +-- .../Conversion/VectorToLLVM/ConvertVectorToLLVM.h | 17 +-- .../VectorToLoops/ConvertVectorToLoops.h | 17 +-- mlir/include/mlir/Dialect/AffineOps/AffineOps.h | 17 +-- mlir/include/mlir/Dialect/AffineOps/AffineOps.td | 17 +-- .../mlir/Dialect/AffineOps/AffineOpsBase.td | 17 +-- mlir/include/mlir/Dialect/CommonFolders.h | 17 +-- mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.h | 17 +-- mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td | 17 +-- mlir/include/mlir/Dialect/FxpMathOps/Passes.h | 17 +-- mlir/include/mlir/Dialect/GPU/GPUDialect.h | 17 +-- mlir/include/mlir/Dialect/GPU/GPUOps.td | 17 +-- mlir/include/mlir/Dialect/GPU/Passes.h | 17 +-- mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h | 17 +-- mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td | 17 +-- mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td | 17 +-- mlir/include/mlir/Dialect/LLVMIR/NVVMDialect.h | 17 +-- mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td | 17 +-- mlir/include/mlir/Dialect/LLVMIR/ROCDLDialect.h | 17 +-- mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td | 17 +-- .../Dialect/Linalg/Analysis/DependenceAnalysis.h | 17 +-- mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h | 17 +-- mlir/include/mlir/Dialect/Linalg/EDSC/Intrinsics.h | 17 +-- mlir/include/mlir/Dialect/Linalg/IR/LinalgBase.td | 17 +-- mlir/include/mlir/Dialect/Linalg/IR/LinalgDoc.td | 17 +-- .../mlir/Dialect/Linalg/IR/LinalgLibraryOps.td | 17 +-- mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.h | 17 +-- mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td | 17 +-- .../mlir/Dialect/Linalg/IR/LinalgStructuredOps.td | 17 +-- mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h | 17 +-- mlir/include/mlir/Dialect/Linalg/IR/LinalgTypes.h | 17 +-- mlir/include/mlir/Dialect/Linalg/Passes.h | 17 +-- .../Linalg/Transforms/LinalgTransformPatterns.td | 17 +-- .../Dialect/Linalg/Transforms/LinalgTransforms.h | 17 +-- .../include/mlir/Dialect/Linalg/Utils/Intrinsics.h | 17 +-- mlir/include/mlir/Dialect/Linalg/Utils/Utils.h | 17 +-- mlir/include/mlir/Dialect/LoopOps/LoopOps.h | 17 +-- mlir/include/mlir/Dialect/LoopOps/LoopOps.td | 17 +-- .../mlir/Dialect/QuantOps/FakeQuantSupport.h | 17 +-- mlir/include/mlir/Dialect/QuantOps/Passes.h | 17 +-- mlir/include/mlir/Dialect/QuantOps/QuantOps.h | 17 +-- mlir/include/mlir/Dialect/QuantOps/QuantOps.td | 17 +-- .../mlir/Dialect/QuantOps/QuantPredicates.td | 17 +-- mlir/include/mlir/Dialect/QuantOps/QuantTypes.h | 17 +-- mlir/include/mlir/Dialect/QuantOps/QuantizeUtils.h | 17 +-- .../include/mlir/Dialect/QuantOps/UniformSupport.h | 17 +-- mlir/include/mlir/Dialect/SDBM/SDBM.h | 17 +-- mlir/include/mlir/Dialect/SDBM/SDBMDialect.h | 17 +-- mlir/include/mlir/Dialect/SDBM/SDBMExpr.h | 17 +-- mlir/include/mlir/Dialect/SPIRV/LayoutUtils.h | 17 +-- mlir/include/mlir/Dialect/SPIRV/Passes.h | 17 +-- .../mlir/Dialect/SPIRV/SPIRVArithmeticOps.td | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVAtomicOps.td | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVBinaryUtils.h | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVBitOps.td | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVCastOps.td | 17 +-- .../mlir/Dialect/SPIRV/SPIRVCompositeOps.td | 17 +-- .../mlir/Dialect/SPIRV/SPIRVControlFlowOps.td | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVDialect.h | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVGroupOps.td | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.td | 17 +-- .../mlir/Dialect/SPIRV/SPIRVNonUniformOps.td | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td | 17 +-- .../mlir/Dialect/SPIRV/SPIRVStructureOps.td | 17 +-- mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h | 17 +-- mlir/include/mlir/Dialect/SPIRV/Serialization.h | 17 +-- mlir/include/mlir/Dialect/StandardOps/Ops.h | 17 +-- mlir/include/mlir/Dialect/StandardOps/Ops.td | 17 +-- mlir/include/mlir/Dialect/Traits.h | 17 +-- .../mlir/Dialect/Utils/StructuredOpsUtils.h | 17 +-- mlir/include/mlir/Dialect/VectorOps/Utils.h | 17 +-- mlir/include/mlir/Dialect/VectorOps/VectorOps.h | 17 +-- mlir/include/mlir/Dialect/VectorOps/VectorOps.td | 17 +-- .../Dialect/VectorOps/VectorTransformPatterns.td | 17 +-- .../mlir/Dialect/VectorOps/VectorTransforms.h | 17 +-- mlir/include/mlir/EDSC/Builders.h | 17 +-- mlir/include/mlir/EDSC/Helpers.h | 17 +-- mlir/include/mlir/EDSC/Intrinsics.h | 17 +-- .../include/mlir/ExecutionEngine/ExecutionEngine.h | 17 +-- mlir/include/mlir/ExecutionEngine/OptUtils.h | 17 +-- mlir/include/mlir/IR/AffineExpr.h | 17 +-- mlir/include/mlir/IR/AffineExprVisitor.h | 17 +-- mlir/include/mlir/IR/AffineMap.h | 17 +-- mlir/include/mlir/IR/AttributeSupport.h | 17 +-- mlir/include/mlir/IR/Attributes.h | 17 +-- mlir/include/mlir/IR/Block.h | 17 +-- mlir/include/mlir/IR/BlockAndValueMapping.h | 17 +-- mlir/include/mlir/IR/BlockSupport.h | 17 +-- mlir/include/mlir/IR/Builders.h | 17 +-- mlir/include/mlir/IR/Diagnostics.h | 17 +-- mlir/include/mlir/IR/Dialect.h | 17 +-- mlir/include/mlir/IR/DialectHooks.h | 17 +-- mlir/include/mlir/IR/DialectImplementation.h | 17 +-- mlir/include/mlir/IR/DialectInterface.h | 17 +-- mlir/include/mlir/IR/DialectSymbolRegistry.def | 17 +-- mlir/include/mlir/IR/Function.h | 17 +-- mlir/include/mlir/IR/FunctionImplementation.h | 17 +-- mlir/include/mlir/IR/FunctionSupport.h | 17 +-- mlir/include/mlir/IR/Identifier.h | 17 +-- mlir/include/mlir/IR/IntegerSet.h | 17 +-- mlir/include/mlir/IR/Location.h | 17 +-- mlir/include/mlir/IR/MLIRContext.h | 17 +-- mlir/include/mlir/IR/Matchers.h | 17 +-- mlir/include/mlir/IR/Module.h | 17 +-- mlir/include/mlir/IR/OpAsmInterface.td | 17 +-- mlir/include/mlir/IR/OpBase.td | 17 +-- mlir/include/mlir/IR/OpDefinition.h | 17 +-- mlir/include/mlir/IR/OpImplementation.h | 17 +-- mlir/include/mlir/IR/Operation.h | 17 +-- mlir/include/mlir/IR/OperationSupport.h | 17 +-- mlir/include/mlir/IR/PatternMatch.h | 17 +-- mlir/include/mlir/IR/Region.h | 17 +-- mlir/include/mlir/IR/RegionGraphTraits.h | 17 +-- mlir/include/mlir/IR/StandardTypes.h | 17 +-- mlir/include/mlir/IR/StorageUniquerSupport.h | 17 +-- mlir/include/mlir/IR/SymbolTable.h | 17 +-- mlir/include/mlir/IR/TypeSupport.h | 17 +-- mlir/include/mlir/IR/TypeUtilities.h | 17 +-- mlir/include/mlir/IR/Types.h | 17 +-- mlir/include/mlir/IR/UseDefLists.h | 17 +-- mlir/include/mlir/IR/Value.h | 17 +-- mlir/include/mlir/IR/Visitors.h | 17 +-- mlir/include/mlir/Parser.h | 17 +-- mlir/include/mlir/Pass/AnalysisManager.h | 17 +-- mlir/include/mlir/Pass/Pass.h | 17 +-- mlir/include/mlir/Pass/PassInstrumentation.h | 17 +-- mlir/include/mlir/Pass/PassManager.h | 17 +-- mlir/include/mlir/Pass/PassOptions.h | 17 +-- mlir/include/mlir/Pass/PassRegistry.h | 17 +-- .../mlir/Quantizer/Configurations/FxpMathConfig.h | 17 +-- .../include/mlir/Quantizer/Support/Configuration.h | 17 +-- .../Quantizer/Support/ConstraintAnalysisGraph.h | 17 +-- .../Support/ConstraintAnalysisGraphTraits.h | 17 +-- mlir/include/mlir/Quantizer/Support/Metadata.h | 17 +-- mlir/include/mlir/Quantizer/Support/Rules.h | 17 +-- mlir/include/mlir/Quantizer/Support/Statistics.h | 17 +-- mlir/include/mlir/Quantizer/Support/TypeUtils.h | 17 +-- .../mlir/Quantizer/Support/UniformConstraints.h | 17 +-- .../mlir/Quantizer/Support/UniformSolvers.h | 17 +-- mlir/include/mlir/Quantizer/Transforms/Passes.h | 17 +-- mlir/include/mlir/Support/DebugStringHelper.h | 17 +-- mlir/include/mlir/Support/FileUtilities.h | 17 +-- mlir/include/mlir/Support/Functional.h | 17 +-- mlir/include/mlir/Support/JitRunner.h | 17 +-- mlir/include/mlir/Support/LLVM.h | 17 +-- mlir/include/mlir/Support/LogicalResult.h | 17 +-- mlir/include/mlir/Support/MathExtras.h | 17 +-- mlir/include/mlir/Support/MlirOptMain.h | 17 +-- mlir/include/mlir/Support/STLExtras.h | 17 +-- mlir/include/mlir/Support/StorageUniquer.h | 17 +-- mlir/include/mlir/Support/StringExtras.h | 17 +-- mlir/include/mlir/Support/ToolUtilities.h | 17 +-- mlir/include/mlir/Support/TranslateClParser.h | 17 +-- mlir/include/mlir/TableGen/Argument.h | 17 +-- mlir/include/mlir/TableGen/Attribute.h | 17 +-- mlir/include/mlir/TableGen/Constraint.h | 17 +-- mlir/include/mlir/TableGen/Dialect.h | 17 +-- mlir/include/mlir/TableGen/Format.h | 17 +-- mlir/include/mlir/TableGen/GenInfo.h | 17 +-- mlir/include/mlir/TableGen/GenNameParser.h | 17 +-- mlir/include/mlir/TableGen/OpInterfaces.h | 17 +-- mlir/include/mlir/TableGen/OpTrait.h | 17 +-- mlir/include/mlir/TableGen/Operator.h | 17 +-- mlir/include/mlir/TableGen/Pattern.h | 17 +-- mlir/include/mlir/TableGen/Predicate.h | 17 +-- mlir/include/mlir/TableGen/Region.h | 17 +-- mlir/include/mlir/TableGen/Type.h | 17 +-- mlir/include/mlir/Target/LLVMIR.h | 17 +-- .../include/mlir/Target/LLVMIR/ModuleTranslation.h | 17 +-- mlir/include/mlir/Target/NVVMIR.h | 17 +-- mlir/include/mlir/Target/ROCDLIR.h | 17 +-- mlir/include/mlir/Transforms/DialectConversion.h | 17 +-- mlir/include/mlir/Transforms/FoldUtils.h | 17 +-- mlir/include/mlir/Transforms/InliningUtils.h | 17 +-- mlir/include/mlir/Transforms/LoopFusionUtils.h | 17 +-- mlir/include/mlir/Transforms/LoopLikeInterface.h | 17 +-- mlir/include/mlir/Transforms/LoopLikeInterface.td | 17 +-- mlir/include/mlir/Transforms/LoopUtils.h | 17 +-- mlir/include/mlir/Transforms/Passes.h | 17 +-- mlir/include/mlir/Transforms/RegionUtils.h | 17 +-- .../include/mlir/Transforms/SideEffectsInterface.h | 17 +-- mlir/include/mlir/Transforms/Utils.h | 17 +-- mlir/include/mlir/Transforms/ViewOpGraph.h | 17 +-- mlir/include/mlir/Transforms/ViewRegionGraph.h | 17 +-- mlir/include/mlir/Translation.h | 17 +-- mlir/lib/Analysis/AffineAnalysis.cpp | 17 +-- mlir/lib/Analysis/AffineStructures.cpp | 17 +-- mlir/lib/Analysis/CallGraph.cpp | 17 +-- mlir/lib/Analysis/Dominance.cpp | 17 +-- mlir/lib/Analysis/InferTypeOpInterface.cpp | 17 +-- mlir/lib/Analysis/Liveness.cpp | 17 +-- mlir/lib/Analysis/LoopAnalysis.cpp | 17 +-- mlir/lib/Analysis/MemRefBoundCheck.cpp | 17 +-- mlir/lib/Analysis/NestedMatcher.cpp | 17 +-- mlir/lib/Analysis/OpStats.cpp | 17 +-- mlir/lib/Analysis/SliceAnalysis.cpp | 17 +-- mlir/lib/Analysis/TestMemRefDependenceCheck.cpp | 17 +-- mlir/lib/Analysis/TestParallelismDetection.cpp | 17 +-- mlir/lib/Analysis/Utils.cpp | 17 +-- mlir/lib/Analysis/VectorAnalysis.cpp | 17 +-- mlir/lib/Analysis/Verifier.cpp | 17 +-- .../AffineToStandard/AffineToStandard.cpp | 17 +-- .../GPUCommon/IndexIntrinsicsOpLowering.h | 17 +-- .../Conversion/GPUCommon/OpToFuncCallLowering.h | 17 +-- .../GPUToCUDA/ConvertKernelFuncToCubin.cpp | 17 +-- .../GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp | 17 +-- mlir/lib/Conversion/GPUToNVVM/GPUToNVVM.td | 17 +-- .../Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp | 17 +-- .../GPUToROCDL/LowerGpuOpsToROCDLOps.cpp | 17 +-- .../Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp | 17 +-- .../GPUToSPIRV/ConvertGPUToSPIRVPass.cpp | 17 +-- mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp | 17 +-- .../LoopToStandard/ConvertLoopToStandard.cpp | 17 +-- mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp | 17 +-- mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp | 17 +-- .../StandardToLLVM/ConvertStandardToLLVM.cpp | 17 +-- .../StandardToSPIRV/ConvertStandardToSPIRV.cpp | 17 +-- .../StandardToSPIRV/ConvertStandardToSPIRVPass.cpp | 17 +-- .../StandardToSPIRV/LegalizeStandardForSPIRV.cpp | 17 +-- .../VectorToLLVM/ConvertVectorToLLVM.cpp | 17 +-- .../VectorToLoops/ConvertVectorToLoops.cpp | 17 +-- mlir/lib/Dialect/AffineOps/AffineOps.cpp | 17 +-- mlir/lib/Dialect/AffineOps/DialectRegistration.cpp | 17 +-- .../Dialect/FxpMathOps/IR/DialectRegistration.cpp | 17 +-- mlir/lib/Dialect/FxpMathOps/IR/FxpMathOps.cpp | 17 +-- .../FxpMathOps/Transforms/LowerUniformRealMath.cpp | 17 +-- .../FxpMathOps/Transforms/UniformKernelUtils.h | 17 +-- mlir/lib/Dialect/GPU/IR/DialectRegistration.cpp | 17 +-- mlir/lib/Dialect/GPU/IR/GPUDialect.cpp | 17 +-- .../lib/Dialect/GPU/Transforms/KernelOutlining.cpp | 17 +-- mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp | 17 +-- mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp | 17 +-- mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp | 17 +-- .../Dialect/Linalg/Analysis/DependenceAnalysis.cpp | 17 +-- mlir/lib/Dialect/Linalg/EDSC/Builders.cpp | 17 +-- mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp | 17 +-- mlir/lib/Dialect/Linalg/IR/LinalgTypes.cpp | 17 +-- mlir/lib/Dialect/Linalg/LinalgRegistration.cpp | 17 +-- mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp | 17 +-- .../Dialect/Linalg/Transforms/LinalgToLoops.cpp | 17 +-- .../Dialect/Linalg/Transforms/LinalgTransforms.cpp | 17 +-- mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp | 17 +-- mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp | 17 +-- mlir/lib/Dialect/Linalg/Utils/Utils.cpp | 17 +-- mlir/lib/Dialect/LoopOps/DialectRegistration.cpp | 17 +-- mlir/lib/Dialect/LoopOps/LoopOps.cpp | 17 +-- .../Dialect/QuantOps/IR/DialectRegistration.cpp | 17 +-- mlir/lib/Dialect/QuantOps/IR/QuantOps.cpp | 17 +-- mlir/lib/Dialect/QuantOps/IR/QuantTypes.cpp | 17 +-- mlir/lib/Dialect/QuantOps/IR/TypeDetail.h | 17 +-- mlir/lib/Dialect/QuantOps/IR/TypeParser.cpp | 17 +-- .../Dialect/QuantOps/Transforms/ConvertConst.cpp | 17 +-- .../QuantOps/Transforms/ConvertSimQuant.cpp | 17 +-- .../Dialect/QuantOps/Utils/FakeQuantSupport.cpp | 17 +-- mlir/lib/Dialect/QuantOps/Utils/QuantizeUtils.cpp | 17 +-- mlir/lib/Dialect/QuantOps/Utils/UniformSupport.cpp | 17 +-- mlir/lib/Dialect/SDBM/SDBM.cpp | 17 +-- mlir/lib/Dialect/SDBM/SDBMDialect.cpp | 17 +-- mlir/lib/Dialect/SDBM/SDBMExpr.cpp | 17 +-- mlir/lib/Dialect/SDBM/SDBMExprDetail.h | 17 +-- mlir/lib/Dialect/SPIRV/DialectRegistration.cpp | 17 +-- mlir/lib/Dialect/SPIRV/LayoutUtils.cpp | 17 +-- mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp | 17 +-- mlir/lib/Dialect/SPIRV/SPIRVOps.cpp | 17 +-- mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp | 17 +-- .../Dialect/SPIRV/Serialization/Deserializer.cpp | 17 +-- .../SPIRV/Serialization/SPIRVBinaryUtils.cpp | 17 +-- .../lib/Dialect/SPIRV/Serialization/Serializer.cpp | 17 +-- .../SPIRV/Serialization/TranslateRegistration.cpp | 17 +-- .../DecorateSPIRVCompositeTypeLayoutPass.cpp | 17 +-- .../SPIRV/Transforms/LowerABIAttributesPass.cpp | 17 +-- .../Dialect/StandardOps/DialectRegistration.cpp | 17 +-- mlir/lib/Dialect/StandardOps/Ops.cpp | 17 +-- mlir/lib/Dialect/Traits.cpp | 17 +-- mlir/lib/Dialect/VectorOps/DialectRegistration.cpp | 17 +-- mlir/lib/Dialect/VectorOps/VectorOps.cpp | 17 +-- mlir/lib/Dialect/VectorOps/VectorTransforms.cpp | 17 +-- mlir/lib/EDSC/Builders.cpp | 17 +-- mlir/lib/EDSC/CoreAPIs.cpp | 17 +-- mlir/lib/EDSC/Helpers.cpp | 17 +-- mlir/lib/EDSC/Intrinsics.cpp | 17 +-- mlir/lib/ExecutionEngine/ExecutionEngine.cpp | 17 +-- mlir/lib/ExecutionEngine/OptUtils.cpp | 17 +-- mlir/lib/IR/AffineExpr.cpp | 17 +-- mlir/lib/IR/AffineExprDetail.h | 17 +-- mlir/lib/IR/AffineMap.cpp | 17 +-- mlir/lib/IR/AffineMapDetail.h | 17 +-- mlir/lib/IR/AsmPrinter.cpp | 17 +-- mlir/lib/IR/AttributeDetail.h | 17 +-- mlir/lib/IR/Attributes.cpp | 17 +-- mlir/lib/IR/Block.cpp | 17 +-- mlir/lib/IR/Builders.cpp | 17 +-- mlir/lib/IR/Diagnostics.cpp | 17 +-- mlir/lib/IR/Dialect.cpp | 17 +-- mlir/lib/IR/Function.cpp | 17 +-- mlir/lib/IR/FunctionImplementation.cpp | 17 +-- mlir/lib/IR/IntegerSet.cpp | 17 +-- mlir/lib/IR/IntegerSetDetail.h | 17 +-- mlir/lib/IR/Location.cpp | 17 +-- mlir/lib/IR/LocationDetail.h | 17 +-- mlir/lib/IR/MLIRContext.cpp | 17 +-- mlir/lib/IR/Module.cpp | 17 +-- mlir/lib/IR/Operation.cpp | 17 +-- mlir/lib/IR/OperationSupport.cpp | 17 +-- mlir/lib/IR/PatternMatch.cpp | 17 +-- mlir/lib/IR/Region.cpp | 17 +-- mlir/lib/IR/StandardTypes.cpp | 17 +-- mlir/lib/IR/SymbolTable.cpp | 17 +-- mlir/lib/IR/TypeDetail.h | 17 +-- mlir/lib/IR/TypeUtilities.cpp | 17 +-- mlir/lib/IR/Types.cpp | 17 +-- mlir/lib/IR/Value.cpp | 17 +-- mlir/lib/IR/Visitors.cpp | 17 +-- mlir/lib/Parser/Lexer.cpp | 17 +-- mlir/lib/Parser/Lexer.h | 17 +-- mlir/lib/Parser/Parser.cpp | 17 +-- mlir/lib/Parser/Token.cpp | 17 +-- mlir/lib/Parser/Token.h | 17 +-- mlir/lib/Parser/TokenKinds.def | 17 +-- mlir/lib/Pass/IRPrinting.cpp | 17 +-- mlir/lib/Pass/Pass.cpp | 17 +-- mlir/lib/Pass/PassDetail.h | 17 +-- mlir/lib/Pass/PassManagerOptions.cpp | 17 +-- mlir/lib/Pass/PassRegistry.cpp | 17 +-- mlir/lib/Pass/PassStatistics.cpp | 17 +-- mlir/lib/Pass/PassTiming.cpp | 17 +-- .../lib/Quantizer/Configurations/FxpMathConfig.cpp | 17 +-- mlir/lib/Quantizer/Support/Configuration.cpp | 17 +-- .../Quantizer/Support/ConstraintAnalysisGraph.cpp | 17 +-- mlir/lib/Quantizer/Support/Metadata.cpp | 17 +-- mlir/lib/Quantizer/Support/Statistics.cpp | 17 +-- mlir/lib/Quantizer/Support/TypeUtils.cpp | 17 +-- mlir/lib/Quantizer/Support/UniformConstraints.cpp | 17 +-- mlir/lib/Quantizer/Support/UniformSolvers.cpp | 17 +-- .../Transforms/AddDefaultStatsTestPass.cpp | 17 +-- .../Transforms/InferQuantizedTypesPass.cpp | 17 +-- .../Transforms/RemoveInstrumentationPass.cpp | 17 +-- mlir/lib/Support/FileUtilities.cpp | 17 +-- mlir/lib/Support/JitRunner.cpp | 17 +-- mlir/lib/Support/MlirOptMain.cpp | 17 +-- mlir/lib/Support/StorageUniquer.cpp | 17 +-- mlir/lib/Support/ToolUtilities.cpp | 17 +-- mlir/lib/Support/TranslateClParser.cpp | 17 +-- mlir/lib/TableGen/Argument.cpp | 17 +-- mlir/lib/TableGen/Attribute.cpp | 17 +-- mlir/lib/TableGen/Constraint.cpp | 17 +-- mlir/lib/TableGen/Dialect.cpp | 17 +-- mlir/lib/TableGen/Format.cpp | 17 +-- mlir/lib/TableGen/OpInterfaces.cpp | 17 +-- mlir/lib/TableGen/OpTrait.cpp | 17 +-- mlir/lib/TableGen/Operator.cpp | 17 +-- mlir/lib/TableGen/Pattern.cpp | 17 +-- mlir/lib/TableGen/Predicate.cpp | 17 +-- mlir/lib/TableGen/Type.cpp | 17 +-- mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp | 17 +-- mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp | 17 +-- mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp | 17 +-- mlir/lib/Target/LLVMIR/ConvertToROCDLIR.cpp | 17 +-- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | 17 +-- mlir/lib/Transforms/AffineDataCopyGeneration.cpp | 17 +-- .../Transforms/AffineLoopInvariantCodeMotion.cpp | 17 +-- mlir/lib/Transforms/CSE.cpp | 17 +-- mlir/lib/Transforms/Canonicalizer.cpp | 17 +-- mlir/lib/Transforms/DialectConversion.cpp | 17 +-- mlir/lib/Transforms/Inliner.cpp | 17 +-- mlir/lib/Transforms/LoopCoalescing.cpp | 17 +-- mlir/lib/Transforms/LoopFusion.cpp | 17 +-- mlir/lib/Transforms/LoopInvariantCodeMotion.cpp | 17 +-- mlir/lib/Transforms/LoopTiling.cpp | 17 +-- mlir/lib/Transforms/LoopUnroll.cpp | 17 +-- mlir/lib/Transforms/LoopUnrollAndJam.cpp | 17 +-- mlir/lib/Transforms/MemRefDataFlowOpt.cpp | 17 +-- mlir/lib/Transforms/PipelineDataTransfer.cpp | 17 +-- mlir/lib/Transforms/SimplifyAffineStructures.cpp | 17 +-- mlir/lib/Transforms/StripDebugInfo.cpp | 17 +-- mlir/lib/Transforms/Utils/FoldUtils.cpp | 17 +-- .../Utils/GreedyPatternRewriteDriver.cpp | 17 +-- mlir/lib/Transforms/Utils/InliningUtils.cpp | 17 +-- mlir/lib/Transforms/Utils/LoopFusionUtils.cpp | 17 +-- mlir/lib/Transforms/Utils/LoopUtils.cpp | 17 +-- mlir/lib/Transforms/Utils/RegionUtils.cpp | 17 +-- mlir/lib/Transforms/Utils/Utils.cpp | 17 +-- mlir/lib/Transforms/Vectorize.cpp | 17 +-- mlir/lib/Transforms/ViewOpGraph.cpp | 17 +-- mlir/lib/Transforms/ViewRegionGraph.cpp | 17 +-- mlir/lib/Translation/Translation.cpp | 17 +-- mlir/test/APITest.h | 17 +-- mlir/test/EDSC/builder-api-test.cpp | 17 +-- mlir/test/SDBM/sdbm-api-test.cpp | 17 +-- .../TestLinalgTransformPatterns.td | 17 +-- .../TestVectorTransformPatterns.td | 17 +-- mlir/test/lib/IR/TestFunc.cpp | 17 +-- mlir/test/lib/IR/TestMatchers.cpp | 17 +-- mlir/test/lib/IR/TestSymbolUses.cpp | 17 +-- mlir/test/lib/Pass/TestPassManager.cpp | 17 +-- mlir/test/lib/TestDialect/TestDialect.cpp | 17 +-- mlir/test/lib/TestDialect/TestDialect.h | 17 +-- mlir/test/lib/TestDialect/TestOps.td | 17 +-- mlir/test/lib/TestDialect/TestPatterns.cpp | 17 +-- mlir/test/lib/Transforms/TestCallGraph.cpp | 17 +-- mlir/test/lib/Transforms/TestConstantFold.cpp | 17 +-- mlir/test/lib/Transforms/TestInlining.cpp | 17 +-- mlir/test/lib/Transforms/TestLinalgTransforms.cpp | 17 +-- mlir/test/lib/Transforms/TestLiveness.cpp | 17 +-- mlir/test/lib/Transforms/TestLoopFusion.cpp | 17 +-- mlir/test/lib/Transforms/TestLoopMapping.cpp | 17 +-- .../lib/Transforms/TestLoopParametricTiling.cpp | 17 +-- .../lib/Transforms/TestMemRefStrideCalculation.cpp | 17 +-- mlir/test/lib/Transforms/TestOpaqueLoc.cpp | 17 +-- .../lib/Transforms/TestVectorToLoopsConversion.cpp | 17 +-- mlir/test/lib/Transforms/TestVectorTransforms.cpp | 17 +-- .../test/lib/Transforms/TestVectorizationUtils.cpp | 17 +-- mlir/test/mlir-cpu-runner/cblas.cpp | 17 +-- mlir/test/mlir-cpu-runner/cblas_interface.cpp | 17 +-- mlir/test/mlir-cpu-runner/include/cblas.h | 17 +-- .../mlir-cpu-runner/include/mlir_runner_utils.h | 17 +-- mlir/test/mlir-cpu-runner/mlir_runner_utils.cpp | 17 +-- mlir/tools/mlir-cpu-runner/mlir-cpu-runner.cpp | 17 +-- .../mlir-cuda-runner/cuda-runtime-wrappers.cpp | 17 +-- mlir/tools/mlir-cuda-runner/mlir-cuda-runner.cpp | 17 +-- mlir/tools/mlir-opt/mlir-opt.cpp | 17 +-- mlir/tools/mlir-tblgen/DocGenUtilities.h | 17 +-- mlir/tools/mlir-tblgen/EnumsGen.cpp | 17 +-- mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp | 17 +-- mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | 17 +-- mlir/tools/mlir-tblgen/OpDocGen.cpp | 17 +-- mlir/tools/mlir-tblgen/OpInterfacesGen.cpp | 17 +-- mlir/tools/mlir-tblgen/ReferenceImplGen.cpp | 17 +-- mlir/tools/mlir-tblgen/RewriterGen.cpp | 17 +-- mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp | 17 +-- mlir/tools/mlir-tblgen/StructsGen.cpp | 17 +-- mlir/tools/mlir-tblgen/mlir-tblgen.cpp | 17 +-- mlir/tools/mlir-translate/mlir-translate.cpp | 17 +-- mlir/unittests/ADT/TypeSwitchTest.cpp | 17 +-- mlir/unittests/Dialect/BroadcastShapeTest.cpp | 17 +-- .../Dialect/QuantOps/QuantizationUtilsTest.cpp | 17 +-- .../Dialect/SPIRV/DeserializationTest.cpp | 17 +-- mlir/unittests/Dialect/SPIRV/SerializationTest.cpp | 17 +-- mlir/unittests/IR/AttributeTest.cpp | 17 +-- mlir/unittests/IR/DialectTest.cpp | 17 +-- mlir/unittests/IR/OperationSupportTest.cpp | 17 +-- mlir/unittests/IR/StringExtrasTest.cpp | 17 +-- mlir/unittests/Pass/AnalysisManagerTest.cpp | 17 +-- mlir/unittests/Quantizer/Support/RulesTest.cpp | 17 +-- .../Quantizer/Support/UniformSolversTest.cpp | 17 +-- mlir/unittests/SDBM/SDBMTest.cpp | 17 +-- mlir/unittests/TableGen/EnumsGenTest.cpp | 17 +-- mlir/unittests/TableGen/FormatTest.cpp | 17 +-- mlir/unittests/TableGen/StructsGenTest.cpp | 17 +-- mlir/unittests/TableGen/enums.td | 17 +-- mlir/unittests/TableGen/structs.td | 17 +-- mlir/utils/generate-test-checks.py | 16 +-- mlir/utils/spirv/define_enum.sh | 16 +-- mlir/utils/spirv/define_inst.sh | 16 +-- mlir/utils/spirv/define_opcodes.sh | 16 +-- mlir/utils/spirv/gen_spirv_dialect.py | 16 +-- 593 files changed, 2464 insertions(+), 7723 deletions(-) (limited to 'mlir/lib/TableGen/Attribute.cpp') diff --git a/mlir/LICENSE.TXT b/mlir/LICENSE.TXT index a4b160b6e33..fa6ac540007 100644 --- a/mlir/LICENSE.TXT +++ b/mlir/LICENSE.TXT @@ -1,12 +1,14 @@ -Copyright 2019 The MLIR Authors. +============================================================================== +The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: +============================================================================== Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - 1. Definitions. + 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. @@ -65,14 +67,14 @@ Copyright 2019 The MLIR Authors. on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. - 2. Grant of Copyright License. Subject to the terms and conditions of + 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. - 3. Grant of Patent License. Subject to the terms and conditions of + 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, @@ -88,7 +90,7 @@ Copyright 2019 The MLIR Authors. granted to You under this License for that Work shall terminate as of the date such litigation is filed. - 4. Redistribution. You may reproduce and distribute copies of the + 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: @@ -129,7 +131,7 @@ Copyright 2019 The MLIR Authors. reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. - 5. Submission of Contributions. Unless You explicitly state otherwise, + 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. @@ -137,12 +139,12 @@ Copyright 2019 The MLIR Authors. the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. - 6. Trademarks. This License does not grant permission to use the trade + 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. - 7. Disclaimer of Warranty. Unless required by applicable law or + 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or @@ -152,7 +154,7 @@ Copyright 2019 The MLIR Authors. appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. - 8. Limitation of Liability. In no event and under no legal theory, + 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be @@ -164,7 +166,7 @@ Copyright 2019 The MLIR Authors. other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. - 9. Accepting Warranty or Additional Liability. While redistributing + 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this @@ -175,9 +177,9 @@ Copyright 2019 The MLIR Authors. incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. - END OF TERMS AND CONDITIONS + END OF TERMS AND CONDITIONS - APPENDIX: How to apply the Apache License to your work. + APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" @@ -188,18 +190,90 @@ Copyright 2019 The MLIR Authors. same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +---- LLVM Exceptions to the Apache 2.0 License ---- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into an Object form of such source code, you +may redistribute such embedded portions in such Object form without complying +with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + +In addition, if you combine or link compiled forms of this Software with +software that is licensed under the GPLv2 ("Combined Software") and if a +court of competent jurisdiction determines that the patent provision (Section +3), the indemnity provision (Section 9) or other Section of the License +conflicts with the conditions of the GPLv2, you may retroactively and +prospectively choose to deem waived or otherwise exclude such Section(s) of +the License, but only in their entirety and only with respect to the Combined +Software. + +============================================================================== +Software from third parties included in the LLVM Project: +============================================================================== +The LLVM Project contains third party software which is under different license +terms. All such code will be identified clearly using at least one of two +mechanisms: +1) It will be in a separate directory tree with its own `LICENSE.txt` or + `LICENSE` file at the top containing the specific license and restrictions + which apply to that software, or +2) It will contain specific license and restriction terms at the top of every + file. + +============================================================================== +Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy): +============================================================================== +University of Illinois/NCSA +Open Source License + +Copyright (c) 2003-2019 University of Illinois at Urbana-Champaign. +All rights reserved. + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE +SOFTWARE. diff --git a/mlir/bindings/python/pybind.cpp b/mlir/bindings/python/pybind.cpp index 54646cbe800..10445edaf12 100644 --- a/mlir/bindings/python/pybind.cpp +++ b/mlir/bindings/python/pybind.cpp @@ -1,19 +1,10 @@ //===- pybind.cpp - MLIR Python bindings ----------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" diff --git a/mlir/examples/toy/Ch1/include/toy/AST.h b/mlir/examples/toy/Ch1/include/toy/AST.h index 901164b0f39..820600b5b1c 100644 --- a/mlir/examples/toy/Ch1/include/toy/AST.h +++ b/mlir/examples/toy/Ch1/include/toy/AST.h @@ -1,19 +1,10 @@ //===- AST.h - Node definition for the Toy AST ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST for the Toy language. It is optimized for // simplicity, not efficiency. The AST forms a tree structure where each node diff --git a/mlir/examples/toy/Ch1/include/toy/Lexer.h b/mlir/examples/toy/Ch1/include/toy/Lexer.h index 2e19cd09b20..a77a91bb564 100644 --- a/mlir/examples/toy/Ch1/include/toy/Lexer.h +++ b/mlir/examples/toy/Ch1/include/toy/Lexer.h @@ -1,19 +1,10 @@ //===- Lexer.h - Lexer for the Toy language -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple Lexer for the Toy language. // diff --git a/mlir/examples/toy/Ch1/include/toy/Parser.h b/mlir/examples/toy/Ch1/include/toy/Parser.h index 9e219e56551..4557ea26859 100644 --- a/mlir/examples/toy/Ch1/include/toy/Parser.h +++ b/mlir/examples/toy/Ch1/include/toy/Parser.h @@ -1,19 +1,10 @@ //===- Parser.h - Toy Language Parser -------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the parser for the Toy language. It processes the Token // provided by the Lexer and returns an AST. diff --git a/mlir/examples/toy/Ch1/parser/AST.cpp b/mlir/examples/toy/Ch1/parser/AST.cpp index 3ec91a4300d..0d6d9359529 100644 --- a/mlir/examples/toy/Ch1/parser/AST.cpp +++ b/mlir/examples/toy/Ch1/parser/AST.cpp @@ -1,19 +1,10 @@ //===- AST.cpp - Helper for printing out the Toy AST ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST dump for the Toy language. // diff --git a/mlir/examples/toy/Ch1/toyc.cpp b/mlir/examples/toy/Ch1/toyc.cpp index 37794d5c4d9..48863fa931c 100644 --- a/mlir/examples/toy/Ch1/toyc.cpp +++ b/mlir/examples/toy/Ch1/toyc.cpp @@ -1,19 +1,10 @@ //===- toyc.cpp - The Toy Compiler ----------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the entry point for the Toy compiler. // diff --git a/mlir/examples/toy/Ch2/include/toy/AST.h b/mlir/examples/toy/Ch2/include/toy/AST.h index 901164b0f39..820600b5b1c 100644 --- a/mlir/examples/toy/Ch2/include/toy/AST.h +++ b/mlir/examples/toy/Ch2/include/toy/AST.h @@ -1,19 +1,10 @@ //===- AST.h - Node definition for the Toy AST ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST for the Toy language. It is optimized for // simplicity, not efficiency. The AST forms a tree structure where each node diff --git a/mlir/examples/toy/Ch2/include/toy/Dialect.h b/mlir/examples/toy/Ch2/include/toy/Dialect.h index 91dd631d2ff..385d6ddb95a 100644 --- a/mlir/examples/toy/Ch2/include/toy/Dialect.h +++ b/mlir/examples/toy/Ch2/include/toy/Dialect.h @@ -1,19 +1,10 @@ //===- Dialect.h - Dialect definition for the Toy IR ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the IR Dialect for the Toy language. // See g3doc/Tutorials/Toy/Ch-2.md for more information. diff --git a/mlir/examples/toy/Ch2/include/toy/Lexer.h b/mlir/examples/toy/Ch2/include/toy/Lexer.h index 144388c460c..6eff64ee5f0 100644 --- a/mlir/examples/toy/Ch2/include/toy/Lexer.h +++ b/mlir/examples/toy/Ch2/include/toy/Lexer.h @@ -1,19 +1,10 @@ //===- Lexer.h - Lexer for the Toy language -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple Lexer for the Toy language. // diff --git a/mlir/examples/toy/Ch2/include/toy/MLIRGen.h b/mlir/examples/toy/Ch2/include/toy/MLIRGen.h index 287f432c847..e1c8ca1201d 100644 --- a/mlir/examples/toy/Ch2/include/toy/MLIRGen.h +++ b/mlir/examples/toy/Ch2/include/toy/MLIRGen.h @@ -1,19 +1,10 @@ //===- MLIRGen.h - MLIR Generation from a Toy AST -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares a simple interface to perform IR generation targeting MLIR // from a Module AST for the Toy language. diff --git a/mlir/examples/toy/Ch2/include/toy/Ops.td b/mlir/examples/toy/Ch2/include/toy/Ops.td index dd88b097ab1..20c4a7463d9 100644 --- a/mlir/examples/toy/Ch2/include/toy/Ops.td +++ b/mlir/examples/toy/Ch2/include/toy/Ops.td @@ -1,19 +1,10 @@ //===- Ops.td - Toy dialect operation definitions ----------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines the operations of the Toy dialect. // diff --git a/mlir/examples/toy/Ch2/include/toy/Parser.h b/mlir/examples/toy/Ch2/include/toy/Parser.h index 9e219e56551..4557ea26859 100644 --- a/mlir/examples/toy/Ch2/include/toy/Parser.h +++ b/mlir/examples/toy/Ch2/include/toy/Parser.h @@ -1,19 +1,10 @@ //===- Parser.h - Toy Language Parser -------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the parser for the Toy language. It processes the Token // provided by the Lexer and returns an AST. diff --git a/mlir/examples/toy/Ch2/mlir/Dialect.cpp b/mlir/examples/toy/Ch2/mlir/Dialect.cpp index 4a3232dabe3..b33cb5cbfe9 100644 --- a/mlir/examples/toy/Ch2/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch2/mlir/Dialect.cpp @@ -1,19 +1,10 @@ //===- Dialect.cpp - Toy IR Dialect registration in MLIR ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the dialect for the Toy IR: custom type parsing and // operation verification. diff --git a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp index 902c634a954..e9987ff2c77 100644 --- a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp @@ -1,19 +1,10 @@ //===- MLIRGen.cpp - MLIR Generation from a Toy AST -----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple IR generation targeting MLIR from a Module AST // for the Toy language. diff --git a/mlir/examples/toy/Ch2/parser/AST.cpp b/mlir/examples/toy/Ch2/parser/AST.cpp index 3ec91a4300d..0d6d9359529 100644 --- a/mlir/examples/toy/Ch2/parser/AST.cpp +++ b/mlir/examples/toy/Ch2/parser/AST.cpp @@ -1,19 +1,10 @@ //===- AST.cpp - Helper for printing out the Toy AST ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST dump for the Toy language. // diff --git a/mlir/examples/toy/Ch2/toyc.cpp b/mlir/examples/toy/Ch2/toyc.cpp index 19def702589..3e3db97b4ae 100644 --- a/mlir/examples/toy/Ch2/toyc.cpp +++ b/mlir/examples/toy/Ch2/toyc.cpp @@ -1,19 +1,10 @@ //===- toyc.cpp - The Toy Compiler ----------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the entry point for the Toy compiler. // diff --git a/mlir/examples/toy/Ch3/include/toy/AST.h b/mlir/examples/toy/Ch3/include/toy/AST.h index 901164b0f39..820600b5b1c 100644 --- a/mlir/examples/toy/Ch3/include/toy/AST.h +++ b/mlir/examples/toy/Ch3/include/toy/AST.h @@ -1,19 +1,10 @@ //===- AST.h - Node definition for the Toy AST ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST for the Toy language. It is optimized for // simplicity, not efficiency. The AST forms a tree structure where each node diff --git a/mlir/examples/toy/Ch3/include/toy/Dialect.h b/mlir/examples/toy/Ch3/include/toy/Dialect.h index 91dd631d2ff..385d6ddb95a 100644 --- a/mlir/examples/toy/Ch3/include/toy/Dialect.h +++ b/mlir/examples/toy/Ch3/include/toy/Dialect.h @@ -1,19 +1,10 @@ //===- Dialect.h - Dialect definition for the Toy IR ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the IR Dialect for the Toy language. // See g3doc/Tutorials/Toy/Ch-2.md for more information. diff --git a/mlir/examples/toy/Ch3/include/toy/Lexer.h b/mlir/examples/toy/Ch3/include/toy/Lexer.h index 144388c460c..6eff64ee5f0 100644 --- a/mlir/examples/toy/Ch3/include/toy/Lexer.h +++ b/mlir/examples/toy/Ch3/include/toy/Lexer.h @@ -1,19 +1,10 @@ //===- Lexer.h - Lexer for the Toy language -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple Lexer for the Toy language. // diff --git a/mlir/examples/toy/Ch3/include/toy/MLIRGen.h b/mlir/examples/toy/Ch3/include/toy/MLIRGen.h index 287f432c847..e1c8ca1201d 100644 --- a/mlir/examples/toy/Ch3/include/toy/MLIRGen.h +++ b/mlir/examples/toy/Ch3/include/toy/MLIRGen.h @@ -1,19 +1,10 @@ //===- MLIRGen.h - MLIR Generation from a Toy AST -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares a simple interface to perform IR generation targeting MLIR // from a Module AST for the Toy language. diff --git a/mlir/examples/toy/Ch3/include/toy/Ops.td b/mlir/examples/toy/Ch3/include/toy/Ops.td index 6c400169da2..a6c93ccba10 100644 --- a/mlir/examples/toy/Ch3/include/toy/Ops.td +++ b/mlir/examples/toy/Ch3/include/toy/Ops.td @@ -1,19 +1,10 @@ //===- Ops.td - Toy dialect operation definitions ----------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines the operations of the Toy dialect. // diff --git a/mlir/examples/toy/Ch3/include/toy/Parser.h b/mlir/examples/toy/Ch3/include/toy/Parser.h index 9e219e56551..4557ea26859 100644 --- a/mlir/examples/toy/Ch3/include/toy/Parser.h +++ b/mlir/examples/toy/Ch3/include/toy/Parser.h @@ -1,19 +1,10 @@ //===- Parser.h - Toy Language Parser -------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the parser for the Toy language. It processes the Token // provided by the Lexer and returns an AST. diff --git a/mlir/examples/toy/Ch3/mlir/Dialect.cpp b/mlir/examples/toy/Ch3/mlir/Dialect.cpp index 4a3232dabe3..b33cb5cbfe9 100644 --- a/mlir/examples/toy/Ch3/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch3/mlir/Dialect.cpp @@ -1,19 +1,10 @@ //===- Dialect.cpp - Toy IR Dialect registration in MLIR ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the dialect for the Toy IR: custom type parsing and // operation verification. diff --git a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp index 902c634a954..e9987ff2c77 100644 --- a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp @@ -1,19 +1,10 @@ //===- MLIRGen.cpp - MLIR Generation from a Toy AST -----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple IR generation targeting MLIR from a Module AST // for the Toy language. diff --git a/mlir/examples/toy/Ch3/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch3/mlir/ToyCombine.cpp index 42a10397513..d52a2c173c1 100644 --- a/mlir/examples/toy/Ch3/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch3/mlir/ToyCombine.cpp @@ -1,19 +1,10 @@ //===- ToyCombine.cpp - Toy High Level Optimizer --------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a set of simple combiners for optimizing operations in // the Toy dialect. diff --git a/mlir/examples/toy/Ch3/mlir/ToyCombine.td b/mlir/examples/toy/Ch3/mlir/ToyCombine.td index 1ca143a913c..e6e33e84d7e 100644 --- a/mlir/examples/toy/Ch3/mlir/ToyCombine.td +++ b/mlir/examples/toy/Ch3/mlir/ToyCombine.td @@ -1,19 +1,10 @@ //===- ToyCombine.td - Pattern Match Optimizations for Toy -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines language-specific pattern match optimizations for Toy using // Declarative Rewrite Rules (DRR) specified using TableGen records. diff --git a/mlir/examples/toy/Ch3/parser/AST.cpp b/mlir/examples/toy/Ch3/parser/AST.cpp index 3ec91a4300d..0d6d9359529 100644 --- a/mlir/examples/toy/Ch3/parser/AST.cpp +++ b/mlir/examples/toy/Ch3/parser/AST.cpp @@ -1,19 +1,10 @@ //===- AST.cpp - Helper for printing out the Toy AST ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST dump for the Toy language. // diff --git a/mlir/examples/toy/Ch3/toyc.cpp b/mlir/examples/toy/Ch3/toyc.cpp index 410a9d677e8..e8b6e94786b 100644 --- a/mlir/examples/toy/Ch3/toyc.cpp +++ b/mlir/examples/toy/Ch3/toyc.cpp @@ -1,19 +1,10 @@ //===- toyc.cpp - The Toy Compiler ----------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the entry point for the Toy compiler. // diff --git a/mlir/examples/toy/Ch4/include/toy/AST.h b/mlir/examples/toy/Ch4/include/toy/AST.h index 901164b0f39..820600b5b1c 100644 --- a/mlir/examples/toy/Ch4/include/toy/AST.h +++ b/mlir/examples/toy/Ch4/include/toy/AST.h @@ -1,19 +1,10 @@ //===- AST.h - Node definition for the Toy AST ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST for the Toy language. It is optimized for // simplicity, not efficiency. The AST forms a tree structure where each node diff --git a/mlir/examples/toy/Ch4/include/toy/Dialect.h b/mlir/examples/toy/Ch4/include/toy/Dialect.h index 556ae972b84..5e8b91dcf48 100644 --- a/mlir/examples/toy/Ch4/include/toy/Dialect.h +++ b/mlir/examples/toy/Ch4/include/toy/Dialect.h @@ -1,19 +1,10 @@ //===- Dialect.h - Dialect definition for the Toy IR ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the IR Dialect for the Toy language. // See g3doc/Tutorials/Toy/Ch-2.md for more information. diff --git a/mlir/examples/toy/Ch4/include/toy/Lexer.h b/mlir/examples/toy/Ch4/include/toy/Lexer.h index 144388c460c..6eff64ee5f0 100644 --- a/mlir/examples/toy/Ch4/include/toy/Lexer.h +++ b/mlir/examples/toy/Ch4/include/toy/Lexer.h @@ -1,19 +1,10 @@ //===- Lexer.h - Lexer for the Toy language -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple Lexer for the Toy language. // diff --git a/mlir/examples/toy/Ch4/include/toy/MLIRGen.h b/mlir/examples/toy/Ch4/include/toy/MLIRGen.h index 287f432c847..e1c8ca1201d 100644 --- a/mlir/examples/toy/Ch4/include/toy/MLIRGen.h +++ b/mlir/examples/toy/Ch4/include/toy/MLIRGen.h @@ -1,19 +1,10 @@ //===- MLIRGen.h - MLIR Generation from a Toy AST -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares a simple interface to perform IR generation targeting MLIR // from a Module AST for the Toy language. diff --git a/mlir/examples/toy/Ch4/include/toy/Ops.td b/mlir/examples/toy/Ch4/include/toy/Ops.td index ef5b30a862b..71167664bbc 100644 --- a/mlir/examples/toy/Ch4/include/toy/Ops.td +++ b/mlir/examples/toy/Ch4/include/toy/Ops.td @@ -1,19 +1,10 @@ //===- Ops.td - Toy dialect operation definitions ----------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines the operations of the Toy dialect. // diff --git a/mlir/examples/toy/Ch4/include/toy/Parser.h b/mlir/examples/toy/Ch4/include/toy/Parser.h index 9e219e56551..4557ea26859 100644 --- a/mlir/examples/toy/Ch4/include/toy/Parser.h +++ b/mlir/examples/toy/Ch4/include/toy/Parser.h @@ -1,19 +1,10 @@ //===- Parser.h - Toy Language Parser -------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the parser for the Toy language. It processes the Token // provided by the Lexer and returns an AST. diff --git a/mlir/examples/toy/Ch4/include/toy/Passes.h b/mlir/examples/toy/Ch4/include/toy/Passes.h index 8c8365d6882..93c51309008 100644 --- a/mlir/examples/toy/Ch4/include/toy/Passes.h +++ b/mlir/examples/toy/Ch4/include/toy/Passes.h @@ -1,19 +1,10 @@ //===- Passes.h - Toy Passes Definition -----------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file exposes the entry points to create compiler passes for Toy. // diff --git a/mlir/examples/toy/Ch4/include/toy/ShapeInferenceInterface.h b/mlir/examples/toy/Ch4/include/toy/ShapeInferenceInterface.h index fc36b5b100d..da0fb66018e 100644 --- a/mlir/examples/toy/Ch4/include/toy/ShapeInferenceInterface.h +++ b/mlir/examples/toy/Ch4/include/toy/ShapeInferenceInterface.h @@ -1,19 +1,10 @@ //===- ShapeInferenceInterface.h - Interface definitions for ShapeInference -=// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains the declarations of the shape inference interfaces defined // in ShapeInferenceInterface.td. diff --git a/mlir/examples/toy/Ch4/include/toy/ShapeInferenceInterface.td b/mlir/examples/toy/Ch4/include/toy/ShapeInferenceInterface.td index 6974575a63c..1b38ada1622 100644 --- a/mlir/examples/toy/Ch4/include/toy/ShapeInferenceInterface.td +++ b/mlir/examples/toy/Ch4/include/toy/ShapeInferenceInterface.td @@ -1,19 +1,10 @@ //===- ShapeInferenceInterface.td - Shape Inference Interface -*- tablegen -==// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines the operations of the Shape Inference Op Interface. // diff --git a/mlir/examples/toy/Ch4/mlir/DeadFunctionEliminationPass.cpp b/mlir/examples/toy/Ch4/mlir/DeadFunctionEliminationPass.cpp index b58adb5d52f..1ee34547860 100644 --- a/mlir/examples/toy/Ch4/mlir/DeadFunctionEliminationPass.cpp +++ b/mlir/examples/toy/Ch4/mlir/DeadFunctionEliminationPass.cpp @@ -1,19 +1,10 @@ //===- DeadFunctionEliminationPass.cpp - Eliminate inlined functions ------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a Module level pass performing dead function // elimination. This is required as a post-processing step after function diff --git a/mlir/examples/toy/Ch4/mlir/Dialect.cpp b/mlir/examples/toy/Ch4/mlir/Dialect.cpp index 8be1094cf15..50116b14bea 100644 --- a/mlir/examples/toy/Ch4/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch4/mlir/Dialect.cpp @@ -1,19 +1,10 @@ //===- Dialect.cpp - Toy IR Dialect registration in MLIR ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the dialect for the Toy IR: custom type parsing and // operation verification. diff --git a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp index 902c634a954..e9987ff2c77 100644 --- a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp @@ -1,19 +1,10 @@ //===- MLIRGen.cpp - MLIR Generation from a Toy AST -----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple IR generation targeting MLIR from a Module AST // for the Toy language. diff --git a/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp index 1f572015c39..517a1f07530 100644 --- a/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch4/mlir/ShapeInferencePass.cpp @@ -1,19 +1,10 @@ //===- ShapeInferencePass.cpp - Shape Inference ---------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a Function level pass performing interprocedural // propagation of array shapes through function specialization. diff --git a/mlir/examples/toy/Ch4/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch4/mlir/ToyCombine.cpp index 604e9fa6c83..2cbf8bdac9b 100644 --- a/mlir/examples/toy/Ch4/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch4/mlir/ToyCombine.cpp @@ -1,19 +1,10 @@ //===- ToyCombine.cpp - Toy High Level Optimizer --------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a set of simple combiners for optimizing operations in // the Toy dialect. diff --git a/mlir/examples/toy/Ch4/mlir/ToyCombine.td b/mlir/examples/toy/Ch4/mlir/ToyCombine.td index 1ca143a913c..e6e33e84d7e 100644 --- a/mlir/examples/toy/Ch4/mlir/ToyCombine.td +++ b/mlir/examples/toy/Ch4/mlir/ToyCombine.td @@ -1,19 +1,10 @@ //===- ToyCombine.td - Pattern Match Optimizations for Toy -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines language-specific pattern match optimizations for Toy using // Declarative Rewrite Rules (DRR) specified using TableGen records. diff --git a/mlir/examples/toy/Ch4/parser/AST.cpp b/mlir/examples/toy/Ch4/parser/AST.cpp index 3ec91a4300d..0d6d9359529 100644 --- a/mlir/examples/toy/Ch4/parser/AST.cpp +++ b/mlir/examples/toy/Ch4/parser/AST.cpp @@ -1,19 +1,10 @@ //===- AST.cpp - Helper for printing out the Toy AST ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST dump for the Toy language. // diff --git a/mlir/examples/toy/Ch4/toyc.cpp b/mlir/examples/toy/Ch4/toyc.cpp index 5ec514ac5b9..e7b584407f6 100644 --- a/mlir/examples/toy/Ch4/toyc.cpp +++ b/mlir/examples/toy/Ch4/toyc.cpp @@ -1,19 +1,10 @@ //===- toyc.cpp - The Toy Compiler ----------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the entry point for the Toy compiler. // diff --git a/mlir/examples/toy/Ch5/include/toy/AST.h b/mlir/examples/toy/Ch5/include/toy/AST.h index 901164b0f39..820600b5b1c 100644 --- a/mlir/examples/toy/Ch5/include/toy/AST.h +++ b/mlir/examples/toy/Ch5/include/toy/AST.h @@ -1,19 +1,10 @@ //===- AST.h - Node definition for the Toy AST ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST for the Toy language. It is optimized for // simplicity, not efficiency. The AST forms a tree structure where each node diff --git a/mlir/examples/toy/Ch5/include/toy/Dialect.h b/mlir/examples/toy/Ch5/include/toy/Dialect.h index 556ae972b84..5e8b91dcf48 100644 --- a/mlir/examples/toy/Ch5/include/toy/Dialect.h +++ b/mlir/examples/toy/Ch5/include/toy/Dialect.h @@ -1,19 +1,10 @@ //===- Dialect.h - Dialect definition for the Toy IR ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the IR Dialect for the Toy language. // See g3doc/Tutorials/Toy/Ch-2.md for more information. diff --git a/mlir/examples/toy/Ch5/include/toy/Lexer.h b/mlir/examples/toy/Ch5/include/toy/Lexer.h index 144388c460c..6eff64ee5f0 100644 --- a/mlir/examples/toy/Ch5/include/toy/Lexer.h +++ b/mlir/examples/toy/Ch5/include/toy/Lexer.h @@ -1,19 +1,10 @@ //===- Lexer.h - Lexer for the Toy language -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple Lexer for the Toy language. // diff --git a/mlir/examples/toy/Ch5/include/toy/MLIRGen.h b/mlir/examples/toy/Ch5/include/toy/MLIRGen.h index 287f432c847..e1c8ca1201d 100644 --- a/mlir/examples/toy/Ch5/include/toy/MLIRGen.h +++ b/mlir/examples/toy/Ch5/include/toy/MLIRGen.h @@ -1,19 +1,10 @@ //===- MLIRGen.h - MLIR Generation from a Toy AST -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares a simple interface to perform IR generation targeting MLIR // from a Module AST for the Toy language. diff --git a/mlir/examples/toy/Ch5/include/toy/Ops.td b/mlir/examples/toy/Ch5/include/toy/Ops.td index b3bda1d647b..bb98ae19a09 100644 --- a/mlir/examples/toy/Ch5/include/toy/Ops.td +++ b/mlir/examples/toy/Ch5/include/toy/Ops.td @@ -1,19 +1,10 @@ //===- Ops.td - Toy dialect operation definitions ----------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines the operations of the Toy dialect. // diff --git a/mlir/examples/toy/Ch5/include/toy/Parser.h b/mlir/examples/toy/Ch5/include/toy/Parser.h index 9e219e56551..4557ea26859 100644 --- a/mlir/examples/toy/Ch5/include/toy/Parser.h +++ b/mlir/examples/toy/Ch5/include/toy/Parser.h @@ -1,19 +1,10 @@ //===- Parser.h - Toy Language Parser -------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the parser for the Toy language. It processes the Token // provided by the Lexer and returns an AST. diff --git a/mlir/examples/toy/Ch5/include/toy/Passes.h b/mlir/examples/toy/Ch5/include/toy/Passes.h index b6a79eda176..97a5d0db46c 100644 --- a/mlir/examples/toy/Ch5/include/toy/Passes.h +++ b/mlir/examples/toy/Ch5/include/toy/Passes.h @@ -1,19 +1,10 @@ //===- Passes.h - Toy Passes Definition -----------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file exposes the entry points to create compiler passes for Toy. // diff --git a/mlir/examples/toy/Ch5/include/toy/ShapeInferenceInterface.h b/mlir/examples/toy/Ch5/include/toy/ShapeInferenceInterface.h index fc36b5b100d..da0fb66018e 100644 --- a/mlir/examples/toy/Ch5/include/toy/ShapeInferenceInterface.h +++ b/mlir/examples/toy/Ch5/include/toy/ShapeInferenceInterface.h @@ -1,19 +1,10 @@ //===- ShapeInferenceInterface.h - Interface definitions for ShapeInference -=// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains the declarations of the shape inference interfaces defined // in ShapeInferenceInterface.td. diff --git a/mlir/examples/toy/Ch5/include/toy/ShapeInferenceInterface.td b/mlir/examples/toy/Ch5/include/toy/ShapeInferenceInterface.td index 6974575a63c..1b38ada1622 100644 --- a/mlir/examples/toy/Ch5/include/toy/ShapeInferenceInterface.td +++ b/mlir/examples/toy/Ch5/include/toy/ShapeInferenceInterface.td @@ -1,19 +1,10 @@ //===- ShapeInferenceInterface.td - Shape Inference Interface -*- tablegen -==// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines the operations of the Shape Inference Op Interface. // diff --git a/mlir/examples/toy/Ch5/mlir/DeadFunctionEliminationPass.cpp b/mlir/examples/toy/Ch5/mlir/DeadFunctionEliminationPass.cpp index b58adb5d52f..1ee34547860 100644 --- a/mlir/examples/toy/Ch5/mlir/DeadFunctionEliminationPass.cpp +++ b/mlir/examples/toy/Ch5/mlir/DeadFunctionEliminationPass.cpp @@ -1,19 +1,10 @@ //===- DeadFunctionEliminationPass.cpp - Eliminate inlined functions ------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a Module level pass performing dead function // elimination. This is required as a post-processing step after function diff --git a/mlir/examples/toy/Ch5/mlir/Dialect.cpp b/mlir/examples/toy/Ch5/mlir/Dialect.cpp index 8be1094cf15..50116b14bea 100644 --- a/mlir/examples/toy/Ch5/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch5/mlir/Dialect.cpp @@ -1,19 +1,10 @@ //===- Dialect.cpp - Toy IR Dialect registration in MLIR ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the dialect for the Toy IR: custom type parsing and // operation verification. diff --git a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp index 3fa761c7404..cba838a2928 100644 --- a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp @@ -1,19 +1,10 @@ //====- LowerToAffineLoops.cpp - Partial lowering from Toy to Affine+Std --===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a partial lowering of Toy operations to a combination of // affine loops and standard operations. This lowering expects that all calls diff --git a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp index 902c634a954..e9987ff2c77 100644 --- a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp @@ -1,19 +1,10 @@ //===- MLIRGen.cpp - MLIR Generation from a Toy AST -----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple IR generation targeting MLIR from a Module AST // for the Toy language. diff --git a/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp index 1f572015c39..517a1f07530 100644 --- a/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch5/mlir/ShapeInferencePass.cpp @@ -1,19 +1,10 @@ //===- ShapeInferencePass.cpp - Shape Inference ---------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a Function level pass performing interprocedural // propagation of array shapes through function specialization. diff --git a/mlir/examples/toy/Ch5/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch5/mlir/ToyCombine.cpp index 604e9fa6c83..2cbf8bdac9b 100644 --- a/mlir/examples/toy/Ch5/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch5/mlir/ToyCombine.cpp @@ -1,19 +1,10 @@ //===- ToyCombine.cpp - Toy High Level Optimizer --------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a set of simple combiners for optimizing operations in // the Toy dialect. diff --git a/mlir/examples/toy/Ch5/mlir/ToyCombine.td b/mlir/examples/toy/Ch5/mlir/ToyCombine.td index 1ca143a913c..e6e33e84d7e 100644 --- a/mlir/examples/toy/Ch5/mlir/ToyCombine.td +++ b/mlir/examples/toy/Ch5/mlir/ToyCombine.td @@ -1,19 +1,10 @@ //===- ToyCombine.td - Pattern Match Optimizations for Toy -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines language-specific pattern match optimizations for Toy using // Declarative Rewrite Rules (DRR) specified using TableGen records. diff --git a/mlir/examples/toy/Ch5/parser/AST.cpp b/mlir/examples/toy/Ch5/parser/AST.cpp index 3ec91a4300d..0d6d9359529 100644 --- a/mlir/examples/toy/Ch5/parser/AST.cpp +++ b/mlir/examples/toy/Ch5/parser/AST.cpp @@ -1,19 +1,10 @@ //===- AST.cpp - Helper for printing out the Toy AST ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST dump for the Toy language. // diff --git a/mlir/examples/toy/Ch5/toyc.cpp b/mlir/examples/toy/Ch5/toyc.cpp index e1ab8c0ce55..836968e2188 100644 --- a/mlir/examples/toy/Ch5/toyc.cpp +++ b/mlir/examples/toy/Ch5/toyc.cpp @@ -1,19 +1,10 @@ //===- toyc.cpp - The Toy Compiler ----------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the entry point for the Toy compiler. // diff --git a/mlir/examples/toy/Ch6/include/toy/AST.h b/mlir/examples/toy/Ch6/include/toy/AST.h index 901164b0f39..820600b5b1c 100644 --- a/mlir/examples/toy/Ch6/include/toy/AST.h +++ b/mlir/examples/toy/Ch6/include/toy/AST.h @@ -1,19 +1,10 @@ //===- AST.h - Node definition for the Toy AST ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST for the Toy language. It is optimized for // simplicity, not efficiency. The AST forms a tree structure where each node diff --git a/mlir/examples/toy/Ch6/include/toy/Dialect.h b/mlir/examples/toy/Ch6/include/toy/Dialect.h index 556ae972b84..5e8b91dcf48 100644 --- a/mlir/examples/toy/Ch6/include/toy/Dialect.h +++ b/mlir/examples/toy/Ch6/include/toy/Dialect.h @@ -1,19 +1,10 @@ //===- Dialect.h - Dialect definition for the Toy IR ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the IR Dialect for the Toy language. // See g3doc/Tutorials/Toy/Ch-2.md for more information. diff --git a/mlir/examples/toy/Ch6/include/toy/Lexer.h b/mlir/examples/toy/Ch6/include/toy/Lexer.h index 144388c460c..6eff64ee5f0 100644 --- a/mlir/examples/toy/Ch6/include/toy/Lexer.h +++ b/mlir/examples/toy/Ch6/include/toy/Lexer.h @@ -1,19 +1,10 @@ //===- Lexer.h - Lexer for the Toy language -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple Lexer for the Toy language. // diff --git a/mlir/examples/toy/Ch6/include/toy/MLIRGen.h b/mlir/examples/toy/Ch6/include/toy/MLIRGen.h index 287f432c847..e1c8ca1201d 100644 --- a/mlir/examples/toy/Ch6/include/toy/MLIRGen.h +++ b/mlir/examples/toy/Ch6/include/toy/MLIRGen.h @@ -1,19 +1,10 @@ //===- MLIRGen.h - MLIR Generation from a Toy AST -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares a simple interface to perform IR generation targeting MLIR // from a Module AST for the Toy language. diff --git a/mlir/examples/toy/Ch6/include/toy/Ops.td b/mlir/examples/toy/Ch6/include/toy/Ops.td index b3bda1d647b..bb98ae19a09 100644 --- a/mlir/examples/toy/Ch6/include/toy/Ops.td +++ b/mlir/examples/toy/Ch6/include/toy/Ops.td @@ -1,19 +1,10 @@ //===- Ops.td - Toy dialect operation definitions ----------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines the operations of the Toy dialect. // diff --git a/mlir/examples/toy/Ch6/include/toy/Parser.h b/mlir/examples/toy/Ch6/include/toy/Parser.h index 9e219e56551..4557ea26859 100644 --- a/mlir/examples/toy/Ch6/include/toy/Parser.h +++ b/mlir/examples/toy/Ch6/include/toy/Parser.h @@ -1,19 +1,10 @@ //===- Parser.h - Toy Language Parser -------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the parser for the Toy language. It processes the Token // provided by the Lexer and returns an AST. diff --git a/mlir/examples/toy/Ch6/include/toy/Passes.h b/mlir/examples/toy/Ch6/include/toy/Passes.h index 00fe4ffe49b..33c2021c8db 100644 --- a/mlir/examples/toy/Ch6/include/toy/Passes.h +++ b/mlir/examples/toy/Ch6/include/toy/Passes.h @@ -1,19 +1,10 @@ //===- Passes.h - Toy Passes Definition -----------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file exposes the entry points to create compiler passes for Toy. // diff --git a/mlir/examples/toy/Ch6/include/toy/ShapeInferenceInterface.h b/mlir/examples/toy/Ch6/include/toy/ShapeInferenceInterface.h index fc36b5b100d..da0fb66018e 100644 --- a/mlir/examples/toy/Ch6/include/toy/ShapeInferenceInterface.h +++ b/mlir/examples/toy/Ch6/include/toy/ShapeInferenceInterface.h @@ -1,19 +1,10 @@ //===- ShapeInferenceInterface.h - Interface definitions for ShapeInference -=// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains the declarations of the shape inference interfaces defined // in ShapeInferenceInterface.td. diff --git a/mlir/examples/toy/Ch6/include/toy/ShapeInferenceInterface.td b/mlir/examples/toy/Ch6/include/toy/ShapeInferenceInterface.td index 6974575a63c..1b38ada1622 100644 --- a/mlir/examples/toy/Ch6/include/toy/ShapeInferenceInterface.td +++ b/mlir/examples/toy/Ch6/include/toy/ShapeInferenceInterface.td @@ -1,19 +1,10 @@ //===- ShapeInferenceInterface.td - Shape Inference Interface -*- tablegen -==// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines the operations of the Shape Inference Op Interface. // diff --git a/mlir/examples/toy/Ch6/mlir/DeadFunctionEliminationPass.cpp b/mlir/examples/toy/Ch6/mlir/DeadFunctionEliminationPass.cpp index b58adb5d52f..1ee34547860 100644 --- a/mlir/examples/toy/Ch6/mlir/DeadFunctionEliminationPass.cpp +++ b/mlir/examples/toy/Ch6/mlir/DeadFunctionEliminationPass.cpp @@ -1,19 +1,10 @@ //===- DeadFunctionEliminationPass.cpp - Eliminate inlined functions ------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a Module level pass performing dead function // elimination. This is required as a post-processing step after function diff --git a/mlir/examples/toy/Ch6/mlir/Dialect.cpp b/mlir/examples/toy/Ch6/mlir/Dialect.cpp index 8be1094cf15..50116b14bea 100644 --- a/mlir/examples/toy/Ch6/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch6/mlir/Dialect.cpp @@ -1,19 +1,10 @@ //===- Dialect.cpp - Toy IR Dialect registration in MLIR ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the dialect for the Toy IR: custom type parsing and // operation verification. diff --git a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp index 3fa761c7404..cba838a2928 100644 --- a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp @@ -1,19 +1,10 @@ //====- LowerToAffineLoops.cpp - Partial lowering from Toy to Affine+Std --===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a partial lowering of Toy operations to a combination of // affine loops and standard operations. This lowering expects that all calls diff --git a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp index c3180b4a92d..377bc11dd27 100644 --- a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp @@ -1,19 +1,10 @@ //====- LowerToLLVM.cpp - Lowering from Toy+Affine+Std to LLVM ------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a partial lowering of Toy operations to a combination of // affine loops and standard operations. This lowering expects that all calls diff --git a/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp index 902c634a954..e9987ff2c77 100644 --- a/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp @@ -1,19 +1,10 @@ //===- MLIRGen.cpp - MLIR Generation from a Toy AST -----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple IR generation targeting MLIR from a Module AST // for the Toy language. diff --git a/mlir/examples/toy/Ch6/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch6/mlir/ShapeInferencePass.cpp index 1f572015c39..517a1f07530 100644 --- a/mlir/examples/toy/Ch6/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch6/mlir/ShapeInferencePass.cpp @@ -1,19 +1,10 @@ //===- ShapeInferencePass.cpp - Shape Inference ---------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a Function level pass performing interprocedural // propagation of array shapes through function specialization. diff --git a/mlir/examples/toy/Ch6/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch6/mlir/ToyCombine.cpp index 604e9fa6c83..2cbf8bdac9b 100644 --- a/mlir/examples/toy/Ch6/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch6/mlir/ToyCombine.cpp @@ -1,19 +1,10 @@ //===- ToyCombine.cpp - Toy High Level Optimizer --------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a set of simple combiners for optimizing operations in // the Toy dialect. diff --git a/mlir/examples/toy/Ch6/mlir/ToyCombine.td b/mlir/examples/toy/Ch6/mlir/ToyCombine.td index 1ca143a913c..e6e33e84d7e 100644 --- a/mlir/examples/toy/Ch6/mlir/ToyCombine.td +++ b/mlir/examples/toy/Ch6/mlir/ToyCombine.td @@ -1,19 +1,10 @@ //===- ToyCombine.td - Pattern Match Optimizations for Toy -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines language-specific pattern match optimizations for Toy using // Declarative Rewrite Rules (DRR) specified using TableGen records. diff --git a/mlir/examples/toy/Ch6/parser/AST.cpp b/mlir/examples/toy/Ch6/parser/AST.cpp index 3ec91a4300d..0d6d9359529 100644 --- a/mlir/examples/toy/Ch6/parser/AST.cpp +++ b/mlir/examples/toy/Ch6/parser/AST.cpp @@ -1,19 +1,10 @@ //===- AST.cpp - Helper for printing out the Toy AST ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST dump for the Toy language. // diff --git a/mlir/examples/toy/Ch6/toyc.cpp b/mlir/examples/toy/Ch6/toyc.cpp index 60e3d0f9791..4e5b2afb7c6 100644 --- a/mlir/examples/toy/Ch6/toyc.cpp +++ b/mlir/examples/toy/Ch6/toyc.cpp @@ -1,19 +1,10 @@ //===- toyc.cpp - The Toy Compiler ----------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the entry point for the Toy compiler. // diff --git a/mlir/examples/toy/Ch7/include/toy/AST.h b/mlir/examples/toy/Ch7/include/toy/AST.h index 558d9deab8e..3d3ae89dbeb 100644 --- a/mlir/examples/toy/Ch7/include/toy/AST.h +++ b/mlir/examples/toy/Ch7/include/toy/AST.h @@ -1,19 +1,10 @@ //===- AST.h - Node definition for the Toy AST ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST for the Toy language. It is optimized for // simplicity, not efficiency. The AST forms a tree structure where each node diff --git a/mlir/examples/toy/Ch7/include/toy/Dialect.h b/mlir/examples/toy/Ch7/include/toy/Dialect.h index b96ff99a5b6..77481b1884f 100644 --- a/mlir/examples/toy/Ch7/include/toy/Dialect.h +++ b/mlir/examples/toy/Ch7/include/toy/Dialect.h @@ -1,19 +1,10 @@ //===- Dialect.h - Dialect definition for the Toy IR ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the IR Dialect for the Toy language. // See g3doc/Tutorials/Toy/Ch-2.md for more information. diff --git a/mlir/examples/toy/Ch7/include/toy/Lexer.h b/mlir/examples/toy/Ch7/include/toy/Lexer.h index 89dc6cba9ff..b41b82f2a0a 100644 --- a/mlir/examples/toy/Ch7/include/toy/Lexer.h +++ b/mlir/examples/toy/Ch7/include/toy/Lexer.h @@ -1,19 +1,10 @@ //===- Lexer.h - Lexer for the Toy language -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple Lexer for the Toy language. // diff --git a/mlir/examples/toy/Ch7/include/toy/MLIRGen.h b/mlir/examples/toy/Ch7/include/toy/MLIRGen.h index 287f432c847..e1c8ca1201d 100644 --- a/mlir/examples/toy/Ch7/include/toy/MLIRGen.h +++ b/mlir/examples/toy/Ch7/include/toy/MLIRGen.h @@ -1,19 +1,10 @@ //===- MLIRGen.h - MLIR Generation from a Toy AST -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares a simple interface to perform IR generation targeting MLIR // from a Module AST for the Toy language. diff --git a/mlir/examples/toy/Ch7/include/toy/Ops.td b/mlir/examples/toy/Ch7/include/toy/Ops.td index 94f1bcf3e82..801aef06934 100644 --- a/mlir/examples/toy/Ch7/include/toy/Ops.td +++ b/mlir/examples/toy/Ch7/include/toy/Ops.td @@ -1,19 +1,10 @@ //===- Ops.td - Toy dialect operation definitions ----------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines the operations of the Toy dialect. // diff --git a/mlir/examples/toy/Ch7/include/toy/Parser.h b/mlir/examples/toy/Ch7/include/toy/Parser.h index df6c4fb2f60..d2659e04dac 100644 --- a/mlir/examples/toy/Ch7/include/toy/Parser.h +++ b/mlir/examples/toy/Ch7/include/toy/Parser.h @@ -1,19 +1,10 @@ //===- Parser.h - Toy Language Parser -------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the parser for the Toy language. It processes the Token // provided by the Lexer and returns an AST. diff --git a/mlir/examples/toy/Ch7/include/toy/Passes.h b/mlir/examples/toy/Ch7/include/toy/Passes.h index 00fe4ffe49b..33c2021c8db 100644 --- a/mlir/examples/toy/Ch7/include/toy/Passes.h +++ b/mlir/examples/toy/Ch7/include/toy/Passes.h @@ -1,19 +1,10 @@ //===- Passes.h - Toy Passes Definition -----------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file exposes the entry points to create compiler passes for Toy. // diff --git a/mlir/examples/toy/Ch7/include/toy/ShapeInferenceInterface.h b/mlir/examples/toy/Ch7/include/toy/ShapeInferenceInterface.h index fc36b5b100d..da0fb66018e 100644 --- a/mlir/examples/toy/Ch7/include/toy/ShapeInferenceInterface.h +++ b/mlir/examples/toy/Ch7/include/toy/ShapeInferenceInterface.h @@ -1,19 +1,10 @@ //===- ShapeInferenceInterface.h - Interface definitions for ShapeInference -=// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains the declarations of the shape inference interfaces defined // in ShapeInferenceInterface.td. diff --git a/mlir/examples/toy/Ch7/include/toy/ShapeInferenceInterface.td b/mlir/examples/toy/Ch7/include/toy/ShapeInferenceInterface.td index 6974575a63c..1b38ada1622 100644 --- a/mlir/examples/toy/Ch7/include/toy/ShapeInferenceInterface.td +++ b/mlir/examples/toy/Ch7/include/toy/ShapeInferenceInterface.td @@ -1,19 +1,10 @@ //===- ShapeInferenceInterface.td - Shape Inference Interface -*- tablegen -==// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines the operations of the Shape Inference Op Interface. // diff --git a/mlir/examples/toy/Ch7/mlir/DeadFunctionEliminationPass.cpp b/mlir/examples/toy/Ch7/mlir/DeadFunctionEliminationPass.cpp index b58adb5d52f..1ee34547860 100644 --- a/mlir/examples/toy/Ch7/mlir/DeadFunctionEliminationPass.cpp +++ b/mlir/examples/toy/Ch7/mlir/DeadFunctionEliminationPass.cpp @@ -1,19 +1,10 @@ //===- DeadFunctionEliminationPass.cpp - Eliminate inlined functions ------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a Module level pass performing dead function // elimination. This is required as a post-processing step after function diff --git a/mlir/examples/toy/Ch7/mlir/Dialect.cpp b/mlir/examples/toy/Ch7/mlir/Dialect.cpp index 0ce896db5de..4f4cbdf2f0f 100644 --- a/mlir/examples/toy/Ch7/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch7/mlir/Dialect.cpp @@ -1,19 +1,10 @@ //===- Dialect.cpp - Toy IR Dialect registration in MLIR ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the dialect for the Toy IR: custom type parsing and // operation verification. diff --git a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp index 3fa761c7404..cba838a2928 100644 --- a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp @@ -1,19 +1,10 @@ //====- LowerToAffineLoops.cpp - Partial lowering from Toy to Affine+Std --===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a partial lowering of Toy operations to a combination of // affine loops and standard operations. This lowering expects that all calls diff --git a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp index c3180b4a92d..377bc11dd27 100644 --- a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp @@ -1,19 +1,10 @@ //====- LowerToLLVM.cpp - Lowering from Toy+Affine+Std to LLVM ------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a partial lowering of Toy operations to a combination of // affine loops and standard operations. This lowering expects that all calls diff --git a/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp index 590b21e53a1..62e8c553709 100644 --- a/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp @@ -1,19 +1,10 @@ //===- MLIRGen.cpp - MLIR Generation from a Toy AST -----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple IR generation targeting MLIR from a Module AST // for the Toy language. diff --git a/mlir/examples/toy/Ch7/mlir/ShapeInferencePass.cpp b/mlir/examples/toy/Ch7/mlir/ShapeInferencePass.cpp index 1f572015c39..517a1f07530 100644 --- a/mlir/examples/toy/Ch7/mlir/ShapeInferencePass.cpp +++ b/mlir/examples/toy/Ch7/mlir/ShapeInferencePass.cpp @@ -1,19 +1,10 @@ //===- ShapeInferencePass.cpp - Shape Inference ---------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a Function level pass performing interprocedural // propagation of array shapes through function specialization. diff --git a/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp index d18396c63bb..2fb0a1c5b69 100644 --- a/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp @@ -1,19 +1,10 @@ //===- ToyCombine.cpp - Toy High Level Optimizer --------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a set of simple combiners for optimizing operations in // the Toy dialect. diff --git a/mlir/examples/toy/Ch7/mlir/ToyCombine.td b/mlir/examples/toy/Ch7/mlir/ToyCombine.td index 1ca143a913c..e6e33e84d7e 100644 --- a/mlir/examples/toy/Ch7/mlir/ToyCombine.td +++ b/mlir/examples/toy/Ch7/mlir/ToyCombine.td @@ -1,19 +1,10 @@ //===- ToyCombine.td - Pattern Match Optimizations for Toy -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines language-specific pattern match optimizations for Toy using // Declarative Rewrite Rules (DRR) specified using TableGen records. diff --git a/mlir/examples/toy/Ch7/parser/AST.cpp b/mlir/examples/toy/Ch7/parser/AST.cpp index 391757f711f..669bc9dbec2 100644 --- a/mlir/examples/toy/Ch7/parser/AST.cpp +++ b/mlir/examples/toy/Ch7/parser/AST.cpp @@ -1,19 +1,10 @@ //===- AST.cpp - Helper for printing out the Toy AST ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the AST dump for the Toy language. // diff --git a/mlir/examples/toy/Ch7/toyc.cpp b/mlir/examples/toy/Ch7/toyc.cpp index ec5a4f8056b..c6afab594e1 100644 --- a/mlir/examples/toy/Ch7/toyc.cpp +++ b/mlir/examples/toy/Ch7/toyc.cpp @@ -1,19 +1,10 @@ //===- toyc.cpp - The Toy Compiler ----------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the entry point for the Toy compiler. // diff --git a/mlir/include/mlir-c/Core.h b/mlir/include/mlir-c/Core.h index c205e898901..5e3e2087f8b 100644 --- a/mlir/include/mlir-c/Core.h +++ b/mlir/include/mlir-c/Core.h @@ -1,18 +1,9 @@ /*===-- mlir-c/Core.h - Core Library C Interface ------------------*- C -*-===*\ |* *| -|* Copyright 2019 The MLIR Authors. *| -|* *| -|* Licensed under the Apache License, Version 2.0 (the "License"); *| -|* you may not use this file except in compliance with the License. *| -|* You may obtain a copy of the License at *| -|* *| -|* http://www.apache.org/licenses/LICENSE-2.0 *| -|* *| -|* Unless required by applicable law or agreed to in writing, software *| -|* distributed under the License is distributed on an "AS IS" BASIS, *| -|* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *| -|* See the License for the specific language governing permissions and *| -|* limitations under the License. *| +|* Part of the MLIR 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 *| |* *| |*===----------------------------------------------------------------------===*| |* *| diff --git a/mlir/include/mlir/ADT/TypeSwitch.h b/mlir/include/mlir/ADT/TypeSwitch.h index 75051b6a539..2dbc611f557 100644 --- a/mlir/include/mlir/ADT/TypeSwitch.h +++ b/mlir/include/mlir/ADT/TypeSwitch.h @@ -1,19 +1,10 @@ //===- TypeSwitch.h - Switch functionality for RTTI casting -*- C++ -*-----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the TypeSwitch template, which mimics a switch() // statement whose cases are type names. diff --git a/mlir/include/mlir/Analysis/AffineAnalysis.h b/mlir/include/mlir/Analysis/AffineAnalysis.h index f506470f36a..5d9422883c1 100644 --- a/mlir/include/mlir/Analysis/AffineAnalysis.h +++ b/mlir/include/mlir/Analysis/AffineAnalysis.h @@ -1,19 +1,10 @@ //===- AffineAnalysis.h - analyses for affine structures --------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file defines prototypes for methods that perform analysis // involving affine structures (AffineExprStorage, AffineMap, IntegerSet, etc.) diff --git a/mlir/include/mlir/Analysis/AffineStructures.h b/mlir/include/mlir/Analysis/AffineStructures.h index 65cf13a0ce6..770bf686f50 100644 --- a/mlir/include/mlir/Analysis/AffineStructures.h +++ b/mlir/include/mlir/Analysis/AffineStructures.h @@ -1,19 +1,10 @@ //===- AffineStructures.h - MLIR Affine Structures Class --------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Structures for affine/polyhedral analysis of ML functions. // diff --git a/mlir/include/mlir/Analysis/CallGraph.h b/mlir/include/mlir/Analysis/CallGraph.h index 700a016e836..8f954161921 100644 --- a/mlir/include/mlir/Analysis/CallGraph.h +++ b/mlir/include/mlir/Analysis/CallGraph.h @@ -1,19 +1,10 @@ //===- CallGraph.h - CallGraph analysis for MLIR ----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains an analysis for computing the multi-level callgraph from a // given top-level operation. This nodes within this callgraph are defined by diff --git a/mlir/include/mlir/Analysis/CallInterfaces.h b/mlir/include/mlir/Analysis/CallInterfaces.h index a18cfa7aba4..a9806bfb8c6 100644 --- a/mlir/include/mlir/Analysis/CallInterfaces.h +++ b/mlir/include/mlir/Analysis/CallInterfaces.h @@ -1,19 +1,10 @@ //===- CallInterfaces.h - Call Interfaces for MLIR --------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains the definitions of the call interfaces defined in // `CallInterfaces.td`. diff --git a/mlir/include/mlir/Analysis/CallInterfaces.td b/mlir/include/mlir/Analysis/CallInterfaces.td index 043f009a8e2..3e5b599baf8 100644 --- a/mlir/include/mlir/Analysis/CallInterfaces.td +++ b/mlir/include/mlir/Analysis/CallInterfaces.td @@ -1,19 +1,10 @@ //===- CallInterfaces.td - Call Interfaces for ops -*- tablegen ---------*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains a set of interfaces that can be used to define information // related to call-like and callable operations. Each of which are defined along diff --git a/mlir/include/mlir/Analysis/Dominance.h b/mlir/include/mlir/Analysis/Dominance.h index f46241e2af0..5c42dbe12c2 100644 --- a/mlir/include/mlir/Analysis/Dominance.h +++ b/mlir/include/mlir/Analysis/Dominance.h @@ -1,19 +1,10 @@ //===- Dominance.h - Dominator analysis for CFGs ----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_ANALYSIS_DOMINANCE_H #define MLIR_ANALYSIS_DOMINANCE_H diff --git a/mlir/include/mlir/Analysis/InferTypeOpInterface.h b/mlir/include/mlir/Analysis/InferTypeOpInterface.h index 2d68ada0d13..baf16162a0b 100644 --- a/mlir/include/mlir/Analysis/InferTypeOpInterface.h +++ b/mlir/include/mlir/Analysis/InferTypeOpInterface.h @@ -1,19 +1,10 @@ //===- InferTypeOpInterface.h - Infer Type Interfaces -----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains the definitions of the infer op interfaces defined in // `InferTypeOpInterface.td`. diff --git a/mlir/include/mlir/Analysis/InferTypeOpInterface.td b/mlir/include/mlir/Analysis/InferTypeOpInterface.td index 14d580962e1..bbcea6be7eb 100644 --- a/mlir/include/mlir/Analysis/InferTypeOpInterface.td +++ b/mlir/include/mlir/Analysis/InferTypeOpInterface.td @@ -1,19 +1,10 @@ //===- InferTypeOpInterface.td - Infer Type interfaces -----*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains a set of interfaces that can be used to define information // related to type inference. diff --git a/mlir/include/mlir/Analysis/Liveness.h b/mlir/include/mlir/Analysis/Liveness.h index 0aa9d9693e4..791c164c7d2 100644 --- a/mlir/include/mlir/Analysis/Liveness.h +++ b/mlir/include/mlir/Analysis/Liveness.h @@ -1,19 +1,10 @@ //===- Liveness.h - Liveness analysis for MLIR ------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains an analysis for computing liveness information from a // given top-level operation. The current version of the analysis uses a diff --git a/mlir/include/mlir/Analysis/LoopAnalysis.h b/mlir/include/mlir/Analysis/LoopAnalysis.h index ad7dc6d6092..66f0033bf2f 100644 --- a/mlir/include/mlir/Analysis/LoopAnalysis.h +++ b/mlir/include/mlir/Analysis/LoopAnalysis.h @@ -1,19 +1,10 @@ //===- LoopAnalysis.h - loop analysis methods -------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file defines prototypes for methods to analyze loops. // diff --git a/mlir/include/mlir/Analysis/NestedMatcher.h b/mlir/include/mlir/Analysis/NestedMatcher.h index 9af26e8842a..2da64e88e14 100644 --- a/mlir/include/mlir/Analysis/NestedMatcher.h +++ b/mlir/include/mlir/Analysis/NestedMatcher.h @@ -1,19 +1,10 @@ //===- NestedMacher.h - Nested matcher for Function -------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_ANALYSIS_MLFUNCTIONMATCHER_H_ #define MLIR_ANALYSIS_MLFUNCTIONMATCHER_H_ diff --git a/mlir/include/mlir/Analysis/Passes.h b/mlir/include/mlir/Analysis/Passes.h index b233ab5f209..0bbc850e6c9 100644 --- a/mlir/include/mlir/Analysis/Passes.h +++ b/mlir/include/mlir/Analysis/Passes.h @@ -1,19 +1,10 @@ //===- Passes.h - Pass Entrypoints ------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file defines prototypes that expose pass constructors in the // analysis library. diff --git a/mlir/include/mlir/Analysis/SliceAnalysis.h b/mlir/include/mlir/Analysis/SliceAnalysis.h index ad6b65387be..d7b6e957014 100644 --- a/mlir/include/mlir/Analysis/SliceAnalysis.h +++ b/mlir/include/mlir/Analysis/SliceAnalysis.h @@ -1,19 +1,10 @@ //===- SliceAnalysis.h - Analysis for Transitive UseDef chains --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_ANALYSIS_SLICEANALYSIS_H_ #define MLIR_ANALYSIS_SLICEANALYSIS_H_ diff --git a/mlir/include/mlir/Analysis/Utils.h b/mlir/include/mlir/Analysis/Utils.h index ea0987df3fe..d06e003faae 100644 --- a/mlir/include/mlir/Analysis/Utils.h +++ b/mlir/include/mlir/Analysis/Utils.h @@ -1,19 +1,10 @@ //===- Utils.h - General analysis utilities ---------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file defines prototypes for various transformation utilities for // memref's and non-loop IR structures. These are not passes by themselves but diff --git a/mlir/include/mlir/Analysis/Verifier.h b/mlir/include/mlir/Analysis/Verifier.h index daaff57683e..b7075b4f157 100644 --- a/mlir/include/mlir/Analysis/Verifier.h +++ b/mlir/include/mlir/Analysis/Verifier.h @@ -1,19 +1,10 @@ //===- Verifier.h - Verifier analysis for MLIR structures -------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_ANALYSIS_VERIFIER_H #define MLIR_ANALYSIS_VERIFIER_H diff --git a/mlir/include/mlir/Conversion/AffineToStandard/AffineToStandard.h b/mlir/include/mlir/Conversion/AffineToStandard/AffineToStandard.h index 4bbe6610e31..8e873bfb1c3 100644 --- a/mlir/include/mlir/Conversion/AffineToStandard/AffineToStandard.h +++ b/mlir/include/mlir/Conversion/AffineToStandard/AffineToStandard.h @@ -1,19 +1,10 @@ //===- AffineToStandard.h - Convert Affine to Standard dialect --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_AFFINETOSTANDARD_AFFINETOSTANDARD_H #define MLIR_CONVERSION_AFFINETOSTANDARD_AFFINETOSTANDARD_H diff --git a/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h b/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h index 6b9b08ed7d5..4eb6379adf6 100644 --- a/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h +++ b/mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h @@ -1,19 +1,10 @@ //===- GPUToCUDAPass.h - MLIR CUDA runtime support --------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_GPUTOCUDA_GPUTOCUDAPASS_H_ #define MLIR_CONVERSION_GPUTOCUDA_GPUTOCUDAPASS_H_ diff --git a/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h b/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h index 635d4366e83..75e4f7e374c 100644 --- a/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h +++ b/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h @@ -1,19 +1,10 @@ //===- GPUToNVVMPass.h - Convert GPU kernel to NVVM dialect -----*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_GPUTONVVM_GPUTONVVMPASS_H_ #define MLIR_CONVERSION_GPUTONVVM_GPUTONVVMPASS_H_ diff --git a/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h b/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h index 54cda41afa1..e913c2e1131 100644 --- a/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h +++ b/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h @@ -1,19 +1,10 @@ //===- GPUToROCDLPass.h - Convert GPU kernel to ROCDL dialect ---*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_GPUTOROCDL_GPUTOROCDLPASS_H_ #define MLIR_CONVERSION_GPUTOROCDL_GPUTOROCDLPASS_H_ diff --git a/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.h b/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.h index 134dbf40b4d..762a6e502d4 100644 --- a/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.h +++ b/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.h @@ -1,19 +1,10 @@ //===- ConvertGPUToSPIRV.h - GPU Ops to SPIR-V dialect patterns ----C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Provides patterns for lowering GPU Ops to SPIR-V dialect. // diff --git a/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.h b/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.h index 8f0a910c74d..37230f4c0e1 100644 --- a/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.h +++ b/mlir/include/mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.h @@ -1,19 +1,10 @@ //===- ConvertGPUToSPIRVPass.h - GPU to SPIR-V conversion pass --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Provides a pass to convert GPU ops to SPIRV ops. // diff --git a/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h b/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h index 6bae08e13be..27950177c1d 100644 --- a/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h +++ b/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h @@ -1,19 +1,10 @@ //===- LinalgToLLVM.h - Utils to convert from the linalg dialect ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_LINALGTOLLVM_LINALGTOLLVM_H_ #define MLIR_CONVERSION_LINALGTOLLVM_LINALGTOLLVM_H_ diff --git a/mlir/include/mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h b/mlir/include/mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h index 095c9f470b3..5cb8f59e6f7 100644 --- a/mlir/include/mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h +++ b/mlir/include/mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h @@ -1,19 +1,10 @@ //===- ConvertLoopToStandard.h - Pass entrypoint ----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_LOOPTOSTANDARD_CONVERTLOOPTOSTANDARD_H_ #define MLIR_CONVERSION_LOOPTOSTANDARD_CONVERTLOOPTOSTANDARD_H_ diff --git a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPU.h b/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPU.h index 58d49a13391..5f3ea87f3cc 100644 --- a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPU.h +++ b/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPU.h @@ -1,19 +1,10 @@ //===- LoopsToGPU.h - Convert loop nests to GPU kernels ---------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_LOOPSTOGPU_LOOPSTOGPU_H_ #define MLIR_CONVERSION_LOOPSTOGPU_LOOPSTOGPU_H_ diff --git a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h b/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h index a42320c9bdf..a3d663ae3d7 100644 --- a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h +++ b/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h @@ -1,19 +1,10 @@ //===- LoopsToGPUPass.h - Pass converting loops to GPU kernels --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_LOOPSTOGPU_LOOPSTOGPUPASS_H_ #define MLIR_CONVERSION_LOOPSTOGPU_LOOPSTOGPUPASS_H_ diff --git a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h index 6f41fb68633..5c8a8e6e494 100644 --- a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h +++ b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h @@ -1,19 +1,10 @@ //===- ConvertStandardToLLVM.h - Convert to the LLVM dialect ----*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Provides a dialect conversion targeting the LLVM IR dialect. By default, it // converts Standard ops and types and provides hooks for dialect-specific diff --git a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h index d49c1c22530..a4d95da6a75 100644 --- a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h +++ b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h @@ -1,19 +1,10 @@ //===- ConvertStandardToLLVMPass.h - Pass entrypoint ------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_STANDARDTOLLVM_CONVERTSTANDARDTOLLVMPASS_H_ #define MLIR_CONVERSION_STANDARDTOLLVM_CONVERTSTANDARDTOLLVMPASS_H_ diff --git a/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h b/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h index 4caa6d9de77..e0e874027bf 100644 --- a/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h +++ b/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h @@ -1,19 +1,10 @@ //===- ConvertStandardToSPIRV.h - Convert to SPIR-V dialect -----*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Provides patterns to lower StandardOps to SPIR-V dialect. // diff --git a/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h b/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h index e8a71feb8b2..7dbaf1c0418 100644 --- a/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h +++ b/mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h @@ -1,19 +1,10 @@ //===- ConvertStandardToSPIRVPass.h - StdOps to SPIR-V pass -----*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Provides a pass to lower from StandardOps to SPIR-V dialect. // diff --git a/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h b/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h index a87e1c658a6..b8b97c21a3e 100644 --- a/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h +++ b/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h @@ -1,19 +1,10 @@ //===- ConvertVectorToLLVM.h - Utils to convert from the vector dialect ---===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_VECTORTOLLVM_CONVERTVECTORTOLLVM_H_ #define MLIR_CONVERSION_VECTORTOLLVM_CONVERTVECTORTOLLVM_H_ diff --git a/mlir/include/mlir/Conversion/VectorToLoops/ConvertVectorToLoops.h b/mlir/include/mlir/Conversion/VectorToLoops/ConvertVectorToLoops.h index 198eaceda41..4f7d0843b73 100644 --- a/mlir/include/mlir/Conversion/VectorToLoops/ConvertVectorToLoops.h +++ b/mlir/include/mlir/Conversion/VectorToLoops/ConvertVectorToLoops.h @@ -1,19 +1,10 @@ //===- ConvertVectorToLoops.h - Utils to convert from the vector dialect --===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_VECTORTOLLVM_CONVERTVECTORTOLOOPS_H_ #define MLIR_CONVERSION_VECTORTOLLVM_CONVERTVECTORTOLOOPS_H_ diff --git a/mlir/include/mlir/Dialect/AffineOps/AffineOps.h b/mlir/include/mlir/Dialect/AffineOps/AffineOps.h index 764f439e020..09408d2efc8 100644 --- a/mlir/include/mlir/Dialect/AffineOps/AffineOps.h +++ b/mlir/include/mlir/Dialect/AffineOps/AffineOps.h @@ -1,19 +1,10 @@ //===- AffineOps.h - MLIR Affine Operations -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines convenience types for working with Affine operations // in the MLIR operation set. diff --git a/mlir/include/mlir/Dialect/AffineOps/AffineOps.td b/mlir/include/mlir/Dialect/AffineOps/AffineOps.td index befdc2f6237..715e3807a95 100644 --- a/mlir/include/mlir/Dialect/AffineOps/AffineOps.td +++ b/mlir/include/mlir/Dialect/AffineOps/AffineOps.td @@ -1,19 +1,10 @@ //===- AffineOps.td - Affine operation definitions ---------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines MLIR affine operations. // diff --git a/mlir/include/mlir/Dialect/AffineOps/AffineOpsBase.td b/mlir/include/mlir/Dialect/AffineOps/AffineOpsBase.td index 755f65c338e..6aee5f3cd4a 100644 --- a/mlir/include/mlir/Dialect/AffineOps/AffineOpsBase.td +++ b/mlir/include/mlir/Dialect/AffineOps/AffineOpsBase.td @@ -1,19 +1,10 @@ //===- AffineOpsBase.td - Affine operation definitions -----*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines base support for MLIR affine operations. // diff --git a/mlir/include/mlir/Dialect/CommonFolders.h b/mlir/include/mlir/Dialect/CommonFolders.h index 45552945f0d..d667de73d41 100644 --- a/mlir/include/mlir/Dialect/CommonFolders.h +++ b/mlir/include/mlir/Dialect/CommonFolders.h @@ -1,19 +1,10 @@ //===- CommonFolders.h - Common Operation Folders----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file declares various common operation folders. These folders // are intended to be used by dialects to support common folding behavior diff --git a/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.h b/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.h index 88a42344c3b..8c0e7aa1aad 100644 --- a/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.h +++ b/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.h @@ -1,19 +1,10 @@ //===- FxpMathOps.h - Fixed point ops ---------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_FXPMATHOPS_FXPMATHOPS_H_ #define MLIR_DIALECT_FXPMATHOPS_FXPMATHOPS_H_ diff --git a/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td b/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td index b1bfb2706cf..d527b759a10 100644 --- a/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td +++ b/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td @@ -1,19 +1,10 @@ //===- FxpMathOps.td - Fixed point ops --------------------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the operation definition file for fixed point ops (and real // equivalents). diff --git a/mlir/include/mlir/Dialect/FxpMathOps/Passes.h b/mlir/include/mlir/Dialect/FxpMathOps/Passes.h index 415b1c0b253..aec21c4c186 100644 --- a/mlir/include/mlir/Dialect/FxpMathOps/Passes.h +++ b/mlir/include/mlir/Dialect/FxpMathOps/Passes.h @@ -1,19 +1,10 @@ //===- Passes.h - Fixed point math passes -----------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines all of the passes owned by the FxpMathOps dialect. // diff --git a/mlir/include/mlir/Dialect/GPU/GPUDialect.h b/mlir/include/mlir/Dialect/GPU/GPUDialect.h index 12c2aa1bbd1..c3ab6ec5729 100644 --- a/mlir/include/mlir/Dialect/GPU/GPUDialect.h +++ b/mlir/include/mlir/Dialect/GPU/GPUDialect.h @@ -1,19 +1,10 @@ //===- GPUDialect.h - MLIR Dialect for GPU Kernels --------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the GPU kernel-related operations and puts them in the // corresponding dialect. diff --git a/mlir/include/mlir/Dialect/GPU/GPUOps.td b/mlir/include/mlir/Dialect/GPU/GPUOps.td index def1ff2b8a1..037664d0d9b 100644 --- a/mlir/include/mlir/Dialect/GPU/GPUOps.td +++ b/mlir/include/mlir/Dialect/GPU/GPUOps.td @@ -1,19 +1,10 @@ //===-- GPUOps.td - GPU dialect operation definitions ------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines some operations of the GPU dialect. // diff --git a/mlir/include/mlir/Dialect/GPU/Passes.h b/mlir/include/mlir/Dialect/GPU/Passes.h index 7c8ce02db90..daf6d28d452 100644 --- a/mlir/include/mlir/Dialect/GPU/Passes.h +++ b/mlir/include/mlir/Dialect/GPU/Passes.h @@ -1,19 +1,10 @@ //===- Passes.h - Pass Entrypoints ------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file defines prototypes that expose pass constructors. // diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h b/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h index a599d51b31f..bef1f2dbf20 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h @@ -1,19 +1,10 @@ //===- LLVMDialect.h - MLIR LLVM IR dialect ---------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the LLVM IR dialect in MLIR, containing LLVM operations and // LLVM type system. diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td index 6257b4a51d9..ed935d5b7f7 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td @@ -1,19 +1,10 @@ //===-- LLVMOpBase.td - LLVM IR dialect shared definitions -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains shared definitions for the LLVM IR dialect and its // subdialects. diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td index cfbbf7da65d..46f63206ef5 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -1,19 +1,10 @@ //===-- LLVMOps.td - LLVM IR dialect op definition file ----*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the LLVM IR operation definition file. // diff --git a/mlir/include/mlir/Dialect/LLVMIR/NVVMDialect.h b/mlir/include/mlir/Dialect/LLVMIR/NVVMDialect.h index 0328cf4ba94..afb6d4ab627 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/NVVMDialect.h +++ b/mlir/include/mlir/Dialect/LLVMIR/NVVMDialect.h @@ -1,19 +1,10 @@ //===- NVVMDialect.h - MLIR NVVM IR dialect ---------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the NVVM IR dialect in MLIR, containing NVVM operations and // NVVM specific extensions to the LLVM type system. diff --git a/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td index bc6887da8e4..f35b7798149 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td @@ -1,19 +1,10 @@ //===-- NVVMOps.td - NVVM IR dialect op definition file ----*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the NVVM IR operation definition file. // diff --git a/mlir/include/mlir/Dialect/LLVMIR/ROCDLDialect.h b/mlir/include/mlir/Dialect/LLVMIR/ROCDLDialect.h index a34c11223f3..dab32d30e8f 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/ROCDLDialect.h +++ b/mlir/include/mlir/Dialect/LLVMIR/ROCDLDialect.h @@ -1,19 +1,10 @@ //===- ROCDLDialect.h - MLIR ROCDL IR dialect -------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the ROCDL dialect in MLIR, containing ROCDL operations // and ROCDL specific extensions to the LLVM type system. diff --git a/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td b/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td index 79d4136d6f5..697ff9740a8 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td @@ -1,19 +1,10 @@ //===-- ROCDLOps.td - ROCDL IR dialect op definition file --*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the ROCDL IR operation definition file. // diff --git a/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h b/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h index 426708b14a8..1a2d6b9b3ba 100644 --- a/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h +++ b/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h @@ -1,19 +1,10 @@ //===- DependenceAnalysis.h - Dependence analysis on SSA views --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_LINALG_ANALYSIS_DEPENDENCEANALYSIS_H_ #define MLIR_DIALECT_LINALG_ANALYSIS_DEPENDENCEANALYSIS_H_ diff --git a/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h b/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h index 8375e750a5c..d0f6c942b95 100644 --- a/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h +++ b/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h @@ -1,19 +1,10 @@ //===- Builders.h - MLIR Declarative Linalg Builders ------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Provides intuitive composable interfaces for building structured MLIR // snippets in a declarative fashion. diff --git a/mlir/include/mlir/Dialect/Linalg/EDSC/Intrinsics.h b/mlir/include/mlir/Dialect/Linalg/EDSC/Intrinsics.h index f1acab69a4d..b04c11f22bb 100644 --- a/mlir/include/mlir/Dialect/Linalg/EDSC/Intrinsics.h +++ b/mlir/include/mlir/Dialect/Linalg/EDSC/Intrinsics.h @@ -1,19 +1,10 @@ //===- Intrinsics.h - MLIR EDSC Intrinsics for Linalg -----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_LINALG_EDSC_INTRINSICS_H_ #define MLIR_DIALECT_LINALG_EDSC_INTRINSICS_H_ diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgBase.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgBase.td index 4e77b0ac0a8..c1adc8b4d05 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgBase.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgBase.td @@ -1,19 +1,10 @@ //===- LinalgBase.td - Linalg dialect base support ---------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the definition file for base linear algebra support. // diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgDoc.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgDoc.td index a3163f50476..819d02d396d 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgDoc.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgDoc.td @@ -1,19 +1,10 @@ //===- LinalgDoc.td - Linalg documentation -----------------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This documentation files exists to circumvent limitations on mixing different // .td files in cases one does not want to have all ops belong to the same diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgLibraryOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgLibraryOps.td index 18ca31cc376..e52019d7992 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgLibraryOps.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgLibraryOps.td @@ -1,19 +1,10 @@ //===- LinalgLibraryOps.td - Linalg dialect library ops -*- tablegen ----*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the operation definition file for linear algebra operations that // correspond to underlying library calls (e.g. BLAS). diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.h b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.h index c5f1f01d0c7..3249edb48e0 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.h +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.h @@ -1,19 +1,10 @@ //===- LinalgOps.h - Linalg Operations --------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_LINALG_LINALGOPS_H_ #define MLIR_DIALECT_LINALG_LINALGOPS_H_ diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td index 5d402a9ded9..728fa619dbe 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td @@ -1,19 +1,10 @@ //===- LinalgOps.td - Linalg dialect ops -------------------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the operation definition file for linear algebra operations. // diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td index 774be6616cd..8674c277e4a 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td @@ -1,19 +1,10 @@ //===- LinalgStructuredOps.td - Linalg dialect library ops -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the operation definition file for structured operations on buffers // that correspond to underlying library calls (e.g. BLAS). diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h b/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h index d196e6ccf94..7399aad6663 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h @@ -1,19 +1,10 @@ //===- LinalgTraits.h - Linalg Traits ---------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_LINALG_LINALGTRAITS_H_ #define MLIR_DIALECT_LINALG_LINALGTRAITS_H_ diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgTypes.h b/mlir/include/mlir/Dialect/Linalg/IR/LinalgTypes.h index f779c3de6ae..abeda3e0552 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgTypes.h +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgTypes.h @@ -1,19 +1,10 @@ //===- LinalgTypes.h - Linalg Types ---------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_LINALG_LINALGTYPES_H_ #define MLIR_DIALECT_LINALG_LINALGTYPES_H_ diff --git a/mlir/include/mlir/Dialect/Linalg/Passes.h b/mlir/include/mlir/Dialect/Linalg/Passes.h index 7ae3877f01e..86cf6fdd027 100644 --- a/mlir/include/mlir/Dialect/Linalg/Passes.h +++ b/mlir/include/mlir/Dialect/Linalg/Passes.h @@ -1,19 +1,10 @@ //===- Passes.h - Linalg pass entry points ----------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file defines prototypes that expose pass constructors. // diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransformPatterns.td b/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransformPatterns.td index dbc162f4132..448ffdf7d4b 100644 --- a/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransformPatterns.td +++ b/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransformPatterns.td @@ -1,19 +1,10 @@ //===- LinalgPatterns.td - Linalg transformation patterns --*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the pattern definition file for declarative Linalg transformation. // diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransforms.h b/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransforms.h index a1a7458ae7f..a88dc4105e2 100644 --- a/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransforms.h +++ b/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransforms.h @@ -1,19 +1,10 @@ //===- LinalgTransforms.h - Linalg transformations as patterns --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef DIALECT_LINALG_TRANSFORMS_LINALGTRANSFORMS_H_ #define DIALECT_LINALG_TRANSFORMS_LINALGTRANSFORMS_H_ diff --git a/mlir/include/mlir/Dialect/Linalg/Utils/Intrinsics.h b/mlir/include/mlir/Dialect/Linalg/Utils/Intrinsics.h index 5a815ba158e..778d853aeef 100644 --- a/mlir/include/mlir/Dialect/Linalg/Utils/Intrinsics.h +++ b/mlir/include/mlir/Dialect/Linalg/Utils/Intrinsics.h @@ -1,19 +1,10 @@ //===- Intrinsics.h - Linalg intrinsics definitions -----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_LINALG_INTRINSICS_H_ #define MLIR_DIALECT_LINALG_INTRINSICS_H_ diff --git a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h index 50039dd9336..1b45179bc9e 100644 --- a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h +++ b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h @@ -1,19 +1,10 @@ //===- Utils.h - Utilities to support the Linalg dialect --------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_LINALG_UTILS_H_ #define MLIR_DIALECT_LINALG_UTILS_H_ diff --git a/mlir/include/mlir/Dialect/LoopOps/LoopOps.h b/mlir/include/mlir/Dialect/LoopOps/LoopOps.h index e7ff6f84977..dba5e819986 100644 --- a/mlir/include/mlir/Dialect/LoopOps/LoopOps.h +++ b/mlir/include/mlir/Dialect/LoopOps/LoopOps.h @@ -1,19 +1,10 @@ //===- Ops.h - Loop MLIR Operations -----------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines convenience types for working with loop operations. // diff --git a/mlir/include/mlir/Dialect/LoopOps/LoopOps.td b/mlir/include/mlir/Dialect/LoopOps/LoopOps.td index e0f5b896309..3b0f120441a 100644 --- a/mlir/include/mlir/Dialect/LoopOps/LoopOps.td +++ b/mlir/include/mlir/Dialect/LoopOps/LoopOps.td @@ -1,19 +1,10 @@ //===- Ops.td - Loop operation definitions ---------------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines MLIR loop operations. // diff --git a/mlir/include/mlir/Dialect/QuantOps/FakeQuantSupport.h b/mlir/include/mlir/Dialect/QuantOps/FakeQuantSupport.h index 23e2967bd77..1a141e3b1b3 100644 --- a/mlir/include/mlir/Dialect/QuantOps/FakeQuantSupport.h +++ b/mlir/include/mlir/Dialect/QuantOps/FakeQuantSupport.h @@ -1,19 +1,10 @@ //===- FakeQuantSupport.h - Support utilities for FakeQuant ops -*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines support utilities for interoperating with FakeQuant* based // QAT (Quantized Aware Training) computations, as implemented by TFLite. Note diff --git a/mlir/include/mlir/Dialect/QuantOps/Passes.h b/mlir/include/mlir/Dialect/QuantOps/Passes.h index c57d7bf41fe..d3109775db2 100644 --- a/mlir/include/mlir/Dialect/QuantOps/Passes.h +++ b/mlir/include/mlir/Dialect/QuantOps/Passes.h @@ -1,19 +1,10 @@ //===- Passes.h - Quantization Passes ------ --------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines all of the passes owned by the quantization dialect. As // things mature, it is expected that passes specific to certain frontend or diff --git a/mlir/include/mlir/Dialect/QuantOps/QuantOps.h b/mlir/include/mlir/Dialect/QuantOps/QuantOps.h index 020d34918d4..9a4eec67c74 100644 --- a/mlir/include/mlir/Dialect/QuantOps/QuantOps.h +++ b/mlir/include/mlir/Dialect/QuantOps/QuantOps.h @@ -1,19 +1,10 @@ //===- QuantOps.h - Quantization Ops and Types ------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_QUANTOPS_QUANTOPS_H_ #define MLIR_DIALECT_QUANTOPS_QUANTOPS_H_ diff --git a/mlir/include/mlir/Dialect/QuantOps/QuantOps.td b/mlir/include/mlir/Dialect/QuantOps/QuantOps.td index 072715d65aa..bbeb9419cc4 100644 --- a/mlir/include/mlir/Dialect/QuantOps/QuantOps.td +++ b/mlir/include/mlir/Dialect/QuantOps/QuantOps.td @@ -1,19 +1,10 @@ //===- QuantOps.td - Quantization operation definition -----*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the operation definition file for Quantization. // diff --git a/mlir/include/mlir/Dialect/QuantOps/QuantPredicates.td b/mlir/include/mlir/Dialect/QuantOps/QuantPredicates.td index 2fbb7995dd4..7225dcc72db 100644 --- a/mlir/include/mlir/Dialect/QuantOps/QuantPredicates.td +++ b/mlir/include/mlir/Dialect/QuantOps/QuantPredicates.td @@ -1,19 +1,10 @@ //===- QuantPredicates.td - Predicates for dialect types ---*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Predicates for types in the Quantization dialect. // diff --git a/mlir/include/mlir/Dialect/QuantOps/QuantTypes.h b/mlir/include/mlir/Dialect/QuantOps/QuantTypes.h index 55e921ff8fb..daeb0374460 100644 --- a/mlir/include/mlir/Dialect/QuantOps/QuantTypes.h +++ b/mlir/include/mlir/Dialect/QuantOps/QuantTypes.h @@ -1,19 +1,10 @@ //===- QuantTypes.h - Quantization Ops and Types ----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_QUANTOPS_QUANT_TYPES_H_ #define MLIR_DIALECT_QUANTOPS_QUANT_TYPES_H_ diff --git a/mlir/include/mlir/Dialect/QuantOps/QuantizeUtils.h b/mlir/include/mlir/Dialect/QuantOps/QuantizeUtils.h index de87ca1e67c..c40b9e6f026 100644 --- a/mlir/include/mlir/Dialect/QuantOps/QuantizeUtils.h +++ b/mlir/include/mlir/Dialect/QuantOps/QuantizeUtils.h @@ -1,19 +1,10 @@ //===- QuantizeUtils.h - Support utilities for quantization -----*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_QUANTOPS_QUANTIZEUTILS_H_ #define MLIR_DIALECT_QUANTOPS_QUANTIZEUTILS_H_ diff --git a/mlir/include/mlir/Dialect/QuantOps/UniformSupport.h b/mlir/include/mlir/Dialect/QuantOps/UniformSupport.h index 0416db34e17..7c74fc56b8f 100644 --- a/mlir/include/mlir/Dialect/QuantOps/UniformSupport.h +++ b/mlir/include/mlir/Dialect/QuantOps/UniformSupport.h @@ -1,19 +1,10 @@ //===- UniformSupport.h - Support utilities for uniform quant ---*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_QUANTOPS_UNIFORMSUPPORT_H_ #define MLIR_DIALECT_QUANTOPS_UNIFORMSUPPORT_H_ diff --git a/mlir/include/mlir/Dialect/SDBM/SDBM.h b/mlir/include/mlir/Dialect/SDBM/SDBM.h index f95a51e407a..c8a0eec8ca8 100644 --- a/mlir/include/mlir/Dialect/SDBM/SDBM.h +++ b/mlir/include/mlir/Dialect/SDBM/SDBM.h @@ -1,19 +1,10 @@ //===- SDBM.h - MLIR SDBM declaration ---------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // A striped difference-bound matrix (SDBM) is a set in Z^N (or R^N) defined // as {(x_1, ... x_n) | f(x_1, ... x_n) >= 0} where f is an SDBM expression. diff --git a/mlir/include/mlir/Dialect/SDBM/SDBMDialect.h b/mlir/include/mlir/Dialect/SDBM/SDBMDialect.h index e3573ba604d..501c66140f0 100644 --- a/mlir/include/mlir/Dialect/SDBM/SDBMDialect.h +++ b/mlir/include/mlir/Dialect/SDBM/SDBMDialect.h @@ -1,19 +1,10 @@ //===- SDBMDialect.h - Dialect for striped DBMs -----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_SDBM_SDBMDIALECT_H #define MLIR_DIALECT_SDBM_SDBMDIALECT_H diff --git a/mlir/include/mlir/Dialect/SDBM/SDBMExpr.h b/mlir/include/mlir/Dialect/SDBM/SDBMExpr.h index 8cb5ef0be10..84a9a8405a8 100644 --- a/mlir/include/mlir/Dialect/SDBM/SDBMExpr.h +++ b/mlir/include/mlir/Dialect/SDBM/SDBMExpr.h @@ -1,19 +1,10 @@ //===- SDBMExpr.h - MLIR SDBM Expression ------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // A striped difference-bound matrix (SDBM) expression is a constant expression, // an identifier, a binary expression with constant RHS and +, stripe operators diff --git a/mlir/include/mlir/Dialect/SPIRV/LayoutUtils.h b/mlir/include/mlir/Dialect/SPIRV/LayoutUtils.h index 7537e5f654b..329caa2d3aa 100644 --- a/mlir/include/mlir/Dialect/SPIRV/LayoutUtils.h +++ b/mlir/include/mlir/Dialect/SPIRV/LayoutUtils.h @@ -1,19 +1,10 @@ //===-- LayoutUtils.h - Decorate composite type with layout information ---===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines utilities used to get alignment and layout information for // types in SPIR-V dialect. diff --git a/mlir/include/mlir/Dialect/SPIRV/Passes.h b/mlir/include/mlir/Dialect/SPIRV/Passes.h index fe029ff27ea..68f149b54d5 100644 --- a/mlir/include/mlir/Dialect/SPIRV/Passes.h +++ b/mlir/include/mlir/Dialect/SPIRV/Passes.h @@ -1,19 +1,10 @@ //===- Passes.h - SPIR-V pass entry points ----------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file defines prototypes that expose pass constructors. // diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVArithmeticOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVArithmeticOps.td index f15d274922a..39858f357ff 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVArithmeticOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVArithmeticOps.td @@ -1,19 +1,10 @@ //===-- SPIRVArithmeticOps.td - MLIR SPIR-V Arithmetic Ops -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains arithmetic ops for the SPIR-V dialect. It corresponds // to "3.32.13. Arithmetic Instructions" of the SPIR-V specification. diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVAtomicOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVAtomicOps.td index 15b6ab0105c..c2ea100c121 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVAtomicOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVAtomicOps.td @@ -1,19 +1,10 @@ //===-- SPIRVAtomicOps.td - MLIR SPIR-V Atomic Ops ---------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains atomic ops for the SPIR-V dialect. It corresponds to // "3.32.18. Atomic Instructions" of the SPIR-V specification. diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td index 838398823ad..5751a32e169 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td @@ -1,19 +1,10 @@ //===- SPIRVBase.td - MLIR SPIR-V Op Definitions Base file -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the base file for SPIR-V operation definition specification. // This file defines the SPIR-V dialect, common SPIR-V types, and utilities diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVBinaryUtils.h b/mlir/include/mlir/Dialect/SPIRV/SPIRVBinaryUtils.h index 3229e28ef1a..6a426488423 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVBinaryUtils.h +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVBinaryUtils.h @@ -1,19 +1,10 @@ //===- SPIRVBinaryUtils.cpp - SPIR-V Binary Module Utils --------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares common utilities for SPIR-V binary module. // diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVBitOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVBitOps.td index d76a1e3854b..360edeec52d 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVBitOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVBitOps.td @@ -1,19 +1,10 @@ //===-- SPIRVBitOps.td - MLIR SPIR-V Bit Ops -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains bit ops for the SPIR-V dialect. It corresponds // to "3.32.13. Bit Instructions" of the SPIR-V specification. diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVCastOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVCastOps.td index e4fe526e420..99fe0bbbf5f 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVCastOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVCastOps.td @@ -1,19 +1,10 @@ //===-- SPIRVCastOps.td - MLIR SPIR-V Cast Ops -------*- tablegen -*-------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains cast ops for the SPIR-V dialect. It corresponds // to "3.32.11. Convertion Instructions" of the SPIR-V specification. diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td index d19fd974684..7bd88ab66e0 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td @@ -1,19 +1,10 @@ //===-- SPIRVCompositeOps.td - MLIR SPIR-V Composite Ops ---*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains composite ops for SPIR-V dialect. It corresponds // to "3.32.12. Composite Instructions" of the SPIR-V spec. diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td index 32a78024560..bc06c0289db 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td @@ -1,19 +1,10 @@ //===-- SPIRVControlFlowOps.td - SPIR-V Control Flow Ops ---*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains control flow ops for the SPIR-V dialect. It corresponds // to "3.32.17. Control-Flow Instructions" of the SPIR-V specification. diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVDialect.h b/mlir/include/mlir/Dialect/SPIRV/SPIRVDialect.h index 2571e5d8928..0c0eebd34d1 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVDialect.h +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVDialect.h @@ -1,19 +1,10 @@ //===- SPIRVDialect.h - MLIR SPIR-V dialect ---------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares the SPIR-V dialect in MLIR. // diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td index a031facdf5a..b2eacbf306a 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td @@ -1,19 +1,10 @@ //===- SPIRVGLSLOps.td - GLSL extended insts spec file -----*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the op definition spec of GLSL extension ops. // diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVGroupOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVGroupOps.td index c0388fe4e23..827636afbaf 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVGroupOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVGroupOps.td @@ -1,19 +1,10 @@ //===-- SPIRVGroupOps.td - MLIR SPIR-V (Sub)Group Ops ------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains group and subgroup ops for the SPIR-V dialect. It // corresponds to "3.32.21. Group and Subgroup Instructions" of the SPIR-V diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td index e1e94bcd861..4057f47931c 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td @@ -1,19 +1,10 @@ //===-- SPIRVLogicalOps.td - MLIR SPIR-V Logical Ops -------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains arithmetic ops for the SPIR-V dialect. It corresponds // to "3.32.15. Relational and Logical Instructions" of the SPIR-V spec. diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h b/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h index 37b4ee24237..e7cf250cc3a 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h @@ -1,19 +1,10 @@ //===- SPIRVLowering.h - SPIR-V lowering utilities -------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines utilities to use while targeting SPIR-V dialect. // diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.td index d9cf0a752b8..91a8ff68bbf 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.td @@ -1,19 +1,10 @@ //===- SPIRVBase.td - MLIR SPIR-V Op Definitions Base file -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the base file for supporting lowering to SPIR-V dialect. This // file defines SPIR-V attributes used for specifying the shader diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVNonUniformOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVNonUniformOps.td index 1b3174c9e9f..f3a9a61a9e9 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVNonUniformOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVNonUniformOps.td @@ -1,19 +1,10 @@ //===-- SPIRVNonUniformOps.td - MLIR SPIR-V NonUniform Ops -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains non-uniform ops for the SPIR-V dialect. It corresponds to // "3.32.24. Non-Uniform Instructions" of the SPIR-V specification. diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h b/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h index cb33146286a..2fa417bfe25 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h @@ -1,19 +1,10 @@ //===- SPIRVOps.h - MLIR SPIR-V operations ----------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares the operations in the SPIR-V dialect. // diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td index 777e5750486..f657d5847d0 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td @@ -1,19 +1,10 @@ //===-- SPIRVOps.td - MLIR SPIR-V Op Definitions Spec ------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the main operation definition specification file for SPIR-V // operations. diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td index d1dacf3d63d..c37796b9f60 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td @@ -1,19 +1,10 @@ //===-- SPIRVStructureOps.td - MLIR SPIR-V Structure Ops ---*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains ops for defining the SPIR-V structure: module, function, // and module-level operations. The representational form of these ops deviate diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h b/mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h index bc3083e8d7c..001d3130778 100644 --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h @@ -1,19 +1,10 @@ //===- SPIRVTypes.h - MLIR SPIR-V Types -------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares the types in the SPIR-V dialect. // diff --git a/mlir/include/mlir/Dialect/SPIRV/Serialization.h b/mlir/include/mlir/Dialect/SPIRV/Serialization.h index bad7355791f..e8240b0072e 100644 --- a/mlir/include/mlir/Dialect/SPIRV/Serialization.h +++ b/mlir/include/mlir/Dialect/SPIRV/Serialization.h @@ -1,19 +1,10 @@ //===- Serialization.h - MLIR SPIR-V (De)serialization ----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares the entry points for serialize and deserialize SPIR-V // binary modules. diff --git a/mlir/include/mlir/Dialect/StandardOps/Ops.h b/mlir/include/mlir/Dialect/StandardOps/Ops.h index 563116823d9..e3ec6f1f7d6 100644 --- a/mlir/include/mlir/Dialect/StandardOps/Ops.h +++ b/mlir/include/mlir/Dialect/StandardOps/Ops.h @@ -1,19 +1,10 @@ //===- Ops.h - Standard MLIR Operations -------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines convenience types for working with standard operations // in the MLIR operation set. diff --git a/mlir/include/mlir/Dialect/StandardOps/Ops.td b/mlir/include/mlir/Dialect/StandardOps/Ops.td index e00674708f6..c31b3dc9395 100644 --- a/mlir/include/mlir/Dialect/StandardOps/Ops.td +++ b/mlir/include/mlir/Dialect/StandardOps/Ops.td @@ -1,19 +1,10 @@ //===- Ops.td - Standard operation definitions -------------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines some MLIR standard operations. // diff --git a/mlir/include/mlir/Dialect/Traits.h b/mlir/include/mlir/Dialect/Traits.h index e04eb829e88..87c8e662a65 100644 --- a/mlir/include/mlir/Dialect/Traits.h +++ b/mlir/include/mlir/Dialect/Traits.h @@ -1,19 +1,10 @@ //===- Traits.h - Common op traits shared by dialects -----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares common op traits that are not core to MLIR but can be // shared by multiple dialects. diff --git a/mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h b/mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h index b7e3990a333..9e7cbba0f43 100644 --- a/mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h +++ b/mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h @@ -1,19 +1,10 @@ //===- StructuredOpsUtils.h - Utilities used by structured ops --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file define utilities that operate on standard types and are // useful across multiple dialects that use structured ops abstractions. These diff --git a/mlir/include/mlir/Dialect/VectorOps/Utils.h b/mlir/include/mlir/Dialect/VectorOps/Utils.h index 68c62cc7ec7..b4d8ad65e60 100644 --- a/mlir/include/mlir/Dialect/VectorOps/Utils.h +++ b/mlir/include/mlir/Dialect/VectorOps/Utils.h @@ -1,19 +1,10 @@ //===- Utils.h - VectorOps Utils ----------------------------*- C++ -*-=======// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_DIALECT_VECTOROPS_UTILS_H_ #define MLIR_DIALECT_VECTOROPS_UTILS_H_ diff --git a/mlir/include/mlir/Dialect/VectorOps/VectorOps.h b/mlir/include/mlir/Dialect/VectorOps/VectorOps.h index 29ad6eecaf9..7234d46b765 100644 --- a/mlir/include/mlir/Dialect/VectorOps/VectorOps.h +++ b/mlir/include/mlir/Dialect/VectorOps/VectorOps.h @@ -1,19 +1,10 @@ //===- VectorOps.h - MLIR Super Vectorizer Operations -----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the Vector dialect. // diff --git a/mlir/include/mlir/Dialect/VectorOps/VectorOps.td b/mlir/include/mlir/Dialect/VectorOps/VectorOps.td index 94262e6f1ff..87ed28caf80 100644 --- a/mlir/include/mlir/Dialect/VectorOps/VectorOps.td +++ b/mlir/include/mlir/Dialect/VectorOps/VectorOps.td @@ -1,19 +1,10 @@ //===- VectorOps.td - Vector op definitions ---------------*- tablegen -*-====// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines MLIR vector operations. // diff --git a/mlir/include/mlir/Dialect/VectorOps/VectorTransformPatterns.td b/mlir/include/mlir/Dialect/VectorOps/VectorTransformPatterns.td index 86ff9b505d5..5d0244f6989 100644 --- a/mlir/include/mlir/Dialect/VectorOps/VectorTransformPatterns.td +++ b/mlir/include/mlir/Dialect/VectorOps/VectorTransformPatterns.td @@ -1,19 +1,10 @@ //===- VectorTransformPatterns.td - Vector-Vector patterns -*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the pattern definition file for declarative Vector transformations. // diff --git a/mlir/include/mlir/Dialect/VectorOps/VectorTransforms.h b/mlir/include/mlir/Dialect/VectorOps/VectorTransforms.h index b48cb51533f..a73444d2023 100644 --- a/mlir/include/mlir/Dialect/VectorOps/VectorTransforms.h +++ b/mlir/include/mlir/Dialect/VectorOps/VectorTransforms.h @@ -1,19 +1,10 @@ //===- VectorTransforms.h - Vector transformations as patterns --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef DIALECT_VECTOROPS_VECTORTRANSFORMS_H_ #define DIALECT_VECTOROPS_VECTORTRANSFORMS_H_ diff --git a/mlir/include/mlir/EDSC/Builders.h b/mlir/include/mlir/EDSC/Builders.h index 11ee0bff342..6607f267057 100644 --- a/mlir/include/mlir/EDSC/Builders.h +++ b/mlir/include/mlir/EDSC/Builders.h @@ -1,19 +1,10 @@ //===- Builders.h - MLIR Declarative Builder Classes ------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Provides intuitive composable interfaces for building structured MLIR // snippets in a declarative fashion. diff --git a/mlir/include/mlir/EDSC/Helpers.h b/mlir/include/mlir/EDSC/Helpers.h index c18307e7121..0be8a6045f7 100644 --- a/mlir/include/mlir/EDSC/Helpers.h +++ b/mlir/include/mlir/EDSC/Helpers.h @@ -1,19 +1,10 @@ //===- Helpers.h - MLIR Declarative Helper Functionality --------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Provides helper classes and syntactic sugar for declarative builders. // diff --git a/mlir/include/mlir/EDSC/Intrinsics.h b/mlir/include/mlir/EDSC/Intrinsics.h index dc0c1186c7a..5edbf9600fb 100644 --- a/mlir/include/mlir/EDSC/Intrinsics.h +++ b/mlir/include/mlir/EDSC/Intrinsics.h @@ -1,19 +1,10 @@ //===- Intrinsics.h - MLIR Operations for Declarative Builders ---*- C++-*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Provides intuitive composable intrinsics for building snippets of MLIR // declaratively diff --git a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h index 4e70a21f6ec..4f218bd0d9b 100644 --- a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h +++ b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h @@ -1,19 +1,10 @@ //===- ExecutionEngine.h - MLIR Execution engine and utils -----*- C++ -*--===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file provides a JIT-backed execution engine for MLIR modules. // diff --git a/mlir/include/mlir/ExecutionEngine/OptUtils.h b/mlir/include/mlir/ExecutionEngine/OptUtils.h index 8c0249d5c09..7b7b2598db5 100644 --- a/mlir/include/mlir/ExecutionEngine/OptUtils.h +++ b/mlir/include/mlir/ExecutionEngine/OptUtils.h @@ -1,19 +1,10 @@ //===- OptUtils.h - MLIR Execution Engine opt pass utilities ----*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares the utility functions to trigger LLVM optimizations from // MLIR Execution Engine. diff --git a/mlir/include/mlir/IR/AffineExpr.h b/mlir/include/mlir/IR/AffineExpr.h index b66933df408..7059489ed4c 100644 --- a/mlir/include/mlir/IR/AffineExpr.h +++ b/mlir/include/mlir/IR/AffineExpr.h @@ -1,19 +1,10 @@ //===- AffineExpr.h - MLIR Affine Expr Class --------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // An affine expression is an affine combination of dimension identifiers and // symbols, including ceildiv/floordiv/mod by a constant integer. diff --git a/mlir/include/mlir/IR/AffineExprVisitor.h b/mlir/include/mlir/IR/AffineExprVisitor.h index 9fa40218b5f..7866d6bb996 100644 --- a/mlir/include/mlir/IR/AffineExprVisitor.h +++ b/mlir/include/mlir/IR/AffineExprVisitor.h @@ -1,19 +1,10 @@ //===- AffineExprVisitor.h - MLIR AffineExpr Visitor Class ------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the AffineExpr visitor class. // diff --git a/mlir/include/mlir/IR/AffineMap.h b/mlir/include/mlir/IR/AffineMap.h index abd3712b0e1..3f9116cb168 100644 --- a/mlir/include/mlir/IR/AffineMap.h +++ b/mlir/include/mlir/IR/AffineMap.h @@ -1,19 +1,10 @@ //===- AffineMap.h - MLIR Affine Map Class ----------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Affine maps are mathematical functions which map a list of dimension // identifiers and symbols, to multidimensional affine expressions. diff --git a/mlir/include/mlir/IR/AttributeSupport.h b/mlir/include/mlir/IR/AttributeSupport.h index 78b3a2779d3..9804d6866f8 100644 --- a/mlir/include/mlir/IR/AttributeSupport.h +++ b/mlir/include/mlir/IR/AttributeSupport.h @@ -1,19 +1,10 @@ //===- AttributeSupport.h ---------------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines support types for registering dialect extended attributes. // diff --git a/mlir/include/mlir/IR/Attributes.h b/mlir/include/mlir/IR/Attributes.h index b5f4b1a7d7c..b8398580f61 100644 --- a/mlir/include/mlir/IR/Attributes.h +++ b/mlir/include/mlir/IR/Attributes.h @@ -1,19 +1,10 @@ //===- Attributes.h - MLIR Attribute Classes --------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_IR_ATTRIBUTES_H #define MLIR_IR_ATTRIBUTES_H diff --git a/mlir/include/mlir/IR/Block.h b/mlir/include/mlir/IR/Block.h index 87c77160e1d..b5189b48a85 100644 --- a/mlir/include/mlir/IR/Block.h +++ b/mlir/include/mlir/IR/Block.h @@ -1,19 +1,10 @@ //===- Block.h - MLIR Block Class -------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the Block class. // diff --git a/mlir/include/mlir/IR/BlockAndValueMapping.h b/mlir/include/mlir/IR/BlockAndValueMapping.h index 287dd508fa6..82173c34368 100644 --- a/mlir/include/mlir/IR/BlockAndValueMapping.h +++ b/mlir/include/mlir/IR/BlockAndValueMapping.h @@ -1,19 +1,10 @@ //===- BlockAndValueMapping.h -----------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines a utility class for maintaining a mapping for multiple // value types. diff --git a/mlir/include/mlir/IR/BlockSupport.h b/mlir/include/mlir/IR/BlockSupport.h index fd30c36aaa3..7cefe870c22 100644 --- a/mlir/include/mlir/IR/BlockSupport.h +++ b/mlir/include/mlir/IR/BlockSupport.h @@ -1,19 +1,10 @@ //===- BlockSupport.h -------------------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines a number of support types for the Block class. // diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h index c199c09feb5..038664f0186 100644 --- a/mlir/include/mlir/IR/Builders.h +++ b/mlir/include/mlir/IR/Builders.h @@ -1,19 +1,10 @@ //===- Builders.h - Helpers for constructing MLIR Classes -------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_IR_BUILDERS_H #define MLIR_IR_BUILDERS_H diff --git a/mlir/include/mlir/IR/Diagnostics.h b/mlir/include/mlir/IR/Diagnostics.h index 9385de9ac4f..e3d0f838208 100644 --- a/mlir/include/mlir/IR/Diagnostics.h +++ b/mlir/include/mlir/IR/Diagnostics.h @@ -1,19 +1,10 @@ //===- Diagnostics.h - MLIR Diagnostics -------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines utilities for emitting diagnostics. // diff --git a/mlir/include/mlir/IR/Dialect.h b/mlir/include/mlir/IR/Dialect.h index a1855e797e8..d3b4b055bc0 100644 --- a/mlir/include/mlir/IR/Dialect.h +++ b/mlir/include/mlir/IR/Dialect.h @@ -1,19 +1,10 @@ //===- Dialect.h - IR Dialect Description -----------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the 'dialect' abstraction. // diff --git a/mlir/include/mlir/IR/DialectHooks.h b/mlir/include/mlir/IR/DialectHooks.h index c51fafb6180..7e4e1d8335b 100644 --- a/mlir/include/mlir/IR/DialectHooks.h +++ b/mlir/include/mlir/IR/DialectHooks.h @@ -1,19 +1,10 @@ //===- DialectHooks.h - MLIR DialectHooks mechanism -------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines abstraction and registration mechanism for dialect hooks. // diff --git a/mlir/include/mlir/IR/DialectImplementation.h b/mlir/include/mlir/IR/DialectImplementation.h index c645a2427b2..1eada8f264b 100644 --- a/mlir/include/mlir/IR/DialectImplementation.h +++ b/mlir/include/mlir/IR/DialectImplementation.h @@ -1,19 +1,10 @@ //===- DialectImplementation.h ----------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains utilities classes for implementing dialect attributes and // types. diff --git a/mlir/include/mlir/IR/DialectInterface.h b/mlir/include/mlir/IR/DialectInterface.h index 4eb41105032..ff1f8fb015a 100644 --- a/mlir/include/mlir/IR/DialectInterface.h +++ b/mlir/include/mlir/IR/DialectInterface.h @@ -1,19 +1,10 @@ //===- DialectInterface.h - IR Dialect Interfaces ---------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_IR_DIALECTINTERFACE_H #define MLIR_IR_DIALECTINTERFACE_H diff --git a/mlir/include/mlir/IR/DialectSymbolRegistry.def b/mlir/include/mlir/IR/DialectSymbolRegistry.def index c1056bd4da0..14b876a2ce9 100644 --- a/mlir/include/mlir/IR/DialectSymbolRegistry.def +++ b/mlir/include/mlir/IR/DialectSymbolRegistry.def @@ -1,19 +1,10 @@ //===- DialectSymbolRegistry.def - MLIR Dialect Symbol Registry -*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file enumerates the different dialects that define custom classes // within the attribute or type system. diff --git a/mlir/include/mlir/IR/Function.h b/mlir/include/mlir/IR/Function.h index 6731f5430fa..3f788bbeeba 100644 --- a/mlir/include/mlir/IR/Function.h +++ b/mlir/include/mlir/IR/Function.h @@ -1,19 +1,10 @@ //===- Function.h - MLIR Function Class -------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Functions are the basic unit of composition in MLIR. // diff --git a/mlir/include/mlir/IR/FunctionImplementation.h b/mlir/include/mlir/IR/FunctionImplementation.h index c557d58429c..9d3e438f67e 100644 --- a/mlir/include/mlir/IR/FunctionImplementation.h +++ b/mlir/include/mlir/IR/FunctionImplementation.h @@ -1,19 +1,10 @@ //===- FunctionImplementation.h - Function-like Op utilities ----*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file provides utility functions for implementing function-like // operations, in particular, parsing, printing and verification components diff --git a/mlir/include/mlir/IR/FunctionSupport.h b/mlir/include/mlir/IR/FunctionSupport.h index 1ba85d73df9..49175ba5e75 100644 --- a/mlir/include/mlir/IR/FunctionSupport.h +++ b/mlir/include/mlir/IR/FunctionSupport.h @@ -1,19 +1,10 @@ //===- FunctionSupport.h - Utility types for function-like ops --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines support types for Operations that represent function-like // constructs to use. diff --git a/mlir/include/mlir/IR/Identifier.h b/mlir/include/mlir/IR/Identifier.h index bc84c200545..604eebf341e 100644 --- a/mlir/include/mlir/IR/Identifier.h +++ b/mlir/include/mlir/IR/Identifier.h @@ -1,19 +1,10 @@ //===- Identifier.h - MLIR Identifier Class ---------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_IR_IDENTIFIER_H #define MLIR_IR_IDENTIFIER_H diff --git a/mlir/include/mlir/IR/IntegerSet.h b/mlir/include/mlir/IR/IntegerSet.h index 6ffe830883b..1238511df34 100644 --- a/mlir/include/mlir/IR/IntegerSet.h +++ b/mlir/include/mlir/IR/IntegerSet.h @@ -1,19 +1,10 @@ //===- IntegerSet.h - MLIR Integer Set Class --------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Integer sets are sets of points from the integer lattice constrained by // affine equality/inequality constraints. This class is meant to represent diff --git a/mlir/include/mlir/IR/Location.h b/mlir/include/mlir/IR/Location.h index bb55ad69057..c36bcb30735 100644 --- a/mlir/include/mlir/IR/Location.h +++ b/mlir/include/mlir/IR/Location.h @@ -1,19 +1,10 @@ //===- Location.h - MLIR Location Classes -----------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // These classes provide the ability to relate MLIR objects back to source // location position information. diff --git a/mlir/include/mlir/IR/MLIRContext.h b/mlir/include/mlir/IR/MLIRContext.h index a93cb8b3353..e0761bcaaf1 100644 --- a/mlir/include/mlir/IR/MLIRContext.h +++ b/mlir/include/mlir/IR/MLIRContext.h @@ -1,19 +1,10 @@ //===- MLIRContext.h - MLIR Global Context Class ----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_IR_MLIRCONTEXT_H #define MLIR_IR_MLIRCONTEXT_H diff --git a/mlir/include/mlir/IR/Matchers.h b/mlir/include/mlir/IR/Matchers.h index 3b36f2fb5eb..5ce2cc7a8a8 100644 --- a/mlir/include/mlir/IR/Matchers.h +++ b/mlir/include/mlir/IR/Matchers.h @@ -1,19 +1,10 @@ //===- Matchers.h - Various common matchers ---------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file provides a simple and efficient mechanism for performing general // tree-based pattern matching over MLIR. This mechanism is inspired by LLVM's diff --git a/mlir/include/mlir/IR/Module.h b/mlir/include/mlir/IR/Module.h index 52d2455c7ae..babc51aad0d 100644 --- a/mlir/include/mlir/IR/Module.h +++ b/mlir/include/mlir/IR/Module.h @@ -1,19 +1,10 @@ //===- Module.h - MLIR Module Class -----------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Module is the top-level container for code in an MLIR program. // diff --git a/mlir/include/mlir/IR/OpAsmInterface.td b/mlir/include/mlir/IR/OpAsmInterface.td index 85726a8c64d..7e31c07575e 100644 --- a/mlir/include/mlir/IR/OpAsmInterface.td +++ b/mlir/include/mlir/IR/OpAsmInterface.td @@ -1,19 +1,10 @@ //===- OpAsmInterface.td - Asm Interfaces for opse ---------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains Interfaces for interacting with the AsmParser and // AsmPrinter. diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index 24e48b329d5..c457d25fc51 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -1,19 +1,10 @@ //===-- OpBase.td - Base op definition file ----------------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the base operation definition file. // diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h index 437540117c4..84f3cf2f444 100644 --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -1,19 +1,10 @@ //===- OpDefinition.h - Classes for defining concrete Op types --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements helper classes for implementing the "Op" types. This // includes the Op type, which is the base class for Op class definitions, diff --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpImplementation.h index fcadce9ab16..e58a5b07038 100644 --- a/mlir/include/mlir/IR/OpImplementation.h +++ b/mlir/include/mlir/IR/OpImplementation.h @@ -1,19 +1,10 @@ //===- OpImplementation.h - Classes for implementing Op types ---*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This classes used by the implementation details of Op types. // diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h index ad0dc600f8f..9ab900c8761 100644 --- a/mlir/include/mlir/IR/Operation.h +++ b/mlir/include/mlir/IR/Operation.h @@ -1,19 +1,10 @@ //===- Operation.h - MLIR Operation Class -----------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the Operation class. // diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h index b7f63218ba5..14681663372 100644 --- a/mlir/include/mlir/IR/OperationSupport.h +++ b/mlir/include/mlir/IR/OperationSupport.h @@ -1,19 +1,10 @@ //===- OperationSupport.h ---------------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines a number of support types that Operation and related // classes build on top of. diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h index 707bb7c139f..e6b5e7a5eb7 100644 --- a/mlir/include/mlir/IR/PatternMatch.h +++ b/mlir/include/mlir/IR/PatternMatch.h @@ -1,19 +1,10 @@ //===- PatternMatch.h - PatternMatcher classes -------==---------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_PATTERNMATCHER_H #define MLIR_PATTERNMATCHER_H diff --git a/mlir/include/mlir/IR/Region.h b/mlir/include/mlir/IR/Region.h index c1390adb40b..00f3ca7fba1 100644 --- a/mlir/include/mlir/IR/Region.h +++ b/mlir/include/mlir/IR/Region.h @@ -1,19 +1,10 @@ //===- Region.h - MLIR Region Class -----------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the Region class. // diff --git a/mlir/include/mlir/IR/RegionGraphTraits.h b/mlir/include/mlir/IR/RegionGraphTraits.h index f45dcc41a4a..b11c87dbd0c 100644 --- a/mlir/include/mlir/IR/RegionGraphTraits.h +++ b/mlir/include/mlir/IR/RegionGraphTraits.h @@ -1,19 +1,10 @@ //===- RegionGraphTraits.h - llvm::GraphTraits for CFGs ---------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements specializations of llvm::GraphTraits for various MLIR // CFG data types. This allows the generic LLVM graph algorithms to be applied diff --git a/mlir/include/mlir/IR/StandardTypes.h b/mlir/include/mlir/IR/StandardTypes.h index b6b4b6ea52c..89ffc45e547 100644 --- a/mlir/include/mlir/IR/StandardTypes.h +++ b/mlir/include/mlir/IR/StandardTypes.h @@ -1,19 +1,10 @@ //===- StandardTypes.h - MLIR Standard Type Classes -------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_IR_STANDARDTYPES_H #define MLIR_IR_STANDARDTYPES_H diff --git a/mlir/include/mlir/IR/StorageUniquerSupport.h b/mlir/include/mlir/IR/StorageUniquerSupport.h index 1a730731f32..f9288197072 100644 --- a/mlir/include/mlir/IR/StorageUniquerSupport.h +++ b/mlir/include/mlir/IR/StorageUniquerSupport.h @@ -1,19 +1,10 @@ //===- StorageUniquerSupport.h - MLIR Storage Uniquer Utilities -*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines utility classes for interfacing with StorageUniquer. // diff --git a/mlir/include/mlir/IR/SymbolTable.h b/mlir/include/mlir/IR/SymbolTable.h index e04beac6bc6..07829186cbf 100644 --- a/mlir/include/mlir/IR/SymbolTable.h +++ b/mlir/include/mlir/IR/SymbolTable.h @@ -1,19 +1,10 @@ //===- SymbolTable.h - MLIR Symbol Table Class ------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_IR_SYMBOLTABLE_H #define MLIR_IR_SYMBOLTABLE_H diff --git a/mlir/include/mlir/IR/TypeSupport.h b/mlir/include/mlir/IR/TypeSupport.h index 86620da0b5c..8cc811cb916 100644 --- a/mlir/include/mlir/IR/TypeSupport.h +++ b/mlir/include/mlir/IR/TypeSupport.h @@ -1,19 +1,10 @@ //===- TypeSupport.h --------------------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines support types for registering dialect extended types. // diff --git a/mlir/include/mlir/IR/TypeUtilities.h b/mlir/include/mlir/IR/TypeUtilities.h index af22f9c4a9f..b4713226559 100644 --- a/mlir/include/mlir/IR/TypeUtilities.h +++ b/mlir/include/mlir/IR/TypeUtilities.h @@ -1,19 +1,10 @@ //===- TypeUtilities.h - Helper function for type queries -------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines generic type utilities. // diff --git a/mlir/include/mlir/IR/Types.h b/mlir/include/mlir/IR/Types.h index 2ab36353dc4..6246e9bedd0 100644 --- a/mlir/include/mlir/IR/Types.h +++ b/mlir/include/mlir/IR/Types.h @@ -1,19 +1,10 @@ //===- Types.h - MLIR Type Classes ------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_IR_TYPES_H #define MLIR_IR_TYPES_H diff --git a/mlir/include/mlir/IR/UseDefLists.h b/mlir/include/mlir/IR/UseDefLists.h index 96e4ace2529..898d0da2b28 100644 --- a/mlir/include/mlir/IR/UseDefLists.h +++ b/mlir/include/mlir/IR/UseDefLists.h @@ -1,19 +1,10 @@ //===- UseDefLists.h --------------------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines generic use/def list machinery and manipulation utilities. // diff --git a/mlir/include/mlir/IR/Value.h b/mlir/include/mlir/IR/Value.h index 11cb8cdcbc7..030e6fa58b1 100644 --- a/mlir/include/mlir/IR/Value.h +++ b/mlir/include/mlir/IR/Value.h @@ -1,19 +1,10 @@ //===- Value.h - Base of the SSA Value hierarchy ----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines generic Value type and manipulation utilities. // diff --git a/mlir/include/mlir/IR/Visitors.h b/mlir/include/mlir/IR/Visitors.h index 50d65627f1a..aaab933d239 100644 --- a/mlir/include/mlir/IR/Visitors.h +++ b/mlir/include/mlir/IR/Visitors.h @@ -1,19 +1,10 @@ //===- Visitors.h - Utilities for visiting operations -----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines utilities for walking and visiting operations. // diff --git a/mlir/include/mlir/Parser.h b/mlir/include/mlir/Parser.h index 3a818ffa9d8..cae1e8b9ab1 100644 --- a/mlir/include/mlir/Parser.h +++ b/mlir/include/mlir/Parser.h @@ -1,19 +1,10 @@ //===- Parser.h - MLIR Parser Library Interface -----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file is contains the interface to the MLIR parser library. // diff --git a/mlir/include/mlir/Pass/AnalysisManager.h b/mlir/include/mlir/Pass/AnalysisManager.h index e233a4a5676..471cd011c40 100644 --- a/mlir/include/mlir/Pass/AnalysisManager.h +++ b/mlir/include/mlir/Pass/AnalysisManager.h @@ -1,19 +1,10 @@ //===- AnalysisManager.h - Analysis Management Infrastructure ---*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_PASS_ANALYSISMANAGER_H #define MLIR_PASS_ANALYSISMANAGER_H diff --git a/mlir/include/mlir/Pass/Pass.h b/mlir/include/mlir/Pass/Pass.h index 380b097c78c..b4e8db86ff0 100644 --- a/mlir/include/mlir/Pass/Pass.h +++ b/mlir/include/mlir/Pass/Pass.h @@ -1,19 +1,10 @@ //===- Pass.h - Base classes for compiler passes ----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_PASS_PASS_H #define MLIR_PASS_PASS_H diff --git a/mlir/include/mlir/Pass/PassInstrumentation.h b/mlir/include/mlir/Pass/PassInstrumentation.h index 4b61850c661..ef75e56ae62 100644 --- a/mlir/include/mlir/Pass/PassInstrumentation.h +++ b/mlir/include/mlir/Pass/PassInstrumentation.h @@ -1,19 +1,10 @@ //===- PassInstrumentation.h ------------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_PASS_PASSINSTRUMENTATION_H_ #define MLIR_PASS_PASSINSTRUMENTATION_H_ diff --git a/mlir/include/mlir/Pass/PassManager.h b/mlir/include/mlir/Pass/PassManager.h index 9de8ace435c..d4f3683f031 100644 --- a/mlir/include/mlir/Pass/PassManager.h +++ b/mlir/include/mlir/Pass/PassManager.h @@ -1,19 +1,10 @@ //===- PassManager.h - Pass Management Interface ----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_PASS_PASSMANAGER_H #define MLIR_PASS_PASSMANAGER_H diff --git a/mlir/include/mlir/Pass/PassOptions.h b/mlir/include/mlir/Pass/PassOptions.h index eabfa73a1b6..8ebeead90c8 100644 --- a/mlir/include/mlir/Pass/PassOptions.h +++ b/mlir/include/mlir/Pass/PassOptions.h @@ -1,19 +1,10 @@ //===- PassOptions.h - Pass Option Utilities --------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains utilities for registering options with compiler passes and // pipelines. diff --git a/mlir/include/mlir/Pass/PassRegistry.h b/mlir/include/mlir/Pass/PassRegistry.h index deb80ef765e..e07b9855c8d 100644 --- a/mlir/include/mlir/Pass/PassRegistry.h +++ b/mlir/include/mlir/Pass/PassRegistry.h @@ -1,19 +1,10 @@ //===- PassRegistry.h - Pass Registration Utilities -------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains utilities for registering information about compiler // passes. diff --git a/mlir/include/mlir/Quantizer/Configurations/FxpMathConfig.h b/mlir/include/mlir/Quantizer/Configurations/FxpMathConfig.h index 467512f2b77..f27d12d7f52 100644 --- a/mlir/include/mlir/Quantizer/Configurations/FxpMathConfig.h +++ b/mlir/include/mlir/Quantizer/Configurations/FxpMathConfig.h @@ -1,19 +1,10 @@ //===- FxpMathConfig.h - Reference fixed point config -----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines a TargetConfiguration for reference fixed-point math // quantization scheme based on the FxpMathOps (plus a small category of diff --git a/mlir/include/mlir/Quantizer/Support/Configuration.h b/mlir/include/mlir/Quantizer/Support/Configuration.h index 17a472de30a..3732fbad3a2 100644 --- a/mlir/include/mlir/Quantizer/Support/Configuration.h +++ b/mlir/include/mlir/Quantizer/Support/Configuration.h @@ -1,19 +1,10 @@ //===- Configuration.h - Configuration object base classes ------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // The quantizer is relatively agnostic to source and target dialects, with // the specific represented by configuration policy objects derived from diff --git a/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraph.h b/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraph.h index 202e86566fc..fe66848b906 100644 --- a/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraph.h +++ b/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraph.h @@ -1,19 +1,10 @@ //===- ConstraintAnalysisGraph.h - Graphs type for constraints --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file provides graph-based data structures for representing anchors // and constraints between them. diff --git a/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraphTraits.h b/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraphTraits.h index 7e2b61d0496..35ec85f13b2 100644 --- a/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraphTraits.h +++ b/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraphTraits.h @@ -1,19 +1,10 @@ //===- ConstraintAnalysisGraphTraits.h - Traits for CAGs --------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Provides graph traits for constraint analysis graphs. // diff --git a/mlir/include/mlir/Quantizer/Support/Metadata.h b/mlir/include/mlir/Quantizer/Support/Metadata.h index 6c327d9df7a..0545e78f917 100644 --- a/mlir/include/mlir/Quantizer/Support/Metadata.h +++ b/mlir/include/mlir/Quantizer/Support/Metadata.h @@ -1,19 +1,10 @@ //===- Metadata.h - Top level types and metadata ----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains top level types needed to construct constraint graphs, // including context/allocator support and concrete metadata structs for diff --git a/mlir/include/mlir/Quantizer/Support/Rules.h b/mlir/include/mlir/Quantizer/Support/Rules.h index 9d1e53df5c0..536dd7ea07e 100644 --- a/mlir/include/mlir/Quantizer/Support/Rules.h +++ b/mlir/include/mlir/Quantizer/Support/Rules.h @@ -1,19 +1,10 @@ //===- Rules.h - Helpers for declaring facts and rules ----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines helper classes and functions for managing state (facts), // merging and tracking modification for various data types important for diff --git a/mlir/include/mlir/Quantizer/Support/Statistics.h b/mlir/include/mlir/Quantizer/Support/Statistics.h index 744c5b640ec..a24eecd3427 100644 --- a/mlir/include/mlir/Quantizer/Support/Statistics.h +++ b/mlir/include/mlir/Quantizer/Support/Statistics.h @@ -1,19 +1,10 @@ //===- Statistics.h - Collects statistics over tensors ----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines adapters for extracting various (per layer and per axis) // statistics over tensors. diff --git a/mlir/include/mlir/Quantizer/Support/TypeUtils.h b/mlir/include/mlir/Quantizer/Support/TypeUtils.h index 074f8b9e854..64ae5d65b57 100644 --- a/mlir/include/mlir/Quantizer/Support/TypeUtils.h +++ b/mlir/include/mlir/Quantizer/Support/TypeUtils.h @@ -1,19 +1,10 @@ //===- TypeUtils.h - Helper function for manipulating types -----*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines various helper functions for manipulating types. The // process of quantizing typically involves a number of type manipulations diff --git a/mlir/include/mlir/Quantizer/Support/UniformConstraints.h b/mlir/include/mlir/Quantizer/Support/UniformConstraints.h index 90b5fe12153..70c022c96a1 100644 --- a/mlir/include/mlir/Quantizer/Support/UniformConstraints.h +++ b/mlir/include/mlir/Quantizer/Support/UniformConstraints.h @@ -1,19 +1,10 @@ //===- UniformConstraints.h - Constraints for uniform quant -----*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines a builder that lets you attach constraints necessary to // perform a variety of uniform quantization conversions to CAG anchors. diff --git a/mlir/include/mlir/Quantizer/Support/UniformSolvers.h b/mlir/include/mlir/Quantizer/Support/UniformSolvers.h index 98df671f81d..d6bd1a25ec3 100644 --- a/mlir/include/mlir/Quantizer/Support/UniformSolvers.h +++ b/mlir/include/mlir/Quantizer/Support/UniformSolvers.h @@ -1,19 +1,10 @@ //===- UniformSolvers.h - Uniform type solver algorithms --------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines algorithms for solving uniform type parameters for various // conditions (i.e. fixed-point, affine, scale matching, etc). diff --git a/mlir/include/mlir/Quantizer/Transforms/Passes.h b/mlir/include/mlir/Quantizer/Transforms/Passes.h index 4fdea58daf4..3490f2953a4 100644 --- a/mlir/include/mlir/Quantizer/Transforms/Passes.h +++ b/mlir/include/mlir/Quantizer/Transforms/Passes.h @@ -1,19 +1,10 @@ //===- Passes.h - Quantizer passes -----------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines entry points to create passes to perform various kinds // of quantization related transforms. diff --git a/mlir/include/mlir/Support/DebugStringHelper.h b/mlir/include/mlir/Support/DebugStringHelper.h index 230ed231458..0fa342686ba 100644 --- a/mlir/include/mlir/Support/DebugStringHelper.h +++ b/mlir/include/mlir/Support/DebugStringHelper.h @@ -1,19 +1,10 @@ //===- DebugStringHelper.h - helpers to generate debug strings --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Convenience functions to make it easier to get a string representation for // ops that have a print method. For use in debugging output and errors diff --git a/mlir/include/mlir/Support/FileUtilities.h b/mlir/include/mlir/Support/FileUtilities.h index 5ce97223176..c13b39efc4f 100644 --- a/mlir/include/mlir/Support/FileUtilities.h +++ b/mlir/include/mlir/Support/FileUtilities.h @@ -1,19 +1,10 @@ //===- FileUtilities.h - utilities for working with files -------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Common utilities for working with files. // diff --git a/mlir/include/mlir/Support/Functional.h b/mlir/include/mlir/Support/Functional.h index e8bf394b110..f18677f806b 100644 --- a/mlir/include/mlir/Support/Functional.h +++ b/mlir/include/mlir/Support/Functional.h @@ -1,19 +1,10 @@ //===- Functional.h - Helpers for functional-style Combinators --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_SUPPORT_FUNCTIONAL_H_ #define MLIR_SUPPORT_FUNCTIONAL_H_ diff --git a/mlir/include/mlir/Support/JitRunner.h b/mlir/include/mlir/Support/JitRunner.h index 14b66a8cebd..71c1d7d5105 100644 --- a/mlir/include/mlir/Support/JitRunner.h +++ b/mlir/include/mlir/Support/JitRunner.h @@ -1,19 +1,10 @@ //===- JitRunner.h - MLIR CPU Execution Driver Library ----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is a library that provides a shared implementation for command line // utilities that execute an MLIR file on the CPU by translating MLIR to LLVM diff --git a/mlir/include/mlir/Support/LLVM.h b/mlir/include/mlir/Support/LLVM.h index 91d145dd3ca..1885ebe609b 100644 --- a/mlir/include/mlir/Support/LLVM.h +++ b/mlir/include/mlir/Support/LLVM.h @@ -1,19 +1,10 @@ //===- LLVM.h - Import and forward declare core LLVM types ------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file forward declares and imports various common LLVM datatypes that // MLIR wants to use unqualified. diff --git a/mlir/include/mlir/Support/LogicalResult.h b/mlir/include/mlir/Support/LogicalResult.h index a9fc77ceef8..418293c0f80 100644 --- a/mlir/include/mlir/Support/LogicalResult.h +++ b/mlir/include/mlir/Support/LogicalResult.h @@ -1,19 +1,10 @@ //===- LogicalResult.h - Utilities for handling success/failure -*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_SUPPORT_LOGICAL_RESULT_H #define MLIR_SUPPORT_LOGICAL_RESULT_H diff --git a/mlir/include/mlir/Support/MathExtras.h b/mlir/include/mlir/Support/MathExtras.h index 767677fbc5d..1fd0634e9e8 100644 --- a/mlir/include/mlir/Support/MathExtras.h +++ b/mlir/include/mlir/Support/MathExtras.h @@ -1,19 +1,10 @@ //===- MathExtras.h - Math functions relevant to MLIR -----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains math functions relevant to MLIR. // diff --git a/mlir/include/mlir/Support/MlirOptMain.h b/mlir/include/mlir/Support/MlirOptMain.h index be8e4328fb1..eac5ee765c2 100644 --- a/mlir/include/mlir/Support/MlirOptMain.h +++ b/mlir/include/mlir/Support/MlirOptMain.h @@ -1,19 +1,10 @@ //===- MlirOptMain.h - MLIR Optimizer Driver main ---------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Main entry function for mlir-opt for when built as standalone binary. // diff --git a/mlir/include/mlir/Support/STLExtras.h b/mlir/include/mlir/Support/STLExtras.h index 9bae7acadd6..9a128611c6e 100644 --- a/mlir/include/mlir/Support/STLExtras.h +++ b/mlir/include/mlir/Support/STLExtras.h @@ -1,19 +1,10 @@ //===- STLExtras.h - STL-like extensions that are used by MLIR --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains stuff that should be arguably sunk down to the LLVM // Support/STLExtras.h file over time. diff --git a/mlir/include/mlir/Support/StorageUniquer.h b/mlir/include/mlir/Support/StorageUniquer.h index fe1f898957a..f505731a649 100644 --- a/mlir/include/mlir/Support/StorageUniquer.h +++ b/mlir/include/mlir/Support/StorageUniquer.h @@ -1,19 +1,10 @@ //===- StorageUniquer.h - Common Storage Class Uniquer ----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_SUPPORT_STORAGEUNIQUER_H #define MLIR_SUPPORT_STORAGEUNIQUER_H diff --git a/mlir/include/mlir/Support/StringExtras.h b/mlir/include/mlir/Support/StringExtras.h index 2f75c8e5d20..5fc6769c124 100644 --- a/mlir/include/mlir/Support/StringExtras.h +++ b/mlir/include/mlir/Support/StringExtras.h @@ -1,19 +1,10 @@ //===- StringExtras.h - String utilities used by MLIR -----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains string utility functions used within MLIR. // diff --git a/mlir/include/mlir/Support/ToolUtilities.h b/mlir/include/mlir/Support/ToolUtilities.h index 13a3742f849..3175ebbdba5 100644 --- a/mlir/include/mlir/Support/ToolUtilities.h +++ b/mlir/include/mlir/Support/ToolUtilities.h @@ -1,19 +1,10 @@ //===- ToolUtilities.h - MLIR Tool Utilities --------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares common utilities for implementing MLIR tools. // diff --git a/mlir/include/mlir/Support/TranslateClParser.h b/mlir/include/mlir/Support/TranslateClParser.h index ccd4fb97676..822d4b1a0a4 100644 --- a/mlir/include/mlir/Support/TranslateClParser.h +++ b/mlir/include/mlir/Support/TranslateClParser.h @@ -1,19 +1,10 @@ //===- TranslateClParser.h - Translations command line parser ---*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains custom command line parser for translations. // diff --git a/mlir/include/mlir/TableGen/Argument.h b/mlir/include/mlir/TableGen/Argument.h index 83909392a43..6a0787e1b6c 100644 --- a/mlir/include/mlir/TableGen/Argument.h +++ b/mlir/include/mlir/TableGen/Argument.h @@ -1,19 +1,10 @@ //===- Argument.h - Argument definitions ------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file contains definitions for TableGen operation's arguments. // Operation arguments fall into two categories: diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index 242376e24ff..747df945cea 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -1,19 +1,10 @@ //===- Attribute.h - Attribute wrapper class --------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Attribute wrapper to simplify using TableGen Record defining a MLIR // Attribute. diff --git a/mlir/include/mlir/TableGen/Constraint.h b/mlir/include/mlir/TableGen/Constraint.h index 17b60da6027..fb7c1d74b64 100644 --- a/mlir/include/mlir/TableGen/Constraint.h +++ b/mlir/include/mlir/TableGen/Constraint.h @@ -1,19 +1,10 @@ //===- Constraint.h - Constraint class --------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Constraint wrapper to simplify using TableGen Record for constraints. // diff --git a/mlir/include/mlir/TableGen/Dialect.h b/mlir/include/mlir/TableGen/Dialect.h index 6861da46e88..56d17f41b56 100644 --- a/mlir/include/mlir/TableGen/Dialect.h +++ b/mlir/include/mlir/TableGen/Dialect.h @@ -1,18 +1,9 @@ // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Dialect wrapper to simplify using TableGen Record defining a MLIR dialect. // diff --git a/mlir/include/mlir/TableGen/Format.h b/mlir/include/mlir/TableGen/Format.h index 6f02c283cad..160ba5f036a 100644 --- a/mlir/include/mlir/TableGen/Format.h +++ b/mlir/include/mlir/TableGen/Format.h @@ -1,19 +1,10 @@ //===- Format.h - Utilities for String Format -------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares utilities for formatting strings. They are specially // tailored to the needs of TableGen'ing op definitions and rewrite rules, diff --git a/mlir/include/mlir/TableGen/GenInfo.h b/mlir/include/mlir/TableGen/GenInfo.h index 0b0bd192ae5..3c732c2ff49 100644 --- a/mlir/include/mlir/TableGen/GenInfo.h +++ b/mlir/include/mlir/TableGen/GenInfo.h @@ -1,19 +1,10 @@ //===- GenInfo.h - Generator info -------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_TABLEGEN_GENINFO_H_ #define MLIR_TABLEGEN_GENINFO_H_ diff --git a/mlir/include/mlir/TableGen/GenNameParser.h b/mlir/include/mlir/TableGen/GenNameParser.h index 7b1e8a36d03..65f4a8ceace 100644 --- a/mlir/include/mlir/TableGen/GenNameParser.h +++ b/mlir/include/mlir/TableGen/GenNameParser.h @@ -1,19 +1,10 @@ //===- GenNameParser.h - Command line parser for generators -----*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // The GenNameParser class adds all passes linked in to the system that are // creatable to the tool. diff --git a/mlir/include/mlir/TableGen/OpInterfaces.h b/mlir/include/mlir/TableGen/OpInterfaces.h index 0959f6be9bb..9bf18161564 100644 --- a/mlir/include/mlir/TableGen/OpInterfaces.h +++ b/mlir/include/mlir/TableGen/OpInterfaces.h @@ -1,19 +1,10 @@ //===- OpInterfaces.h - OpInterfaces wrapper class --------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // OpInterfaces wrapper to simplify using TableGen OpInterfaces. // diff --git a/mlir/include/mlir/TableGen/OpTrait.h b/mlir/include/mlir/TableGen/OpTrait.h index c3ea9a7bda0..59fc7acbfd7 100644 --- a/mlir/include/mlir/TableGen/OpTrait.h +++ b/mlir/include/mlir/TableGen/OpTrait.h @@ -1,19 +1,10 @@ //===- OpTrait.h - OpTrait wrapper class ------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // OpTrait wrapper to simplify using TableGen Record defining an MLIR OpTrait. // diff --git a/mlir/include/mlir/TableGen/Operator.h b/mlir/include/mlir/TableGen/Operator.h index 89fd4ed8d2e..dd5ff353bf9 100644 --- a/mlir/include/mlir/TableGen/Operator.h +++ b/mlir/include/mlir/TableGen/Operator.h @@ -1,19 +1,10 @@ //===- Operator.h - Operator class ------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Operator wrapper to simplify using TableGen Record defining a MLIR Op. // diff --git a/mlir/include/mlir/TableGen/Pattern.h b/mlir/include/mlir/TableGen/Pattern.h index 8bd1c918e31..bf89f6e7c82 100644 --- a/mlir/include/mlir/TableGen/Pattern.h +++ b/mlir/include/mlir/TableGen/Pattern.h @@ -1,19 +1,10 @@ //===- Pattern.h - Pattern wrapper class ------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Pattern wrapper class to simplify using TableGen Record defining a MLIR // Pattern. diff --git a/mlir/include/mlir/TableGen/Predicate.h b/mlir/include/mlir/TableGen/Predicate.h index 49f7ebcfe52..045b7fece2e 100644 --- a/mlir/include/mlir/TableGen/Predicate.h +++ b/mlir/include/mlir/TableGen/Predicate.h @@ -1,19 +1,10 @@ //===- Predicate.h - Predicate class ----------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Wrapper around predicates defined in TableGen. // diff --git a/mlir/include/mlir/TableGen/Region.h b/mlir/include/mlir/TableGen/Region.h index 21dffe687f4..778f68622bf 100644 --- a/mlir/include/mlir/TableGen/Region.h +++ b/mlir/include/mlir/TableGen/Region.h @@ -1,19 +1,10 @@ //===- TGRegion.h - TableGen region definitions -----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_TABLEGEN_REGION_H_ #define MLIR_TABLEGEN_REGION_H_ diff --git a/mlir/include/mlir/TableGen/Type.h b/mlir/include/mlir/TableGen/Type.h index 03cbd104dc1..35de70f52fd 100644 --- a/mlir/include/mlir/TableGen/Type.h +++ b/mlir/include/mlir/TableGen/Type.h @@ -1,19 +1,10 @@ //===- Type.h - Type class --------------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Type wrapper to simplify using TableGen Record defining a MLIR Type. // diff --git a/mlir/include/mlir/Target/LLVMIR.h b/mlir/include/mlir/Target/LLVMIR.h index 7ed7b39c4db..1cdc26ccee6 100644 --- a/mlir/include/mlir/Target/LLVMIR.h +++ b/mlir/include/mlir/Target/LLVMIR.h @@ -1,19 +1,10 @@ //===- LLVMIR.h - MLIR to LLVM IR conversion --------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares the entry point for the MLIR to LLVM IR conversion. // diff --git a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h index 7464e2a347d..4a5010ea09a 100644 --- a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h +++ b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h @@ -1,19 +1,10 @@ //===- ModuleTranslation.h - MLIR to LLVM conversion ------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the translation between an MLIR LLVM dialect module and // the corresponding LLVMIR module. It only handles core LLVM IR operations. diff --git a/mlir/include/mlir/Target/NVVMIR.h b/mlir/include/mlir/Target/NVVMIR.h index ec9858e0fd7..377ee16d4e4 100644 --- a/mlir/include/mlir/Target/NVVMIR.h +++ b/mlir/include/mlir/Target/NVVMIR.h @@ -1,19 +1,10 @@ //===- NVVMIR.h - MLIR to LLVM + NVVM IR conversion -------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares the entry point for the MLIR to LLVM + NVVM IR conversion. // diff --git a/mlir/include/mlir/Target/ROCDLIR.h b/mlir/include/mlir/Target/ROCDLIR.h index fd00e9458ef..25937eedd5a 100644 --- a/mlir/include/mlir/Target/ROCDLIR.h +++ b/mlir/include/mlir/Target/ROCDLIR.h @@ -1,19 +1,10 @@ //===- ROCDLIR.h - MLIR to LLVM + ROCDL IR conversion -----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares the entry point for the MLIR to LLVM + ROCDL IR // conversion. diff --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h index f9f1207c0a0..dca26348689 100644 --- a/mlir/include/mlir/Transforms/DialectConversion.h +++ b/mlir/include/mlir/Transforms/DialectConversion.h @@ -1,19 +1,10 @@ //===- DialectConversion.h - MLIR dialect conversion pass -------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares a generic pass for converting between MLIR dialects. // diff --git a/mlir/include/mlir/Transforms/FoldUtils.h b/mlir/include/mlir/Transforms/FoldUtils.h index 65dd1b6df16..ed18619c44a 100644 --- a/mlir/include/mlir/Transforms/FoldUtils.h +++ b/mlir/include/mlir/Transforms/FoldUtils.h @@ -1,19 +1,10 @@ //===- FoldUtils.h - Operation Fold Utilities -------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file declares various operation folding utilities. These // utilities are intended to be used by passes to unify and simply their logic. diff --git a/mlir/include/mlir/Transforms/InliningUtils.h b/mlir/include/mlir/Transforms/InliningUtils.h index 47c4f48f468..e4739bba66b 100644 --- a/mlir/include/mlir/Transforms/InliningUtils.h +++ b/mlir/include/mlir/Transforms/InliningUtils.h @@ -1,19 +1,10 @@ //===- InliningUtils.h - Inliner utilities ----------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file defines interfaces for various inlining utility methods. // diff --git a/mlir/include/mlir/Transforms/LoopFusionUtils.h b/mlir/include/mlir/Transforms/LoopFusionUtils.h index af84b8911eb..4c307ffeda3 100644 --- a/mlir/include/mlir/Transforms/LoopFusionUtils.h +++ b/mlir/include/mlir/Transforms/LoopFusionUtils.h @@ -1,19 +1,10 @@ //===- LoopFusionUtils.h - Loop fusion utilities ----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file defines prototypes for various loop fusion utility // methods: these are not passes by themselves but are used either by passes, diff --git a/mlir/include/mlir/Transforms/LoopLikeInterface.h b/mlir/include/mlir/Transforms/LoopLikeInterface.h index a8bc0d11378..cba9ae78122 100644 --- a/mlir/include/mlir/Transforms/LoopLikeInterface.h +++ b/mlir/include/mlir/Transforms/LoopLikeInterface.h @@ -1,19 +1,10 @@ //===- LoopLikeInterface.h - Loop-like operations interface ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the operation interface for loop like operations. // diff --git a/mlir/include/mlir/Transforms/LoopLikeInterface.td b/mlir/include/mlir/Transforms/LoopLikeInterface.td index 583cfe26d87..089a3e19c35 100644 --- a/mlir/include/mlir/Transforms/LoopLikeInterface.td +++ b/mlir/include/mlir/Transforms/LoopLikeInterface.td @@ -1,19 +1,10 @@ //===- LoopLikeInterface.td - LoopLike interface -----------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines the interface for loop-like operations as used by LICM. // diff --git a/mlir/include/mlir/Transforms/LoopUtils.h b/mlir/include/mlir/Transforms/LoopUtils.h index 37434ea2ea8..a08a3fc8307 100644 --- a/mlir/include/mlir/Transforms/LoopUtils.h +++ b/mlir/include/mlir/Transforms/LoopUtils.h @@ -1,19 +1,10 @@ //===- LoopUtils.h - Loop transformation utilities --------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file defines prototypes for various loop transformation utility // methods: these are not passes by themselves but are used either by passes, diff --git a/mlir/include/mlir/Transforms/Passes.h b/mlir/include/mlir/Transforms/Passes.h index 5480a9a4fe1..1ea8f060e39 100644 --- a/mlir/include/mlir/Transforms/Passes.h +++ b/mlir/include/mlir/Transforms/Passes.h @@ -1,19 +1,10 @@ //===- Passes.h - Pass Entrypoints ------------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file defines prototypes that expose pass constructors in the loop // transformation library. diff --git a/mlir/include/mlir/Transforms/RegionUtils.h b/mlir/include/mlir/Transforms/RegionUtils.h index 63236d6a5a0..9639dfad857 100644 --- a/mlir/include/mlir/Transforms/RegionUtils.h +++ b/mlir/include/mlir/Transforms/RegionUtils.h @@ -1,19 +1,10 @@ //===- RegionUtils.h - Region-related transformation utilities --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_TRANSFORMS_REGIONUTILS_H_ #define MLIR_TRANSFORMS_REGIONUTILS_H_ diff --git a/mlir/include/mlir/Transforms/SideEffectsInterface.h b/mlir/include/mlir/Transforms/SideEffectsInterface.h index 443596b60c1..69c2a272c70 100644 --- a/mlir/include/mlir/Transforms/SideEffectsInterface.h +++ b/mlir/include/mlir/Transforms/SideEffectsInterface.h @@ -1,19 +1,10 @@ //===- SideEffectsInterface.h - dialect interface modeling side effects ---===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file specifies a dialect interface to model side-effects. // diff --git a/mlir/include/mlir/Transforms/Utils.h b/mlir/include/mlir/Transforms/Utils.h index 02c368ec496..a8268c1daa2 100644 --- a/mlir/include/mlir/Transforms/Utils.h +++ b/mlir/include/mlir/Transforms/Utils.h @@ -1,19 +1,10 @@ //===- Utils.h - General transformation utilities ---------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This header file defines prototypes for various transformation utilities for // memref's and non-loop IR structures. These are not passes by themselves but diff --git a/mlir/include/mlir/Transforms/ViewOpGraph.h b/mlir/include/mlir/Transforms/ViewOpGraph.h index 41f5eb5838d..c1782081adc 100644 --- a/mlir/include/mlir/Transforms/ViewOpGraph.h +++ b/mlir/include/mlir/Transforms/ViewOpGraph.h @@ -1,19 +1,10 @@ //===- ViewOpGraph.h - View/write op graphviz graphs ------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines interface to produce Graphviz outputs of MLIR op within block. // diff --git a/mlir/include/mlir/Transforms/ViewRegionGraph.h b/mlir/include/mlir/Transforms/ViewRegionGraph.h index 4378d38fae1..e8c47500c74 100644 --- a/mlir/include/mlir/Transforms/ViewRegionGraph.h +++ b/mlir/include/mlir/Transforms/ViewRegionGraph.h @@ -1,19 +1,10 @@ //===- ViewRegionGraph.h - View/write graphviz graphs -----------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines interface to produce Graphviz outputs of MLIR Regions. // diff --git a/mlir/include/mlir/Translation.h b/mlir/include/mlir/Translation.h index 0bf8178146a..9244b971753 100644 --- a/mlir/include/mlir/Translation.h +++ b/mlir/include/mlir/Translation.h @@ -1,19 +1,10 @@ //===- Translation.h - Translation registry ---------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Registry for user-provided translations. // diff --git a/mlir/lib/Analysis/AffineAnalysis.cpp b/mlir/lib/Analysis/AffineAnalysis.cpp index 60b2f17292b..27aa0748711 100644 --- a/mlir/lib/Analysis/AffineAnalysis.cpp +++ b/mlir/lib/Analysis/AffineAnalysis.cpp @@ -1,19 +1,10 @@ //===- AffineAnalysis.cpp - Affine structures analysis routines -----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements miscellaneous analysis routines for affine structures // (expressions, maps, sets), and other utilities relying on such analysis. diff --git a/mlir/lib/Analysis/AffineStructures.cpp b/mlir/lib/Analysis/AffineStructures.cpp index 21c2830c016..7ab547483cd 100644 --- a/mlir/lib/Analysis/AffineStructures.cpp +++ b/mlir/lib/Analysis/AffineStructures.cpp @@ -1,19 +1,10 @@ //===- AffineStructures.cpp - MLIR Affine Structures Class-----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Structures for affine/polyhedral analysis of MLIR functions. // diff --git a/mlir/lib/Analysis/CallGraph.cpp b/mlir/lib/Analysis/CallGraph.cpp index 6ec7c059526..65f6e83bcdf 100644 --- a/mlir/lib/Analysis/CallGraph.cpp +++ b/mlir/lib/Analysis/CallGraph.cpp @@ -1,19 +1,10 @@ //===- CallGraph.cpp - CallGraph analysis for MLIR ------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains interfaces and analyses for defining a nested callgraph. // diff --git a/mlir/lib/Analysis/Dominance.cpp b/mlir/lib/Analysis/Dominance.cpp index 532972b771b..060a505593a 100644 --- a/mlir/lib/Analysis/Dominance.cpp +++ b/mlir/lib/Analysis/Dominance.cpp @@ -1,19 +1,10 @@ //===- Dominance.cpp - Dominator analysis for CFGs ------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Implementation of dominance related classes and instantiations of extern // templates. diff --git a/mlir/lib/Analysis/InferTypeOpInterface.cpp b/mlir/lib/Analysis/InferTypeOpInterface.cpp index cbbd44681ba..2e52de2b3fa 100644 --- a/mlir/lib/Analysis/InferTypeOpInterface.cpp +++ b/mlir/lib/Analysis/InferTypeOpInterface.cpp @@ -1,19 +1,10 @@ //===- InferTypeOpInterface.cpp - Infer Type Interfaces ---------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains the definitions of the infer op interfaces defined in // `InferTypeOpInterface.td`. diff --git a/mlir/lib/Analysis/Liveness.cpp b/mlir/lib/Analysis/Liveness.cpp index edb18e5645d..bef0b9fa385 100644 --- a/mlir/lib/Analysis/Liveness.cpp +++ b/mlir/lib/Analysis/Liveness.cpp @@ -1,19 +1,10 @@ //===- Liveness.cpp - Liveness analysis for MLIR --------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Implementation of the liveness analysis. // diff --git a/mlir/lib/Analysis/LoopAnalysis.cpp b/mlir/lib/Analysis/LoopAnalysis.cpp index 9dfbfe0c542..5499f887c1e 100644 --- a/mlir/lib/Analysis/LoopAnalysis.cpp +++ b/mlir/lib/Analysis/LoopAnalysis.cpp @@ -1,19 +1,10 @@ //===- LoopAnalysis.cpp - Misc loop analysis routines //-------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements miscellaneous loop analysis routines. // diff --git a/mlir/lib/Analysis/MemRefBoundCheck.cpp b/mlir/lib/Analysis/MemRefBoundCheck.cpp index 4696ce64c22..1f7c1a1ae31 100644 --- a/mlir/lib/Analysis/MemRefBoundCheck.cpp +++ b/mlir/lib/Analysis/MemRefBoundCheck.cpp @@ -1,19 +1,10 @@ //===- MemRefBoundCheck.cpp - MLIR Affine Structures Class ----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to check memref accesses for out of bound // accesses. diff --git a/mlir/lib/Analysis/NestedMatcher.cpp b/mlir/lib/Analysis/NestedMatcher.cpp index 5f2be48b327..97eaafd37ce 100644 --- a/mlir/lib/Analysis/NestedMatcher.cpp +++ b/mlir/lib/Analysis/NestedMatcher.cpp @@ -1,19 +1,10 @@ //===- NestedMatcher.cpp - NestedMatcher Impl ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Analysis/NestedMatcher.h" #include "mlir/Dialect/AffineOps/AffineOps.h" diff --git a/mlir/lib/Analysis/OpStats.cpp b/mlir/lib/Analysis/OpStats.cpp index 1c9f6211a84..dbd938710ef 100644 --- a/mlir/lib/Analysis/OpStats.cpp +++ b/mlir/lib/Analysis/OpStats.cpp @@ -1,19 +1,10 @@ //===- OpStats.cpp - Prints stats of operations in module -----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Module.h" #include "mlir/IR/Operation.h" diff --git a/mlir/lib/Analysis/SliceAnalysis.cpp b/mlir/lib/Analysis/SliceAnalysis.cpp index b09bddddd66..befe3d39759 100644 --- a/mlir/lib/Analysis/SliceAnalysis.cpp +++ b/mlir/lib/Analysis/SliceAnalysis.cpp @@ -1,19 +1,10 @@ //===- UseDefAnalysis.cpp - Analysis for Transitive UseDef chains ---------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements Analysis functions specific to slicing in Function. // diff --git a/mlir/lib/Analysis/TestMemRefDependenceCheck.cpp b/mlir/lib/Analysis/TestMemRefDependenceCheck.cpp index 80a579d163f..c6d7519740e 100644 --- a/mlir/lib/Analysis/TestMemRefDependenceCheck.cpp +++ b/mlir/lib/Analysis/TestMemRefDependenceCheck.cpp @@ -1,19 +1,10 @@ //===- TestMemRefDependenceCheck.cpp - Test dep analysis ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to run pair-wise memref access dependence checks. // diff --git a/mlir/lib/Analysis/TestParallelismDetection.cpp b/mlir/lib/Analysis/TestParallelismDetection.cpp index a9f9ea94a45..6cfc5431df3 100644 --- a/mlir/lib/Analysis/TestParallelismDetection.cpp +++ b/mlir/lib/Analysis/TestParallelismDetection.cpp @@ -1,19 +1,10 @@ //===- ParallelismDetection.cpp - Parallelism Detection pass ------------*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to detect parallel affine 'affine.for' ops. // diff --git a/mlir/lib/Analysis/Utils.cpp b/mlir/lib/Analysis/Utils.cpp index 73aa07e7d7b..0e7d10e78cf 100644 --- a/mlir/lib/Analysis/Utils.cpp +++ b/mlir/lib/Analysis/Utils.cpp @@ -1,19 +1,10 @@ //===- Utils.cpp ---- Misc utilities for analysis -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements miscellaneous analysis routines for non-loop IR // structures. diff --git a/mlir/lib/Analysis/VectorAnalysis.cpp b/mlir/lib/Analysis/VectorAnalysis.cpp index a7917eba503..cd77eff9e40 100644 --- a/mlir/lib/Analysis/VectorAnalysis.cpp +++ b/mlir/lib/Analysis/VectorAnalysis.cpp @@ -1,19 +1,10 @@ //===- VectorAnalysis.cpp - Analysis for Vectorization --------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Analysis/AffineAnalysis.h" #include "mlir/Analysis/LoopAnalysis.h" diff --git a/mlir/lib/Analysis/Verifier.cpp b/mlir/lib/Analysis/Verifier.cpp index be499a93898..d4861b1a2e7 100644 --- a/mlir/lib/Analysis/Verifier.cpp +++ b/mlir/lib/Analysis/Verifier.cpp @@ -1,19 +1,10 @@ //===- Verifier.cpp - MLIR Verifier Implementation ------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the verify() methods on the various IR types, performing // (potentially expensive) checks on the holistic structure of the code. This diff --git a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp index 144b4a97e87..ce1e5c4a2af 100644 --- a/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp +++ b/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp @@ -1,19 +1,10 @@ //===- AffineToStandard.cpp - Lower affine constructs to primitives -------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file lowers affine constructs (If and For statements, AffineApply // operations) within a function into their standard If and For equivalent ops. diff --git a/mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h b/mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h index a408ab5b5d9..2ca9717ad86 100644 --- a/mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h +++ b/mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h @@ -1,19 +1,10 @@ //===- IndexIntrinsicsOpLowering.h - GPU IndexOps Lowering class *- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_GPUCOMMON_INDEXINTRINSICSOPLOWERING_H_ #define MLIR_CONVERSION_GPUCOMMON_INDEXINTRINSICSOPLOWERING_H_ diff --git a/mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h b/mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h index 3ab8e75633e..97881d359f6 100644 --- a/mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h +++ b/mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h @@ -1,19 +1,10 @@ //===- OpToFuncCallLowering.h - GPU ops lowering to custom calls *- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CONVERSION_GPUCOMMON_OPTOFUNCCALLLOWERING_H_ #define MLIR_CONVERSION_GPUCOMMON_OPTOFUNCCALLLOWERING_H_ diff --git a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp index a91c43e1e92..66a2e66f99a 100644 --- a/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp +++ b/mlir/lib/Conversion/GPUToCUDA/ConvertKernelFuncToCubin.cpp @@ -1,19 +1,10 @@ //===- ConvertKernelFuncToCubin.cpp - MLIR GPU lowering passes ------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to convert gpu kernel functions into a // corresponding binary blob that can be executed on a CUDA GPU. Currently diff --git a/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp b/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp index 840ad6ba701..3383cf13d36 100644 --- a/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp +++ b/mlir/lib/Conversion/GPUToCUDA/ConvertLaunchFuncToCudaCalls.cpp @@ -1,19 +1,10 @@ //===- ConvertLaunchFuncToCudaCalls.cpp - MLIR CUDA lowering passes -------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to convert gpu.launch_func op into a sequence of // CUDA runtime calls. As the CUDA runtime does not have a stable published ABI, diff --git a/mlir/lib/Conversion/GPUToNVVM/GPUToNVVM.td b/mlir/lib/Conversion/GPUToNVVM/GPUToNVVM.td index 8c27ba49686..0a6aec07041 100644 --- a/mlir/lib/Conversion/GPUToNVVM/GPUToNVVM.td +++ b/mlir/lib/Conversion/GPUToNVVM/GPUToNVVM.td @@ -1,19 +1,10 @@ //==-- GPUToNVVM.td - GPU Ops to NVVM Patterns ---------------*- tablegen -*==// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Defines Patterns to lower GPU ops to NVVM. // diff --git a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp index bf18ea03dab..e15ad823a2b 100644 --- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp +++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp @@ -1,19 +1,10 @@ //===- LowerGpuOpsToNVVMOps.cpp - MLIR GPU to NVVM lowering passes --------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to generate NVVMIR operations for higher-level // GPU operations. diff --git a/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp b/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp index 59892dbcee8..83770641bd4 100644 --- a/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp +++ b/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp @@ -1,19 +1,10 @@ //===- LowerGpuOpsToROCDLOps.cpp - MLIR GPU to ROCDL lowering passes ------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to generate ROCDLIR operations for higher-level // GPU operations. diff --git a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp index 0c34fc2b8e1..95c46853b1f 100644 --- a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp +++ b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp @@ -1,19 +1,10 @@ //===- ConvertGPUToSPIRV.cpp - Convert GPU ops to SPIR-V dialect ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the conversion patterns from GPU ops to SPIR-V dialect. // diff --git a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp index b8fe27e92a2..115096003e1 100644 --- a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp +++ b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp @@ -1,19 +1,10 @@ //===- ConvertGPUToSPIRVPass.cpp - GPU to SPIR-V dialect lowering passes --===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to convert a kernel function in the GPU Dialect // into a spv.module operation diff --git a/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp b/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp index 8b6b9fb7930..1b70df6f8bd 100644 --- a/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp +++ b/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp @@ -1,19 +1,10 @@ //===- LinalgToLLVM.cpp - conversion from Linalg to LLVM dialect ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h" #include "mlir/Conversion/AffineToStandard/AffineToStandard.h" diff --git a/mlir/lib/Conversion/LoopToStandard/ConvertLoopToStandard.cpp b/mlir/lib/Conversion/LoopToStandard/ConvertLoopToStandard.cpp index d8df7487e71..59dac73de9c 100644 --- a/mlir/lib/Conversion/LoopToStandard/ConvertLoopToStandard.cpp +++ b/mlir/lib/Conversion/LoopToStandard/ConvertLoopToStandard.cpp @@ -1,19 +1,10 @@ //===- ConvertLoopToStandard.cpp - ControlFlow to CFG conversion ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to convert loop.for, loop.if and loop.terminator // ops into standard CFG ops. diff --git a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp index 3cbce7caa76..24bb8ffc462 100644 --- a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp +++ b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp @@ -1,19 +1,10 @@ //===- LoopsToGPU.cpp - Convert an affine loop nest to a GPU kernel -------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This implements a straightforward conversion of an loop nest into a GPU // kernel. The caller is expected to guarantee that the conversion is correct diff --git a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp index 63836883512..4dfd26a4392 100644 --- a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp +++ b/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp @@ -1,19 +1,10 @@ //===- LoopsToGPUPass.cpp - Convert a loop nest to a GPU kernel -----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h" #include "mlir/Conversion/LoopsToGPU/LoopsToGPU.h" diff --git a/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp index 67b545c4ec8..160678efe9f 100644 --- a/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp @@ -1,19 +1,10 @@ //===- ConvertStandardToLLVM.cpp - Standard to LLVM dialect conversion-----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to convert MLIR standard and builtin dialects // into the LLVM IR dialect. diff --git a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp index f7b0c9cb9bc..af1c92ef11d 100644 --- a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp +++ b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp @@ -1,19 +1,10 @@ //===- ConvertStandardToSPIRV.cpp - Standard to SPIR-V dialect conversion--===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements patterns to convert Standard Ops to the SPIR-V dialect. // diff --git a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp index 113789abe8a..41deec1f6ab 100644 --- a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp +++ b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp @@ -1,19 +1,10 @@ //===- ConvertStandardToSPIRVPass.cpp - Convert Std Ops to SPIR-V Ops -----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to convert MLIR standard ops into the SPIR-V // ops. diff --git a/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp b/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp index 2e1a7f09ff8..5d693336c3f 100644 --- a/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp +++ b/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp @@ -1,19 +1,10 @@ //===- LegalizeStandardForSPIRV.cpp - Legalize ops for SPIR-V lowering ----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This transformation pass legalizes operations before the conversion to SPIR-V // dialect to handle ops that cannot be lowered directly. diff --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp index 5099cb01bbc..56005220d3f 100644 --- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp +++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp @@ -1,19 +1,10 @@ //===- VectorToLLVM.cpp - Conversion from Vector to the LLVM dialect ------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h" diff --git a/mlir/lib/Conversion/VectorToLoops/ConvertVectorToLoops.cpp b/mlir/lib/Conversion/VectorToLoops/ConvertVectorToLoops.cpp index 33778e42329..3ed031b985a 100644 --- a/mlir/lib/Conversion/VectorToLoops/ConvertVectorToLoops.cpp +++ b/mlir/lib/Conversion/VectorToLoops/ConvertVectorToLoops.cpp @@ -1,19 +1,10 @@ //===- VectorToLoops.cpp - Conversion from Vector to mix of Loops and Std -===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements target-dependent lowering of vector transfer operations. // diff --git a/mlir/lib/Dialect/AffineOps/AffineOps.cpp b/mlir/lib/Dialect/AffineOps/AffineOps.cpp index 3a21de389c7..bfe72101e85 100644 --- a/mlir/lib/Dialect/AffineOps/AffineOps.cpp +++ b/mlir/lib/Dialect/AffineOps/AffineOps.cpp @@ -1,19 +1,10 @@ //===- AffineOps.cpp - MLIR Affine Operations -----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/AffineOps/AffineOps.h" #include "mlir/Dialect/StandardOps/Ops.h" diff --git a/mlir/lib/Dialect/AffineOps/DialectRegistration.cpp b/mlir/lib/Dialect/AffineOps/DialectRegistration.cpp index 9197e3c619f..775e25ec8ea 100644 --- a/mlir/lib/Dialect/AffineOps/DialectRegistration.cpp +++ b/mlir/lib/Dialect/AffineOps/DialectRegistration.cpp @@ -1,19 +1,10 @@ //===- DialectRegistration.cpp - Register Affine Op dialect ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/AffineOps/AffineOps.h" using namespace mlir; diff --git a/mlir/lib/Dialect/FxpMathOps/IR/DialectRegistration.cpp b/mlir/lib/Dialect/FxpMathOps/IR/DialectRegistration.cpp index aa6782e1464..57d5ae8e789 100644 --- a/mlir/lib/Dialect/FxpMathOps/IR/DialectRegistration.cpp +++ b/mlir/lib/Dialect/FxpMathOps/IR/DialectRegistration.cpp @@ -1,19 +1,10 @@ //===- DialectRegistration.cpp - Register FxpMathOps dialect --------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/FxpMathOps/FxpMathOps.h" diff --git a/mlir/lib/Dialect/FxpMathOps/IR/FxpMathOps.cpp b/mlir/lib/Dialect/FxpMathOps/IR/FxpMathOps.cpp index 18c07b07117..30e7dc04104 100644 --- a/mlir/lib/Dialect/FxpMathOps/IR/FxpMathOps.cpp +++ b/mlir/lib/Dialect/FxpMathOps/IR/FxpMathOps.cpp @@ -1,19 +1,10 @@ //===- FxpMathOps.cpp - Op implementation for FxpMathOps ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/FxpMathOps/FxpMathOps.h" #include "mlir/Dialect/QuantOps/QuantTypes.h" diff --git a/mlir/lib/Dialect/FxpMathOps/Transforms/LowerUniformRealMath.cpp b/mlir/lib/Dialect/FxpMathOps/Transforms/LowerUniformRealMath.cpp index e1951ff900b..725751eb6c1 100644 --- a/mlir/lib/Dialect/FxpMathOps/Transforms/LowerUniformRealMath.cpp +++ b/mlir/lib/Dialect/FxpMathOps/Transforms/LowerUniformRealMath.cpp @@ -1,19 +1,10 @@ //===- LowerUniformRealMath.cpp ------------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "UniformKernelUtils.h" diff --git a/mlir/lib/Dialect/FxpMathOps/Transforms/UniformKernelUtils.h b/mlir/lib/Dialect/FxpMathOps/Transforms/UniformKernelUtils.h index 57a8422b362..bce5285a8b0 100644 --- a/mlir/lib/Dialect/FxpMathOps/Transforms/UniformKernelUtils.h +++ b/mlir/lib/Dialect/FxpMathOps/Transforms/UniformKernelUtils.h @@ -1,19 +1,10 @@ //===- UniformKernelUtils.h - Utilities for lowering uniform math - C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_FXPMATH_UNIFORM_KERNEL_UTILS_H_ #define MLIR_FXPMATH_UNIFORM_KERNEL_UTILS_H_ diff --git a/mlir/lib/Dialect/GPU/IR/DialectRegistration.cpp b/mlir/lib/Dialect/GPU/IR/DialectRegistration.cpp index af50d0270cf..511c69e0695 100644 --- a/mlir/lib/Dialect/GPU/IR/DialectRegistration.cpp +++ b/mlir/lib/Dialect/GPU/IR/DialectRegistration.cpp @@ -1,19 +1,10 @@ //===- DialectRegistration.cpp - MLIR GPU dialect registration ------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/GPU/GPUDialect.h" diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp index 349c1fa4644..62d6a4b7ea4 100644 --- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp +++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp @@ -1,19 +1,10 @@ //===- GPUDialect.cpp - MLIR Dialect for GPU Kernels implementation -------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the GPU kernel-related dialect and its operations. // diff --git a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp index 8f5f50e4909..6a7cd290dd2 100644 --- a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp @@ -1,19 +1,10 @@ //===- KernelOutlining.cpp - Implementation of GPU kernel outlining -------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the GPU dialect kernel outlining pass. // diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp index b94ee335bd2..b8d2d242657 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -1,19 +1,10 @@ //===- LLVMDialect.cpp - LLVM IR Ops and Dialect registration -------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the types and operation details for the LLVM IR dialect in // MLIR, and the LLVM IR dialect. It also registers the dialect. diff --git a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp index e4708fbe535..3a8e84ea918 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp @@ -1,19 +1,10 @@ //===- NVVMDialect.cpp - NVVM IR Ops and Dialect registration -------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the types and operation details for the NVVM IR dialect in // MLIR, and the LLVM IR dialect. It also registers the dialect. diff --git a/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp index 30c55b52e59..c11572cf5a2 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp @@ -1,19 +1,10 @@ //===- ROCDLDialect.cpp - ROCDL IR Ops and Dialect registration -----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the types and operation details for the ROCDL IR dialect in // MLIR, and the LLVM IR dialect. It also registers the dialect. diff --git a/mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp b/mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp index ee122e16037..5fbbdea60c2 100644 --- a/mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp +++ b/mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp @@ -1,19 +1,10 @@ //===- DependenceAnalysis.cpp - Dependence analysis on SSA views ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements view-based alias and dependence analyses. // diff --git a/mlir/lib/Dialect/Linalg/EDSC/Builders.cpp b/mlir/lib/Dialect/Linalg/EDSC/Builders.cpp index 7b530d7f0df..af5e576b290 100644 --- a/mlir/lib/Dialect/Linalg/EDSC/Builders.cpp +++ b/mlir/lib/Dialect/Linalg/EDSC/Builders.cpp @@ -1,19 +1,10 @@ //===- Builders.cpp - MLIR Declarative Linalg Builders --------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/Linalg/EDSC/Builders.h" #include "mlir/Dialect/Linalg/EDSC/Intrinsics.h" diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp index c5f30b7e10b..10c37c0ec43 100644 --- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp @@ -1,19 +1,10 @@ //===- LinalgOps.cpp - Implementation of the linalg operations ------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a the Linalg operations. // diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgTypes.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgTypes.cpp index 263a64c5cdc..32b1620f67c 100644 --- a/mlir/lib/Dialect/Linalg/IR/LinalgTypes.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgTypes.cpp @@ -1,19 +1,10 @@ //===- Dialect.cpp - Implementation of the linalg dialect and types -------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the Linalg dialect types and dialect. // diff --git a/mlir/lib/Dialect/Linalg/LinalgRegistration.cpp b/mlir/lib/Dialect/Linalg/LinalgRegistration.cpp index df21ffa88ac..768b18b57f0 100644 --- a/mlir/lib/Dialect/Linalg/LinalgRegistration.cpp +++ b/mlir/lib/Dialect/Linalg/LinalgRegistration.cpp @@ -1,19 +1,10 @@ //===- LinalgRegistration.cpp - Register the linalg dialect statically ----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/Linalg/IR/LinalgOps.h" #include "mlir/Dialect/Linalg/IR/LinalgTypes.h" diff --git a/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp b/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp index 49cea7e4170..27dcf663d23 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp @@ -1,19 +1,10 @@ //===- Fusion.cpp - Implementation of linalg Fusion -----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the linalg dialect Fusion pass. // diff --git a/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp b/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp index e468c19a0b4..0f333791dd7 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp @@ -1,19 +1,10 @@ //===- LowerToLoops.cpp - conversion from Linalg library ops to loops------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/AffineOps/AffineOps.h" #include "mlir/Dialect/Linalg/IR/LinalgOps.h" diff --git a/mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp b/mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp index 999406e05cf..451803797f4 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp @@ -1,19 +1,10 @@ //===- LinalgTransforms.cpp - Linalg transformations as patterns ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements logic for transforming Linalg operations. // diff --git a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp index b1dae455194..08bc1518a19 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp @@ -1,19 +1,10 @@ //===- Promotion.cpp - Implementation of linalg Promotion -----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the linalg dialect Promotion pass. // diff --git a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp index 07d559918cf..99645a23100 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp @@ -1,19 +1,10 @@ //===- Tiling.cpp - Implementation of linalg Tiling -----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the linalg dialect Tiling pass. // diff --git a/mlir/lib/Dialect/Linalg/Utils/Utils.cpp b/mlir/lib/Dialect/Linalg/Utils/Utils.cpp index 125937807f4..ae02af0ecc8 100644 --- a/mlir/lib/Dialect/Linalg/Utils/Utils.cpp +++ b/mlir/lib/Dialect/Linalg/Utils/Utils.cpp @@ -1,19 +1,10 @@ //===- Utils.cpp - Utilities to support the Linalg dialect ----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements utilities for the Linalg dialect. // diff --git a/mlir/lib/Dialect/LoopOps/DialectRegistration.cpp b/mlir/lib/Dialect/LoopOps/DialectRegistration.cpp index 5724402e690..6564e78855c 100644 --- a/mlir/lib/Dialect/LoopOps/DialectRegistration.cpp +++ b/mlir/lib/Dialect/LoopOps/DialectRegistration.cpp @@ -1,19 +1,10 @@ //===- DialectRegistration.cpp - Register loop dialect --------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/LoopOps/LoopOps.h" using namespace mlir; diff --git a/mlir/lib/Dialect/LoopOps/LoopOps.cpp b/mlir/lib/Dialect/LoopOps/LoopOps.cpp index 9610a1ac270..d3040c1bbb2 100644 --- a/mlir/lib/Dialect/LoopOps/LoopOps.cpp +++ b/mlir/lib/Dialect/LoopOps/LoopOps.cpp @@ -1,19 +1,10 @@ //===- Ops.cpp - Loop MLIR Operations -------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/LoopOps/LoopOps.h" #include "mlir/Dialect/StandardOps/Ops.h" diff --git a/mlir/lib/Dialect/QuantOps/IR/DialectRegistration.cpp b/mlir/lib/Dialect/QuantOps/IR/DialectRegistration.cpp index b071248f4bb..1738d6d7277 100644 --- a/mlir/lib/Dialect/QuantOps/IR/DialectRegistration.cpp +++ b/mlir/lib/Dialect/QuantOps/IR/DialectRegistration.cpp @@ -1,19 +1,10 @@ //===- DialectRegistration.cpp - Register Quantization dialect ------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/QuantOps/QuantOps.h" diff --git a/mlir/lib/Dialect/QuantOps/IR/QuantOps.cpp b/mlir/lib/Dialect/QuantOps/IR/QuantOps.cpp index 51f19940dcb..faeff246bd2 100644 --- a/mlir/lib/Dialect/QuantOps/IR/QuantOps.cpp +++ b/mlir/lib/Dialect/QuantOps/IR/QuantOps.cpp @@ -1,19 +1,10 @@ //===- QuantOps.cpp - Quantization Type and Ops Implementation --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/QuantOps/QuantOps.h" #include "TypeDetail.h" diff --git a/mlir/lib/Dialect/QuantOps/IR/QuantTypes.cpp b/mlir/lib/Dialect/QuantOps/IR/QuantTypes.cpp index bc8290cda16..2e33963602c 100644 --- a/mlir/lib/Dialect/QuantOps/IR/QuantTypes.cpp +++ b/mlir/lib/Dialect/QuantOps/IR/QuantTypes.cpp @@ -1,19 +1,10 @@ //===- QuantOps.cpp - Quantization Type and Ops Implementation --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/QuantOps/QuantTypes.h" #include "TypeDetail.h" diff --git a/mlir/lib/Dialect/QuantOps/IR/TypeDetail.h b/mlir/lib/Dialect/QuantOps/IR/TypeDetail.h index 13a88da3043..801a0de32b4 100644 --- a/mlir/lib/Dialect/QuantOps/IR/TypeDetail.h +++ b/mlir/lib/Dialect/QuantOps/IR/TypeDetail.h @@ -1,19 +1,10 @@ //===- TypeDetail.h - QuantOps Type detail ----------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef TYPE_DETAIL_H_ #define TYPE_DETAIL_H_ diff --git a/mlir/lib/Dialect/QuantOps/IR/TypeParser.cpp b/mlir/lib/Dialect/QuantOps/IR/TypeParser.cpp index 2bdde1f94f8..2689a2dff89 100644 --- a/mlir/lib/Dialect/QuantOps/IR/TypeParser.cpp +++ b/mlir/lib/Dialect/QuantOps/IR/TypeParser.cpp @@ -1,19 +1,10 @@ //===- TypeParser.h - Quantization Type Parser ------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/QuantOps/QuantOps.h" #include "mlir/Dialect/QuantOps/QuantTypes.h" diff --git a/mlir/lib/Dialect/QuantOps/Transforms/ConvertConst.cpp b/mlir/lib/Dialect/QuantOps/Transforms/ConvertConst.cpp index 61636dcdd8b..08a5ec59e8d 100644 --- a/mlir/lib/Dialect/QuantOps/Transforms/ConvertConst.cpp +++ b/mlir/lib/Dialect/QuantOps/Transforms/ConvertConst.cpp @@ -1,19 +1,10 @@ //===- ConvertConst.cpp - Quantizes constant ops --------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/QuantOps/Passes.h" #include "mlir/Dialect/QuantOps/QuantOps.h" diff --git a/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp b/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp index 83fa9237dee..2a4c14f2231 100644 --- a/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp +++ b/mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp @@ -1,19 +1,10 @@ //===- ConvertSimQuant.cpp - Converts simulated quant ops------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/QuantOps/FakeQuantSupport.h" #include "mlir/Dialect/QuantOps/Passes.h" diff --git a/mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp b/mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp index f4256cf25c8..cbd4315f832 100644 --- a/mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp +++ b/mlir/lib/Dialect/QuantOps/Utils/FakeQuantSupport.cpp @@ -1,19 +1,10 @@ //===- FakeQuantSupport.cpp - Support utilities for FakeQuant ops ---------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/QuantOps/FakeQuantSupport.h" #include "mlir/Dialect/QuantOps/QuantTypes.h" diff --git a/mlir/lib/Dialect/QuantOps/Utils/QuantizeUtils.cpp b/mlir/lib/Dialect/QuantOps/Utils/QuantizeUtils.cpp index 56e2cbae4f0..094fefee486 100644 --- a/mlir/lib/Dialect/QuantOps/Utils/QuantizeUtils.cpp +++ b/mlir/lib/Dialect/QuantOps/Utils/QuantizeUtils.cpp @@ -1,19 +1,10 @@ //===- QuantizeUtils.cpp - Support utilities for quantization -------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/QuantOps/QuantizeUtils.h" #include "mlir/Dialect/QuantOps/UniformSupport.h" diff --git a/mlir/lib/Dialect/QuantOps/Utils/UniformSupport.cpp b/mlir/lib/Dialect/QuantOps/Utils/UniformSupport.cpp index 34e767dfee3..df002336c16 100644 --- a/mlir/lib/Dialect/QuantOps/Utils/UniformSupport.cpp +++ b/mlir/lib/Dialect/QuantOps/Utils/UniformSupport.cpp @@ -1,19 +1,10 @@ //===- UniformSupport.cpp - Support utilities for uniform quant -----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/QuantOps/UniformSupport.h" #include "mlir/IR/StandardTypes.h" diff --git a/mlir/lib/Dialect/SDBM/SDBM.cpp b/mlir/lib/Dialect/SDBM/SDBM.cpp index 510e13e8028..03ffe3ffbb9 100644 --- a/mlir/lib/Dialect/SDBM/SDBM.cpp +++ b/mlir/lib/Dialect/SDBM/SDBM.cpp @@ -1,19 +1,10 @@ //===- SDBM.cpp - MLIR SDBM implementation --------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // A striped difference-bound matrix (SDBM) is a set in Z^N (or R^N) defined // as {(x_1, ... x_n) | f(x_1, ... x_n) >= 0} where f is an SDBM expression. diff --git a/mlir/lib/Dialect/SDBM/SDBMDialect.cpp b/mlir/lib/Dialect/SDBM/SDBMDialect.cpp index d3d895fec88..fab9463a866 100644 --- a/mlir/lib/Dialect/SDBM/SDBMDialect.cpp +++ b/mlir/lib/Dialect/SDBM/SDBMDialect.cpp @@ -1,19 +1,10 @@ //===- SDBMDialect.cpp - Dialect for striped difference-bound matrices ----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/SDBM/SDBMDialect.h" diff --git a/mlir/lib/Dialect/SDBM/SDBMExpr.cpp b/mlir/lib/Dialect/SDBM/SDBMExpr.cpp index 44cdd18cf98..68e3e1c278e 100644 --- a/mlir/lib/Dialect/SDBM/SDBMExpr.cpp +++ b/mlir/lib/Dialect/SDBM/SDBMExpr.cpp @@ -1,19 +1,10 @@ //===- SDBMExpr.cpp - MLIR SDBM Expression implementation -----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // A striped difference-bound matrix (SDBM) expression is a constant expression, // an identifier, a binary expression with constant RHS and +, stripe operators diff --git a/mlir/lib/Dialect/SDBM/SDBMExprDetail.h b/mlir/lib/Dialect/SDBM/SDBMExprDetail.h index 0441200754c..fb80b45902e 100644 --- a/mlir/lib/Dialect/SDBM/SDBMExprDetail.h +++ b/mlir/lib/Dialect/SDBM/SDBMExprDetail.h @@ -1,19 +1,10 @@ //===- SDBMExprDetail.h - MLIR SDBM Expression storage details --*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This holds implementation details of SDBMExpr, in particular underlying // storage types. diff --git a/mlir/lib/Dialect/SPIRV/DialectRegistration.cpp b/mlir/lib/Dialect/SPIRV/DialectRegistration.cpp index 63e9e812c39..431b40ef022 100644 --- a/mlir/lib/Dialect/SPIRV/DialectRegistration.cpp +++ b/mlir/lib/Dialect/SPIRV/DialectRegistration.cpp @@ -1,19 +1,10 @@ //===- DialectRegistration.cpp - MLIR SPIR-V dialect registration ---------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/SPIRV/SPIRVDialect.h" diff --git a/mlir/lib/Dialect/SPIRV/LayoutUtils.cpp b/mlir/lib/Dialect/SPIRV/LayoutUtils.cpp index 5db478d388b..a12d04edd68 100644 --- a/mlir/lib/Dialect/SPIRV/LayoutUtils.cpp +++ b/mlir/lib/Dialect/SPIRV/LayoutUtils.cpp @@ -1,19 +1,10 @@ //===-- LayoutUtils.cpp - Decorate composite type with layout information -===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements Utilities used to get alignment and layout information // for types in SPIR-V dialect. diff --git a/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp b/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp index ca9b883a703..7b6c013f9ed 100644 --- a/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp @@ -1,19 +1,10 @@ //===- SPIRVLowering.cpp - Standard to SPIR-V dialect conversion--===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements utilities used to lower to SPIR-V dialect. // diff --git a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp index a20c18056e1..e42dc10f55d 100644 --- a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp @@ -1,19 +1,10 @@ //===- SPIRVOps.cpp - MLIR SPIR-V operations ------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the operations in the SPIR-V dialect. // diff --git a/mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp b/mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp index 15621aa5fde..18e027afb4c 100644 --- a/mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp @@ -1,19 +1,10 @@ //===- SPIRVTypes.cpp - MLIR SPIR-V Types ---------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the types in the SPIR-V dialect. // diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp index 799828cb629..9e820c6f42b 100644 --- a/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp @@ -1,19 +1,10 @@ //===- Deserializer.cpp - MLIR SPIR-V Deserialization ---------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the SPIR-V binary to MLIR SPIR-V module deserialization. // diff --git a/mlir/lib/Dialect/SPIRV/Serialization/SPIRVBinaryUtils.cpp b/mlir/lib/Dialect/SPIRV/Serialization/SPIRVBinaryUtils.cpp index ba383b2cc6c..13405c9883d 100644 --- a/mlir/lib/Dialect/SPIRV/Serialization/SPIRVBinaryUtils.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/SPIRVBinaryUtils.cpp @@ -1,19 +1,10 @@ //===- SPIRVBinaryUtils.cpp - MLIR SPIR-V Binary Module Utilities ---------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines common utilities for SPIR-V binary module. // diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp index 9b47045ea61..7ff471dfda5 100644 --- a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp @@ -1,19 +1,10 @@ //===- Serializer.cpp - MLIR SPIR-V Serialization -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the MLIR SPIR-V module to SPIR-V binary serialization. // diff --git a/mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp b/mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp index e9b4f23cca4..750710fa3d9 100644 --- a/mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp @@ -1,19 +1,10 @@ //===- TranslateRegistration.cpp - hooks to mlir-translate ----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a translation from SPIR-V binary module to MLIR SPIR-V // ModuleOp. diff --git a/mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp index be486f858fe..07621d6fa80 100644 --- a/mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp @@ -1,19 +1,10 @@ //===- DecorateSPIRVCompositeTypeLayoutPass.cpp - Decorate composite type -===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to decorate the composite types used by // composite objects in the StorageBuffer, PhysicalStorageBuffer, Uniform, and diff --git a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp index 93ce2c0a0d5..76e1b9b716e 100644 --- a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp @@ -1,19 +1,10 @@ //===- LowerABIAttributesPass.cpp - Decorate composite type ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to lower attributes that specify the shader ABI // for the functions in the generated SPIR-V module. diff --git a/mlir/lib/Dialect/StandardOps/DialectRegistration.cpp b/mlir/lib/Dialect/StandardOps/DialectRegistration.cpp index 6b5578f93cf..684806009e5 100644 --- a/mlir/lib/Dialect/StandardOps/DialectRegistration.cpp +++ b/mlir/lib/Dialect/StandardOps/DialectRegistration.cpp @@ -1,19 +1,10 @@ //===- DialectRegistration.cpp - Register standard Op dialect -------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/StandardOps/Ops.h" using namespace mlir; diff --git a/mlir/lib/Dialect/StandardOps/Ops.cpp b/mlir/lib/Dialect/StandardOps/Ops.cpp index 94166b5a7dd..55da59a0c74 100644 --- a/mlir/lib/Dialect/StandardOps/Ops.cpp +++ b/mlir/lib/Dialect/StandardOps/Ops.cpp @@ -1,19 +1,10 @@ //===- Ops.cpp - Standard MLIR Operations ---------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/StandardOps/Ops.h" diff --git a/mlir/lib/Dialect/Traits.cpp b/mlir/lib/Dialect/Traits.cpp index 0ac07c2c4f5..3aea206c07e 100644 --- a/mlir/lib/Dialect/Traits.cpp +++ b/mlir/lib/Dialect/Traits.cpp @@ -1,19 +1,10 @@ //===- Traits.cpp - Common op traits shared by dialects -------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/Traits.h" #include "mlir/IR/StandardTypes.h" diff --git a/mlir/lib/Dialect/VectorOps/DialectRegistration.cpp b/mlir/lib/Dialect/VectorOps/DialectRegistration.cpp index 0caa1cf629e..edd6abb4e2e 100644 --- a/mlir/lib/Dialect/VectorOps/DialectRegistration.cpp +++ b/mlir/lib/Dialect/VectorOps/DialectRegistration.cpp @@ -1,19 +1,10 @@ //===- DialectRegistration.cpp - Register super vectorization dialect -----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/VectorOps/VectorOps.h" using namespace mlir; diff --git a/mlir/lib/Dialect/VectorOps/VectorOps.cpp b/mlir/lib/Dialect/VectorOps/VectorOps.cpp index 18c1714f403..8ceff014029 100644 --- a/mlir/lib/Dialect/VectorOps/VectorOps.cpp +++ b/mlir/lib/Dialect/VectorOps/VectorOps.cpp @@ -1,19 +1,10 @@ //===- VectorOps.cpp - MLIR Super Vectorizer Operations -------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements convenience types for working with super-vectorization // operations, in particular super-vector loads and stores. diff --git a/mlir/lib/Dialect/VectorOps/VectorTransforms.cpp b/mlir/lib/Dialect/VectorOps/VectorTransforms.cpp index e5c281cbf64..927aeda4ecd 100644 --- a/mlir/lib/Dialect/VectorOps/VectorTransforms.cpp +++ b/mlir/lib/Dialect/VectorOps/VectorTransforms.cpp @@ -1,19 +1,10 @@ //===- VectorToLoops.cpp - Conversion within the Vector dialect -----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements target-independent rewrites as 1->N patterns. // diff --git a/mlir/lib/EDSC/Builders.cpp b/mlir/lib/EDSC/Builders.cpp index 35108ed5666..b25eb987a9e 100644 --- a/mlir/lib/EDSC/Builders.cpp +++ b/mlir/lib/EDSC/Builders.cpp @@ -1,19 +1,10 @@ //===- Builders.cpp - MLIR Declarative Builder Classes --------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/EDSC/Builders.h" #include "mlir/Dialect/StandardOps/Ops.h" diff --git a/mlir/lib/EDSC/CoreAPIs.cpp b/mlir/lib/EDSC/CoreAPIs.cpp index 46199c29c14..6f7c1728bb0 100644 --- a/mlir/lib/EDSC/CoreAPIs.cpp +++ b/mlir/lib/EDSC/CoreAPIs.cpp @@ -1,19 +1,10 @@ //===- Types.cpp - Implementations of MLIR Core C APIs --------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir-c/Core.h" diff --git a/mlir/lib/EDSC/Helpers.cpp b/mlir/lib/EDSC/Helpers.cpp index 1771eb0a427..79888334cd9 100644 --- a/mlir/lib/EDSC/Helpers.cpp +++ b/mlir/lib/EDSC/Helpers.cpp @@ -1,19 +1,10 @@ //===- Helpers.cpp - MLIR Declarative Helper Functionality ----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/EDSC/Helpers.h" #include "mlir/Dialect/StandardOps/Ops.h" diff --git a/mlir/lib/EDSC/Intrinsics.cpp b/mlir/lib/EDSC/Intrinsics.cpp index c6738c42993..1bb32b97867 100644 --- a/mlir/lib/EDSC/Intrinsics.cpp +++ b/mlir/lib/EDSC/Intrinsics.cpp @@ -1,19 +1,10 @@ //===- Intrinsics.cpp - MLIR Operations for Declarative Builders ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/EDSC/Intrinsics.h" #include "mlir/EDSC/Builders.h" diff --git a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp index 5098ba81762..1537018076a 100644 --- a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp @@ -1,19 +1,10 @@ //===- ExecutionEngine.cpp - MLIR Execution engine and utils --------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the execution engine for MLIR modules based on LLVM Orc // JIT engine. diff --git a/mlir/lib/ExecutionEngine/OptUtils.cpp b/mlir/lib/ExecutionEngine/OptUtils.cpp index dc3bd20794e..ec2ae5f2dcc 100644 --- a/mlir/lib/ExecutionEngine/OptUtils.cpp +++ b/mlir/lib/ExecutionEngine/OptUtils.cpp @@ -1,19 +1,10 @@ //===- OptUtils.cpp - MLIR Execution Engine optimization pass utilities ---===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the utility functions to trigger LLVM optimizations from // MLIR Execution Engine. diff --git a/mlir/lib/IR/AffineExpr.cpp b/mlir/lib/IR/AffineExpr.cpp index 009c1a1485c..dd8ce00c82a 100644 --- a/mlir/lib/IR/AffineExpr.cpp +++ b/mlir/lib/IR/AffineExpr.cpp @@ -1,19 +1,10 @@ //===- AffineExpr.cpp - MLIR Affine Expr Classes --------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/AffineExpr.h" #include "AffineExprDetail.h" diff --git a/mlir/lib/IR/AffineExprDetail.h b/mlir/lib/IR/AffineExprDetail.h index 214fee65056..8824ddd8682 100644 --- a/mlir/lib/IR/AffineExprDetail.h +++ b/mlir/lib/IR/AffineExprDetail.h @@ -1,19 +1,10 @@ //===- AffineExprDetail.h - MLIR Affine Expr storage details ----*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This holds implementation details of AffineExpr. Ideally it would not be // exposed and would be kept local to AffineExpr.cpp however, MLIRContext.cpp diff --git a/mlir/lib/IR/AffineMap.cpp b/mlir/lib/IR/AffineMap.cpp index 6cfef363985..50624afa3eb 100644 --- a/mlir/lib/IR/AffineMap.cpp +++ b/mlir/lib/IR/AffineMap.cpp @@ -1,19 +1,10 @@ //===- AffineMap.cpp - MLIR Affine Map Classes ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/AffineMap.h" #include "AffineMapDetail.h" diff --git a/mlir/lib/IR/AffineMapDetail.h b/mlir/lib/IR/AffineMapDetail.h index a247783540c..f00c4ba216e 100644 --- a/mlir/lib/IR/AffineMapDetail.h +++ b/mlir/lib/IR/AffineMapDetail.h @@ -1,19 +1,10 @@ //===- AffineMapDetail.h - MLIR Affine Map details Class --------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This holds implementation details of AffineMap. // diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp index 177d8a5ef05..a574f87c530 100644 --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -1,19 +1,10 @@ //===- AsmPrinter.cpp - MLIR Assembly Printer Implementation --------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the MLIR AsmPrinter class, which is used to implement // the various print() methods on the core IR objects. diff --git a/mlir/lib/IR/AttributeDetail.h b/mlir/lib/IR/AttributeDetail.h index da4aa69dda4..c78d49c0f87 100644 --- a/mlir/lib/IR/AttributeDetail.h +++ b/mlir/lib/IR/AttributeDetail.h @@ -1,19 +1,10 @@ //===- AttributeDetail.h - MLIR Affine Map details Class --------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This holds implementation details of Attribute. // diff --git a/mlir/lib/IR/Attributes.cpp b/mlir/lib/IR/Attributes.cpp index bb35a63bf5d..3a9c91f6f77 100644 --- a/mlir/lib/IR/Attributes.cpp +++ b/mlir/lib/IR/Attributes.cpp @@ -1,19 +1,10 @@ //===- Attributes.cpp - MLIR Affine Expr Classes --------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Attributes.h" #include "AttributeDetail.h" diff --git a/mlir/lib/IR/Block.cpp b/mlir/lib/IR/Block.cpp index 894f9ba38d0..b168a8facd2 100644 --- a/mlir/lib/IR/Block.cpp +++ b/mlir/lib/IR/Block.cpp @@ -1,19 +1,10 @@ //===- Block.cpp - MLIR Block Class ---------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Block.h" #include "mlir/IR/Builders.h" diff --git a/mlir/lib/IR/Builders.cpp b/mlir/lib/IR/Builders.cpp index 733fcd13994..2ef10b6e669 100644 --- a/mlir/lib/IR/Builders.cpp +++ b/mlir/lib/IR/Builders.cpp @@ -1,19 +1,10 @@ //===- Builders.cpp - Helpers for constructing MLIR Classes ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Builders.h" #include "mlir/IR/AffineExpr.h" diff --git a/mlir/lib/IR/Diagnostics.cpp b/mlir/lib/IR/Diagnostics.cpp index 59e16a48865..6ec92f05370 100644 --- a/mlir/lib/IR/Diagnostics.cpp +++ b/mlir/lib/IR/Diagnostics.cpp @@ -1,19 +1,10 @@ //===- Diagnostics.cpp - MLIR Diagnostics ---------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Diagnostics.h" #include "mlir/IR/Attributes.h" diff --git a/mlir/lib/IR/Dialect.cpp b/mlir/lib/IR/Dialect.cpp index c6266b09668..b2485a368fd 100644 --- a/mlir/lib/IR/Dialect.cpp +++ b/mlir/lib/IR/Dialect.cpp @@ -1,19 +1,10 @@ //===- Dialect.cpp - Dialect implementation -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Dialect.h" #include "mlir/IR/Diagnostics.h" diff --git a/mlir/lib/IR/Function.cpp b/mlir/lib/IR/Function.cpp index b51c77f34c2..72b5ac46a8f 100644 --- a/mlir/lib/IR/Function.cpp +++ b/mlir/lib/IR/Function.cpp @@ -1,19 +1,10 @@ //===- Function.cpp - MLIR Function Classes -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Function.h" #include "mlir/IR/BlockAndValueMapping.h" diff --git a/mlir/lib/IR/FunctionImplementation.cpp b/mlir/lib/IR/FunctionImplementation.cpp index 9cec216468d..79863bc74f4 100644 --- a/mlir/lib/IR/FunctionImplementation.cpp +++ b/mlir/lib/IR/FunctionImplementation.cpp @@ -1,19 +1,10 @@ //===- FunctionImplementation.cpp - Utilities for function-like ops -------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/FunctionImplementation.h" #include "mlir/IR/Builders.h" diff --git a/mlir/lib/IR/IntegerSet.cpp b/mlir/lib/IR/IntegerSet.cpp index ce50fa7cc5b..835b4c3a7e2 100644 --- a/mlir/lib/IR/IntegerSet.cpp +++ b/mlir/lib/IR/IntegerSet.cpp @@ -1,19 +1,10 @@ //===- IntegerSet.cpp - MLIR Integer Set class ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/IntegerSet.h" #include "IntegerSetDetail.h" diff --git a/mlir/lib/IR/IntegerSetDetail.h b/mlir/lib/IR/IntegerSetDetail.h index b3eda5205fb..54ffd47bd47 100644 --- a/mlir/lib/IR/IntegerSetDetail.h +++ b/mlir/lib/IR/IntegerSetDetail.h @@ -1,19 +1,10 @@ //===- IntegerSetDetail.h - MLIR IntegerSet storage details -----*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This holds implementation details of IntegerSet. // diff --git a/mlir/lib/IR/Location.cpp b/mlir/lib/IR/Location.cpp index 1ea75d5e30e..e23a73647a4 100644 --- a/mlir/lib/IR/Location.cpp +++ b/mlir/lib/IR/Location.cpp @@ -1,19 +1,10 @@ //===- Location.cpp - MLIR Location Classes -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Location.h" #include "LocationDetail.h" diff --git a/mlir/lib/IR/LocationDetail.h b/mlir/lib/IR/LocationDetail.h index 6ccaa17018c..a47a2111c4f 100644 --- a/mlir/lib/IR/LocationDetail.h +++ b/mlir/lib/IR/LocationDetail.h @@ -1,19 +1,10 @@ //===- LocationDetail.h - MLIR Location storage details ---------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This holds implementation details of the location attributes. // diff --git a/mlir/lib/IR/MLIRContext.cpp b/mlir/lib/IR/MLIRContext.cpp index d3feca14477..42d77ae2a3d 100644 --- a/mlir/lib/IR/MLIRContext.cpp +++ b/mlir/lib/IR/MLIRContext.cpp @@ -1,19 +1,10 @@ //===- MLIRContext.cpp - MLIR Type Classes --------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/MLIRContext.h" #include "AffineExprDetail.h" diff --git a/mlir/lib/IR/Module.cpp b/mlir/lib/IR/Module.cpp index c52a55b20fe..c5af227459c 100644 --- a/mlir/lib/IR/Module.cpp +++ b/mlir/lib/IR/Module.cpp @@ -1,19 +1,10 @@ //===- Module.cpp - MLIR Module Operation ---------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Module.h" #include "mlir/IR/Builders.h" diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp index 53399ce00a3..1dc7cb4bafd 100644 --- a/mlir/lib/IR/Operation.cpp +++ b/mlir/lib/IR/Operation.cpp @@ -1,19 +1,10 @@ //===- Operation.cpp - Operation support code -----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Operation.h" #include "mlir/IR/BlockAndValueMapping.h" diff --git a/mlir/lib/IR/OperationSupport.cpp b/mlir/lib/IR/OperationSupport.cpp index 333685a16fd..1c68686a0cb 100644 --- a/mlir/lib/IR/OperationSupport.cpp +++ b/mlir/lib/IR/OperationSupport.cpp @@ -1,19 +1,10 @@ //===- OperationSupport.cpp -----------------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains out-of-line implementations of the support types that // Operation and related classes build on top of. diff --git a/mlir/lib/IR/PatternMatch.cpp b/mlir/lib/IR/PatternMatch.cpp index 3887a0308b0..d5749fabc07 100644 --- a/mlir/lib/IR/PatternMatch.cpp +++ b/mlir/lib/IR/PatternMatch.cpp @@ -1,19 +1,10 @@ //===- PatternMatch.cpp - Base classes for pattern match ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/PatternMatch.h" #include "mlir/IR/BlockAndValueMapping.h" diff --git a/mlir/lib/IR/Region.cpp b/mlir/lib/IR/Region.cpp index 26f14c43424..935854a5365 100644 --- a/mlir/lib/IR/Region.cpp +++ b/mlir/lib/IR/Region.cpp @@ -1,19 +1,10 @@ //===- Region.cpp - MLIR Region Class -------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Region.h" #include "mlir/IR/BlockAndValueMapping.h" diff --git a/mlir/lib/IR/StandardTypes.cpp b/mlir/lib/IR/StandardTypes.cpp index 7c494e219e8..441b59ed9cd 100644 --- a/mlir/lib/IR/StandardTypes.cpp +++ b/mlir/lib/IR/StandardTypes.cpp @@ -1,19 +1,10 @@ //===- StandardTypes.cpp - MLIR Standard Type Classes ---------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/StandardTypes.h" #include "TypeDetail.h" diff --git a/mlir/lib/IR/SymbolTable.cpp b/mlir/lib/IR/SymbolTable.cpp index bd8cb59cea7..83e5802093c 100644 --- a/mlir/lib/IR/SymbolTable.cpp +++ b/mlir/lib/IR/SymbolTable.cpp @@ -1,19 +1,10 @@ //===- SymbolTable.cpp - MLIR Symbol Table Class --------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/SymbolTable.h" #include "llvm/ADT/SmallString.h" diff --git a/mlir/lib/IR/TypeDetail.h b/mlir/lib/IR/TypeDetail.h index 5bcb0b61aa5..b3e0edd3a57 100644 --- a/mlir/lib/IR/TypeDetail.h +++ b/mlir/lib/IR/TypeDetail.h @@ -1,19 +1,10 @@ //===- TypeDetail.h - MLIR Type storage details -----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This holds implementation details of Type. // diff --git a/mlir/lib/IR/TypeUtilities.cpp b/mlir/lib/IR/TypeUtilities.cpp index 8200e3a3bc6..8bc67e46fdc 100644 --- a/mlir/lib/IR/TypeUtilities.cpp +++ b/mlir/lib/IR/TypeUtilities.cpp @@ -1,19 +1,10 @@ //===- TypeUtilities.cpp - Helper function for type queries ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines generic type utilities. // diff --git a/mlir/lib/IR/Types.cpp b/mlir/lib/IR/Types.cpp index 23c80c96aad..923d6e16f57 100644 --- a/mlir/lib/IR/Types.cpp +++ b/mlir/lib/IR/Types.cpp @@ -1,19 +1,10 @@ //===- Types.cpp - MLIR Type Classes --------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Types.h" #include "TypeDetail.h" diff --git a/mlir/lib/IR/Value.cpp b/mlir/lib/IR/Value.cpp index 660d8ae3248..d723eec8b29 100644 --- a/mlir/lib/IR/Value.cpp +++ b/mlir/lib/IR/Value.cpp @@ -1,19 +1,10 @@ //===- Value.cpp - MLIR Value Classes -------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Value.h" #include "mlir/IR/Block.h" diff --git a/mlir/lib/IR/Visitors.cpp b/mlir/lib/IR/Visitors.cpp index ea2a6d69418..404e74a82c9 100644 --- a/mlir/lib/IR/Visitors.cpp +++ b/mlir/lib/IR/Visitors.cpp @@ -1,19 +1,10 @@ //===- Visitors.cpp - MLIR Visitor Utilties -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Visitors.h" #include "mlir/IR/Operation.h" diff --git a/mlir/lib/Parser/Lexer.cpp b/mlir/lib/Parser/Lexer.cpp index 29104c82e23..7d8337a9cb3 100644 --- a/mlir/lib/Parser/Lexer.cpp +++ b/mlir/lib/Parser/Lexer.cpp @@ -1,19 +1,10 @@ //===- Lexer.cpp - MLIR Lexer Implementation ------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the lexer for the MLIR textual form. // diff --git a/mlir/lib/Parser/Lexer.h b/mlir/lib/Parser/Lexer.h index a7a2ac4214c..a760dca9396 100644 --- a/mlir/lib/Parser/Lexer.h +++ b/mlir/lib/Parser/Lexer.h @@ -1,19 +1,10 @@ //===- Lexer.h - MLIR Lexer Interface ---------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file declares the MLIR Lexer class. // diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp index f78704842fe..e25f4d19654 100644 --- a/mlir/lib/Parser/Parser.cpp +++ b/mlir/lib/Parser/Parser.cpp @@ -1,19 +1,10 @@ //===- Parser.cpp - MLIR Parser Implementation ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the parser for the MLIR textual form. // diff --git a/mlir/lib/Parser/Token.cpp b/mlir/lib/Parser/Token.cpp index c01d6032cbd..84de4c396f4 100644 --- a/mlir/lib/Parser/Token.cpp +++ b/mlir/lib/Parser/Token.cpp @@ -1,19 +1,10 @@ //===- Token.cpp - MLIR Token Implementation ------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the Token class for the MLIR textual form. // diff --git a/mlir/lib/Parser/Token.h b/mlir/lib/Parser/Token.h index 333c4d29aad..7487736fac7 100644 --- a/mlir/lib/Parser/Token.h +++ b/mlir/lib/Parser/Token.h @@ -1,19 +1,10 @@ //===- Token.h - MLIR Token Interface ---------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_LIB_PARSER_TOKEN_H #define MLIR_LIB_PARSER_TOKEN_H diff --git a/mlir/lib/Parser/TokenKinds.def b/mlir/lib/Parser/TokenKinds.def index 19cd343274d..fc9f7821f1a 100644 --- a/mlir/lib/Parser/TokenKinds.def +++ b/mlir/lib/Parser/TokenKinds.def @@ -1,19 +1,10 @@ //===- TokenKinds.def - MLIR Token Description ------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file is intended to be #include'd multiple times to extract information // about tokens for various clients in the lexer. diff --git a/mlir/lib/Pass/IRPrinting.cpp b/mlir/lib/Pass/IRPrinting.cpp index 9d1c1f0d391..132a0bec4b7 100644 --- a/mlir/lib/Pass/IRPrinting.cpp +++ b/mlir/lib/Pass/IRPrinting.cpp @@ -1,19 +1,10 @@ //===- IRPrinting.cpp -----------------------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "PassDetail.h" #include "mlir/IR/Module.h" diff --git a/mlir/lib/Pass/Pass.cpp b/mlir/lib/Pass/Pass.cpp index f893c7babf9..22e58cc5b63 100644 --- a/mlir/lib/Pass/Pass.cpp +++ b/mlir/lib/Pass/Pass.cpp @@ -1,19 +1,10 @@ //===- Pass.cpp - Pass infrastructure implementation ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements common pass infrastructure. // diff --git a/mlir/lib/Pass/PassDetail.h b/mlir/lib/Pass/PassDetail.h index d0a2ea63e7d..9a52535bedf 100644 --- a/mlir/lib/Pass/PassDetail.h +++ b/mlir/lib/Pass/PassDetail.h @@ -1,19 +1,10 @@ //===- PassDetail.h - MLIR Pass details -------------------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_PASS_PASSDETAIL_H_ #define MLIR_PASS_PASSDETAIL_H_ diff --git a/mlir/lib/Pass/PassManagerOptions.cpp b/mlir/lib/Pass/PassManagerOptions.cpp index c29e0d08869..87487069d97 100644 --- a/mlir/lib/Pass/PassManagerOptions.cpp +++ b/mlir/lib/Pass/PassManagerOptions.cpp @@ -1,19 +1,10 @@ //===- PassManagerOptions.cpp - PassManager Command Line Options ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Pass/Pass.h" #include "mlir/Pass/PassManager.h" diff --git a/mlir/lib/Pass/PassRegistry.cpp b/mlir/lib/Pass/PassRegistry.cpp index 1a321d666c4..93753d363db 100644 --- a/mlir/lib/Pass/PassRegistry.cpp +++ b/mlir/lib/Pass/PassRegistry.cpp @@ -1,19 +1,10 @@ //===- PassRegistry.cpp - Pass Registration Utilities ---------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Pass/PassRegistry.h" #include "mlir/Pass/Pass.h" diff --git a/mlir/lib/Pass/PassStatistics.cpp b/mlir/lib/Pass/PassStatistics.cpp index 530697421ef..0ab656c2054 100644 --- a/mlir/lib/Pass/PassStatistics.cpp +++ b/mlir/lib/Pass/PassStatistics.cpp @@ -1,19 +1,10 @@ //===- PassStatistics.cpp -------------------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "PassDetail.h" #include "mlir/Pass/PassManager.h" diff --git a/mlir/lib/Pass/PassTiming.cpp b/mlir/lib/Pass/PassTiming.cpp index 113b65a09b5..93e640e7890 100644 --- a/mlir/lib/Pass/PassTiming.cpp +++ b/mlir/lib/Pass/PassTiming.cpp @@ -1,19 +1,10 @@ //===- PassTiming.cpp -----------------------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "PassDetail.h" #include "mlir/Pass/PassManager.h" diff --git a/mlir/lib/Quantizer/Configurations/FxpMathConfig.cpp b/mlir/lib/Quantizer/Configurations/FxpMathConfig.cpp index 94e364238c5..ba9c078a765 100644 --- a/mlir/lib/Quantizer/Configurations/FxpMathConfig.cpp +++ b/mlir/lib/Quantizer/Configurations/FxpMathConfig.cpp @@ -1,19 +1,10 @@ //===- FxpMathConfig.cpp - Reference fixed point config -------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines a TargetConfiguration for reference fixed-point math // quantization scheme based on the FxpMathOps (plus a small category of diff --git a/mlir/lib/Quantizer/Support/Configuration.cpp b/mlir/lib/Quantizer/Support/Configuration.cpp index 78a74514f8b..f64cc85f0f7 100644 --- a/mlir/lib/Quantizer/Support/Configuration.cpp +++ b/mlir/lib/Quantizer/Support/Configuration.cpp @@ -1,19 +1,10 @@ //===- Configuration.cpp - Configuration object base classes --------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Quantizer/Support/Configuration.h" diff --git a/mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp b/mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp index 13fed0f9b1c..38aa5dc811b 100644 --- a/mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp +++ b/mlir/lib/Quantizer/Support/ConstraintAnalysisGraph.cpp @@ -1,19 +1,10 @@ //===- ConstraintAnalysisGraph.cpp - Graphs type for constraints ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Quantizer/Support/ConstraintAnalysisGraph.h" diff --git a/mlir/lib/Quantizer/Support/Metadata.cpp b/mlir/lib/Quantizer/Support/Metadata.cpp index 89478c4209d..b7badfd5f87 100644 --- a/mlir/lib/Quantizer/Support/Metadata.cpp +++ b/mlir/lib/Quantizer/Support/Metadata.cpp @@ -1,19 +1,10 @@ //===- Metadata.cpp - Top level types and metadata ------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Quantizer/Support/Metadata.h" diff --git a/mlir/lib/Quantizer/Support/Statistics.cpp b/mlir/lib/Quantizer/Support/Statistics.cpp index 6753898dbdc..3c8b041e244 100644 --- a/mlir/lib/Quantizer/Support/Statistics.cpp +++ b/mlir/lib/Quantizer/Support/Statistics.cpp @@ -1,19 +1,10 @@ //===- Statistics.cpp - Collects statistics over tensors ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Quantizer/Support/Statistics.h" diff --git a/mlir/lib/Quantizer/Support/TypeUtils.cpp b/mlir/lib/Quantizer/Support/TypeUtils.cpp index fab4e565308..a1f52c585a1 100644 --- a/mlir/lib/Quantizer/Support/TypeUtils.cpp +++ b/mlir/lib/Quantizer/Support/TypeUtils.cpp @@ -1,19 +1,10 @@ //===- TypeUtils.cpp - Helper function for manipulating types -------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Quantizer/Support/TypeUtils.h" diff --git a/mlir/lib/Quantizer/Support/UniformConstraints.cpp b/mlir/lib/Quantizer/Support/UniformConstraints.cpp index 1a800dad4ac..b20213568a1 100644 --- a/mlir/lib/Quantizer/Support/UniformConstraints.cpp +++ b/mlir/lib/Quantizer/Support/UniformConstraints.cpp @@ -1,19 +1,10 @@ //===- UniformConstraints.cpp - Constraints for uniform quant -------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Quantizer/Support/UniformConstraints.h" diff --git a/mlir/lib/Quantizer/Support/UniformSolvers.cpp b/mlir/lib/Quantizer/Support/UniformSolvers.cpp index 77d69be8382..2f6bb20792f 100644 --- a/mlir/lib/Quantizer/Support/UniformSolvers.cpp +++ b/mlir/lib/Quantizer/Support/UniformSolvers.cpp @@ -1,19 +1,10 @@ //===- UniformSolvers.cpp - Uniform type solver algorithms ----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Quantizer/Support/UniformSolvers.h" #include "mlir/Support/LLVM.h" diff --git a/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp b/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp index a3cbe214040..a27f09bf942 100644 --- a/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp +++ b/mlir/lib/Quantizer/Transforms/AddDefaultStatsTestPass.cpp @@ -1,19 +1,10 @@ //===- AddDefaultStatsTestPass.cpp - Testing pass to add default stats ----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines a testing pass to add default statistics nodes to every // quantization eligible op. Useful for unit testing. diff --git a/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp b/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp index 68c263bc423..c8569c2fe19 100644 --- a/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp +++ b/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp @@ -1,19 +1,10 @@ //===- InferQuantizedTypesPass.cpp - Infers quantized types ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines the primary pass for instantiating a CAG, running it to // convergence on a module to determine eligible quantized type transforms, and diff --git a/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp b/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp index 0266520bec3..da5bd12ea1c 100644 --- a/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp +++ b/mlir/lib/Quantizer/Transforms/RemoveInstrumentationPass.cpp @@ -1,19 +1,10 @@ //===- RemoveInstrumentationPass.cpp - Removes instrumentation ------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines a pass to remove any instrumentation ops. It is often one // of the final steps when performing quantization and is run after any diff --git a/mlir/lib/Support/FileUtilities.cpp b/mlir/lib/Support/FileUtilities.cpp index 6f0dc93b235..a56ae57ba25 100644 --- a/mlir/lib/Support/FileUtilities.cpp +++ b/mlir/lib/Support/FileUtilities.cpp @@ -1,19 +1,10 @@ //===- FileUtilities.cpp - utilities for working with files ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Definitions of common utilities for working with files. // diff --git a/mlir/lib/Support/JitRunner.cpp b/mlir/lib/Support/JitRunner.cpp index dcd23437401..b327d3d4756 100644 --- a/mlir/lib/Support/JitRunner.cpp +++ b/mlir/lib/Support/JitRunner.cpp @@ -1,19 +1,10 @@ //===- jit-runner.cpp - MLIR CPU Execution Driver Library -----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is a library that provides a shared implementation for command line // utilities that execute an MLIR file on the CPU by translating MLIR to LLVM diff --git a/mlir/lib/Support/MlirOptMain.cpp b/mlir/lib/Support/MlirOptMain.cpp index c256e970c95..4a76801211c 100644 --- a/mlir/lib/Support/MlirOptMain.cpp +++ b/mlir/lib/Support/MlirOptMain.cpp @@ -1,19 +1,10 @@ //===- MlirOptMain.cpp - MLIR Optimizer Driver ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is a utility that runs an optimization pass and prints the result back // out. It is designed to support unit testing. diff --git a/mlir/lib/Support/StorageUniquer.cpp b/mlir/lib/Support/StorageUniquer.cpp index cae4dce143f..d6f6bac4236 100644 --- a/mlir/lib/Support/StorageUniquer.cpp +++ b/mlir/lib/Support/StorageUniquer.cpp @@ -1,19 +1,10 @@ //===- StorageUniquer.cpp - Common Storage Class Uniquer ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Support/StorageUniquer.h" diff --git a/mlir/lib/Support/ToolUtilities.cpp b/mlir/lib/Support/ToolUtilities.cpp index 60d0eee6b8a..cd2df7809b7 100644 --- a/mlir/lib/Support/ToolUtilities.cpp +++ b/mlir/lib/Support/ToolUtilities.cpp @@ -1,19 +1,10 @@ //===- ToolUtilities.cpp - MLIR Tool Utilities ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines common utilities for implementing MLIR tools. // diff --git a/mlir/lib/Support/TranslateClParser.cpp b/mlir/lib/Support/TranslateClParser.cpp index 115c0c03f50..1f538cb531d 100644 --- a/mlir/lib/Support/TranslateClParser.cpp +++ b/mlir/lib/Support/TranslateClParser.cpp @@ -1,19 +1,10 @@ //===- TranslateClParser.h - Translations command line parser -------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains custom command line parser for translations. // diff --git a/mlir/lib/TableGen/Argument.cpp b/mlir/lib/TableGen/Argument.cpp index 17dba054e4f..080e717092e 100644 --- a/mlir/lib/TableGen/Argument.cpp +++ b/mlir/lib/TableGen/Argument.cpp @@ -1,19 +1,10 @@ //===- Argument.cpp - Argument definitions --------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/TableGen/Argument.h" #include "llvm/TableGen/Record.h" diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index ec946a855fc..92f5b1f7d9f 100644 --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -1,19 +1,10 @@ //===- Attribute.cpp - Attribute wrapper class ----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Attribute wrapper to simplify using TableGen Record defining a MLIR // Attribute. diff --git a/mlir/lib/TableGen/Constraint.cpp b/mlir/lib/TableGen/Constraint.cpp index ef3fa5271fa..022c5ad04df 100644 --- a/mlir/lib/TableGen/Constraint.cpp +++ b/mlir/lib/TableGen/Constraint.cpp @@ -1,19 +1,10 @@ //===- Constraint.cpp - Constraint class ----------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Constraint wrapper to simplify using TableGen Record for constraints. // diff --git a/mlir/lib/TableGen/Dialect.cpp b/mlir/lib/TableGen/Dialect.cpp index ace4ce3d0f6..d9e8e2f7154 100644 --- a/mlir/lib/TableGen/Dialect.cpp +++ b/mlir/lib/TableGen/Dialect.cpp @@ -1,19 +1,10 @@ //===- Dialect.cpp - Dialect wrapper class --------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Dialect wrapper to simplify using TableGen Record defining a MLIR dialect. // diff --git a/mlir/lib/TableGen/Format.cpp b/mlir/lib/TableGen/Format.cpp index 967d51a61f7..07742ab6a40 100644 --- a/mlir/lib/TableGen/Format.cpp +++ b/mlir/lib/TableGen/Format.cpp @@ -1,19 +1,10 @@ //===- Format.cpp - Utilities for String Format ---------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines utilities for formatting strings. They are specially // tailored to the needs of TableGen'ing op definitions and rewrite rules, diff --git a/mlir/lib/TableGen/OpInterfaces.cpp b/mlir/lib/TableGen/OpInterfaces.cpp index 1687f3ac795..b1e56efc029 100644 --- a/mlir/lib/TableGen/OpInterfaces.cpp +++ b/mlir/lib/TableGen/OpInterfaces.cpp @@ -1,19 +1,10 @@ //===- OpInterfaces.cpp - OpInterfaces class ------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // OpInterfaces wrapper to simplify using TableGen OpInterfaces. // diff --git a/mlir/lib/TableGen/OpTrait.cpp b/mlir/lib/TableGen/OpTrait.cpp index 0e436a87497..86e34cd46b5 100644 --- a/mlir/lib/TableGen/OpTrait.cpp +++ b/mlir/lib/TableGen/OpTrait.cpp @@ -1,19 +1,10 @@ //===- OpTrait.cpp - OpTrait class ----------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // OpTrait wrapper to simplify using TableGen Record defining a MLIR OpTrait. // diff --git a/mlir/lib/TableGen/Operator.cpp b/mlir/lib/TableGen/Operator.cpp index 3825363bec0..d61eec4ad44 100644 --- a/mlir/lib/TableGen/Operator.cpp +++ b/mlir/lib/TableGen/Operator.cpp @@ -1,19 +1,10 @@ //===- Operator.cpp - Operator class --------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Operator wrapper to simplify using TableGen Record defining a MLIR Op. // diff --git a/mlir/lib/TableGen/Pattern.cpp b/mlir/lib/TableGen/Pattern.cpp index e8f44087b85..1045b784ae2 100644 --- a/mlir/lib/TableGen/Pattern.cpp +++ b/mlir/lib/TableGen/Pattern.cpp @@ -1,19 +1,10 @@ //===- Pattern.cpp - Pattern wrapper class --------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Pattern wrapper class to simplify using TableGen Record defining a MLIR // Pattern. diff --git a/mlir/lib/TableGen/Predicate.cpp b/mlir/lib/TableGen/Predicate.cpp index f8f23e04c3f..c52e15dbdea 100644 --- a/mlir/lib/TableGen/Predicate.cpp +++ b/mlir/lib/TableGen/Predicate.cpp @@ -1,19 +1,10 @@ //===- Predicate.cpp - Predicate class ------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Wrapper around predicates defined in TableGen. // diff --git a/mlir/lib/TableGen/Type.cpp b/mlir/lib/TableGen/Type.cpp index a558be4c89d..9a309bdde46 100644 --- a/mlir/lib/TableGen/Type.cpp +++ b/mlir/lib/TableGen/Type.cpp @@ -1,19 +1,10 @@ //===- Type.cpp - Type class ----------------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Type wrapper to simplify using TableGen Record defining a MLIR Type. // diff --git a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp index 7273d3dfd7b..6f3e2ef21aa 100644 --- a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp @@ -1,19 +1,10 @@ //===- ConvertFromLLVMIR.cpp - MLIR to LLVM IR conversion -----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a translation between LLVM IR and the MLIR LLVM dialect. // diff --git a/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp index e69dce7b59b..4cc59974960 100644 --- a/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp @@ -1,19 +1,10 @@ //===- ConvertToLLVMIR.cpp - MLIR to LLVM IR conversion -------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a translation between the MLIR LLVM dialect and LLVM IR. // diff --git a/mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp index 8baed9854f1..a5992174df3 100644 --- a/mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertToNVVMIR.cpp @@ -1,19 +1,10 @@ //===- ConvertToNVVMIR.cpp - MLIR to LLVM IR conversion -------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a translation between the MLIR LLVM + NVVM dialects and // LLVM IR with NVVM intrinsics and metadata. diff --git a/mlir/lib/Target/LLVMIR/ConvertToROCDLIR.cpp b/mlir/lib/Target/LLVMIR/ConvertToROCDLIR.cpp index f119b138e13..881d165e0c8 100644 --- a/mlir/lib/Target/LLVMIR/ConvertToROCDLIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertToROCDLIR.cpp @@ -1,19 +1,10 @@ //===- ConvertToROCDLIR.cpp - MLIR to LLVM IR conversion ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a translation between the MLIR LLVM + ROCDL dialects and // LLVM IR with ROCDL intrinsics and metadata. diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp index ec28434b823..e8376364c41 100644 --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -1,19 +1,10 @@ //===- ModuleTranslation.cpp - MLIR to LLVM conversion --------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements the translation between an MLIR LLVM dialect module and // the corresponding LLVMIR module. It only handles core LLVM IR operations. diff --git a/mlir/lib/Transforms/AffineDataCopyGeneration.cpp b/mlir/lib/Transforms/AffineDataCopyGeneration.cpp index 5bc33943e50..1e1b8775d32 100644 --- a/mlir/lib/Transforms/AffineDataCopyGeneration.cpp +++ b/mlir/lib/Transforms/AffineDataCopyGeneration.cpp @@ -1,19 +1,10 @@ //===- AffineDataCopyGeneration.cpp - Explicit memref copying pass ------*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to automatically promote accessed memref regions // to buffers in a faster memory space that is explicitly managed, with the diff --git a/mlir/lib/Transforms/AffineLoopInvariantCodeMotion.cpp b/mlir/lib/Transforms/AffineLoopInvariantCodeMotion.cpp index 23199dd8a39..1f33c0f5dca 100644 --- a/mlir/lib/Transforms/AffineLoopInvariantCodeMotion.cpp +++ b/mlir/lib/Transforms/AffineLoopInvariantCodeMotion.cpp @@ -1,19 +1,10 @@ //===- AffineLoopInvariantCodeMotion.cpp - Code to perform loop fusion-----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements loop invariant code motion. // diff --git a/mlir/lib/Transforms/CSE.cpp b/mlir/lib/Transforms/CSE.cpp index 18f9fce5e46..714fb1d0109 100644 --- a/mlir/lib/Transforms/CSE.cpp +++ b/mlir/lib/Transforms/CSE.cpp @@ -1,19 +1,10 @@ //===- CSE.cpp - Common Sub-expression Elimination ------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This transformation pass performs a simple common sub-expression elimination // algorithm on operations within a function. diff --git a/mlir/lib/Transforms/Canonicalizer.cpp b/mlir/lib/Transforms/Canonicalizer.cpp index 7dcdeb67cdc..5b3a1eb1cf3 100644 --- a/mlir/lib/Transforms/Canonicalizer.cpp +++ b/mlir/lib/Transforms/Canonicalizer.cpp @@ -1,19 +1,10 @@ //===- Canonicalizer.cpp - Canonicalize MLIR operations -------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This transformation pass converts operations into their canonical forms by // folding constants, applying operation identity transformations etc. diff --git a/mlir/lib/Transforms/DialectConversion.cpp b/mlir/lib/Transforms/DialectConversion.cpp index 05066ef599c..a19274acd1b 100644 --- a/mlir/lib/Transforms/DialectConversion.cpp +++ b/mlir/lib/Transforms/DialectConversion.cpp @@ -1,19 +1,10 @@ //===- DialectConversion.cpp - MLIR dialect conversion generic pass -------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Transforms/DialectConversion.h" #include "mlir/IR/Block.h" diff --git a/mlir/lib/Transforms/Inliner.cpp b/mlir/lib/Transforms/Inliner.cpp index b158948069e..b2cee7da083 100644 --- a/mlir/lib/Transforms/Inliner.cpp +++ b/mlir/lib/Transforms/Inliner.cpp @@ -1,19 +1,10 @@ //===- Inliner.cpp - Pass to inline function calls ------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a basic inlining algorithm that operates bottom up over // the Strongly Connect Components(SCCs) of the CallGraph. This enables a more diff --git a/mlir/lib/Transforms/LoopCoalescing.cpp b/mlir/lib/Transforms/LoopCoalescing.cpp index c1eec56526e..2aee688c6c1 100644 --- a/mlir/lib/Transforms/LoopCoalescing.cpp +++ b/mlir/lib/Transforms/LoopCoalescing.cpp @@ -1,19 +1,10 @@ //===- LoopCoalescing.cpp - Pass transforming loop nests into single loops-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/LoopOps/LoopOps.h" #include "mlir/Dialect/StandardOps/Ops.h" diff --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp index 60f0264eb35..51e30ba7163 100644 --- a/mlir/lib/Transforms/LoopFusion.cpp +++ b/mlir/lib/Transforms/LoopFusion.cpp @@ -1,19 +1,10 @@ //===- LoopFusion.cpp - Code to perform loop fusion -----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements loop fusion. // diff --git a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp index bd58827d001..93c80822fb3 100644 --- a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp +++ b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp @@ -1,19 +1,10 @@ //===- LoopInvariantCodeMotion.cpp - Code to perform loop fusion-----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements loop invariant code motion. // diff --git a/mlir/lib/Transforms/LoopTiling.cpp b/mlir/lib/Transforms/LoopTiling.cpp index 361a4d8ecb9..5389c7e4429 100644 --- a/mlir/lib/Transforms/LoopTiling.cpp +++ b/mlir/lib/Transforms/LoopTiling.cpp @@ -1,19 +1,10 @@ //===- LoopTiling.cpp --- Loop tiling pass ------------------------------*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to tile loop nests. // diff --git a/mlir/lib/Transforms/LoopUnroll.cpp b/mlir/lib/Transforms/LoopUnroll.cpp index 40f48ada4d7..e94c6c8b0bb 100644 --- a/mlir/lib/Transforms/LoopUnroll.cpp +++ b/mlir/lib/Transforms/LoopUnroll.cpp @@ -1,19 +1,10 @@ //===- LoopUnroll.cpp - Code to perform loop unrolling --------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements loop unrolling. // diff --git a/mlir/lib/Transforms/LoopUnrollAndJam.cpp b/mlir/lib/Transforms/LoopUnrollAndJam.cpp index a857b8ec95a..3cefcaacadc 100644 --- a/mlir/lib/Transforms/LoopUnrollAndJam.cpp +++ b/mlir/lib/Transforms/LoopUnrollAndJam.cpp @@ -1,19 +1,10 @@ //===- LoopUnrollAndJam.cpp - Code to perform loop unroll and jam ---------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements loop unroll and jam. Unroll and jam is a transformation // that improves locality, in particular, register reuse, while also improving diff --git a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp index 0695aafe171..957f41a9d3e 100644 --- a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp +++ b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp @@ -1,19 +1,10 @@ //===- MemRefDataFlowOpt.cpp - MemRef DataFlow Optimization pass ------ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to forward memref stores to loads, thereby // potentially getting rid of intermediate memref's entirely. diff --git a/mlir/lib/Transforms/PipelineDataTransfer.cpp b/mlir/lib/Transforms/PipelineDataTransfer.cpp index 4162936ea2d..12ce6c66abd 100644 --- a/mlir/lib/Transforms/PipelineDataTransfer.cpp +++ b/mlir/lib/Transforms/PipelineDataTransfer.cpp @@ -1,19 +1,10 @@ //===- PipelineDataTransfer.cpp --- Pass for pipelining data movement ---*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to pipeline data transfers. // diff --git a/mlir/lib/Transforms/SimplifyAffineStructures.cpp b/mlir/lib/Transforms/SimplifyAffineStructures.cpp index 9512ff738aa..217e06bc877 100644 --- a/mlir/lib/Transforms/SimplifyAffineStructures.cpp +++ b/mlir/lib/Transforms/SimplifyAffineStructures.cpp @@ -1,19 +1,10 @@ //===- SimplifyAffineStructures.cpp ---------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to simplify affine structures. // diff --git a/mlir/lib/Transforms/StripDebugInfo.cpp b/mlir/lib/Transforms/StripDebugInfo.cpp index 772df3da3c7..cdfc7fd7e41 100644 --- a/mlir/lib/Transforms/StripDebugInfo.cpp +++ b/mlir/lib/Transforms/StripDebugInfo.cpp @@ -1,19 +1,10 @@ //===- StripDebugInfo.cpp - Pass to strip debug information ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Function.h" #include "mlir/IR/Operation.h" diff --git a/mlir/lib/Transforms/Utils/FoldUtils.cpp b/mlir/lib/Transforms/Utils/FoldUtils.cpp index 85d1f21305e..ce39625831a 100644 --- a/mlir/lib/Transforms/Utils/FoldUtils.cpp +++ b/mlir/lib/Transforms/Utils/FoldUtils.cpp @@ -1,19 +1,10 @@ //===- FoldUtils.cpp ---- Fold Utilities ----------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines various operation fold utilities. These utilities are // intended to be used by passes to unify and simply their logic. diff --git a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp index fe4a6f9f9e0..3ab4e287bb2 100644 --- a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp +++ b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp @@ -1,19 +1,10 @@ //===- GreedyPatternRewriteDriver.cpp - A greedy rewriter -----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements mlir::applyPatternsGreedily. // diff --git a/mlir/lib/Transforms/Utils/InliningUtils.cpp b/mlir/lib/Transforms/Utils/InliningUtils.cpp index 048130c0d3a..e7b34bb3956 100644 --- a/mlir/lib/Transforms/Utils/InliningUtils.cpp +++ b/mlir/lib/Transforms/Utils/InliningUtils.cpp @@ -1,19 +1,10 @@ //===- InliningUtils.cpp ---- Misc utilities for inlining -----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements miscellaneous inlining utilities. // diff --git a/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp b/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp index d5cda3265de..4745a26e168 100644 --- a/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp +++ b/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp @@ -1,19 +1,10 @@ //===- LoopFusionUtils.cpp ---- Utilities for loop fusion ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements loop fusion transformation utility functions. // diff --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp index bc1ced408a9..3d4db22c866 100644 --- a/mlir/lib/Transforms/Utils/LoopUtils.cpp +++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp @@ -1,19 +1,10 @@ //===- LoopUtils.cpp ---- Misc utilities for loop transformation ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements miscellaneous loop transformation routines. // diff --git a/mlir/lib/Transforms/Utils/RegionUtils.cpp b/mlir/lib/Transforms/Utils/RegionUtils.cpp index 749d5bf1dd0..569c5416edd 100644 --- a/mlir/lib/Transforms/Utils/RegionUtils.cpp +++ b/mlir/lib/Transforms/Utils/RegionUtils.cpp @@ -1,19 +1,10 @@ //===- RegionUtils.cpp - Region-related transformation utilities ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Transforms/RegionUtils.h" #include "mlir/IR/Block.h" diff --git a/mlir/lib/Transforms/Utils/Utils.cpp b/mlir/lib/Transforms/Utils/Utils.cpp index 96a6cdc544f..409729a5f20 100644 --- a/mlir/lib/Transforms/Utils/Utils.cpp +++ b/mlir/lib/Transforms/Utils/Utils.cpp @@ -1,19 +1,10 @@ //===- Utils.cpp ---- Misc utilities for code and data transformation -----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements miscellaneous transformation routines for non-loop IR // structures. diff --git a/mlir/lib/Transforms/Vectorize.cpp b/mlir/lib/Transforms/Vectorize.cpp index d8f5b1dc0e4..2dbac868cc0 100644 --- a/mlir/lib/Transforms/Vectorize.cpp +++ b/mlir/lib/Transforms/Vectorize.cpp @@ -1,19 +1,10 @@ //===- Vectorize.cpp - Vectorize Pass Impl --------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements vectorization of loops, operations and data types to // a target-independent, n-D super-vector abstraction. diff --git a/mlir/lib/Transforms/ViewOpGraph.cpp b/mlir/lib/Transforms/ViewOpGraph.cpp index 591562d0245..508c547a52b 100644 --- a/mlir/lib/Transforms/ViewOpGraph.cpp +++ b/mlir/lib/Transforms/ViewOpGraph.cpp @@ -1,19 +1,10 @@ //===- ViewOpGraph.cpp - View/write op graphviz graphs --------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Transforms/ViewOpGraph.h" #include "mlir/IR/Block.h" diff --git a/mlir/lib/Transforms/ViewRegionGraph.cpp b/mlir/lib/Transforms/ViewRegionGraph.cpp index db55415d62e..77111087d07 100644 --- a/mlir/lib/Transforms/ViewRegionGraph.cpp +++ b/mlir/lib/Transforms/ViewRegionGraph.cpp @@ -1,19 +1,10 @@ //===- ViewRegionGraph.cpp - View/write graphviz graphs -------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Transforms/ViewRegionGraph.h" #include "mlir/IR/RegionGraphTraits.h" diff --git a/mlir/lib/Translation/Translation.cpp b/mlir/lib/Translation/Translation.cpp index 8b5f98714e4..80c1e483731 100644 --- a/mlir/lib/Translation/Translation.cpp +++ b/mlir/lib/Translation/Translation.cpp @@ -1,19 +1,10 @@ //===- Translation.cpp - Translation registry -----------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Definitions of the translation registry. // diff --git a/mlir/test/APITest.h b/mlir/test/APITest.h index 9475bae2b58..08d64a0e48d 100644 --- a/mlir/test/APITest.h +++ b/mlir/test/APITest.h @@ -1,19 +1,10 @@ //===- Test.h - Simple macros for API unit tests ----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file define simple macros for declaring test functions and running them. // The actual checking must be performed on the outputs with FileCheck. diff --git a/mlir/test/EDSC/builder-api-test.cpp b/mlir/test/EDSC/builder-api-test.cpp index 376fc249a18..cfe703281e2 100644 --- a/mlir/test/EDSC/builder-api-test.cpp +++ b/mlir/test/EDSC/builder-api-test.cpp @@ -1,19 +1,10 @@ //===- builder-api-test.cpp - Tests for Declarative Builder APIs ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // RUN: mlir-edsc-builder-api-test | FileCheck %s diff --git a/mlir/test/SDBM/sdbm-api-test.cpp b/mlir/test/SDBM/sdbm-api-test.cpp index 12aff301d88..a672290d01d 100644 --- a/mlir/test/SDBM/sdbm-api-test.cpp +++ b/mlir/test/SDBM/sdbm-api-test.cpp @@ -1,19 +1,10 @@ //===- sdbm-api-test.cpp - Tests for SDBM expression APIs -----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // RUN: mlir-sdbm-api-test | FileCheck %s diff --git a/mlir/test/lib/DeclarativeTransforms/TestLinalgTransformPatterns.td b/mlir/test/lib/DeclarativeTransforms/TestLinalgTransformPatterns.td index d2313927398..d07f6060c3b 100644 --- a/mlir/test/lib/DeclarativeTransforms/TestLinalgTransformPatterns.td +++ b/mlir/test/lib/DeclarativeTransforms/TestLinalgTransformPatterns.td @@ -1,19 +1,10 @@ //===- TestLinalgTransformPatterns.td - Test patterns --*- tablegen ----*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the pattern definition file for declarative Linalg transformations // tests. diff --git a/mlir/test/lib/DeclarativeTransforms/TestVectorTransformPatterns.td b/mlir/test/lib/DeclarativeTransforms/TestVectorTransformPatterns.td index 228a8a018d6..29875ccd543 100644 --- a/mlir/test/lib/DeclarativeTransforms/TestVectorTransformPatterns.td +++ b/mlir/test/lib/DeclarativeTransforms/TestVectorTransformPatterns.td @@ -1,19 +1,10 @@ //===- TestVectorTransformPatterns.td - Test patterns ---*- tablegen ----*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is the pattern definition file for declarative Vector transformations // tests. diff --git a/mlir/test/lib/IR/TestFunc.cpp b/mlir/test/lib/IR/TestFunc.cpp index 880d0785bb5..3e131590fae 100644 --- a/mlir/test/lib/IR/TestFunc.cpp +++ b/mlir/test/lib/IR/TestFunc.cpp @@ -1,19 +1,10 @@ //===- TestFunctionLike.cpp - Pass to test helpers on FunctionLike --------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Function.h" #include "mlir/Pass/Pass.h" diff --git a/mlir/test/lib/IR/TestMatchers.cpp b/mlir/test/lib/IR/TestMatchers.cpp index 5985a88ffa6..b62daa8437c 100644 --- a/mlir/test/lib/IR/TestMatchers.cpp +++ b/mlir/test/lib/IR/TestMatchers.cpp @@ -1,19 +1,10 @@ //===- TestMatchers.cpp - Pass to test matchers ---------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/StandardOps/Ops.h" #include "mlir/IR/Function.h" diff --git a/mlir/test/lib/IR/TestSymbolUses.cpp b/mlir/test/lib/IR/TestSymbolUses.cpp index 8ef4bb48a1c..c8fb1d8eecf 100644 --- a/mlir/test/lib/IR/TestSymbolUses.cpp +++ b/mlir/test/lib/IR/TestSymbolUses.cpp @@ -1,19 +1,10 @@ //===- TestSymbolUses.cpp - Pass to test symbol uselists ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "TestDialect.h" #include "mlir/IR/Function.h" diff --git a/mlir/test/lib/Pass/TestPassManager.cpp b/mlir/test/lib/Pass/TestPassManager.cpp index d1e1a6d13ee..2e811634880 100644 --- a/mlir/test/lib/Pass/TestPassManager.cpp +++ b/mlir/test/lib/Pass/TestPassManager.cpp @@ -1,19 +1,10 @@ //===- TestPassManager.cpp - Test pass manager functionality --------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Function.h" #include "mlir/Pass/Pass.h" diff --git a/mlir/test/lib/TestDialect/TestDialect.cpp b/mlir/test/lib/TestDialect/TestDialect.cpp index 12d024f6593..976a1976f01 100644 --- a/mlir/test/lib/TestDialect/TestDialect.cpp +++ b/mlir/test/lib/TestDialect/TestDialect.cpp @@ -1,19 +1,10 @@ //===- TestDialect.cpp - MLIR Dialect for Testing -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "TestDialect.h" #include "mlir/IR/Function.h" diff --git a/mlir/test/lib/TestDialect/TestDialect.h b/mlir/test/lib/TestDialect/TestDialect.h index 783b8a1bcdd..20db0f39b81 100644 --- a/mlir/test/lib/TestDialect/TestDialect.h +++ b/mlir/test/lib/TestDialect/TestDialect.h @@ -1,19 +1,10 @@ //===- TestDialect.h - MLIR Dialect for testing -----------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines a fake 'test' dialect that can be used for testing things // that do not have a respective counterpart in the main source directories. diff --git a/mlir/test/lib/TestDialect/TestOps.td b/mlir/test/lib/TestDialect/TestOps.td index ea071f0ddf4..a8709ddca27 100644 --- a/mlir/test/lib/TestDialect/TestOps.td +++ b/mlir/test/lib/TestDialect/TestOps.td @@ -1,19 +1,10 @@ //===-- TestOps.td - Test dialect operation definitions ----*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef TEST_OPS #define TEST_OPS diff --git a/mlir/test/lib/TestDialect/TestPatterns.cpp b/mlir/test/lib/TestDialect/TestPatterns.cpp index 1f6224dba3a..b886097202d 100644 --- a/mlir/test/lib/TestDialect/TestPatterns.cpp +++ b/mlir/test/lib/TestDialect/TestPatterns.cpp @@ -1,19 +1,10 @@ //===- TestPatterns.cpp - Test dialect pattern driver ---------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "TestDialect.h" #include "mlir/IR/PatternMatch.h" diff --git a/mlir/test/lib/Transforms/TestCallGraph.cpp b/mlir/test/lib/Transforms/TestCallGraph.cpp index debf5e77645..6378d953648 100644 --- a/mlir/test/lib/Transforms/TestCallGraph.cpp +++ b/mlir/test/lib/Transforms/TestCallGraph.cpp @@ -1,19 +1,10 @@ //===- TestCallGraph.cpp - Test callgraph construction and iteration ------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains test passes for constructing and iterating over a // callgraph. diff --git a/mlir/test/lib/Transforms/TestConstantFold.cpp b/mlir/test/lib/Transforms/TestConstantFold.cpp index 5a0e9ed3f3c..f660bccca1d 100644 --- a/mlir/test/lib/Transforms/TestConstantFold.cpp +++ b/mlir/test/lib/Transforms/TestConstantFold.cpp @@ -1,19 +1,10 @@ //===- TestConstantFold.cpp - Pass to test constant folding ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/AffineOps/AffineOps.h" #include "mlir/Dialect/StandardOps/Ops.h" diff --git a/mlir/test/lib/Transforms/TestInlining.cpp b/mlir/test/lib/Transforms/TestInlining.cpp index 0571dc62b73..36378283f8e 100644 --- a/mlir/test/lib/Transforms/TestInlining.cpp +++ b/mlir/test/lib/Transforms/TestInlining.cpp @@ -1,19 +1,10 @@ //===- TestInlining.cpp - Pass to inline calls in the test dialect --------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // TODO(riverriddle) This pass is only necessary because the main inlining pass // has no abstracted away the call+callee relationship. When the inlining diff --git a/mlir/test/lib/Transforms/TestLinalgTransforms.cpp b/mlir/test/lib/Transforms/TestLinalgTransforms.cpp index 37030ca2059..6ea995d3dfe 100644 --- a/mlir/test/lib/Transforms/TestLinalgTransforms.cpp +++ b/mlir/test/lib/Transforms/TestLinalgTransforms.cpp @@ -1,19 +1,10 @@ //===- TestLinalgTransforms.cpp - Test Linalg transformation patterns -----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements logic for testing Linalg transformations. // diff --git a/mlir/test/lib/Transforms/TestLiveness.cpp b/mlir/test/lib/Transforms/TestLiveness.cpp index d97060247f4..23725740df4 100644 --- a/mlir/test/lib/Transforms/TestLiveness.cpp +++ b/mlir/test/lib/Transforms/TestLiveness.cpp @@ -1,20 +1,11 @@ //===- TestLiveness.cpp - Test liveness construction and information //-------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains test passes for constructing and resolving liveness // information. diff --git a/mlir/test/lib/Transforms/TestLoopFusion.cpp b/mlir/test/lib/Transforms/TestLoopFusion.cpp index 7dc722f21f6..23e5035153e 100644 --- a/mlir/test/lib/Transforms/TestLoopFusion.cpp +++ b/mlir/test/lib/Transforms/TestLoopFusion.cpp @@ -1,19 +1,10 @@ //===- TestLoopFusion.cpp - Test loop fusion ------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to test various loop fusion utility functions. // diff --git a/mlir/test/lib/Transforms/TestLoopMapping.cpp b/mlir/test/lib/Transforms/TestLoopMapping.cpp index 7f587fc3170..5b1394d5996 100644 --- a/mlir/test/lib/Transforms/TestLoopMapping.cpp +++ b/mlir/test/lib/Transforms/TestLoopMapping.cpp @@ -1,19 +1,10 @@ //===- TestLoopMapping.cpp --- Parametric loop mapping pass ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to parametrically map loop.for loops to virtual // processing element dimensions. diff --git a/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp b/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp index 9a8e1917e1f..7b0cdcade4d 100644 --- a/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp +++ b/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp @@ -1,19 +1,10 @@ //===- TestLoopParametricTiling.cpp --- Parametric loop tiling pass -------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a pass to parametrically tile nests of standard loops. // diff --git a/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp b/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp index 40788b259c5..d5e0b7df02b 100644 --- a/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp +++ b/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp @@ -1,19 +1,10 @@ //===- TestMemRefStrideCalculation.cpp - Pass to test strides computation--===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/StandardOps/Ops.h" #include "mlir/IR/StandardTypes.h" diff --git a/mlir/test/lib/Transforms/TestOpaqueLoc.cpp b/mlir/test/lib/Transforms/TestOpaqueLoc.cpp index 0db53322fb8..9a261c0bb3b 100644 --- a/mlir/test/lib/Transforms/TestOpaqueLoc.cpp +++ b/mlir/test/lib/Transforms/TestOpaqueLoc.cpp @@ -1,19 +1,10 @@ //===- TestOpaqueLoc.cpp - Pass to test opaque locations ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/StandardOps/Ops.h" #include "mlir/IR/Builders.h" diff --git a/mlir/test/lib/Transforms/TestVectorToLoopsConversion.cpp b/mlir/test/lib/Transforms/TestVectorToLoopsConversion.cpp index e5f5f749bd0..a31f8e474b4 100644 --- a/mlir/test/lib/Transforms/TestVectorToLoopsConversion.cpp +++ b/mlir/test/lib/Transforms/TestVectorToLoopsConversion.cpp @@ -1,19 +1,10 @@ //===- TestVectorToLoopsConversion.cpp - Test VectorTransfers lowering ----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include diff --git a/mlir/test/lib/Transforms/TestVectorTransforms.cpp b/mlir/test/lib/Transforms/TestVectorTransforms.cpp index 1d513065330..664d49ab4e5 100644 --- a/mlir/test/lib/Transforms/TestVectorTransforms.cpp +++ b/mlir/test/lib/Transforms/TestVectorTransforms.cpp @@ -1,19 +1,10 @@ //===- TestVectorToVectorConversion.cpp - Test VectorTransfers lowering ---===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include diff --git a/mlir/test/lib/Transforms/TestVectorizationUtils.cpp b/mlir/test/lib/Transforms/TestVectorizationUtils.cpp index 35df0631ca7..e131f4803ef 100644 --- a/mlir/test/lib/Transforms/TestVectorizationUtils.cpp +++ b/mlir/test/lib/Transforms/TestVectorizationUtils.cpp @@ -1,19 +1,10 @@ //===- VectorizerTestPass.cpp - VectorizerTestPass Pass Impl --------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file implements a simple testing pass for vectorization functionality. // diff --git a/mlir/test/mlir-cpu-runner/cblas.cpp b/mlir/test/mlir-cpu-runner/cblas.cpp index d219b7b1256..aebb8f212b4 100644 --- a/mlir/test/mlir-cpu-runner/cblas.cpp +++ b/mlir/test/mlir-cpu-runner/cblas.cpp @@ -1,19 +1,10 @@ //===- cblas.cpp - Simple Blas subset implementation ----------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Simple Blas subset implementation. // diff --git a/mlir/test/mlir-cpu-runner/cblas_interface.cpp b/mlir/test/mlir-cpu-runner/cblas_interface.cpp index 831702f594e..5e3a00e7fd1 100644 --- a/mlir/test/mlir-cpu-runner/cblas_interface.cpp +++ b/mlir/test/mlir-cpu-runner/cblas_interface.cpp @@ -1,19 +1,10 @@ //===- cblas_interface.cpp - Simple Blas subset interface -----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Simple Blas subset interface implementation. // diff --git a/mlir/test/mlir-cpu-runner/include/cblas.h b/mlir/test/mlir-cpu-runner/include/cblas.h index 522ac8380b9..ccd316ff52e 100644 --- a/mlir/test/mlir-cpu-runner/include/cblas.h +++ b/mlir/test/mlir-cpu-runner/include/cblas.h @@ -1,19 +1,10 @@ //===- cblas.h - Simple Blas subset ---------------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CPU_RUNNER_CBLAS_H_ #define MLIR_CPU_RUNNER_CBLAS_H_ diff --git a/mlir/test/mlir-cpu-runner/include/mlir_runner_utils.h b/mlir/test/mlir-cpu-runner/include/mlir_runner_utils.h index d4b6e1fedb0..1f4e638c33e 100644 --- a/mlir/test/mlir-cpu-runner/include/mlir_runner_utils.h +++ b/mlir/test/mlir-cpu-runner/include/mlir_runner_utils.h @@ -1,19 +1,10 @@ //===- mlir_runner_utils.h - Utils for debugging MLIR CPU execution -------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #ifndef MLIR_CPU_RUNNER_MLIRUTILS_H_ #define MLIR_CPU_RUNNER_MLIRUTILS_H_ diff --git a/mlir/test/mlir-cpu-runner/mlir_runner_utils.cpp b/mlir/test/mlir-cpu-runner/mlir_runner_utils.cpp index 56829c629bb..fc3a782c080 100644 --- a/mlir/test/mlir-cpu-runner/mlir_runner_utils.cpp +++ b/mlir/test/mlir-cpu-runner/mlir_runner_utils.cpp @@ -1,19 +1,10 @@ //===- mlir_runner_utils.cpp - Utils for MLIR CPU execution ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Utilities for interfacing MLIR types with C code as well as printing, // debugging etc. diff --git a/mlir/tools/mlir-cpu-runner/mlir-cpu-runner.cpp b/mlir/tools/mlir-cpu-runner/mlir-cpu-runner.cpp index f7023c4cf61..144f73d9c97 100644 --- a/mlir/tools/mlir-cpu-runner/mlir-cpu-runner.cpp +++ b/mlir/tools/mlir-cpu-runner/mlir-cpu-runner.cpp @@ -1,19 +1,10 @@ //===- mlir-cpu-runner.cpp - MLIR CPU Execution Driver---------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Main entry point to a command line utility that executes an MLIR file on the // CPU by translating MLIR to LLVM IR before JIT-compiling and executing the diff --git a/mlir/tools/mlir-cuda-runner/cuda-runtime-wrappers.cpp b/mlir/tools/mlir-cuda-runner/cuda-runtime-wrappers.cpp index 0698095afcf..9f1591b5a8c 100644 --- a/mlir/tools/mlir-cuda-runner/cuda-runtime-wrappers.cpp +++ b/mlir/tools/mlir-cuda-runner/cuda-runtime-wrappers.cpp @@ -1,19 +1,10 @@ //===- cuda-runtime-wrappers.cpp - MLIR CUDA runner wrapper library -------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Implements C wrappers around the CUDA library for easy linking in ORC jit. // Also adds some debugging helpers that are helpful when writing MLIR code to diff --git a/mlir/tools/mlir-cuda-runner/mlir-cuda-runner.cpp b/mlir/tools/mlir-cuda-runner/mlir-cuda-runner.cpp index c1ca4ebd8e1..d6160d6d6e0 100644 --- a/mlir/tools/mlir-cuda-runner/mlir-cuda-runner.cpp +++ b/mlir/tools/mlir-cuda-runner/mlir-cuda-runner.cpp @@ -1,19 +1,10 @@ //===- mlir-cpu-runner.cpp - MLIR CPU Execution Driver---------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is a command line utility that executes an MLIR file on the GPU by // translating MLIR to NVVM/LVVM IR before JIT-compiling and executing the diff --git a/mlir/tools/mlir-opt/mlir-opt.cpp b/mlir/tools/mlir-opt/mlir-opt.cpp index d01f66d4e0b..b0dd1b59ce7 100644 --- a/mlir/tools/mlir-opt/mlir-opt.cpp +++ b/mlir/tools/mlir-opt/mlir-opt.cpp @@ -1,19 +1,10 @@ //===- mlir-opt.cpp - MLIR Optimizer Driver -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // Main entry function for mlir-opt for when built as standalone binary. // diff --git a/mlir/tools/mlir-tblgen/DocGenUtilities.h b/mlir/tools/mlir-tblgen/DocGenUtilities.h index b7617742727..1b3c8541aee 100644 --- a/mlir/tools/mlir-tblgen/DocGenUtilities.h +++ b/mlir/tools/mlir-tblgen/DocGenUtilities.h @@ -1,19 +1,10 @@ //===- DocGenUtilities.h - MLIR doc gen utilities ---------------*- C++ -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file defines common utilities for generating documents from tablegen // structures. diff --git a/mlir/tools/mlir-tblgen/EnumsGen.cpp b/mlir/tools/mlir-tblgen/EnumsGen.cpp index e278fdd80e8..610a380dab3 100644 --- a/mlir/tools/mlir-tblgen/EnumsGen.cpp +++ b/mlir/tools/mlir-tblgen/EnumsGen.cpp @@ -1,19 +1,10 @@ //===- EnumsGen.cpp - MLIR enum utility generator -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // EnumsGen generates common utility functions for enums. // diff --git a/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp b/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp index f4b1279f11e..30f720e8d73 100644 --- a/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp +++ b/mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp @@ -1,19 +1,10 @@ //===- LLVMIRConversionGen.cpp - MLIR LLVM IR builder generator -----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file uses tablegen definitions of the LLVM IR Dialect operations to // generate the code building the LLVM IR from it. diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp index df8feb855c5..52cbc08c429 100644 --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -1,19 +1,10 @@ //===- OpDefinitionsGen.cpp - MLIR op definitions generator ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // OpDefinitionsGen uses the description of operations to generate C++ // definitions for ops. diff --git a/mlir/tools/mlir-tblgen/OpDocGen.cpp b/mlir/tools/mlir-tblgen/OpDocGen.cpp index 8b048d9ea94..87a27238ce3 100644 --- a/mlir/tools/mlir-tblgen/OpDocGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDocGen.cpp @@ -1,19 +1,10 @@ //===- OpDocGen.cpp - MLIR operation documentation generator --------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // OpDocGen uses the description of operations to generate documentation for the // operations. diff --git a/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp b/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp index a48bd2509bc..a96736cd2c5 100644 --- a/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp +++ b/mlir/tools/mlir-tblgen/OpInterfacesGen.cpp @@ -1,19 +1,10 @@ //===- OpInterfacesGen.cpp - MLIR op interface utility generator ----------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // OpInterfacesGen generates definitions for operation interfaces. // diff --git a/mlir/tools/mlir-tblgen/ReferenceImplGen.cpp b/mlir/tools/mlir-tblgen/ReferenceImplGen.cpp index 9181d0e90ed..90b60e5efed 100644 --- a/mlir/tools/mlir-tblgen/ReferenceImplGen.cpp +++ b/mlir/tools/mlir-tblgen/ReferenceImplGen.cpp @@ -1,19 +1,10 @@ //===- ReferenceImplGen.cpp - MLIR reference implementation generator -----===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // ReferenceImplGen uses the description of operations to generate reference // implementations for the ops. diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp index a74bc23a95a..8cfd454d629 100644 --- a/mlir/tools/mlir-tblgen/RewriterGen.cpp +++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp @@ -1,19 +1,10 @@ //===- RewriterGen.cpp - MLIR pattern rewriter generator ------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // RewriterGen uses pattern rewrite definitions to generate rewriter matchers. // diff --git a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp index 6d5bcc116ad..1aa7d5968d2 100644 --- a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp +++ b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp @@ -1,19 +1,10 @@ //===- SPIRVSerializationGen.cpp - SPIR-V serialization utility generator -===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // SPIRVSerializationGen generates common utility functions for SPIR-V // serialization. diff --git a/mlir/tools/mlir-tblgen/StructsGen.cpp b/mlir/tools/mlir-tblgen/StructsGen.cpp index d8844957ece..576085e41eb 100644 --- a/mlir/tools/mlir-tblgen/StructsGen.cpp +++ b/mlir/tools/mlir-tblgen/StructsGen.cpp @@ -1,19 +1,10 @@ //===- StructsGen.cpp - MLIR struct utility generator ---------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // StructsGen generates common utility functions for grouping attributes into a // set of structured data. diff --git a/mlir/tools/mlir-tblgen/mlir-tblgen.cpp b/mlir/tools/mlir-tblgen/mlir-tblgen.cpp index 993a05d7095..3c9778b3ec7 100644 --- a/mlir/tools/mlir-tblgen/mlir-tblgen.cpp +++ b/mlir/tools/mlir-tblgen/mlir-tblgen.cpp @@ -1,19 +1,10 @@ //===- mlir-tblgen.cpp - Top-Level TableGen implementation for MLIR -------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains the main function for MLIR's TableGen. // diff --git a/mlir/tools/mlir-translate/mlir-translate.cpp b/mlir/tools/mlir-translate/mlir-translate.cpp index b5622e3ecf8..3b15c5f3875 100644 --- a/mlir/tools/mlir-translate/mlir-translate.cpp +++ b/mlir/tools/mlir-translate/mlir-translate.cpp @@ -1,19 +1,10 @@ //===- mlir-translate.cpp - MLIR Translate Driver -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This is a command line utility that translates a file from/to MLIR using one // of the registered translations. diff --git a/mlir/unittests/ADT/TypeSwitchTest.cpp b/mlir/unittests/ADT/TypeSwitchTest.cpp index b6a78de892e..549fb9b221e 100644 --- a/mlir/unittests/ADT/TypeSwitchTest.cpp +++ b/mlir/unittests/ADT/TypeSwitchTest.cpp @@ -1,19 +1,10 @@ //===- TypeSwitchTest.cpp - TypeSwitch unit tests -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/ADT/TypeSwitch.h" #include "gtest/gtest.h" diff --git a/mlir/unittests/Dialect/BroadcastShapeTest.cpp b/mlir/unittests/Dialect/BroadcastShapeTest.cpp index c475fa79476..594e98741e1 100644 --- a/mlir/unittests/Dialect/BroadcastShapeTest.cpp +++ b/mlir/unittests/Dialect/BroadcastShapeTest.cpp @@ -1,19 +1,10 @@ //===- BroadcastShapeTest.cpp - broadcasting shape unit tests -------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/Traits.h" #include "llvm/ADT/SmallVector.h" diff --git a/mlir/unittests/Dialect/QuantOps/QuantizationUtilsTest.cpp b/mlir/unittests/Dialect/QuantOps/QuantizationUtilsTest.cpp index d10623e3d1d..4f6ad302c7c 100644 --- a/mlir/unittests/Dialect/QuantOps/QuantizationUtilsTest.cpp +++ b/mlir/unittests/Dialect/QuantOps/QuantizationUtilsTest.cpp @@ -1,19 +1,10 @@ //===- QuantizationUtilsTest.cpp - unit tests for quantization utils ------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/QuantOps/QuantizeUtils.h" #include "mlir/Dialect/QuantOps/UniformSupport.h" diff --git a/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp b/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp index ed5bd9ebecc..72fee15ac90 100644 --- a/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp +++ b/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp @@ -1,19 +1,10 @@ //===- DeserializationTest.cpp - SPIR-V Deserialization Tests -------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // The purpose of this file is to provide negative deserialization tests. // For positive deserialization tests, please use serialization and diff --git a/mlir/unittests/Dialect/SPIRV/SerializationTest.cpp b/mlir/unittests/Dialect/SPIRV/SerializationTest.cpp index 2728ab820b6..61f5fcbfb7b 100644 --- a/mlir/unittests/Dialect/SPIRV/SerializationTest.cpp +++ b/mlir/unittests/Dialect/SPIRV/SerializationTest.cpp @@ -1,19 +1,10 @@ //===- SerializationTest.cpp - SPIR-V Serialization Tests -----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// // // This file contains corner case tests for the SPIR-V serializer that are not // covered by normal serialization and deserialization roundtripping. diff --git a/mlir/unittests/IR/AttributeTest.cpp b/mlir/unittests/IR/AttributeTest.cpp index 3db87b29c2d..5a1750e1123 100644 --- a/mlir/unittests/IR/AttributeTest.cpp +++ b/mlir/unittests/IR/AttributeTest.cpp @@ -1,19 +1,10 @@ //===- AttributeTest.cpp - Attribute unit tests ---------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Attributes.h" #include "mlir/IR/StandardTypes.h" diff --git a/mlir/unittests/IR/DialectTest.cpp b/mlir/unittests/IR/DialectTest.cpp index e48d2d7d710..1438d322652 100644 --- a/mlir/unittests/IR/DialectTest.cpp +++ b/mlir/unittests/IR/DialectTest.cpp @@ -1,19 +1,10 @@ //===- DialectTest.cpp - Dialect unit tests -------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Dialect.h" #include "gtest/gtest.h" diff --git a/mlir/unittests/IR/OperationSupportTest.cpp b/mlir/unittests/IR/OperationSupportTest.cpp index d7dae4648fe..004a940ca6c 100644 --- a/mlir/unittests/IR/OperationSupportTest.cpp +++ b/mlir/unittests/IR/OperationSupportTest.cpp @@ -1,19 +1,10 @@ //===- OperationSupportTest.cpp - Operation support unit tests ------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/OperationSupport.h" #include "mlir/IR/Builders.h" diff --git a/mlir/unittests/IR/StringExtrasTest.cpp b/mlir/unittests/IR/StringExtrasTest.cpp index def65950365..3773006faee 100644 --- a/mlir/unittests/IR/StringExtrasTest.cpp +++ b/mlir/unittests/IR/StringExtrasTest.cpp @@ -1,19 +1,10 @@ //===- StringExtrasTest.cpp - Tests for utility methods in StringExtras.h -===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Support/StringExtras.h" #include "gtest/gtest.h" diff --git a/mlir/unittests/Pass/AnalysisManagerTest.cpp b/mlir/unittests/Pass/AnalysisManagerTest.cpp index 790ad9c2589..0ea2c3f66e5 100644 --- a/mlir/unittests/Pass/AnalysisManagerTest.cpp +++ b/mlir/unittests/Pass/AnalysisManagerTest.cpp @@ -1,19 +1,10 @@ //===- AnalysisManagerTest.cpp - AnalysisManager unit tests ---------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Pass/AnalysisManager.h" #include "mlir/IR/Builders.h" diff --git a/mlir/unittests/Quantizer/Support/RulesTest.cpp b/mlir/unittests/Quantizer/Support/RulesTest.cpp index 7ddfb715751..e2593848cbf 100644 --- a/mlir/unittests/Quantizer/Support/RulesTest.cpp +++ b/mlir/unittests/Quantizer/Support/RulesTest.cpp @@ -1,19 +1,10 @@ //===- RulesTest.cpp - Rules unit tests -----------------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Quantizer/Support/Rules.h" #include "llvm/Support/raw_ostream.h" diff --git a/mlir/unittests/Quantizer/Support/UniformSolversTest.cpp b/mlir/unittests/Quantizer/Support/UniformSolversTest.cpp index 4a53f923d3d..4e27cdc1d66 100644 --- a/mlir/unittests/Quantizer/Support/UniformSolversTest.cpp +++ b/mlir/unittests/Quantizer/Support/UniformSolversTest.cpp @@ -1,19 +1,10 @@ //===- UniformSolversTest.cpp - Tests for uniform solvers -----------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Quantizer/Support/UniformSolvers.h" #include "gtest/gtest.h" diff --git a/mlir/unittests/SDBM/SDBMTest.cpp b/mlir/unittests/SDBM/SDBMTest.cpp index 99756dcaa96..aa55ce58477 100644 --- a/mlir/unittests/SDBM/SDBMTest.cpp +++ b/mlir/unittests/SDBM/SDBMTest.cpp @@ -1,19 +1,10 @@ //===- SDBMTest.cpp - SDBM expression unit tests --------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/Dialect/SDBM/SDBM.h" #include "mlir/Dialect/SDBM/SDBMDialect.h" diff --git a/mlir/unittests/TableGen/EnumsGenTest.cpp b/mlir/unittests/TableGen/EnumsGenTest.cpp index 3934e8b0ed2..e4fe68482ef 100644 --- a/mlir/unittests/TableGen/EnumsGenTest.cpp +++ b/mlir/unittests/TableGen/EnumsGenTest.cpp @@ -1,19 +1,10 @@ //===- EnumsGenTest.cpp - TableGen EnumsGen Tests -------------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/Optional.h" diff --git a/mlir/unittests/TableGen/FormatTest.cpp b/mlir/unittests/TableGen/FormatTest.cpp index 7338a8f7554..0566c8a5a7b 100644 --- a/mlir/unittests/TableGen/FormatTest.cpp +++ b/mlir/unittests/TableGen/FormatTest.cpp @@ -1,19 +1,10 @@ //===- FormatTest.cpp - TableGen Format Utility Tests ---------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/TableGen/Format.h" #include "gmock/gmock.h" diff --git a/mlir/unittests/TableGen/StructsGenTest.cpp b/mlir/unittests/TableGen/StructsGenTest.cpp index b446ca9558a..45455d7e2aa 100644 --- a/mlir/unittests/TableGen/StructsGenTest.cpp +++ b/mlir/unittests/TableGen/StructsGenTest.cpp @@ -1,19 +1,10 @@ //===- StructsGenTest.cpp - TableGen StructsGen Tests ---------------------===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// #include "mlir/IR/Attributes.h" #include "mlir/IR/Identifier.h" diff --git a/mlir/unittests/TableGen/enums.td b/mlir/unittests/TableGen/enums.td index 806d4a9d7b9..7d44856f9dc 100644 --- a/mlir/unittests/TableGen/enums.td +++ b/mlir/unittests/TableGen/enums.td @@ -1,19 +1,10 @@ //===-- enums.td - EnumsGen test definition file -----------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// include "mlir/IR/OpBase.td" diff --git a/mlir/unittests/TableGen/structs.td b/mlir/unittests/TableGen/structs.td index efa0a6024c5..88551751182 100644 --- a/mlir/unittests/TableGen/structs.td +++ b/mlir/unittests/TableGen/structs.td @@ -1,19 +1,10 @@ //===-- structs.td - StructsGen test definition file -------*- tablegen -*-===// // -// Copyright 2019 The MLIR Authors. +// Part of the MLIR 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 // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================= +//===----------------------------------------------------------------------===// include "mlir/IR/OpBase.td" diff --git a/mlir/utils/generate-test-checks.py b/mlir/utils/generate-test-checks.py index 3bb4ffe4a4f..6dc40c797e2 100755 --- a/mlir/utils/generate-test-checks.py +++ b/mlir/utils/generate-test-checks.py @@ -17,19 +17,9 @@ adding checks to a test case fast, it is *not* designed to be authoritative about what constitutes a good test! """ -# Copyright 2019 The MLIR Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# 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 import argparse import os # Used to advertise this file's name ("autogenerated_note"). diff --git a/mlir/utils/spirv/define_enum.sh b/mlir/utils/spirv/define_enum.sh index 9da898f7d4c..87b88c93133 100755 --- a/mlir/utils/spirv/define_enum.sh +++ b/mlir/utils/spirv/define_enum.sh @@ -1,18 +1,8 @@ #!/bin/bash -# Copyright 2019 The MLIR Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# 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 # Script for defining a new enum attr using SPIR-V spec from the Internet. # diff --git a/mlir/utils/spirv/define_inst.sh b/mlir/utils/spirv/define_inst.sh index f11078a8e76..322c67e8da8 100755 --- a/mlir/utils/spirv/define_inst.sh +++ b/mlir/utils/spirv/define_inst.sh @@ -1,17 +1,7 @@ #!/bin/bash -# Copyright 2019 The MLIR Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# 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 # Script for defining a new op using SPIR-V spec from the Internet. # diff --git a/mlir/utils/spirv/define_opcodes.sh b/mlir/utils/spirv/define_opcodes.sh index 05c36571115..7b9aeab9c08 100755 --- a/mlir/utils/spirv/define_opcodes.sh +++ b/mlir/utils/spirv/define_opcodes.sh @@ -1,18 +1,8 @@ #!/bin/bash -# Copyright 2019 The MLIR Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# 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 # Script for defining map for opname to opcode using SPIR-V spec from the # Internet diff --git a/mlir/utils/spirv/gen_spirv_dialect.py b/mlir/utils/spirv/gen_spirv_dialect.py index be7116c211f..2433cf4e6da 100755 --- a/mlir/utils/spirv/gen_spirv_dialect.py +++ b/mlir/utils/spirv/gen_spirv_dialect.py @@ -1,19 +1,9 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -# Copyright 2019 The MLIR Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# 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 # Script for updating SPIR-V dialect by scraping information from SPIR-V # HTML and JSON specs from the Internet. -- cgit v1.2.3