Skip to content

Commit

Permalink
Prepare LLVM dependency bump (#1453)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsetoain authored May 3, 2024
1 parent fe5456b commit 7b22ed2
Show file tree
Hide file tree
Showing 17 changed files with 369 additions and 270 deletions.
19 changes: 8 additions & 11 deletions include/aie/Dialect/AIE/IR/AIEOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ def AIE_GetStreamOp: AIE_Op<"get_stream", [
let extraClassDeclaration = [{
bool isWideStream() { return getStreamValue().getType().isInteger(128); }
bool isFloatStream() {
return getStreamValue().getType().isa<mlir::FloatType>();
return llvm::isa<mlir::FloatType>(getStreamValue().getType());
}
}];
}
Expand All @@ -1407,7 +1407,7 @@ def AIE_PutStreamOp: AIE_Op<"put_stream", [HasParent<"CoreOp">]> {
let extraClassDeclaration = [{
bool isWideStream() { return getStreamValue().getType().isInteger(128); }
bool isFloatStream() {
return getStreamValue().getType().isa<mlir::FloatType>();
return llvm::isa<mlir::FloatType>(getStreamValue().getType());
}
}];
}
Expand Down Expand Up @@ -1920,24 +1920,21 @@ def AIE_ObjectFifoRegisterProcessOp: AIE_Op<"objectfifo.register_process", []> {
ObjectFifoCreateOp getObjectFifo();

mlir::DenseIntElementsAttr getAcquirePattern() {
return getAcquirePatternTensor()
return llvm::cast<mlir::DenseIntElementsAttr>(getAcquirePatternTensor()
.getDefiningOp<mlir::arith::ConstantOp>()
.getValue()
.cast<mlir::DenseIntElementsAttr>();
.getValue());
}

mlir::DenseIntElementsAttr getReleasePattern() {
return getReleasePatternTensor()
return llvm::cast<mlir::DenseIntElementsAttr>(getReleasePatternTensor()
.getDefiningOp<mlir::arith::ConstantOp>()
.getValue()
.cast<mlir::DenseIntElementsAttr>();
.getValue());
}

int getProcessLength() {
return getLength()
return llvm::cast<mlir::IntegerAttr>(getLength()
.getDefiningOp<mlir::arith::ConstantOp>()
.getValue()
.cast<mlir::IntegerAttr>()
.getValue())
.getInt();
}
}];
Expand Down
4 changes: 2 additions & 2 deletions include/aie/Dialect/AIE/IR/AIETypes.td
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ include "aie/Dialect/AIE/IR/AIEAttrs.td"
include "mlir/IR/AttrTypeBase.td"

def AIE_ObjectFifoType :
DialectType<AIE_Dialect, CPred<"$_self.isa<AIEObjectFifoType>()">,
DialectType<AIE_Dialect, CPred<"llvm::isa<AIEObjectFifoType>($_self)">,
"AIE objectFifo type">;

def AIE_ObjectFifoSubviewType :
DialectType<AIE_Dialect, CPred<"$_self.isa<AIEObjectFifoSubviewType>()">,
DialectType<AIE_Dialect, CPred<"llvm::isa<AIEObjectFifoSubviewType>($_self)">,
"AIE ObjectFifoSubview type">;

def AIE_Type : AnyTypeOf<[AIE_ObjectFifoType, AIE_ObjectFifoSubviewType]>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ include "mlir/IR/PatternBase.td"

