[clang] [CIR] Upstream SelectOp and ShiftOp (PR #133405)
Bruno Cardoso Lopes via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 28 15:36:27 PDT 2025
================
@@ -759,6 +762,46 @@ LogicalResult cir::BinOp::verify() {
return mlir::success();
}
+//===----------------------------------------------------------------------===//
+// ShiftOp
+//===----------------------------------------------------------------------===//
+LogicalResult cir::ShiftOp::verify() {
+ mlir::Operation *op = getOperation();
+ mlir::Type resType = getResult().getType();
+ assert(!cir::MissingFeatures::vectorType());
+ bool isOp0Vec = false;
+ bool isOp1Vec = false;
+ if (isOp0Vec != isOp1Vec)
+ return emitOpError() << "input types cannot be one vector and one scalar";
+ if (isOp1Vec && op->getOperand(1).getType() != resType) {
+ return emitOpError() << "shift amount must have the type of the result "
+ << "if it is vector shift";
+ }
+ return mlir::success();
+}
+
+//===----------------------------------------------------------------------===//
+// SelectOp
+//===----------------------------------------------------------------------===//
+
+OpFoldResult cir::SelectOp::fold(FoldAdaptor adaptor) {
+ mlir::Attribute condition = adaptor.getCondition();
----------------
bcardosolopes wrote:
Please add tests for the folders.
https://github.com/llvm/llvm-project/pull/133405
More information about the cfe-commits
mailing list