Skip to content

Commit 4cc4c32

Browse files
committed
[CIR] Add Plus and Minus to Unary
1 parent f5b1b06 commit 4cc4c32

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,14 +543,18 @@ def ScopeOp : CIR_Op<"scope", [DeclareOpInterfaceMethods<RegionBranchOpInterface
543543
// UnaryOp
544544
//===----------------------------------------------------------------------===//
545545

546-
def UnaryOpKind_Inc : I32EnumAttrCase<"Inc", 1, "inc">;
547-
def UnaryOpKind_Dec : I32EnumAttrCase<"Dec", 2, "dec">;
546+
def UnaryOpKind_Inc : I32EnumAttrCase<"Inc", 1, "inc">;
547+
def UnaryOpKind_Dec : I32EnumAttrCase<"Dec", 2, "dec">;
548+
def UnaryOpKind_Plus : I32EnumAttrCase<"Plus", 3, "plus">;
549+
def UnaryOpKind_Minus : I32EnumAttrCase<"Minus", 4, "minus">;
548550

549551
def UnaryOpKind : I32EnumAttr<
550552
"UnaryOpKind",
551553
"unary operation kind",
552554
[UnaryOpKind_Inc,
553-
UnaryOpKind_Dec]> {
555+
UnaryOpKind_Dec,
556+
UnaryOpKind_Plus,
557+
UnaryOpKind_Minus]> {
554558
let cppNamespace = "::mlir::cir";
555559
}
556560

@@ -561,7 +565,7 @@ def UnaryOp : CIR_Op<"unary",
561565
let summary = "Unary operations";
562566
let description = [{
563567
`cir.unary` performs the unary operation according to
564-
the specified opcode kind: [inc, dec].
568+
the specified opcode kind: [inc, dec, plus, minus].
565569

566570
Note for inc and dec: the operation corresponds only to the
567571
addition/subtraction, its input is expect to come from a load

clang/lib/CIR/Dialect/IR/CIRDialect.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,12 @@ LogicalResult UnaryOp::verify() {
13141314
return emitOpError() << "requires result to be used by a memory store "
13151315
"to the same address as the input memory load";
13161316
}
1317+
case cir::UnaryOpKind::Plus:
1318+
// Nothing to verify.
1319+
return success();
1320+
case cir::UnaryOpKind::Minus:
1321+
// Nothing to verify.
1322+
return success();
13171323
}
13181324

13191325
llvm_unreachable("Unknown UnaryOp kind?");

0 commit comments

Comments
 (0)