[PATCH] D72533: [mlir] Add a signedness semantics bit to IntegerType

Lei Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 10 11:56:01 PST 2020


antiagainst created this revision.
antiagainst added reviewers: rriddle, mehdi_amini.
Herald added subscribers: llvm-commits, lucyrfox, mgester, arpith-jacob, nicolasvasilache, shauheen, burmako, jpienaar.
Herald added a project: LLVM.

Thus far IntegerType has been signless: a value of IntegerType does
not have a sign intrinsically and it's up to the specific operation
to decide how to interpret those bits. For example, std.addi does
two's complement arithmetic, and std.divis/std.diviu treats the first
bit as a sign.

This design choice was made some time ago when we did't have lots
of dialects and dialects were more rigid. Today we have much more
extensible infrastructure and different dialect may want different
modelling over integer signedness. So while we can say we want
signless integers in the standard dialect, we cannot dictate for
others. Requiring each dialect to model the signedness semantics
with another set of custom types is duplicating the functionality
everywhere, considering the fundamental role integer types play.

This CL extends the IntegerType with a signedness semantics bit.
This gives each dialect an option to opt in signedness semantics
if that's what they want and helps code sharing. The parser is
modified to recognize `si[1-9][0-9]*` and `ui[1-9][0-9]*` as
signed and unsigned integer types, respectively, leaving the
original `i[1-9][0-9]*` to continue to mean no indication over
signedness semantics. All existing dialects are not affected (yet)
as this is a feature to be opt in.

More discussions can be found at:

https://groups.google.com/a/tensorflow.org/d/msg/mlir/XmkV8HOPWpo/7O4X0Nb_AQAJ


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72533

Files:
  mlir/docs/LangRef.md
  mlir/docs/Rationale.md
  mlir/include/mlir/IR/Attributes.h
  mlir/include/mlir/IR/Builders.h
  mlir/include/mlir/IR/OpBase.td
  mlir/include/mlir/IR/StandardTypes.h
  mlir/include/mlir/IR/Types.h
  mlir/lib/IR/AsmPrinter.cpp
  mlir/lib/IR/Attributes.cpp
  mlir/lib/IR/Builders.cpp
  mlir/lib/IR/MLIRContext.cpp
  mlir/lib/IR/StandardTypes.cpp
  mlir/lib/IR/TypeDetail.h
  mlir/lib/Parser/Lexer.cpp
  mlir/lib/Parser/Parser.cpp
  mlir/lib/Parser/Token.cpp
  mlir/lib/Parser/Token.h
  mlir/lib/Parser/TokenKinds.def
  mlir/test/IR/invalid.mlir
  mlir/test/IR/parser.mlir
  mlir/test/mlir-tblgen/predicate.td

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72533.237409.patch
Type: text/x-patch
Size: 35404 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200110/efee6e48/attachment.bin>


More information about the llvm-commits mailing list