1// RUN: mlir-translate -mlir-to-cpp %s | FileCheck %s -check-prefix=CPP-DEFAULT 2// RUN: mlir-translate -mlir-to-cpp -declare-variables-at-top %s | FileCheck %s -check-prefix=CPP-DECLTOP 3 4func.func @emitc_constant() { 5 %c0 = "emitc.constant"(){value = #emitc.opaque<"INT_MAX">} : () -> i32 6 %c1 = "emitc.constant"(){value = 42 : i32} : () -> i32 7 %c2 = "emitc.constant"(){value = -1 : i32} : () -> i32 8 %c3 = "emitc.constant"(){value = -1 : si8} : () -> si8 9 %c4 = "emitc.constant"(){value = 255 : ui8} : () -> ui8 10 %c5 = "emitc.constant"(){value = #emitc.opaque<"CHAR_MIN">} : () -> !emitc.opaque<"char"> 11 %c6 = "emitc.constant"(){value = 2 : index} : () -> index 12 %c7 = "emitc.constant"(){value = 2.0 : f32} : () -> f32 13 %f64 = "emitc.constant"(){value = 4.0 : f64} : () -> f64 14 %f16 = "emitc.constant"(){value = 2.0 : f16} : () -> f16 15 %bf16 = "emitc.constant"(){value = 4.0 : bf16} : () -> bf16 16 %c8 = "emitc.constant"(){value = dense<0> : tensor<i32>} : () -> tensor<i32> 17 %c9 = "emitc.constant"(){value = dense<[0, 1]> : tensor<2xindex>} : () -> tensor<2xindex> 18 %c10 = "emitc.constant"(){value = dense<[[0.0, 1.0], [2.0, 3.0]]> : tensor<2x2xf32>} : () -> tensor<2x2xf32> 19 return 20} 21// CPP-DEFAULT: void emitc_constant() { 22// CPP-DEFAULT-NEXT: int32_t [[V0:[^ ]*]] = INT_MAX; 23// CPP-DEFAULT-NEXT: int32_t [[V1:[^ ]*]] = 42; 24// CPP-DEFAULT-NEXT: int32_t [[V2:[^ ]*]] = -1; 25// CPP-DEFAULT-NEXT: int8_t [[V3:[^ ]*]] = -1; 26// CPP-DEFAULT-NEXT: uint8_t [[V4:[^ ]*]] = 255; 27// CPP-DEFAULT-NEXT: char [[V5:[^ ]*]] = CHAR_MIN; 28// CPP-DEFAULT-NEXT: size_t [[V6:[^ ]*]] = 2; 29// CPP-DEFAULT-NEXT: float [[V7:[^ ]*]] = 2.000000000e+00f; 30// CPP-DEFAULT-NEXT: double [[F64:[^ ]*]] = 4.00000000000000000e+00; 31// CPP-DEFAULT-NEXT: _Float16 [[F16:[^ ]*]] = 2.00000e+00f16; 32// CPP-DEFAULT-NEXT: __bf16 [[BF16:[^ ]*]] = 4.0000e+00bf16; 33// CPP-DEFAULT-NEXT: Tensor<int32_t> [[V8:[^ ]*]] = {0}; 34// CPP-DEFAULT-NEXT: Tensor<size_t, 2> [[V9:[^ ]*]] = {0, 1}; 35// CPP-DEFAULT-NEXT: Tensor<float, 2, 2> [[V10:[^ ]*]] = {0.0e+00f, 1.000000000e+00f, 2.000000000e+00f, 3.000000000e+00f}; 36 37// CPP-DECLTOP: void emitc_constant() { 38// CPP-DECLTOP-NEXT: int32_t [[V0:[^ ]*]]; 39// CPP-DECLTOP-NEXT: int32_t [[V1:[^ ]*]]; 40// CPP-DECLTOP-NEXT: int32_t [[V2:[^ ]*]]; 41// CPP-DECLTOP-NEXT: int8_t [[V3:[^ ]*]]; 42// CPP-DECLTOP-NEXT: uint8_t [[V4:[^ ]*]]; 43// CPP-DECLTOP-NEXT: char [[V5:[^ ]*]]; 44// CPP-DECLTOP-NEXT: size_t [[V6:[^ ]*]]; 45// CPP-DECLTOP-NEXT: float [[V7:[^ ]*]]; 46// CPP-DECLTOP-NEXT: double [[F64:[^ ]*]]; 47// CPP-DECLTOP-NEXT: _Float16 [[F16:[^ ]*]]; 48// CPP-DECLTOP-NEXT: __bf16 [[BF16:[^ ]*]]; 49// CPP-DECLTOP-NEXT: Tensor<int32_t> [[V8:[^ ]*]]; 50// CPP-DECLTOP-NEXT: Tensor<size_t, 2> [[V9:[^ ]*]]; 51// CPP-DECLTOP-NEXT: Tensor<float, 2, 2> [[V10:[^ ]*]]; 52// CPP-DECLTOP-NEXT: [[V0]] = INT_MAX; 53// CPP-DECLTOP-NEXT: [[V1]] = 42; 54// CPP-DECLTOP-NEXT: [[V2]] = -1; 55// CPP-DECLTOP-NEXT: [[V3]] = -1; 56// CPP-DECLTOP-NEXT: [[V4]] = 255; 57// CPP-DECLTOP-NEXT: [[V5]] = CHAR_MIN; 58// CPP-DECLTOP-NEXT: [[V6]] = 2; 59// CPP-DECLTOP-NEXT: [[V7]] = 2.000000000e+00f; 60// CPP-DECLTOP-NEXT: [[F64]] = 4.00000000000000000e+00; 61// CPP-DECLTOP-NEXT: [[F16]] = 2.00000e+00f16; 62// CPP-DECLTOP-NEXT: [[BF16]] = 4.0000e+00bf16; 63// CPP-DECLTOP-NEXT: [[V8]] = {0}; 64// CPP-DECLTOP-NEXT: [[V9]] = {0, 1}; 65// CPP-DECLTOP-NEXT: [[V10]] = {0.0e+00f, 1.000000000e+00f, 2.000000000e+00f, 3.000000000e+00f}; 66