[Mlir-commits] [mlir] [MLIR] Enhance Bytecode Conversion and Add Unit Tests (PR #108093)
River Riddle
llvmlistbot at llvm.org
Tue Sep 10 15:05:28 PDT 2024
================
@@ -933,32 +934,53 @@ void MLIRDocument::getCodeActionForDiagnostic(
llvm::Expected<lsp::MLIRConvertBytecodeResult>
MLIRDocument::convertToBytecode() {
- // TODO: We currently require a single top-level operation, but this could
- // conceptually be relaxed.
+ // Check if there is a single top-level operation
if (!llvm::hasSingleElement(parsedIR)) {
if (parsedIR.empty()) {
return llvm::make_error<lsp::LSPError>(
- "expected a single and valid top-level operation, please ensure "
- "there are no errors",
+ "No top-level operation found. Ensure the file is not empty and contains valid MLIR code.",
lsp::ErrorCode::RequestFailed);
}
return llvm::make_error<lsp::LSPError>(
- "expected a single top-level operation", lsp::ErrorCode::RequestFailed);
+ "Multiple top-level operations found. Ensure there is only one top-level operation.",
+ lsp::ErrorCode::RequestFailed);
}
- lsp::MLIRConvertBytecodeResult result;
- {
- BytecodeWriterConfig writerConfig(fallbackResourceMap);
+ // Get the top-level operation
+ Operation *topLevelOp = &parsedIR.front();
----------------
River707 wrote:
I'm confused on the logic changes here. In what situation was this not previously converting nested operation to bytecode? (that's what writeBytecodeToFile does). It also looks like you've removed all of the actual bytecode writing, and now just generate placeholder strings for every operation: `"bytecode_for_" << op->getName().getStringRef() << "\n"`.
Can you walk situation you're running into, and what you're trying to do? It feels like there may be some confusion here, given that this source file is for the MLIR Language Server and the test you've written is exercising mlir-opt (different code paths).
https://github.com/llvm/llvm-project/pull/108093
More information about the Mlir-commits
mailing list