Skip to content

Commit

Permalink
[CIR][CIRGen] Removed extra space in "cir.shift( right)" (#997) (#1009)
Browse files Browse the repository at this point in the history
The MLIR docs at https://mlir.llvm.org/docs/DefiningDialects/Operations/#literals
specify that "An empty literal `` may be used to remove a space that is
inserted implicitly after certain literal elements", so I inserted one
before the `right` literal to remove the extra space that was being
printed. Oddly, the bug is also fixed by inserting an empty literal
_after_ the `left` literal, which leads me to believe that tablegen is
inserting an implicit space after the `left` literal.
  • Loading branch information
MarcoCalabretta authored Oct 28, 2024
1 parent 74d8fe9 commit d7de21f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion clang/include/clang/CIR/Dialect/IR/CIROps.td
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ def ShiftOp : CIR_Op<"shift", [Pure]> {

let assemblyFormat = [{
`(`
(`left` $isShiftleft^) : (`right`)?
(`left` $isShiftleft^) : (```right`)?
`,` $value `:` type($value)
`,` $amount `:` type($amount)
`)` `->` type($result) attr-dict
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/CodeGen/binassign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ int foo(int a, int b) {
// CHECK: = cir.binop(sub,
// CHECK: cir.store {{.*}}[[Value]]
// CHECK: = cir.load {{.*}}[[Value]]
// CHECK: = cir.shift( right
// CHECK: = cir.shift(right
// CHECK: cir.store {{.*}}[[Value]]
// CHECK: = cir.load {{.*}}[[Value]]
// CHECK: = cir.shift(left
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/CodeGen/binop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void b0(int a, int b) {
// CHECK: = cir.binop(rem, %9, %10) : !s32i
// CHECK: = cir.binop(add, %12, %13) nsw : !s32i
// CHECK: = cir.binop(sub, %15, %16) nsw : !s32i
// CHECK: = cir.shift( right, %18 : !s32i, %19 : !s32i) -> !s32i
// CHECK: = cir.shift(right, %18 : !s32i, %19 : !s32i) -> !s32i
// CHECK: = cir.shift(left, %21 : !s32i, %22 : !s32i) -> !s32i
// CHECK: = cir.binop(and, %24, %25) : !s32i
// CHECK: = cir.binop(xor, %27, %28) : !s32i
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/CodeGen/vectype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ void vector_int_test(int x, unsigned short usx) {
// CHECK: %{{[0-9]+}} = cir.shift(left, {{%.*}} : !cir.vector<!s32i x 4>,
// CHECK-SAME: {{%.*}} : !cir.vector<!s32i x 4>) -> !cir.vector<!s32i x 4>
vi4 y = a >> b;
// CHECK: %{{[0-9]+}} = cir.shift( right, {{%.*}} : !cir.vector<!s32i x 4>,
// CHECK: %{{[0-9]+}} = cir.shift(right, {{%.*}} : !cir.vector<!s32i x 4>,
// CHECK-SAME: {{%.*}} : !cir.vector<!s32i x 4>) -> !cir.vector<!s32i x 4>

vus2 z = { usx, usx };
// CHECK: %{{[0-9]+}} = cir.vec.create(%{{[0-9]+}}, %{{[0-9]+}} : !u16i, !u16i) : !cir.vector<!u16i x 2>
vus2 zamt = { 3, 4 };
// CHECK: %{{[0-9]+}} = cir.const #cir.const_vector<[#cir.int<3> : !u16i, #cir.int<4> : !u16i]> : !cir.vector<!u16i x 2>
vus2 zzz = z >> zamt;
// CHECK: %{{[0-9]+}} = cir.shift( right, {{%.*}} : !cir.vector<!u16i x 2>,
// CHECK: %{{[0-9]+}} = cir.shift(right, {{%.*}} : !cir.vector<!u16i x 2>,
// CHECK-SAME: {{%.*}} : !cir.vector<!u16i x 2>) -> !cir.vector<!u16i x 2>
}

Expand Down

0 comments on commit d7de21f

Please sign in to comment.