|
1 | | -// RUN: mlir-opt -convert-math-to-emitc=language-target=C %s | FileCheck %s --check-prefix=C |
2 | | -// RUN: mlir-opt -convert-math-to-emitc=language-target=CPP %s | FileCheck %s --check-prefix=CPP |
| 1 | +// RUN: mlir-opt -convert-math-to-emitc=language-target=c99 %s | FileCheck %s --check-prefix=c99 |
| 2 | +// RUN: mlir-opt -convert-math-to-emitc=language-target=cpp11 %s | FileCheck %s --check-prefix=cpp11 |
3 | 3 |
|
4 | | -func.func @absf_to_call_opaque(%arg0: f32) { |
5 | | - // C: emitc.call_opaque "fabsf" |
6 | | - // CPP: emitc.call_opaque "std::fabs" |
7 | | - %1 = math.absf %arg0 : f32 |
| 4 | +func.func @absf(%arg0: f32, %arg1: f64) { |
| 5 | + // c99: emitc.call_opaque "fabsf" |
| 6 | + // c99-NEXT: emitc.call_opaque "fabs" |
| 7 | + // cpp11: emitc.call_opaque "std::fabs" |
| 8 | + // cpp11-NEXT: emitc.call_opaque "std::fabs" |
| 9 | + %0 = math.absf %arg0 : f32 |
| 10 | + %1 = math.absf %arg1 : f64 |
8 | 11 | return |
9 | | - } |
10 | | -func.func @floor_to_call_opaque(%arg0: f32) { |
11 | | - // C: emitc.call_opaque "floorf" |
12 | | - // CPP: emitc.call_opaque "std::floor" |
13 | | - %1 = math.floor %arg0 : f32 |
14 | | - return |
15 | | - } |
16 | | -func.func @sin_to_call_opaque(%arg0: f32) { |
17 | | - // C: emitc.call_opaque "sinf" |
18 | | - // CPP: emitc.call_opaque "std::sin" |
19 | | - %1 = math.sin %arg0 : f32 |
| 12 | +} |
| 13 | + |
| 14 | +func.func @floor(%arg0: f32, %arg1: f64) { |
| 15 | + // c99: emitc.call_opaque "floorf" |
| 16 | + // c99-NEXT: emitc.call_opaque "floor" |
| 17 | + // cpp11: emitc.call_opaque "std::floor" |
| 18 | + // cpp11-NEXT: emitc.call_opaque "std::floor" |
| 19 | + %0 = math.floor %arg0 : f32 |
| 20 | + %1 = math.floor %arg1 : f64 |
20 | 21 | return |
21 | | - } |
22 | | -func.func @cos_to_call_opaque(%arg0: f32) { |
23 | | - // C: emitc.call_opaque "cosf" |
24 | | - // CPP: emitc.call_opaque "std::cos" |
25 | | - %1 = math.cos %arg0 : f32 |
| 22 | +} |
| 23 | + |
| 24 | +func.func @sin(%arg0: f32, %arg1: f64) { |
| 25 | + // c99: emitc.call_opaque "sinf" |
| 26 | + // c99-NEXT: emitc.call_opaque "sin" |
| 27 | + // cpp11: emitc.call_opaque "std::sin" |
| 28 | + // cpp11-NEXT: emitc.call_opaque "std::sin" |
| 29 | + %0 = math.sin %arg0 : f32 |
| 30 | + %1 = math.sin %arg1 : f64 |
26 | 31 | return |
27 | | - } |
28 | | -func.func @asin_to_call_opaque(%arg0: f32) { |
29 | | - // C: emitc.call_opaque "asinf" |
30 | | - // CPP: emitc.call_opaque "std::asin" |
31 | | - %1 = math.asin %arg0 : f32 |
| 32 | +} |
| 33 | + |
| 34 | +func.func @cos(%arg0: f32, %arg1: f64) { |
| 35 | + // c99: emitc.call_opaque "cosf" |
| 36 | + // c99-NEXT: emitc.call_opaque "cos" |
| 37 | + // cpp11: emitc.call_opaque "std::cos" |
| 38 | + // cpp11-NEXT: emitc.call_opaque "std::cos" |
| 39 | + %0 = math.cos %arg0 : f32 |
| 40 | + %1 = math.cos %arg1 : f64 |
32 | 41 | return |
33 | | - } |
34 | | -func.func @acos_to_call_opaque(%arg0: f64) { |
35 | | - // C: emitc.call_opaque "acos" |
36 | | - // CPP: emitc.call_opaque "std::acos" |
37 | | - %1 = math.acos %arg0 : f64 |
| 42 | +} |
| 43 | + |
| 44 | +func.func @asin(%arg0: f32, %arg1: f64) { |
| 45 | + // c99: emitc.call_opaque "asinf" |
| 46 | + // c99-NEXT: emitc.call_opaque "asin" |
| 47 | + // cpp11: emitc.call_opaque "std::asin" |
| 48 | + // cpp11-NEXT: emitc.call_opaque "std::asin" |
| 49 | + %0 = math.asin %arg0 : f32 |
| 50 | + %1 = math.asin %arg1 : f64 |
38 | 51 | return |
39 | | - } |
40 | | -func.func @atan2_to_call_opaque(%arg0: f64, %arg1: f64) { |
41 | | - // C: emitc.call_opaque "atan2" |
42 | | - // CPP: emitc.call_opaque "std::atan2" |
43 | | - %1 = math.atan2 %arg0, %arg1 : f64 |
| 52 | +} |
| 53 | + |
| 54 | +func.func @acos(%arg0: f32, %arg1: f64) { |
| 55 | + // c99: emitc.call_opaque "acosf" |
| 56 | + // c99-NEXT: emitc.call_opaque "acos" |
| 57 | + // cpp11: emitc.call_opaque "std::acos" |
| 58 | + // cpp11-NEXT: emitc.call_opaque "std::acos" |
| 59 | + %0 = math.acos %arg0 : f32 |
| 60 | + %1 = math.acos %arg1 : f64 |
44 | 61 | return |
45 | | - } |
46 | | -func.func @ceil_to_call_opaque(%arg0: f64) { |
47 | | - // C: emitc.call_opaque "ceil" |
48 | | - // CPP: emitc.call_opaque "std::ceil" |
49 | | - %1 = math.ceil %arg0 : f64 |
| 62 | +} |
| 63 | + |
| 64 | +func.func @atan2(%arg0: f32, %arg1: f32, %arg2: f64, %arg3: f64) { |
| 65 | + // c99: emitc.call_opaque "atan2f" |
| 66 | + // c99-NEXT: emitc.call_opaque "atan2" |
| 67 | + // cpp11: emitc.call_opaque "std::atan2" |
| 68 | + // cpp11-NEXT: emitc.call_opaque "std::atan2" |
| 69 | + %0 = math.atan2 %arg0, %arg1 : f32 |
| 70 | + %1 = math.atan2 %arg2, %arg3 : f64 |
50 | 71 | return |
51 | | - } |
52 | | -func.func @exp_to_call_opaque(%arg0: f64) { |
53 | | - // C: emitc.call_opaque "exp" |
54 | | - // CPP: emitc.call_opaque "std::exp" |
55 | | - %1 = math.exp %arg0 : f64 |
| 72 | +} |
| 73 | + |
| 74 | +func.func @ceil(%arg0: f32, %arg1: f64) { |
| 75 | + // c99: emitc.call_opaque "ceilf" |
| 76 | + // c99-NEXT: emitc.call_opaque "ceil" |
| 77 | + // cpp11: emitc.call_opaque "std::ceil" |
| 78 | + // cpp11-NEXT: emitc.call_opaque "std::ceil" |
| 79 | + %0 = math.ceil %arg0 : f32 |
| 80 | + %1 = math.ceil %arg1 : f64 |
56 | 81 | return |
57 | | - } |
58 | | -func.func @powf_to_call_opaque(%arg0: f64, %arg1: f64) { |
59 | | - // C: emitc.call_opaque "pow" |
60 | | - // CPP: emitc.call_opaque "std::pow" |
61 | | - %1 = math.powf %arg0, %arg1 : f64 |
| 82 | +} |
| 83 | + |
| 84 | +func.func @exp(%arg0: f32, %arg1: f64) { |
| 85 | + // c99: emitc.call_opaque "expf" |
| 86 | + // c99-NEXT: emitc.call_opaque "exp" |
| 87 | + // cpp11: emitc.call_opaque "std::exp" |
| 88 | + // cpp11-NEXT: emitc.call_opaque "std::exp" |
| 89 | + %0 = math.exp %arg0 : f32 |
| 90 | + %1 = math.exp %arg1 : f64 |
62 | 91 | return |
63 | | - } |
| 92 | +} |
64 | 93 |
|
| 94 | +func.func @powf(%arg0: f32, %arg1: f32, %arg2: f64, %arg3: f64) { |
| 95 | + // c99: emitc.call_opaque "powf" |
| 96 | + // c99-NEXT: emitc.call_opaque "pow" |
| 97 | + // cpp11: emitc.call_opaque "std::pow" |
| 98 | + // cpp11-NEXT: emitc.call_opaque "std::pow" |
| 99 | + %0 = math.powf %arg0, %arg1 : f32 |
| 100 | + %1 = math.powf %arg2, %arg3 : f64 |
| 101 | + return |
| 102 | +} |
65 | 103 |
|
| 104 | +func.func @round(%arg0: f32, %arg1: f64) { |
| 105 | + // c99: emitc.call_opaque "roundf" |
| 106 | + // c99-NEXT: emitc.call_opaque "round" |
| 107 | + // cpp11: emitc.call_opaque "std::round" |
| 108 | + // cpp11-NEXT: emitc.call_opaque "std::round" |
| 109 | + %0 = math.round %arg0 : f32 |
| 110 | + %1 = math.round %arg1 : f64 |
| 111 | + return |
| 112 | +} |
0 commit comments