===----------------------------------------------------------------------===// Serialization registration ===----------------------------------------------------------------------===//
| 45 | // Serialization registration |
| 46 | //===----------------------------------------------------------------------===// |
| 47 | static FailureOr<cuda_tile::ModuleOp> getCudaTileModuleOp(Operation *op) { |
| 48 | cuda_tile::ModuleOp moduleOp = dyn_cast<cuda_tile::ModuleOp>(op); |
| 49 | if (moduleOp) |
| 50 | return moduleOp; |
| 51 | // Also support a CUDA Tile IR Module nested in a MLIR Module for convenience |
| 52 | // since the MLIR parse is adding one implicitly by default. |
| 53 | if (auto moduleOp = dyn_cast<mlir::ModuleOp>(op)) { |
| 54 | if (!llvm::hasSingleElement(*moduleOp.getBody()) || |
| 55 | !llvm::isa<cuda_tile::ModuleOp>(moduleOp.getBody()->front())) { |
| 56 | return op->emitError( |
| 57 | "expected a single CUDA Tile IR module in the MLIR module"); |
| 58 | } |
| 59 | return cast<cuda_tile::ModuleOp>(moduleOp.getBody()->front()); |
| 60 | } |
| 61 | return op->emitError("expected a CUDA Tile IR module, but got a " + |
| 62 | op->getName().getStringRef()); |
| 63 | } |
| 64 | |
| 65 | static void registerToTileIRBytecodeTranslation() { |
| 66 | TranslateFromMLIRRegistration toBytecode( |
no test coverage detected