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

Function generateOperandSerialization

tools/cuda-tile-tblgen/BytecodeGen.cpp:497–520  ·  view source on GitHub ↗

Generates C++ code within the 'write ' function to serialize the operands of the given operation.

Source from the content-addressed store, hash-verified

495/// Generates C++ code within the 'write<OpName>' function to serialize the
496/// operands of the given operation.
497static void generateOperandSerialization(const Operator &op, raw_ostream &os) {
498 if (op.getNumOperands() == 0)
499 return;
500
501 if (op.getTrait("::mlir::OpTrait::AttrSizedOperandSegments")) {
502 os << " // Serialize Operands (AttrSizedOperandSegments) - version "
503 "validation done by flags field.\n";
504 for (const auto &[index, odsOperand] : llvm::enumerate(op.getOperands()))
505 generateOperandSerializationLogic(os, index, odsOperand.isOptional(),
506 odsOperand.isVariadic());
507 } else {
508 bool opHasOptionalOperands =
509 llvm::any_of(op.getOperands(),
510 [](const auto &operand) { return operand.isOptional(); });
511 bool opHasVariadicOperands =
512 llvm::any_of(op.getOperands(),
513 [](const auto &operand) { return operand.isVariadic(); });
514 bool encodeSize = opHasVariadicOperands || opHasOptionalOperands;
515 os << llvm::formatv(
516 " writeOperands(op->getOperands(), writer, /*encodeSize=*/{0});\n",
517 encodeSize ? "true" : "false");
518 }
519 os << "\n";
520}
521
522/// Generates C++ code within the 'write<OpName>' function to serialize the
523/// regions of the given operation, if it has any.

Callers 1

generateOpWriterFunction · 0.85

Calls 1

Tested by

no test coverage detected