summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp
diff options
context:
space:
mode:
authorRiver Riddle <riverriddle@google.com>2019-12-17 14:57:07 -0800
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-12-17 14:57:41 -0800
commit74278dd01e5713920a35f1c3e0731e535667c19a (patch)
tree3aa35ade367c4f86e092c52471346e6456e52aa0 /mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp
parent6fa3bd5b3e57806ffa34946bd36528f72bf06b58 (diff)
downloadbcm5719-llvm-74278dd01e5713920a35f1c3e0731e535667c19a.tar.gz
bcm5719-llvm-74278dd01e5713920a35f1c3e0731e535667c19a.zip
NFC: Use TypeSwitch to simplify existing code.
PiperOrigin-RevId: 286066371
Diffstat (limited to 'mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp')
-rw-r--r--mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp33
1 files changed, 14 insertions, 19 deletions
diff --git a/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp
index 51cdd7270d9..5d6a92fee92 100644
--- a/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp
+++ b/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp
@@ -21,6 +21,7 @@
//===----------------------------------------------------------------------===//
#include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h"
+#include "mlir/ADT/TypeSwitch.h"
#include "mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h"
#include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
@@ -232,25 +233,19 @@ Type LLVMTypeConverter::convertVectorType(VectorType type) {
}
// Dispatch based on the actual type. Return null type on error.
-Type LLVMTypeConverter::convertStandardType(Type type) {
- if (auto funcType = type.dyn_cast<FunctionType>())
- return convertFunctionType(funcType);
- if (auto intType = type.dyn_cast<IntegerType>())
- return convertIntegerType(intType);
- if (auto floatType = type.dyn_cast<FloatType>())
- return convertFloatType(floatType);
- if (auto indexType = type.dyn_cast<IndexType>())
- return convertIndexType(indexType);
- if (auto memRefType = type.dyn_cast<MemRefType>())
- return convertMemRefType(memRefType);
- if (auto memRefType = type.dyn_cast<UnrankedMemRefType>())
- return convertUnrankedMemRefType(memRefType);
- if (auto vectorType = type.dyn_cast<VectorType>())
- return convertVectorType(vectorType);
- if (auto llvmType = type.dyn_cast<LLVM::LLVMType>())
- return llvmType;
-
- return {};
+Type LLVMTypeConverter::convertStandardType(Type t) {
+ return TypeSwitch<Type, Type>(t)
+ .Case([&](FloatType type) { return convertFloatType(type); })
+ .Case([&](FunctionType type) { return convertFunctionType(type); })
+ .Case([&](IndexType type) { return convertIndexType(type); })
+ .Case([&](IntegerType type) { return convertIntegerType(type); })
+ .Case([&](MemRefType type) { return convertMemRefType(type); })
+ .Case([&](UnrankedMemRefType type) {
+ return convertUnrankedMemRefType(type);
+ })
+ .Case([&](VectorType type) { return convertVectorType(type); })
+ .Case([](LLVM::LLVMType type) { return type; })
+ .Default([](Type) { return Type(); });
}
LLVMOpLowering::LLVMOpLowering(StringRef rootOpName, MLIRContext *context,
OpenPOWER on IntegriCloud