Changeset View
Changeset View
Standalone View
Standalone View
mlir/lib/IR/Operation.cpp
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | size_t byteSize = | ||||
totalSizeToAlloc<detail::OperandStorage, BlockOperand, Region, OpOperand>( | totalSizeToAlloc<detail::OperandStorage, BlockOperand, Region, OpOperand>( | ||||
needsOperandStorage ? 1 : 0, numSuccessors, numRegions, numOperands); | needsOperandStorage ? 1 : 0, numSuccessors, numRegions, numOperands); | ||||
size_t prefixByteSize = llvm::alignTo( | size_t prefixByteSize = llvm::alignTo( | ||||
Operation::prefixAllocSize(numTrailingResults, numInlineResults), | Operation::prefixAllocSize(numTrailingResults, numInlineResults), | ||||
alignof(Operation)); | alignof(Operation)); | ||||
char *mallocMem = reinterpret_cast<char *>(malloc(byteSize + prefixByteSize)); | char *mallocMem = reinterpret_cast<char *>(malloc(byteSize + prefixByteSize)); | ||||
void *rawMem = mallocMem + prefixByteSize; | void *rawMem = mallocMem + prefixByteSize; | ||||
// Populate default attributes. | |||||
if (Optional<RegisteredOperationName> info = name.getRegisteredInfo()) | |||||
info->populateDefaultAttrs(attributes); | |||||
// Create the new Operation. | // Create the new Operation. | ||||
Operation *op = ::new (rawMem) Operation( | Operation *op = ::new (rawMem) Operation( | ||||
location, name, numResults, numSuccessors, numRegions, | location, name, numResults, numSuccessors, numRegions, | ||||
attributes.getDictionary(location.getContext()), needsOperandStorage); | attributes.getDictionary(location.getContext()), needsOperandStorage); | ||||
assert((numSuccessors == 0 || op->mightHaveTrait<OpTrait::IsTerminator>()) && | assert((numSuccessors == 0 || op->mightHaveTrait<OpTrait::IsTerminator>()) && | ||||
"unexpected successors in a non-terminator operation"); | "unexpected successors in a non-terminator operation"); | ||||
▲ Show 20 Lines • Show All 1,123 Lines • Show Last 20 Lines |