diff options
author | Matthias Springer <mspringer@nvidia.com> | 2025-04-10 16:05:57 +0200 |
---|---|---|
committer | Matthias Springer <mspringer@nvidia.com> | 2025-04-10 16:05:57 +0200 |
commit | f0279157c733ac96bdd894ebc69a31831692ce48 (patch) | |
tree | bdc80048c511aff0faef076636ebd4e93b3a0ec9 | |
parent | 6defc8ee66caef0191015a6943f1694ee7410459 (diff) | |
download | llvm-users/matthias-springer/value_semantics_docs.zip llvm-users/matthias-springer/value_semantics_docs.tar.gz llvm-users/matthias-springer/value_semantics_docs.tar.bz2 |
[mlir][IR] Add `ValueSemantics` trait to integer, float, ... typesusers/matthias-springer/value_semantics_docs
-rw-r--r-- | mlir/include/mlir/IR/BuiltinTypes.td | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/mlir/include/mlir/IR/BuiltinTypes.td b/mlir/include/mlir/IR/BuiltinTypes.td index 771de01..56f026b 100644 --- a/mlir/include/mlir/IR/BuiltinTypes.td +++ b/mlir/include/mlir/IR/BuiltinTypes.td @@ -36,6 +36,19 @@ class Builtin_Type<string name, string typeMnemonic, list<Trait> traits = [], //===----------------------------------------------------------------------===// /// Type trait indicating that the type has value semantics. +/// +/// Reading (from) an SSA value with a value-semantics type always gives the +/// same value. +/// +/// Examples: +/// * An integer SSA value semantically always carries the same integer value. +/// * Reading (extracting) from a tensor always yields a semantically +/// equivalent SSA value. (But the extracted value itself does not +/// necessarily have value semantics.) +/// +/// Counter examples: +/// * Loading from a memref may yield different values, depending on the state +/// of the memory. def ValueSemantics : NativeTypeTrait<"ValueSemantics"> { let cppNamespace = "::mlir"; } @@ -44,7 +57,7 @@ def ValueSemantics : NativeTypeTrait<"ValueSemantics"> { // ComplexType //===----------------------------------------------------------------------===// -def Builtin_Complex : Builtin_Type<"Complex", "complex"> { +def Builtin_Complex : Builtin_Type<"Complex", "complex", [ValueSemantics]> { let summary = "Complex number with a parameterized element type"; let description = [{ Syntax: @@ -84,7 +97,8 @@ class Builtin_FloatType<string name, string mnemonic, : Builtin_Type<name, mnemonic, /*traits=*/[ DeclareTypeInterfaceMethods< FloatTypeInterface, - ["getFloatSemantics"] # declaredInterfaceMethods>]> { + ["getFloatSemantics"] # declaredInterfaceMethods>, + ValueSemantics]> { } // Float types that are cached in MLIRContext. @@ -466,7 +480,7 @@ def Builtin_Function : Builtin_Type<"Function", "function"> { //===----------------------------------------------------------------------===// def Builtin_Index : Builtin_Type<"Index", "index", - [VectorElementTypeInterface]> { + [VectorElementTypeInterface, ValueSemantics]> { let summary = "Integer-like type with unknown platform-dependent bit width"; let description = [{ Syntax: @@ -497,7 +511,7 @@ def Builtin_Index : Builtin_Type<"Index", "index", //===----------------------------------------------------------------------===// def Builtin_Integer : Builtin_Type<"Integer", "integer", - [VectorElementTypeInterface]> { + [VectorElementTypeInterface, ValueSemantics]> { let summary = "Integer type with arbitrary precision up to a fixed limit"; let description = [{ Syntax: @@ -1075,7 +1089,7 @@ def Builtin_RankedTensor : Builtin_Type<"RankedTensor", "tensor", [ // TupleType //===----------------------------------------------------------------------===// -def Builtin_Tuple : Builtin_Type<"Tuple", "tuple"> { +def Builtin_Tuple : Builtin_Type<"Tuple", "tuple", [ValueSemantics]> { let summary = "Fixed-sized collection of other types"; let description = [{ Syntax: |