|
17 | 17 |
|
18 | 18 | #include "mlir/Interfaces/ControlFlowInterfaces.h"
|
19 | 19 | #include "mlir/Interfaces/FunctionImplementation.h"
|
20 |
| -#include "mlir/Support/LogicalResult.h" |
21 | 20 |
|
22 | 21 | #include "clang/CIR/Dialect/IR/CIROpsDialect.cpp.inc"
|
23 | 22 | #include "clang/CIR/Dialect/IR/CIROpsEnums.cpp.inc"
|
@@ -1427,15 +1426,32 @@ OpFoldResult cir::SelectOp::fold(FoldAdaptor adaptor) {
|
1427 | 1426 | //===----------------------------------------------------------------------===//
|
1428 | 1427 | LogicalResult cir::ShiftOp::verify() {
|
1429 | 1428 | mlir::Operation *op = getOperation();
|
1430 |
| - const bool isOp0Vec = mlir::isa<cir::VectorType>(op->getOperand(0).getType()); |
1431 |
| - const bool isOp1Vec = mlir::isa<cir::VectorType>(op->getOperand(1).getType()); |
1432 |
| - if (isOp0Vec != isOp1Vec) |
| 1429 | + auto op0VecTy = mlir::dyn_cast<cir::VectorType>(op->getOperand(0).getType()); |
| 1430 | + auto op1VecTy = mlir::dyn_cast<cir::VectorType>(op->getOperand(1).getType()); |
| 1431 | + if (!op0VecTy ^ !op1VecTy) |
1433 | 1432 | return emitOpError() << "input types cannot be one vector and one scalar";
|
1434 | 1433 |
|
1435 |
| - if (isOp1Vec && !mlir::isa<cir::VectorType>(getResult().getType())) { |
1436 |
| - return emitOpError() << "the type of the result must be a vector " |
1437 |
| - << "if it is vector shift"; |
| 1434 | + if (op0VecTy) { |
| 1435 | + if (op0VecTy.getSize() != op1VecTy.getSize()) |
| 1436 | + return emitOpError() << "input vector types must have the same size"; |
| 1437 | + |
| 1438 | + auto opResultTy = mlir::dyn_cast<cir::VectorType>(getResult().getType()); |
| 1439 | + if (!opResultTy) |
| 1440 | + return emitOpError() << "the type of the result must be a vector " |
| 1441 | + << "if it is vector shift"; |
| 1442 | + |
| 1443 | + auto op0VecEleTy = mlir::cast<cir::IntType>(op0VecTy.getElementType()); |
| 1444 | + auto op1VecEleTy = mlir::cast<cir::IntType>(op1VecTy.getElementType()); |
| 1445 | + if (op0VecEleTy.getWidth() != op1VecEleTy.getWidth()) |
| 1446 | + return emitOpError() |
| 1447 | + << "vector operands do not have the same elements sizes"; |
| 1448 | + |
| 1449 | + auto resVecEleTy = mlir::cast<cir::IntType>(opResultTy.getElementType()); |
| 1450 | + if (op0VecEleTy.getWidth() != resVecEleTy.getWidth()) |
| 1451 | + return emitOpError() << "vector operands and result type do not have the " |
| 1452 | + "same elements sizes"; |
1438 | 1453 | }
|
| 1454 | + |
1439 | 1455 | return mlir::success();
|
1440 | 1456 | }
|
1441 | 1457 |
|
|
0 commit comments