Skip to content

Commit a31fd58

Browse files
committed
Add some uncommited files.
1 parent 87f80dc commit a31fd58

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

mlir/include/mlir/Dialect/Arith/Utils/Utils.h

+6
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ Value createProduct(OpBuilder &builder, Location loc, ArrayRef<Value> values,
146146
// Map strings to float types.
147147
std::optional<FloatType> parseFloatType(MLIRContext *ctx, StringRef name);
148148

149+
// Map strings to Int types.
150+
std::optional<IntegerType> parseIntType(MLIRContext *ctx, StringRef name);
151+
152+
// Map strings to int or float types.
153+
std::optional<Type> parseIntOrFloatType(MLIRContext *ctx, StringRef name);
154+
149155
} // namespace arith
150156
} // namespace mlir
151157

mlir/lib/Dialect/Arith/Utils/Utils.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -380,4 +380,29 @@ std::optional<FloatType> parseFloatType(MLIRContext *ctx, StringRef name) {
380380
.Default(std::nullopt);
381381
}
382382

383+
/// Map strings to Int types.
384+
std::optional<IntegerType> parseIntType(MLIRContext *ctx, StringRef name) {
385+
Builder b(ctx);
386+
return llvm::StringSwitch<std::optional<IntegerType>>(name)
387+
.Case("i1", b.getIntegerType(1))
388+
.Case("i2", b.getIntegerType(2))
389+
.Case("i4", b.getIntegerType(4))
390+
.Case("i6", b.getIntegerType(6))
391+
.Case("i8", b.getIntegerType(8))
392+
.Case("i16", b.getIntegerType(16))
393+
.Case("i32", b.getIntegerType(32))
394+
.Case("i64", b.getIntegerType(64))
395+
.Case("i80", b.getIntegerType(80))
396+
.Case("i128", b.getIntegerType(128))
397+
.Default(std::nullopt);
398+
}
399+
/// Map strings to Int or Float types.
400+
std::optional<Type> parseIntOrFloatType(MLIRContext *ctx, StringRef name) {
401+
if (auto floatTy = parseFloatType(ctx, name))
402+
return *floatTy;
403+
if (auto intTy = parseIntType(ctx, name))
404+
return *intTy;
405+
return std::nullopt;
406+
}
407+
383408
} // namespace mlir::arith

mlir/lib/Dialect/GPU/Transforms/ImitateUnsupportedTypes.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,6 @@ void mlir::populateImitateUnsupportedTypesTypeConverter(
702702

703703
typeConverter.addSourceMaterialization(materializeCast);
704704
typeConverter.addTargetMaterialization(materializeCast);
705-
typeConverter.addArgumentMaterialization(materializeCast);
706705
}
707706

708707
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)