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

Method addConstant

lib/Bytecode/Writer/BytecodeWriter.cpp:466–481  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

464namespace {
465struct ConstantManager {
466 LogicalResult addConstant(Attribute attr, uint64_t &index) {
467 auto it = constantsMap.find(attr);
468 if (it != constantsMap.end()) {
469 index = std::distance(constantsMap.begin(), it);
470 return success();
471 }
472 SmallVector<char> data;
473 llvm::raw_svector_ostream dataStream(data);
474 EncodingWriter writer(dataStream);
475 if (failed(serializeAttribute(attr, writer)))
476 return emitError(UnknownLoc::get(attr.getContext()),
477 "failed to serialize attribute");
478 index = constantsMap.size();
479 constantsMap[attr] = std::move(data);
480 return success();
481 }
482
483 // Look up a constant by attribute without adding it
484 LogicalResult getConstantIndex(Attribute attr, uint64_t &index) const {

Callers 2

writeSingleAttributeMethod · 0.80
writeGlobalSectionFunction · 0.80

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected