| 1671 | } |
| 1672 | |
| 1673 | LogicalResult cuda_tile::writeBytecode(raw_ostream &os, |
| 1674 | cuda_tile::ModuleOp module, |
| 1675 | BytecodeVersion targetVersion) { |
| 1676 | // Before trying to write the bytecode, verify that the module is |
| 1677 | // self-contained, meaning it does not have any external dependencies that |
| 1678 | // cannot be serialized into bytecode. |
| 1679 | if (failed(verifySelfContainedModuleAndOperationInvariants(module))) |
| 1680 | return failure(); |
| 1681 | |
| 1682 | // Write the header of the bytecode file. |
| 1683 | BytecodeWriterConfig config{targetVersion}; |
| 1684 | if (failed(writeHeader(os, module, config))) |
| 1685 | return failure(); |
| 1686 | |
| 1687 | // Initialize Managers |
| 1688 | StringManager stringMgr; |
| 1689 | TypeManager typeMgr(config); |
| 1690 | ConstantManager constantMgr; |
| 1691 | DebugInfoWriter debuginfo(stringMgr); |
| 1692 | |
| 1693 | // Collect all function information to populate the type, string, and constant |
| 1694 | // tables |
| 1695 | FunctionTableWriter funcWriter(typeMgr, constantMgr, stringMgr, debuginfo, |
| 1696 | config); |
| 1697 | if (failed(funcWriter.buildFunctionMap(module))) |
| 1698 | return failure(); |
| 1699 | if (failed(writeGlobalSection(os, module, stringMgr, typeMgr, constantMgr, |
| 1700 | debuginfo, config))) { |
| 1701 | return failure(); |
| 1702 | } |
| 1703 | if (failed(funcWriter.writeFunctionTableSection(os))) |
| 1704 | return failure(); |
| 1705 | if (failed(constantMgr.writeConstantSection(os))) |
| 1706 | return failure(); |
| 1707 | if (failed(debuginfo.writeDebugInfoSection(os))) |
| 1708 | return failure(); |
| 1709 | if (failed(typeMgr.writeTypeSection(os))) |
| 1710 | return failure(); |
| 1711 | if (failed(writeProducerSection(os, module, stringMgr, config))) |
| 1712 | return failure(); |
| 1713 | if (failed(stringMgr.writeStringSection(os))) |
| 1714 | return failure(); |
| 1715 | |
| 1716 | // Write the end section to indicate the end of the bytecode. |
| 1717 | os.write(Bytecode::Section::EndOfBytecode); |
| 1718 | return success(); |
| 1719 | } |
nothing calls this directly
no test coverage detected