[all-commits] [llvm/llvm-project] 35b685: [mlir] Add a signedness semantics bit to IntegerType

Lei Zhang via All-commits all-commits at lists.llvm.org
Fri Feb 21 06:17:19 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 35b685270b410f6a1351c2a527021f22330c25b9
      https://github.com/llvm/llvm-project/commit/35b685270b410f6a1351c2a527021f22330c25b9
  Author: Lei Zhang <antiagainst at google.com>
  Date:   2020-02-21 (Fri, 21 Feb 2020)

  Changed paths:
    M mlir/docs/LangRef.md
    M mlir/docs/Rationale.md
    M mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td
    M mlir/include/mlir/Dialect/GPU/GPUOps.td
    M mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
    M mlir/include/mlir/Dialect/QuantOps/QuantPredicates.td
    M mlir/include/mlir/Dialect/QuantOps/UniformSupport.h
    M mlir/include/mlir/Dialect/StandardOps/Ops.td
    M mlir/include/mlir/Dialect/VectorOps/VectorOps.td
    M mlir/include/mlir/IR/Attributes.h
    M mlir/include/mlir/IR/Builders.h
    M mlir/include/mlir/IR/Matchers.h
    M mlir/include/mlir/IR/OpBase.td
    M mlir/include/mlir/IR/OpDefinition.h
    M mlir/include/mlir/IR/Operation.h
    M mlir/include/mlir/IR/StandardTypes.h
    M mlir/include/mlir/IR/Types.h
    M mlir/lib/Analysis/Utils.cpp
    M mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
    M mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
    M mlir/lib/Dialect/AffineOps/EDSC/Builders.cpp
    M mlir/lib/Dialect/FxpMathOps/Transforms/UniformKernelUtils.h
    M mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
    M mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
    M mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
    M mlir/lib/Dialect/Linalg/Utils/Utils.cpp
    M mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
    M mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp
    M mlir/lib/Dialect/SPIRV/TargetAndABI.cpp
    M mlir/lib/Dialect/StandardOps/Ops.cpp
    M mlir/lib/Dialect/VectorOps/VectorOps.cpp
    M mlir/lib/IR/AsmPrinter.cpp
    M mlir/lib/IR/Attributes.cpp
    M mlir/lib/IR/Builders.cpp
    M mlir/lib/IR/MLIRContext.cpp
    M mlir/lib/IR/Operation.cpp
    M mlir/lib/IR/StandardTypes.cpp
    M mlir/lib/IR/TypeDetail.h
    M mlir/lib/Parser/Lexer.cpp
    M mlir/lib/Parser/Parser.cpp
    M mlir/lib/Parser/Token.cpp
    M mlir/lib/Parser/Token.h
    M mlir/lib/Parser/TokenKinds.def
    M mlir/lib/Transforms/LoopFusion.cpp
    M mlir/test/IR/invalid.mlir
    M mlir/test/IR/parser.mlir
    M mlir/test/lib/TestDialect/TestDialect.cpp
    M mlir/test/lib/TestDialect/TestPatterns.cpp
    M mlir/test/mlir-tblgen/op-attribute.td
    M mlir/test/mlir-tblgen/predicate.td

  Log Message:
  -----------
  [mlir] Add a signedness semantics bit to IntegerType

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 opt in.

More discussions can be found at:

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

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




More information about the All-commits mailing list