|
| 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 | + |
| 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 |
| 11 | + return |
| 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 |
| 21 | + return |
| 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 |
| 31 | + return |
| 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 |
| 41 | + return |
| 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 |
| 51 | + return |
| 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 |
| 61 | + return |
| 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 |
| 71 | + return |
| 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 |
| 81 | + return |
| 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 |
| 91 | + return |
| 92 | +} |
| 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 | +} |
| 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