66 lines · plain
1// Check that the wide integer constant emulation produces the same result as wide2// constants and that printing works. Emulate i16 ops with i8 ops.3 4// RUN: mlir-opt %s --test-arith-emulate-wide-int="widest-int-supported=8" \5// RUN: --convert-vector-to-scf --convert-scf-to-cf --convert-cf-to-llvm --convert-vector-to-llvm \6// RUN: --convert-func-to-llvm --convert-arith-to-llvm --reconcile-unrealized-casts | \7// RUN: mlir-runner -e entry -entry-point-result=void \8// RUN: --shared-libs=%mlir_c_runner_utils | \9// RUN: FileCheck %s --match-full-lines --check-prefix=EMULATED10 11func.func @entry() {12 %cst0 = arith.constant 0 : i1613 func.call @emulate_constant(%cst0) : (i16) -> ()14 func.call @foo(%cst0) : (i16) -> ()15 return16}17 18func.func @emulate_constant(%first : i16) {19 // EMULATED: ( 0, 0 )20 vector.print %first : i1621 22 %cst0 = arith.constant 0 : i1623 %cst1 = arith.constant 1 : i1624 %cst_n1 = arith.constant -1 : i1625 %cst_n3 = arith.constant -3 : i1626 27 %cst13 = arith.constant 13 : i1628 %cst256 = arith.constant 256 : i1629 30 %cst_i16_max = arith.constant 32767 : i1631 %cst_i16_min = arith.constant -32768 : i1632 33 // EMULATED-NEXT: ( 0, 0 )34 vector.print %cst0 : i1635 // EMULATED-NEXT: ( 1, 0 )36 vector.print %cst1 : i1637 38 // EMULATED-NEXT: ( -1, -1 )39 vector.print %cst_n1 : i1640 // EMULATED-NEXT: ( -3, -1 )41 vector.print %cst_n3 : i1642 43 // EMULATED-NEXT: ( 13, 0 )44 vector.print %cst13 : i1645 // EMULATED-NEXT: ( 0, 1 )46 vector.print %cst256 : i1647 48 // EMULATED-NEXT: ( -1, 127 )49 vector.print %cst_i16_max : i1650 // EMULATED-NEXT: ( 0, -128 )51 vector.print %cst_i16_min : i1652 return53}54 55func.func @foo(%first: i16) {56 // These should not be emulated because the function name does not start with57 // 'emulated_'.58 59 // EMULATED-NEXT: 060 vector.print %first : i1661 // EMULATED-NEXT: 162 %cst1 = arith.constant 1 : i1663 vector.print %cst1 : i1664 return65}66