Skip to content

Commit 9e17a7e

Browse files
committed
one underscore
1 parent 77a0523 commit 9e17a7e

File tree

3 files changed

+33
-28
lines changed

3 files changed

+33
-28
lines changed

mlir/lib/Conversion/ArithToAPFloat/ArithToAPFloat.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
#include "mlir/IR/PatternMatch.h"
1616
#include "mlir/IR/Verifier.h"
1717
#include "mlir/Transforms/WalkPatternRewriteDriver.h"
18-
#include "llvm/Support/Debug.h"
19-
20-
#define DEBUG_TYPE "arith-to-apfloat"
2118

2219
namespace mlir {
2320
#define GEN_PASS_DEF_ARITHTOAPFLOATCONVERSIONPASS
@@ -59,7 +56,7 @@ lookupOrCreateBinaryFn(OpBuilder &b, SymbolOpInterface symTable, StringRef name,
5956
auto i32Type = IntegerType::get(symTable->getContext(), 32);
6057
auto i64Type = IntegerType::get(symTable->getContext(), 64);
6158

62-
std::string funcName = (llvm::Twine("__mlir_apfloat_") + name).str();
59+
std::string funcName = (llvm::Twine("_mlir_apfloat_") + name).str();
6360
FunctionType funcT =
6461
FunctionType::get(b.getContext(), {i32Type, i64Type, i64Type}, {i64Type});
6562
FailureOr<FuncOp> func =

mlir/lib/ExecutionEngine/APFloatWrappers.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,24 @@
2121
//
2222
#include "llvm/ADT/APFloat.h"
2323

24-
#if (defined(_WIN32) || defined(__CYGWIN__))
25-
#define MLIR_APFLOAT_WRAPPERS_EXPORTED __declspec(dllexport)
24+
#ifdef _WIN32
25+
#ifndef MLIR_APFLOAT_WRAPPERS_EXPORT
26+
#ifdef mlir_apfloat_wrappers_EXPORTS
27+
// We are building this library
28+
#define MLIR_APFLOAT_WRAPPERS_EXPORT __declspec(dllexport)
2629
#else
27-
#define MLIR_APFLOAT_WRAPPERS_EXPORTED __attribute__((visibility("default")))
28-
#endif
30+
// We are using this library
31+
#define MLIR_APFLOAT_WRAPPERS_EXPORT __declspec(dllimport)
32+
#endif // mlir_apfloat_wrappers_EXPORTS
33+
#endif // MLIR_APFLOAT_WRAPPERS_EXPORT
34+
#else
35+
// Non-windows: use visibility attributes.
36+
#define MLIR_APFLOAT_WRAPPERS_EXPORT __attribute__((visibility("default")))
37+
#endif // _WIN32
2938

3039
/// Binary operations without rounding mode.
3140
#define APFLOAT_BINARY_OP(OP) \
32-
MLIR_APFLOAT_WRAPPERS_EXPORTED int64_t __mlir_apfloat_##OP( \
41+
MLIR_APFLOAT_WRAPPERS_EXPORT int64_t _mlir_apfloat_##OP( \
3342
int32_t semantics, uint64_t a, uint64_t b) { \
3443
const llvm::fltSemantics &sem = llvm::APFloatBase::EnumToSemantics( \
3544
static_cast<llvm::APFloatBase::Semantics>(semantics)); \
@@ -42,7 +51,7 @@
4251

4352
/// Binary operations with rounding mode.
4453
#define APFLOAT_BINARY_OP_ROUNDING_MODE(OP, ROUNDING_MODE) \
45-
MLIR_APFLOAT_WRAPPERS_EXPORTED int64_t __mlir_apfloat_##OP( \
54+
MLIR_APFLOAT_WRAPPERS_EXPORT int64_t _mlir_apfloat_##OP( \
4655
int32_t semantics, uint64_t a, uint64_t b) { \
4756
const llvm::fltSemantics &sem = llvm::APFloatBase::EnumToSemantics( \
4857
static_cast<llvm::APFloatBase::Semantics>(semantics)); \
@@ -69,8 +78,7 @@ APFLOAT_BINARY_OP(remainder)
6978

7079
#undef APFLOAT_BINARY_OP
7180

72-
MLIR_APFLOAT_WRAPPERS_EXPORTED void printApFloat(int32_t semantics,
73-
uint64_t a) {
81+
MLIR_APFLOAT_WRAPPERS_EXPORT void printApFloat(int32_t semantics, uint64_t a) {
7482
const llvm::fltSemantics &sem = llvm::APFloatBase::EnumToSemantics(
7583
static_cast<llvm::APFloatBase::Semantics>(semantics));
7684
unsigned bitWidth = llvm::APFloatBase::semanticsSizeInBits(sem);

mlir/test/Conversion/ArithToApfloat/arith-to-apfloat.mlir

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: mlir-opt %s --convert-arith-to-apfloat -split-input-file -verify-diagnostics | FileCheck %s
22

3-
// CHECK-LABEL: func.func private @__mlir_apfloat_add(i32, i64, i64) -> i64
3+
// CHECK-LABEL: func.func private @_mlir_apfloat_add(i32, i64, i64) -> i64
44

55
// CHECK-LABEL: func.func @foo() -> f8E4M3FN {
66
// CHECK: %[[CONSTANT_0:.*]] = arith.constant 2.250000e+00 : f8E4M3FN
@@ -12,7 +12,7 @@
1212
// CHECK: return %[[CONSTANT_0]] : f6E3M2FN
1313
// CHECK: }
1414

15-
// Illustrate that both f8E4M3FN and f6E3M2FN calling the same __mlir_apfloat_add is fine
15+
// Illustrate that both f8E4M3FN and f6E3M2FN calling the same _mlir_apfloat_add is fine
1616
// because each gets its own semantics enum and gets bitcast/extui/trunci to its own width.
1717
// CHECK-LABEL: func.func @full_example() {
1818
// CHECK: %[[CONSTANT_0:.*]] = arith.constant 1.375000e+00 : f8E4M3FN
@@ -23,7 +23,7 @@
2323
// CHECK: %[[EXTUI_1:.*]] = arith.extui %[[BITCAST_1]] : i8 to i64
2424
// // fltSemantics semantics for f8E4M3FN
2525
// CHECK: %[[CONSTANT_1:.*]] = arith.constant 10 : i32
26-
// CHECK: %[[VAL_1:.*]] = call @__mlir_apfloat_add(%[[CONSTANT_1]], %[[EXTUI_0]], %[[EXTUI_1]]) : (i32, i64, i64) -> i64
26+
// CHECK: %[[VAL_1:.*]] = call @_mlir_apfloat_add(%[[CONSTANT_1]], %[[EXTUI_0]], %[[EXTUI_1]]) : (i32, i64, i64) -> i64
2727
// CHECK: %[[TRUNCI_0:.*]] = arith.trunci %[[VAL_1]] : i64 to i8
2828
// CHECK: %[[BITCAST_2:.*]] = arith.bitcast %[[TRUNCI_0]] : i8 to f8E4M3FN
2929
// CHECK: vector.print %[[BITCAST_2]] : f8E4M3FN
@@ -36,7 +36,7 @@
3636
// CHECK: %[[EXTUI_3:.*]] = arith.extui %[[BITCAST_4]] : i6 to i64
3737
// // fltSemantics semantics for f6E3M2FN
3838
// CHECK: %[[CONSTANT_3:.*]] = arith.constant 16 : i32
39-
// CHECK: %[[VAL_3:.*]] = call @__mlir_apfloat_add(%[[CONSTANT_3]], %[[EXTUI_2]], %[[EXTUI_3]]) : (i32, i64, i64) -> i64
39+
// CHECK: %[[VAL_3:.*]] = call @_mlir_apfloat_add(%[[CONSTANT_3]], %[[EXTUI_2]], %[[EXTUI_3]]) : (i32, i64, i64) -> i64
4040
// CHECK: %[[TRUNCI_1:.*]] = arith.trunci %[[VAL_3]] : i64 to i6
4141
// CHECK: %[[BITCAST_5:.*]] = arith.bitcast %[[TRUNCI_1]] : i6 to f6E3M2FN
4242
// CHECK: vector.print %[[BITCAST_5]] : f6E3M2FN
@@ -69,9 +69,9 @@ func.func @full_example() {
6969

7070
// -----
7171

72-
// CHECK: func.func private @__mlir_apfloat_add(i32, i64, i64) -> i64
72+
// CHECK: func.func private @_mlir_apfloat_add(i32, i64, i64) -> i64
7373
// CHECK: %[[sem:.*]] = arith.constant 18 : i32
74-
// CHECK: call @__mlir_apfloat_add(%[[sem]], %{{.*}}, %{{.*}}) : (i32, i64, i64) -> i64
74+
// CHECK: call @_mlir_apfloat_add(%[[sem]], %{{.*}}, %{{.*}}) : (i32, i64, i64) -> i64
7575
func.func @addf(%arg0: f4E2M1FN, %arg1: f4E2M1FN) {
7676
%0 = arith.addf %arg0, %arg1 : f4E2M1FN
7777
return
@@ -80,48 +80,48 @@ func.func @addf(%arg0: f4E2M1FN, %arg1: f4E2M1FN) {
8080
// -----
8181

8282
// Test decl collision (different type)
83-
// expected-error@+1{{matched function '__mlir_apfloat_add' but with different type: '(i32, i32, f32) -> index' (expected '(i32, i64, i64) -> i64')}}
84-
func.func private @__mlir_apfloat_add(i32, i32, f32) -> index
83+
// expected-error@+1{{matched function '_mlir_apfloat_add' but with different type: '(i32, i32, f32) -> index' (expected '(i32, i64, i64) -> i64')}}
84+
func.func private @_mlir_apfloat_add(i32, i32, f32) -> index
8585
func.func @addf(%arg0: f4E2M1FN, %arg1: f4E2M1FN) {
8686
%0 = arith.addf %arg0, %arg1 : f4E2M1FN
8787
return
8888
}
8989

9090
// -----
9191

92-
// CHECK: func.func private @__mlir_apfloat_subtract(i32, i64, i64) -> i64
92+
// CHECK: func.func private @_mlir_apfloat_subtract(i32, i64, i64) -> i64
9393
// CHECK: %[[sem:.*]] = arith.constant 18 : i32
94-
// CHECK: call @__mlir_apfloat_subtract(%[[sem]], %{{.*}}, %{{.*}}) : (i32, i64, i64) -> i64
94+
// CHECK: call @_mlir_apfloat_subtract(%[[sem]], %{{.*}}, %{{.*}}) : (i32, i64, i64) -> i64
9595
func.func @subf(%arg0: f4E2M1FN, %arg1: f4E2M1FN) {
9696
%0 = arith.subf %arg0, %arg1 : f4E2M1FN
9797
return
9898
}
9999

100100
// -----
101101

102-
// CHECK: func.func private @__mlir_apfloat_multiply(i32, i64, i64) -> i64
102+
// CHECK: func.func private @_mlir_apfloat_multiply(i32, i64, i64) -> i64
103103
// CHECK: %[[sem:.*]] = arith.constant 18 : i32
104-
// CHECK: call @__mlir_apfloat_multiply(%[[sem]], %{{.*}}, %{{.*}}) : (i32, i64, i64) -> i64
104+
// CHECK: call @_mlir_apfloat_multiply(%[[sem]], %{{.*}}, %{{.*}}) : (i32, i64, i64) -> i64
105105
func.func @subf(%arg0: f4E2M1FN, %arg1: f4E2M1FN) {
106106
%0 = arith.mulf %arg0, %arg1 : f4E2M1FN
107107
return
108108
}
109109

110110
// -----
111111

112-
// CHECK: func.func private @__mlir_apfloat_divide(i32, i64, i64) -> i64
112+
// CHECK: func.func private @_mlir_apfloat_divide(i32, i64, i64) -> i64
113113
// CHECK: %[[sem:.*]] = arith.constant 18 : i32
114-
// CHECK: call @__mlir_apfloat_divide(%[[sem]], %{{.*}}, %{{.*}}) : (i32, i64, i64) -> i64
114+
// CHECK: call @_mlir_apfloat_divide(%[[sem]], %{{.*}}, %{{.*}}) : (i32, i64, i64) -> i64
115115
func.func @subf(%arg0: f4E2M1FN, %arg1: f4E2M1FN) {
116116
%0 = arith.divf %arg0, %arg1 : f4E2M1FN
117117
return
118118
}
119119

120120
// -----
121121

122-
// CHECK: func.func private @__mlir_apfloat_remainder(i32, i64, i64) -> i64
122+
// CHECK: func.func private @_mlir_apfloat_remainder(i32, i64, i64) -> i64
123123
// CHECK: %[[sem:.*]] = arith.constant 18 : i32
124-
// CHECK: call @__mlir_apfloat_remainder(%[[sem]], %{{.*}}, %{{.*}}) : (i32, i64, i64) -> i64
124+
// CHECK: call @_mlir_apfloat_remainder(%[[sem]], %{{.*}}, %{{.*}}) : (i32, i64, i64) -> i64
125125
func.func @remf(%arg0: f4E2M1FN, %arg1: f4E2M1FN) {
126126
%0 = arith.remf %arg0, %arg1 : f4E2M1FN
127127
return

0 commit comments

Comments
 (0)