[all-commits] [llvm/llvm-project] 759a7b: [mlir] Add the ability to define dialect-specific ...

Aman LaChapelle via All-commits all-commits at lists.llvm.org
Thu Oct 3 10:26:05 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 759a7b5933654b67b9b7089d9aef2ca287cc38fa
      https://github.com/llvm/llvm-project/commit/759a7b5933654b67b9b7089d9aef2ca287cc38fa
  Author: Aman LaChapelle <aman.lachapelle at gmail.com>
  Date:   2024-10-03 (Thu, 03 Oct 2024)

  Changed paths:
    M mlir/include/mlir/IR/AttrTypeBase.td
    M mlir/include/mlir/IR/Attributes.h
    M mlir/include/mlir/IR/BuiltinLocationAttributes.td
    M mlir/include/mlir/IR/Location.h
    M mlir/lib/AsmParser/Parser.cpp
    M mlir/lib/IR/AsmPrinter.cpp
    M mlir/lib/IR/Location.cpp
    M mlir/test/IR/invalid-locations.mlir
    M mlir/test/IR/locations.mlir
    M mlir/test/IR/pretty-locations.mlir
    M mlir/test/lib/Dialect/Test/TestAttrDefs.td
    M mlir/unittests/IR/CMakeLists.txt
    A mlir/unittests/IR/LocationTest.cpp

  Log Message:
  -----------
  [mlir] Add the ability to define dialect-specific location attrs. (#105584)

This patch adds the capability to define dialect-specific location
attrs. This is useful in particular for defining location structure that
doesn't necessarily fit within the core MLIR location hierarchy, but
doesn't make sense to push upstream (i.e. a custom use case).

This patch adds an AttributeTrait, `IsLocation`, which is tagged onto
all the builtin location attrs, as well as the test location attribute.
This is necessary because previously LocationAttr::classof only returned
true if the attribute was one of the builtin location attributes, and
well, the point of this patch is to allow dialects to define their own
location attributes.

There was an alternate implementation I considered wherein LocationAttr
becomes an AttrInterface, but that was discarded because there are
likely to be *many* locations in a single program, and I was concerned
that forcing every MLIR user to pay the cost of the additional
lookup/dispatch was unacceptable. It also would have been a *much* more
invasive change. It would have allowed for more flexibility in terms of
pretty printing, but it's unclear how useful/necessary that flexibility
would be given how much customizability there already is for attribute
definitions.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list