[Mlir-commits] [mlir] cc83dc1 - Import llvm::StringSwitch into mlir namespace.
Christian Sigg
llvmlistbot at llvm.org
Thu Oct 8 02:39:35 PDT 2020
Author: Christian Sigg
Date: 2020-10-08T11:39:24+02:00
New Revision: cc83dc191c1ef04907ccd4308cc6aa5bf6fcd3c6
URL: https://github.com/llvm/llvm-project/commit/cc83dc191c1ef04907ccd4308cc6aa5bf6fcd3c6
DIFF: https://github.com/llvm/llvm-project/commit/cc83dc191c1ef04907ccd4308cc6aa5bf6fcd3c6.diff
LOG: Import llvm::StringSwitch into mlir namespace.
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D88971
Added:
Modified:
mlir/include/mlir/Support/LLVM.h
mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h
mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp
mlir/lib/Dialect/PDL/IR/PDL.cpp
mlir/lib/ExecutionEngine/JitRunner.cpp
mlir/lib/IR/SymbolTable.cpp
mlir/lib/Parser/Lexer.cpp
mlir/lib/TableGen/Format.cpp
mlir/lib/TableGen/Predicate.cpp
mlir/test/lib/Dialect/Test/TestDialect.cpp
mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp
mlir/tools/mlir-tblgen/OpFormatGen.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Support/LLVM.h b/mlir/include/mlir/Support/LLVM.h
index 17e020442eb4..e8595ae29ed7 100644
--- a/mlir/include/mlir/Support/LLVM.h
+++ b/mlir/include/mlir/Support/LLVM.h
@@ -60,6 +60,8 @@ template <typename T>
class SmallVectorImpl;
template <typename AllocatorTy>
class StringSet;
+template <typename T, typename R>
+class StringSwitch;
template <typename T>
class TinyPtrVector;
template <typename T, typename ResultT>
@@ -111,6 +113,8 @@ using llvm::SmallPtrSet;
using llvm::SmallPtrSetImpl;
using llvm::SmallVector;
using llvm::SmallVectorImpl;
+template <typename T, typename R = T>
+using StringSwitch = llvm::StringSwitch<T, R>;
using llvm::TinyPtrVector;
template <typename T, typename ResultT = void>
using TypeSwitch = llvm::TypeSwitch<T, ResultT>;
diff --git a/mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h b/mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h
index 93381054dd21..f4b7cedeb0e1 100644
--- a/mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h
+++ b/mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h
@@ -27,7 +27,7 @@ struct GPUIndexIntrinsicOpLowering : public ConvertToLLVMPattern {
unsigned indexBitwidth;
static dimension dimensionToIndex(Op op) {
- return llvm::StringSwitch<dimension>(op.dimension())
+ return StringSwitch<dimension>(op.dimension())
.Case("x", X)
.Case("y", Y)
.Case("z", Z)
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp
index aa611d76a67a..574d0aa8c37f 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp
@@ -440,7 +440,7 @@ static LLVMType parseTypeImpl(DialectAsmParser &parser,
if (failed(parser.parseKeyword(&key)))
return LLVMType();
- return llvm::StringSwitch<function_ref<LLVMType()>>(key)
+ return StringSwitch<function_ref<LLVMType()>>(key)
.Case("void", [&] { return LLVMVoidType::get(ctx); })
.Case("half", [&] { return LLVMHalfType::get(ctx); })
.Case("bfloat", [&] { return LLVMBFloatType::get(ctx); })
diff --git a/mlir/lib/Dialect/PDL/IR/PDL.cpp b/mlir/lib/Dialect/PDL/IR/PDL.cpp
index a0b9c969becf..ba1eb7b99574 100644
--- a/mlir/lib/Dialect/PDL/IR/PDL.cpp
+++ b/mlir/lib/Dialect/PDL/IR/PDL.cpp
@@ -34,7 +34,7 @@ Type PDLDialect::parseType(DialectAsmParser &parser) const {
return Type();
Builder &builder = parser.getBuilder();
- Type result = llvm::StringSwitch<Type>(keyword)
+ Type result = StringSwitch<Type>(keyword)
.Case("attribute", builder.getType<AttributeType>())
.Case("operation", builder.getType<OperationType>())
.Case("type", builder.getType<TypeType>())
diff --git a/mlir/lib/ExecutionEngine/JitRunner.cpp b/mlir/lib/ExecutionEngine/JitRunner.cpp
index 2b18adb37347..7d141e90edda 100644
--- a/mlir/lib/ExecutionEngine/JitRunner.cpp
+++ b/mlir/lib/ExecutionEngine/JitRunner.cpp
@@ -291,7 +291,7 @@ int mlir::JitRunnerMain(
Error (*)(Options &, ModuleOp, StringRef,
std::function<llvm::Error(llvm::Module *)>);
auto compileAndExecuteFn =
- llvm::StringSwitch<CompileAndExecuteFnT>(options.mainFuncType.getValue())
+ StringSwitch<CompileAndExecuteFnT>(options.mainFuncType.getValue())
.Case("i32", compileAndExecuteSingleReturnFunction<int32_t>)
.Case("i64", compileAndExecuteSingleReturnFunction<int64_t>)
.Case("f32", compileAndExecuteSingleReturnFunction<float>)
diff --git a/mlir/lib/IR/SymbolTable.cpp b/mlir/lib/IR/SymbolTable.cpp
index b064d83b5faa..e18e691f8cc8 100644
--- a/mlir/lib/IR/SymbolTable.cpp
+++ b/mlir/lib/IR/SymbolTable.cpp
@@ -166,7 +166,7 @@ SymbolTable::Visibility SymbolTable::getSymbolVisibility(Operation *symbol) {
return Visibility::Public;
// Otherwise, switch on the string value.
- return llvm::StringSwitch<Visibility>(vis.getValue())
+ return StringSwitch<Visibility>(vis.getValue())
.Case("private", Visibility::Private)
.Case("nested", Visibility::Nested)
.Case("public", Visibility::Public);
diff --git a/mlir/lib/Parser/Lexer.cpp b/mlir/lib/Parser/Lexer.cpp
index 9a3418eaf832..ee31ff0cf9e4 100644
--- a/mlir/lib/Parser/Lexer.cpp
+++ b/mlir/lib/Parser/Lexer.cpp
@@ -212,7 +212,7 @@ Token Lexer::lexBareIdentifierOrKeyword(const char *tokStart) {
isAllDigit(spelling.drop_front(2))))
return Token(Token::inttype, spelling);
- Token::Kind kind = llvm::StringSwitch<Token::Kind>(spelling)
+ Token::Kind kind = StringSwitch<Token::Kind>(spelling)
#define TOK_KEYWORD(SPELLING) .Case(#SPELLING, Token::kw_##SPELLING)
#include "TokenKinds.def"
.Default(Token::bare_identifier);
diff --git a/mlir/lib/TableGen/Format.cpp b/mlir/lib/TableGen/Format.cpp
index 12735875c1c1..7d17a0aef3f9 100644
--- a/mlir/lib/TableGen/Format.cpp
+++ b/mlir/lib/TableGen/Format.cpp
@@ -60,7 +60,7 @@ Optional<StringRef> FmtContext::getSubstFor(StringRef placeholder) const {
}
FmtContext::PHKind FmtContext::getPlaceHolderKind(StringRef str) {
- return llvm::StringSwitch<FmtContext::PHKind>(str)
+ return StringSwitch<FmtContext::PHKind>(str)
.Case("_builder", FmtContext::PHKind::Builder)
.Case("_op", FmtContext::PHKind::Op)
.Case("_self", FmtContext::PHKind::Self)
diff --git a/mlir/lib/TableGen/Predicate.cpp b/mlir/lib/TableGen/Predicate.cpp
index 8927296af223..a37847f0d489 100644
--- a/mlir/lib/TableGen/Predicate.cpp
+++ b/mlir/lib/TableGen/Predicate.cpp
@@ -119,7 +119,7 @@ static PredCombinerKind getPredCombinerKind(const Pred &pred) {
return PredCombinerKind::Leaf;
const auto &combinedPred = static_cast<const CombinedPred &>(pred);
- return llvm::StringSwitch<PredCombinerKind>(
+ return StringSwitch<PredCombinerKind>(
combinedPred.getCombinerDef()->getName())
.Case("PredCombinerAnd", PredCombinerKind::And)
.Case("PredCombinerOr", PredCombinerKind::Or)
diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp
index c84a7717abe7..4ca89bced5eb 100644
--- a/mlir/test/lib/Dialect/Test/TestDialect.cpp
+++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp
@@ -685,7 +685,7 @@ void SideEffectOp::getEffects(
// Get the specific memory effect.
MemoryEffects::Effect *effect =
- llvm::StringSwitch<MemoryEffects::Effect *>(
+ StringSwitch<MemoryEffects::Effect *>(
effectElement.get("effect").cast<StringAttr>().getValue())
.Case("allocate", MemoryEffects::Allocate::get())
.Case("free", MemoryEffects::Free::get())
diff --git a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp
index 4fe3cd1ee174..64424b4ac3d2 100644
--- a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp
+++ b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp
@@ -288,7 +288,7 @@ Token Lexer::lexIdentifier(const char *tokStart) {
// Check to see if this identifier is a keyword.
StringRef str(tokStart, curPtr - tokStart);
- Token::Kind kind = llvm::StringSwitch<Token::Kind>(str)
+ Token::Kind kind = StringSwitch<Token::Kind>(str)
.Case("def", Token::Kind::kw_def)
.Case("ods_def", Token::Kind::kw_ods_def)
.Case("floordiv", Token::Kind::kw_floordiv)
diff --git a/mlir/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp
index 336c9111677b..9b8f24923240 100644
--- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp
@@ -719,7 +719,7 @@ static void genLiteralParser(StringRef value, OpMethodBody &body) {
body << "Keyword(\"" << value << "\")";
return;
}
- body << (StringRef)llvm::StringSwitch<StringRef>(value)
+ body << (StringRef)StringSwitch<StringRef>(value)
.Case("->", "Arrow()")
.Case(":", "Colon()")
.Case(",", "Comma()")
@@ -1936,7 +1936,7 @@ Token FormatLexer::lexIdentifier(const char *tokStart) {
// Check to see if this identifier is a keyword.
StringRef str(tokStart, curPtr - tokStart);
Token::Kind kind =
- llvm::StringSwitch<Token::Kind>(str)
+ StringSwitch<Token::Kind>(str)
.Case("attr-dict", Token::kw_attr_dict)
.Case("attr-dict-with-keyword", Token::kw_attr_dict_w_keyword)
.Case("custom", Token::kw_custom)
More information about the Mlir-commits
mailing list