MCPcopy Create free account
hub / github.com/NVIDIA/cuda-tile / writeOperation

Method writeOperation

lib/Bytecode/Writer/BytecodeWriter.cpp:954–986  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

952 : typeMgr(tm), constMgr(cm), strMgr(sm), debuginfo(dm), config(cfg) {}
953
954 LogicalResult writeOperation(Operation *op, EncodingWriter &writer) {
955 auto opcode = getOpcodeForOperation(op);
956 if (!opcode)
957 return op->emitError("operation not supported in bytecode (missing from "
958 "BytecodeOpcodes.td)");
959
960 // Version checking for public operations.
961 uint32_t opcodeValue = static_cast<uint32_t>(*opcode);
962 if (!mlir::cuda_tile::detail::isOpcodeAvailableInVersion(
963 opcodeValue, config.bytecodeVersion))
964 return op->emitError() << "operation '" << op->getName().getStringRef()
965 << "' is not available in bytecode version "
966 << config.bytecodeVersion.toString();
967
968 writer.writeVarInt(*opcode);
969
970 if (failed(debuginfo.validateDebugInfo(op)))
971 return failure();
972
973 uint64_t functionLocIndex =
974 debuginfo.getOpIndex(op->getParentOfType<FunctionOpInterface>());
975 debuginfo.addDebugInfo(functionLocIndex, op->getLoc());
976
977 auto numSerializedResults =
978 dispatchOpWriter(op, writer, typeMgr, constMgr, strMgr, config);
979 if (failed(numSerializedResults))
980 return failure();
981 // Only add serialized results to valueIndexMap. Results that were not
982 // serialized (due to version compatibility) should not be indexed.
983 for (size_t i = 0; i < *numSerializedResults; ++i)
984 valueIndexMap[op->getResult(i)] = nextValueIndex++;
985 return success();
986 }
987
988 std::optional<Bytecode::Opcode> getOpcodeForOperation(Operation *op) {
989 auto it = Bytecode::getOpcodeMap().find(op->getName().getStringRef());

Callers

nothing calls this directly

Calls 6

emitErrorMethod · 0.80
writeVarIntMethod · 0.80
validateDebugInfoMethod · 0.80
getOpIndexMethod · 0.80
addDebugInfoMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected