diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp index d30a6b8398f06..ef5f1b069b40a 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -716,7 +716,7 @@ static void destructureIndices(Type currType, ArrayRef indices, dynamicIndices.push_back(val); } } else { - rawConstantIndices.push_back(iter.get()); + rawConstantIndices.push_back(cast(iter)); } // Skip for very first iteration of this loop. First index does not index @@ -805,7 +805,7 @@ static void printGEPIndices(OpAsmPrinter &printer, LLVM::GEPOp gepOp, if (Value val = llvm::dyn_cast_if_present(cst)) printer.printOperand(val); else - printer << cst.get().getInt(); + printer << cast(cst).getInt(); }); } @@ -821,11 +821,12 @@ verifyStructIndices(Type baseGEPType, unsigned indexPos, return TypeSwitch(baseGEPType) .Case([&](LLVMStructType structType) -> LogicalResult { - if (!indices[indexPos].is()) + auto attr = dyn_cast(indices[indexPos]); + if (!attr) return emitOpError() << "expected index " << indexPos << " indexing a struct to be constant"; - int32_t gepIndex = indices[indexPos].get().getInt(); + int32_t gepIndex = attr.getInt(); ArrayRef elementTypes = structType.getBody(); if (gepIndex < 0 || static_cast(gepIndex) >= elementTypes.size()) @@ -1100,11 +1101,11 @@ CallInterfaceCallable CallOp::getCallableForCallee() { void CallOp::setCalleeFromCallable(CallInterfaceCallable callee) { // Direct call. if (FlatSymbolRefAttr calleeAttr = getCalleeAttr()) { - auto symRef = callee.get(); + auto symRef = cast(callee); return setCalleeAttr(cast(symRef)); } // Indirect call, callee Value is the first operand. - return setOperand(0, callee.get()); + return setOperand(0, cast(callee)); } Operation::operand_range CallOp::getArgOperands() { @@ -1564,11 +1565,11 @@ CallInterfaceCallable InvokeOp::getCallableForCallee() { void InvokeOp::setCalleeFromCallable(CallInterfaceCallable callee) { // Direct call. if (FlatSymbolRefAttr calleeAttr = getCalleeAttr()) { - auto symRef = callee.get(); + auto symRef = cast(callee); return setCalleeAttr(cast(symRef)); } // Indirect call, callee Value is the first operand. - return setOperand(0, callee.get()); + return setOperand(0, cast(callee)); } Operation::operand_range InvokeOp::getArgOperands() { @@ -3259,7 +3260,7 @@ OpFoldResult LLVM::GEPOp::fold(FoldAdaptor adaptor) { if (Value val = llvm::dyn_cast_if_present(existing)) gepArgs.emplace_back(val); else - gepArgs.emplace_back(existing.get().getInt()); + gepArgs.emplace_back(cast(existing).getInt()); continue; } diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp index 4e5600c715915..453b206de294e 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp @@ -280,7 +280,7 @@ getPointerDataLayoutEntry(DataLayoutEntryListRef params, LLVMPointerType type, for (DataLayoutEntryInterface entry : params) { if (!entry.isTypeEntry()) continue; - if (cast(entry.getKey().get()).getAddressSpace() == + if (cast(cast(entry.getKey())).getAddressSpace() == type.getAddressSpace()) { currentEntry = entry.getValue(); break; @@ -356,7 +356,8 @@ bool LLVMPointerType::areCompatible(DataLayoutEntryListRef oldLayout, continue; uint64_t size = kDefaultPointerSizeBits; uint64_t abi = kDefaultPointerAlignment; - auto newType = llvm::cast(newEntry.getKey().get()); + auto newType = + llvm::cast(llvm::cast(newEntry.getKey())); const auto *it = llvm::find_if(oldLayout, [&](DataLayoutEntryInterface entry) { if (auto type = llvm::dyn_cast_if_present(entry.getKey())) { @@ -392,7 +393,7 @@ LogicalResult LLVMPointerType::verifyEntries(DataLayoutEntryListRef entries, for (DataLayoutEntryInterface entry : entries) { if (!entry.isTypeEntry()) continue; - auto key = entry.getKey().get(); + auto key = llvm::cast(entry.getKey()); auto values = llvm::dyn_cast(entry.getValue()); if (!values || (values.size() != 3 && values.size() != 4)) { return emitError(loc) @@ -625,11 +626,12 @@ LogicalResult LLVMStructType::verifyEntries(DataLayoutEntryListRef entries, if (!entry.isTypeEntry()) continue; - auto key = llvm::cast(entry.getKey().get()); + auto key = llvm::cast(llvm::cast(entry.getKey())); auto values = llvm::dyn_cast(entry.getValue()); if (!values || (values.size() != 2 && values.size() != 1)) { return emitError(loc) - << "expected layout attribute for " << entry.getKey().get() + << "expected layout attribute for " + << llvm::cast(entry.getKey()) << " to be a dense integer elements attribute of 1 or 2 elements"; } if (!values.getElementType().isInteger(64))