[PATCH] D76243: [mlir][spirv] Move type checks from dialect class to type hierarchy

Lei Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 17 07:25:14 PDT 2020


antiagainst marked 2 inline comments as done.
antiagainst added inline comments.


================
Comment at: mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp:164
     // If the type is already valid in SPIR-V, directly return.
-    return spirv::SPIRVDialect::isValidType(type) ? type : Optional<Type>();
+    return type.isa<spirv::SPIRVType>() ? type : Optional<Type>();
   });
----------------
mravishankar wrote:
> You could just make this a dyn_cast<spirv::SPIRVType>()
I think it's different. If this is not a SPIR-V type, then `dyn_cast<spirv::SPIRVType>()` gives us a `Type()` instead of `llvm::None`. The former will let the framework to try another conversion rule but the later will directly fail. (Although here it is the last conversion rule so probably doesn't matter that much.)  Anyway, this is completely changed in the next commit (https://reviews.llvm.org/D76244). :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76243/new/

https://reviews.llvm.org/D76243





More information about the llvm-commits mailing list