[all-commits] [llvm/llvm-project] 5cd0b8: [mlir] Allow IntegerAttr to parse zero width integ...

Stella Laurenzo via All-commits all-commits at lists.llvm.org
Thu Dec 30 20:37:54 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5cd0b817e2398d9643f74728970fe4c65776c012
      https://github.com/llvm/llvm-project/commit/5cd0b817e2398d9643f74728970fe4c65776c012
  Author: Stella Laurenzo <stellaraccident at gmail.com>
  Date:   2021-12-30 (Thu, 30 Dec 2021)

  Changed paths:
    M mlir/lib/Parser/AttributeParser.cpp
    M mlir/test/IR/attribute.mlir
    M mlir/test/IR/invalid-ops.mlir

  Log Message:
  -----------
  [mlir] Allow IntegerAttr to parse zero width integers.

https://reviews.llvm.org/D109555 added support to APInt for this, so the special case to disable it is no longer valid. It is in fact legal to construct these programmatically today, and they print properly but do not parse.

Justification: zero bit integers arise naturally in various bit reduction optimization problems, and having them defined for MLIR reduces special casing.

I think there is a solid case for i0 and ui0 being supported. I'm less convinced about si0 and opted to just allow the parser to round-trip values that already verify. The counter argument is that the proper singular value for an si0 is -1. But the counter to this counter is that the sign bit is N-1, which does not exist for si0 and it is not unreasonable to consider this non-existent bit to be 0. Various sources consider it having the singular value "0" to be the least surprising.

Reviewed By: lattner

Differential Revision: https://reviews.llvm.org/D116413




More information about the All-commits mailing list