def toDefaultAddressSpace : NativeCodeCall<"TypeAttr::get(memRefToDefaultAddressSpace($0.getValue()))">;
def hasNonDefaultAddressSpace : Constraint<
CPred<"$0.getValue().cast<mlir::MemRefType>().getMemorySpace() != 0">,
CPred<"llvm::cast<mlir::MemRefType>($0.getValue()).getMemorySpace() != 0">,
"has non-default address space">;
def : Pat<
/*pattern*/ (MemRef_GlobalOp $sym_name, $sym_visibility, $type, $initial_value, $constant, $attrs),
Expand Down
9 changes: 5 additions & 4 deletions include/aie/Dialect/AIEVec/AIEVecUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ inline mlir::VectorType createVectorType(unsigned lanes,

// Return the size (in bits) of the underlying element type of the vector
inline int32_t getElementSizeInBits(mlir::VectorType type) {
return type.cast<mlir::ShapedType>().getElementTypeBitWidth();
return llvm::cast<mlir::ShapedType>(type).getElementTypeBitWidth();
}

// Return the number of lanes along the vectorized dimension for the vector
Expand Down Expand Up @@ -147,7 +147,7 @@ flattenedStridedExpr(llvm::ArrayRef<int64_t> sizes,

// Construct a linearized affine expression for the upd op.
inline mlir::AffineExpr constructLinearizedAffineExprForUPDOp(UPDOp updOp) {
auto memRefType = updOp.getSource().getType().cast<mlir::MemRefType>();
auto memRefType = llvm::cast<mlir::MemRefType>(updOp.getSource().getType());
mlir::MLIRContext *context = memRefType.getContext();

llvm::SmallVector<mlir::AffineExpr, 8> exprVec;
Expand All @@ -164,7 +164,8 @@ inline mlir::AffineExpr constructLinearizedAffineExprForUPDOp(UPDOp updOp) {

for (auto index : apOf.getMapOperands())
if (auto cIdx = index.getDefiningOp<mlir::arith::ConstantOp>()) {
auto idxVal = cIdx.getValue().cast<mlir::IntegerAttr>().getValue();
auto idxVal =
llvm::cast<mlir::IntegerAttr>(cIdx.getValue()).getValue();
unsigned idx = idxVal.getSExtValue();
indexExprs.push_back(getAffineConstantExpr(idx, context));
} else {
Expand All @@ -176,7 +177,7 @@ inline mlir::AffineExpr constructLinearizedAffineExprForUPDOp(UPDOp updOp) {

exprVec.push_back(map.getResult(0).replaceDims(indexExprs));
} else if (auto cOp = value.getDefiningOp<mlir::arith::ConstantOp>()) {
auto idxVal = cOp.getValue().cast<mlir::IntegerAttr>().getValue();
auto idxVal = llvm::cast<mlir::IntegerAttr>(cOp.getValue()).getValue();
unsigned idx = idxVal.getSExtValue();
exprVec.push_back(getAffineConstantExpr(idx, context));
} else {
Expand Down
8 changes: 4 additions & 4 deletions lib/CAPI/Dialects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(XLLVM, xllvm, xilinx::xllvm::XLLVMDialect)
//===---------------------------------------------------------------------===//

bool aieTypeIsObjectFifoType(MlirType type) {
return unwrap(type).isa<xilinx::AIE::AIEObjectFifoType>();
return llvm::isa<xilinx::AIE::AIEObjectFifoType>(unwrap(type));
}

MlirType aieObjectFifoTypeGet(MlirType type) {
return wrap(xilinx::AIE::AIEObjectFifoType::get(
unwrap(type).cast<mlir::MemRefType>()));
llvm::cast<mlir::MemRefType>(unwrap(type))));
}

//===---------------------------------------------------------------------===//
// ObjectFifoSubviewType
//===---------------------------------------------------------------------===//

bool aieTypeIsObjectFifoSubviewType(MlirType type) {
return unwrap(type).isa<xilinx::AIE::AIEObjectFifoSubviewType>();
return llvm::isa<xilinx::AIE::AIEObjectFifoSubviewType>(unwrap(type));
}

MlirType aieObjectFifoSubviewTypeGet(MlirType type) {
return wrap(xilinx::AIE::AIEObjectFifoSubviewType::get(
unwrap(type).cast<mlir::MemRefType>()));
llvm::cast<mlir::MemRefType>(unwrap(type))));
}
8 changes: 4 additions & 4 deletions lib/Conversion/AIEVecToLLVM/AIEVecToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ class MulElemOpConversion
unsigned lhsBitWidth = lhsScaTy.getIntOrFloatBitWidth();

// Integer types
if (lhsScaTy.isa<IntegerType>()) {
if (llvm::isa<IntegerType>(lhsScaTy)) {
if (lhsBitWidth == 8) {
return {DecodedMulElemOp::Kind::I8_I8_I32_32x1x2x1,
aiev2_mul_mac_compute_control(
Expand Down Expand Up @@ -842,7 +842,7 @@ class SRSOpConversion : public mlir::ConvertOpToLLVMPattern<aievec::SRSOp> {
int resultVectorSize = resultBitWidth * resultLanes;

// Integer types
if (resultScaTy.isa<IntegerType>()) {
if (llvm::isa<IntegerType>(resultScaTy)) {
// create constant for sign
auto signCst = rewriter.create<LLVM::ConstantOp>(
loc, rewriter.getI32Type(), rewriter.getI32IntegerAttr(1));
Expand Down Expand Up @@ -1251,7 +1251,7 @@ class BroadcastScalarOpConversion
unsigned resultBitWidth = resultScaTy.getIntOrFloatBitWidth();

// Integer types
if (resultScaTy.isa<IntegerType>()) {
if (llvm::isa<IntegerType>(resultScaTy)) {
Value src = adaptor.getSource();
Type srcType = src.getType();
unsigned srcBitWidth = srcType.getIntOrFloatBitWidth();
Expand Down Expand Up @@ -1324,7 +1324,7 @@ class ShiftOpConversion : public mlir::ConvertOpToLLVMPattern<aievec::ShiftOp> {
Value shiftOp = nullptr;
SmallVector<Value> operands(
{adaptor.getLhs(), adaptor.getRhs(), stepCst, adaptor.getShift()});
if (resultScaTy.isa<IntegerType>()) {
if (llvm::isa<IntegerType>(resultScaTy)) {
// Integer types
shiftOp = rewriter.create<xllvm::VectorShiftI512I512IntrOp>(
loc, VectorType::get({16}, rewriter.getI32Type()),
Expand Down
28 changes: 15 additions & 13 deletions lib/Dialect/AIE/IR/AIEDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ static OptionalParseResult aieTypeParser(DialectAsmParser &parser,
return failure();

// Check that the type is a MemRef type.
if (!elementType.isa<MemRefType>()) {
if (!llvm::isa<MemRefType>(elementType)) {
parser.emitError(typeLoc, "element type for an objectFifo must be "
"a MemRefType, got: ")
<< elementType;
Expand All @@ -297,7 +297,7 @@ static OptionalParseResult aieTypeParser(DialectAsmParser &parser,
return failure();

// Check that the type is a MemRefType.
if (!elementType.isa<MemRefType>()) {
if (!llvm::isa<MemRefType>(elementType)) {
parser.emitError(typeLoc, "element type for a subview must be "
"a MemRefType, got: ")
<< elementType;
Expand Down Expand Up @@ -340,14 +340,14 @@ Type AIEDialect::parseType(DialectAsmParser &parser) const {

/// Print an instance of a type registered to the AIE dialect.
void AIEDialect::printType(Type type, DialectAsmPrinter &printer) const {
if (type.isa<AIEObjectFifoType>()) {
auto objectFifoType = type.cast<AIEObjectFifoType>();
if (llvm::isa<AIEObjectFifoType>(type)) {
auto objectFifoType = llvm::cast<AIEObjectFifoType>(type);
printer << "objectfifo<";
printer << objectFifoType.getElementType();
printer << '>';

} else if (type.isa<AIEObjectFifoSubviewType>()) {
auto subviewType = type.cast<AIEObjectFifoSubviewType>();
} else if (llvm::isa<AIEObjectFifoSubviewType>(type)) {
auto subviewType = llvm::cast<AIEObjectFifoSubviewType>(type);
printer << "objectfifosubview<";
printer << subviewType.getElementType();
printer << '>';
Expand Down Expand Up @@ -561,15 +561,15 @@ LogicalResult ObjectFifoLinkOp::verify() {
if (isJoin()) {
ObjectFifoCreateOp fifoOut = getOutputObjectFifos()[0];
auto elemType =
fifoOut.getElemType().cast<AIEObjectFifoType>().getElementType();
llvm::cast<AIEObjectFifoType>(fifoOut.getElemType()).getElementType();
int64_t outputSize = 1;
for (auto dim : elemType.getShape())
outputSize *= dim;

int inputSize = 0;
for (auto fifoIn : getInputObjectFifos()) {
auto elemType =
fifoIn.getElemType().cast<AIEObjectFifoType>().getElementType();
llvm::cast<AIEObjectFifoType>(fifoIn.getElemType()).getElementType();
int64_t nextInputSize = 1;
for (int64_t dim : elemType.getShape())
nextInputSize *= dim;
Expand All @@ -592,7 +592,7 @@ LogicalResult ObjectFifoLinkOp::verify() {
}

auto elemType =
fifoIn.getElemType().cast<AIEObjectFifoType>().getElementType();
llvm::cast<AIEObjectFifoType>(fifoIn.getElemType()).getElementType();
int64_t inputSize = 1;
for (auto dim : elemType.getShape())
inputSize *= dim;
Expand All @@ -611,7 +611,7 @@ LogicalResult ObjectFifoLinkOp::verify() {
}

auto elemType =
fifoOut.getElemType().cast<AIEObjectFifoType>().getElementType();
llvm::cast<AIEObjectFifoType>(fifoOut.getElemType()).getElementType();
int64_t nextOutputSize = 1;
for (int64_t dim : elemType.getShape())
nextOutputSize *= dim;
Expand Down Expand Up @@ -744,9 +744,11 @@ LogicalResult ObjectFifoAcquireOp::verify() {
}

auto objFifoElem =
getObjectFifo().getElemType().cast<AIEObjectFifoType>().getElementType();
llvm::cast<AIEObjectFifoType>(getObjectFifo().getElemType())
.getElementType();
auto objFifoSubviewElem =
getResult().getType().cast<AIEObjectFifoSubviewType>().getElementType();
llvm::cast<AIEObjectFifoSubviewType>(getResult().getType())
.getElementType();
if (objFifoElem != objFifoSubviewElem)
return emitOpError(
"ObjectFifo element and ObjectFifoSubview element must match.\n");
Expand Down Expand Up @@ -1275,7 +1277,7 @@ TileOp CoreOp::getTileOp() { return cast<TileOp>(getTile().getDefiningOp()); }
//===----------------------------------------------------------------------===//

int64_t BufferOp::getAllocationSize() {
auto type = getType().cast<MemRefType>();
auto type = llvm::cast<MemRefType>(getType());
return type.getNumElements() * type.getElementTypeBitWidth() / 8;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Dialect/AIE/Transforms/AIECoreToStandard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ struct AIEBufferToStandard : OpConversionPattern<BufferOp> {
matchAndRewrite(BufferOp buffer, OpAdaptor adaptor,
ConversionPatternRewriter &rewriter) const override {
rewriter.setInsertionPointToStart(module.getBody());
auto t = buffer.getType().cast<MemRefType>();
auto t = llvm::cast<MemRefType>(buffer.getType());
int col = llvm::cast<TileOp>(buffer.getTile().getDefiningOp()).getCol();
int row = llvm::cast<TileOp>(buffer.getTile().getDefiningOp()).getRow();
auto symName = buffer.name().getValue();
Expand Down
47 changes: 24 additions & 23 deletions lib/Dialect/AIE/Transforms/AIEObjectFifoStatefulTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ struct AIEObjectFifoStatefulTransformPass
return;

std::vector<BufferOp> buffers;
auto fifo = op.getElemType().cast<AIEObjectFifoType>();
auto elemType = fifo.getElementType().cast<MemRefType>();
auto fifo = llvm::cast<AIEObjectFifoType>(op.getElemType());
auto elemType = llvm::cast<MemRefType>(fifo.getElementType());
int numElem = op.size();
int of_elem_index = 0; // used to give objectFifo elements a symbolic name

Expand All @@ -337,16 +337,14 @@ struct AIEObjectFifoStatefulTransformPass
if (op.name() != fifoIn.name())
return;
} else {
auto fifoInType = linkOp->getInputObjectFifos()[0]
.getElemType()
.cast<AIEObjectFifoType>();
auto elemInType = fifoInType.getElementType().cast<MemRefType>();
auto fifoInType = llvm::cast<AIEObjectFifoType>(
linkOp->getInputObjectFifos()[0].getElemType());
auto elemInType = llvm::cast<MemRefType>(fifoInType.getElementType());
int inSize = elemInType.getNumElements();

auto fifoOutType = linkOp->getOutputObjectFifos()[0]
.getElemType()
.cast<AIEObjectFifoType>();
auto elemOutType = fifoOutType.getElementType().cast<MemRefType>();
auto fifoOutType = llvm::cast<AIEObjectFifoType>(
linkOp->getOutputObjectFifos()[0].getElemType());
auto elemOutType = llvm::cast<MemRefType>(fifoOutType.getElementType());

if (int outSize = elemOutType.getNumElements(); inSize >= outSize) {
if (op.name() != fifoIn.name())
Expand Down Expand Up @@ -492,8 +490,8 @@ struct AIEObjectFifoStatefulTransformPass
int acqNum = 1;
int relNum = 1;

auto fifo = op.getElemType().cast<AIEObjectFifoType>();
auto elemType = fifo.getElementType().cast<MemRefType>();
auto fifo = llvm::cast<AIEObjectFifoType>(op.getElemType());
auto elemType = llvm::cast<MemRefType>(fifo.getElementType());
int len = elemType.getNumElements();

// search for the buffers/locks (based on if this objFifo has a link)
Expand Down Expand Up @@ -648,8 +646,8 @@ struct AIEObjectFifoStatefulTransformPass
if (numBlocks == 0)
return;

auto fifo = op.getElemType().cast<AIEObjectFifoType>();
auto elemType = fifo.getElementType().cast<MemRefType>();
auto fifo = llvm::cast<AIEObjectFifoType>(op.getElemType());
auto elemType = llvm::cast<MemRefType>(fifo.getElementType());
int lenOut = elemType.getNumElements();
int acqNum = 1;
int relNum = 1;
Expand All @@ -672,8 +670,9 @@ struct AIEObjectFifoStatefulTransformPass
relNum = linkOp->getFifoIns().size();
} else {
for (auto fifoIn : linkOp->getInputObjectFifos()) {
auto fifoType = fifoIn.getElemType().cast<AIEObjectFifoType>();
auto elemType = fifoType.getElementType().cast<MemRefType>();
auto fifoType =
llvm::cast<AIEObjectFifoType>(fifoIn.getElemType());
auto elemType = llvm::cast<MemRefType>(fifoType.getElementType());
if (fifoIn.name() == op.name())
break;
extraOffset += elemType.getNumElements();
Expand All @@ -687,18 +686,20 @@ struct AIEObjectFifoStatefulTransformPass
relNum = linkOp->getFifoOuts().size();
} else {
for (auto fifoOut : linkOp->getOutputObjectFifos()) {
auto fifoType = fifoOut.getElemType().cast<AIEObjectFifoType>();
auto elemType = fifoType.getElementType().cast<MemRefType>();
auto fifoType =
llvm::cast<AIEObjectFifoType>(fifoOut.getElemType());
auto elemType = llvm::cast<MemRefType>(fifoType.getElementType());
if (fifoOut.name() == op.name())
break;
extraOffset += elemType.getNumElements();
}
}
} else {
if (target != op) {
auto targetFifo = target.getElemType().cast<AIEObjectFifoType>();
auto targetFifo =
llvm::cast<AIEObjectFifoType>(target.getElemType());
auto targetElemType =
targetFifo.getElementType().cast<MemRefType>();
llvm::cast<MemRefType>(targetFifo.getElementType());
lenOut = targetElemType.getNumElements();
}
}
Expand Down Expand Up @@ -1225,7 +1226,7 @@ struct AIEObjectFifoStatefulTransformPass
}

builder.setInsertionPointAfter(createOp);
auto datatype = createOp.getElemType().cast<AIEObjectFifoType>();
auto datatype = llvm::cast<AIEObjectFifoType>(createOp.getElemType());
auto consumerObjFifoSize =
builder.getIntegerAttr(builder.getI32Type(), consumerDepth);
// rename and replace split objectFifo
Expand Down Expand Up @@ -1596,8 +1597,8 @@ struct AIEObjectFifoStatefulTransformPass
auto sym_name = createOp.getName();
createOp->setAttr(SymbolTable::getSymbolAttrName(),
builder.getStringAttr("__erase_" + sym_name));
auto memrefType =
createOp.getElemType().cast<AIEObjectFifoType>().getElementType();
auto memrefType = llvm::cast<AIEObjectFifoType>(createOp.getElemType())
.getElementType();
builder.create<memref::GlobalOp>(builder.getUnknownLoc(), sym_name,
builder.getStringAttr("public"),
memrefType, nullptr, false, nullptr);
Expand Down
Loading

0 comments on commit 7b22ed2

Please sign in to comment.