|
| 1 | +// RUN: cir-tool %s -cir-to-func -cir-to-memref -o - | FileCheck %s -check-prefix=MLIR |
| 2 | +// RUN: cir-tool %s -cir-to-func -cir-to-memref -cir-to-llvm -o - | mlir-translate -mlir-to-llvmir | FileCheck %s -check-prefix=LLVM |
| 3 | + |
| 4 | +module { |
| 5 | + cir.func @foo() { |
| 6 | + %0 = cir.alloca i32, cir.ptr <i32>, ["a", init] {alignment = 4 : i64} |
| 7 | + %1 = cir.alloca i32, cir.ptr <i32>, ["b", init] {alignment = 4 : i64} |
| 8 | + %2 = cir.cst(2 : i32) : i32 |
| 9 | + cir.store %2, %0 : i32, cir.ptr <i32> |
| 10 | + cir.store %2, %1 : i32, cir.ptr <i32> |
| 11 | + |
| 12 | + %3 = cir.load %0 : cir.ptr <i32>, i32 |
| 13 | + %4 = cir.unary(plus, %3) : i32, i32 |
| 14 | + cir.store %4, %0 : i32, cir.ptr <i32> |
| 15 | + |
| 16 | + %5 = cir.load %1 : cir.ptr <i32>, i32 |
| 17 | + %6 = cir.unary(minus, %5) : i32, i32 |
| 18 | + cir.store %6, %1 : i32, cir.ptr <i32> |
| 19 | + cir.return |
| 20 | + } |
| 21 | +} |
| 22 | + |
| 23 | +// MLIR: %[[#INPUT_PLUS:]] = memref.load |
| 24 | +// MLIR: memref.store %[[#INPUT_PLUS]] |
| 25 | +// MLIR: %[[#INPUT_MINUS:]] = memref.load |
| 26 | +// MLIR: %[[ZERO:[a-z0-9_]+]] = arith.constant 0 |
| 27 | +// MLIR: arith.subi %[[ZERO]], %[[#INPUT_MINUS]] |
| 28 | + |
| 29 | +// LLVM: = sub i32 0, %[[#]] |
0 commit comments