xref: /llvm-project/mlir/test/Target/Cpp/literal_call_operand.mlir (revision c4fd1fd6d4e0d21b2315fadecbcdc0892f3c6925)
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_call_operand() {
5  %p0 = emitc.literal "M_PI" : f32
6  %1 = emitc.call_opaque "foo"(%p0) : (f32) -> f32
7  return
8}
9// CPP-DEFAULT: void emitc_call_operand() {
10// CPP-DEFAULT-NEXT: float v1 = foo(M_PI);
11
12// CPP-DECLTOP: void emitc_call_operand() {
13// CPP-DECLTOP-NEXT: float v1;
14// CPP-DECLTOP-NEXT: v1 = foo(M_PI);
15
16func.func @emitc_call_operand_arg() {
17  %p0 = emitc.literal "M_PI" : f32
18  %1 = emitc.call_opaque "bar"(%p0) {args = [42 : i32, 0 : index]} : (f32) -> f32
19  return
20}
21// CPP-DEFAULT: void emitc_call_operand_arg() {
22// CPP-DEFAULT-NEXT: float v1 = bar(42, M_PI);
23
24// CPP-DECLTOP: void emitc_call_operand_arg() {
25// CPP-DECLTOP-NEXT: float v1;
26// CPP-DECLTOP-NEXT: v1 = bar(42, M_PI);
27