Skip to content

Commit 4e3ddc4

Browse files
committed
Rename to mangling_mode, addressing review comments
1 parent 852dd15 commit 4e3ddc4

File tree

15 files changed

+55
-48
lines changed

15 files changed

+55
-48
lines changed

mlir/include/mlir/Dialect/DLTI/DLTIAttrs.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ def DLTI_DataLayoutSpecAttr :
7777
/// Returns the alloca memory space identifier.
7878
StringAttr getAllocaMemorySpaceIdentifier(MLIRContext *context) const;
7979

80-
/// Returns the mangling style identifier.
81-
StringAttr getManglingStyleIdentifier(MLIRContext *context) const;
80+
/// Returns the mangling mode identifier.
81+
StringAttr getManglingModeIdentifier(MLIRContext *context) const;
8282

8383
/// Returns the program memory space identifier.
8484
StringAttr getProgramMemorySpaceIdentifier(MLIRContext *context) const;

mlir/include/mlir/Dialect/DLTI/DLTIBase.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ def DLTI_Dialect : Dialect {
4949
constexpr const static ::llvm::StringLiteral
5050
kDataLayoutEndiannessLittle = "little";
5151

52+
// Mangling mode, a.k.a mangling style used to mangle llvm names
5253
constexpr const static ::llvm::StringLiteral
53-
kDataLayoutManglingStyleKey = "dlti.mangling_style";
54+
kDataLayoutManglingModeKey = "dlti.mangling_mode";
5455

5556
constexpr const static ::llvm::StringLiteral
5657
kDataLayoutAllocaMemorySpaceKey = "dlti.alloca_memory_space";

mlir/include/mlir/Interfaces/DataLayoutInterfaces.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ Attribute getDefaultEndianness(DataLayoutEntryInterface entry);
7878
/// DataLayoutInterface if specified, otherwise returns the default.
7979
Attribute getDefaultAllocaMemorySpace(DataLayoutEntryInterface entry);
8080

81-
/// Default handler for mangling style request. Dispatches to the
81+
/// Default handler for mangling mode request. Dispatches to the
8282
/// DataLayoutInterface if specified, otherwise returns the default.
83-
Attribute getDefaultManglingStyle(DataLayoutEntryInterface entry);
83+
Attribute getDefaultManglingMode(DataLayoutEntryInterface entry);
8484

8585
/// Default handler for program memory space request. Dispatches to the
8686
/// DataLayoutInterface if specified, otherwise returns the default.
@@ -234,8 +234,8 @@ class DataLayout {
234234
/// Returns the memory space used for AllocaOps.
235235
Attribute getAllocaMemorySpace() const;
236236

237-
/// Returns the mangling style.
238-
Attribute getManglingStyle() const;
237+
/// Returns the mangling mode.
238+
Attribute getManglingMode() const;
239239

240240
/// Returns the memory space used for program memory operations.
241241
Attribute getProgramMemorySpace() const;
@@ -283,8 +283,8 @@ class DataLayout {
283283

284284
/// Cache for the endianness.
285285
mutable std::optional<Attribute> endianness;
286-
/// Cache for the mangling style.
287-
mutable std::optional<Attribute> manglingStyle;
286+
/// Cache for the mangling mode.
287+
mutable std::optional<Attribute> manglingMode;
288288
/// Cache for alloca, global, and program memory spaces.
289289
mutable std::optional<Attribute> allocaMemorySpace;
290290
mutable std::optional<Attribute> programMemorySpace;

mlir/include/mlir/Interfaces/DataLayoutInterfaces.td

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ def DataLayoutSpecInterface : AttrInterface<"DataLayoutSpecInterface", [DLTIQuer
154154
/*args=*/(ins "::mlir::MLIRContext *":$context)
155155
>,
156156
InterfaceMethod<
157-
/*description=*/"Returns the mangling style identifier.",
157+
/*description=*/"Returns the mangling mode identifier.",
158158
/*retTy=*/"::mlir::StringAttr",
159-
/*methodName=*/"getManglingStyleIdentifier",
159+
/*methodName=*/"getManglingModeIdentifier",
160160
/*args=*/(ins "::mlir::MLIRContext *":$context)
161161
>,
162162
InterfaceMethod<
@@ -488,15 +488,15 @@ def DataLayoutOpInterface : OpInterface<"DataLayoutOpInterface"> {
488488
}]
489489
>,
490490
StaticInterfaceMethod<
491-
/*description=*/"Returns the mangling style computed "
491+
/*description=*/"Returns the mangling mode computed "
492492
"using the relevant entries. The data layout object "
493493
"can be used for recursive queries.",
494494
/*retTy=*/"::mlir::Attribute",
495-
/*methodName=*/"getManglingStyle",
495+
/*methodName=*/"getManglingMode",
496496
/*args=*/(ins "::mlir::DataLayoutEntryInterface":$entry),
497497
/*methodBody=*/"",
498498
/*defaultImplementation=*/[{
499-
return ::mlir::detail::getDefaultManglingStyle(entry);
499+
return ::mlir::detail::getDefaultManglingMode(entry);
500500
}]
501501
>,
502502
StaticInterfaceMethod<

mlir/lib/Dialect/DLTI/DLTI.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,9 @@ DataLayoutSpecAttr::getGlobalMemorySpaceIdentifier(MLIRContext *context) const {
398398
}
399399

400400
StringAttr
401-
DataLayoutSpecAttr::getManglingStyleIdentifier(MLIRContext *context) const {
401+
DataLayoutSpecAttr::getManglingModeIdentifier(MLIRContext *context) const {
402402
return Builder(context).getStringAttr(
403-
DLTIDialect::kDataLayoutManglingStyleKey);
403+
DLTIDialect::kDataLayoutManglingModeKey);
404404
}
405405

406406
StringAttr
@@ -613,7 +613,7 @@ class TargetDataLayoutInterface : public DataLayoutDialectInterface {
613613
entryName == DLTIDialect::kDataLayoutProgramMemorySpaceKey ||
614614
entryName == DLTIDialect::kDataLayoutGlobalMemorySpaceKey ||
615615
entryName == DLTIDialect::kDataLayoutStackAlignmentKey ||
616-
entryName == DLTIDialect::kDataLayoutManglingStyleKey)
616+
entryName == DLTIDialect::kDataLayoutManglingModeKey)
617617
return success();
618618
return emitError(loc) << "unknown data layout entry name: " << entryName;
619619
}

mlir/lib/Interfaces/DataLayoutInterfaces.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,11 @@ mlir::detail::getDefaultAllocaMemorySpace(DataLayoutEntryInterface entry) {
258258
return entry.getValue();
259259
}
260260

261-
// Returns the mangling style if specified in the given entry.
261+
// Returns the mangling mode if specified in the given entry.
262262
// If the entry is empty, an empty attribute is returned.
263-
Attribute
264-
mlir::detail::getDefaultManglingStyle(DataLayoutEntryInterface entry) {
265-
if (entry == DataLayoutEntryInterface()) {
263+
Attribute mlir::detail::getDefaultManglingMode(DataLayoutEntryInterface entry) {
264+
if (entry == DataLayoutEntryInterface())
266265
return Attribute();
267-
}
268266

269267
return entry.getValue();
270268
}
@@ -623,20 +621,20 @@ mlir::Attribute mlir::DataLayout::getAllocaMemorySpace() const {
623621
return *allocaMemorySpace;
624622
}
625623

626-
mlir::Attribute mlir::DataLayout::getManglingStyle() const {
624+
mlir::Attribute mlir::DataLayout::getManglingMode() const {
627625
checkValid();
628-
if (manglingStyle)
629-
return *manglingStyle;
626+
if (manglingMode)
627+
return *manglingMode;
630628
DataLayoutEntryInterface entry;
631629
if (originalLayout)
632630
entry = originalLayout.getSpecForIdentifier(
633-
originalLayout.getManglingStyleIdentifier(originalLayout.getContext()));
631+
originalLayout.getManglingModeIdentifier(originalLayout.getContext()));
634632

635633
if (auto iface = dyn_cast_or_null<DataLayoutOpInterface>(scope))
636-
manglingStyle = iface.getManglingStyle(entry);
634+
manglingMode = iface.getManglingMode(entry);
637635
else
638-
manglingStyle = detail::getDefaultManglingStyle(entry);
639-
return *manglingStyle;
636+
manglingMode = detail::getDefaultManglingMode(entry);
637+
return *manglingMode;
640638
}
641639

642640
mlir::Attribute mlir::DataLayout::getProgramMemorySpace() const {

mlir/lib/Target/LLVMIR/DataLayoutImporter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ DataLayoutImporter::tryToEmplaceEndiannessEntry(StringRef endianness,
163163
return success();
164164
}
165165

166-
LogicalResult DataLayoutImporter::tryToEmplaceManglingStyleEntry(
166+
LogicalResult DataLayoutImporter::tryToEmplaceManglingModeEntry(
167167
StringRef token, llvm::StringLiteral manglingKey) {
168168
auto key = StringAttr::get(context, manglingKey);
169169
if (keyEntries.count(key))
@@ -269,10 +269,10 @@ void DataLayoutImporter::translateDataLayout(
269269
return;
270270
continue;
271271
}
272-
// Parse the mangling style.
272+
// Parse the mangling mode.
273273
if (*prefix == "m") {
274-
if (failed(tryToEmplaceManglingStyleEntry(
275-
token, DLTIDialect::kDataLayoutManglingStyleKey)))
274+
if (failed(tryToEmplaceManglingModeEntry(
275+
token, DLTIDialect::kDataLayoutManglingModeKey)))
276276
return;
277277
continue;
278278
}

mlir/lib/Target/LLVMIR/DataLayoutImporter.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ class DataLayoutImporter {
100100
LogicalResult tryToEmplaceAddrSpaceEntry(StringRef token,
101101
llvm::StringLiteral spaceKey);
102102

103-
/// Adds an mangling style entry if there is none yet.
104-
LogicalResult tryToEmplaceManglingStyleEntry(StringRef token,
105-
llvm::StringLiteral manglingKey);
103+
/// Adds an mangling mode entry if there is none yet.
104+
LogicalResult tryToEmplaceManglingModeEntry(StringRef token,
105+
llvm::StringLiteral manglingKey);
106106

107107
/// Adds a stack alignment entry if there is none yet.
108108
LogicalResult tryToEmplaceStackAlignmentEntry(StringRef token);

mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ translateDataLayout(DataLayoutSpecInterface attribute,
199199
layoutStream << "-" << (isLittleEndian ? "e" : "E");
200200
continue;
201201
}
202-
if (key.getValue() == DLTIDialect::kDataLayoutManglingStyleKey) {
202+
if (key.getValue() == DLTIDialect::kDataLayoutManglingModeKey) {
203203
auto value = cast<StringAttr>(entry.getValue());
204204
layoutStream << "-m:" << value.getValue();
205205
continue;

mlir/test/Dialect/LLVMIR/layout.mlir

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module {
99
// CHECK: endianness = ""
1010
// CHECK: global_memory_space = 0
1111
// CHECK: index = 64
12+
// CHECK: mangling_mode = ""
1213
// CHECK: preferred = 8
1314
// CHECK: program_memory_space = 0
1415
// CHECK: size = 8
@@ -20,6 +21,7 @@ module {
2021
// CHECK: endianness = ""
2122
// CHECK: global_memory_space = 0
2223
// CHECK: index = 64
24+
// CHECK: mangling_mode = ""
2325
// CHECK: preferred = 8
2426
// CHECK: program_memory_space = 0
2527
// CHECK: size = 8
@@ -31,6 +33,7 @@ module {
3133
// CHECK: endianness = ""
3234
// CHECK: global_memory_space = 0
3335
// CHECK: index = 64
36+
// CHECK: mangling_mode = ""
3437
// CHECK: preferred = 8
3538
// CHECK: program_memory_space = 0
3639
// CHECK: size = 8
@@ -50,7 +53,8 @@ module attributes { dlti.dl_spec = #dlti.dl_spec<
5053
#dlti.dl_entry<"dlti.alloca_memory_space", 5 : ui64>,
5154
#dlti.dl_entry<"dlti.global_memory_space", 2 : ui64>,
5255
#dlti.dl_entry<"dlti.program_memory_space", 3 : ui64>,
53-
#dlti.dl_entry<"dlti.stack_alignment", 128 : i64>
56+
#dlti.dl_entry<"dlti.stack_alignment", 128 : i64>,
57+
#dlti.dl_entry<"dlti.mangling_mode", "e">
5458
>} {
5559
// CHECK: @spec
5660
func.func @spec() {
@@ -60,6 +64,7 @@ module attributes { dlti.dl_spec = #dlti.dl_spec<
6064
// CHECK: endianness = "little"
6165
// CHECK: global_memory_space = 2
6266
// CHECK: index = 32
67+
// CHECK: mangling_mode = "e"
6368
// CHECK: preferred = 8
6469
// CHECK: program_memory_space = 3
6570
// CHECK: size = 4
@@ -82,6 +87,7 @@ module attributes { dlti.dl_spec = #dlti.dl_spec<
8287
// CHECK: endianness = "little"
8388
// CHECK: global_memory_space = 2
8489
// CHECK: index = 64
90+
// CHECK: mangling_mode = "e"
8591
// CHECK: preferred = 8
8692
// CHECK: program_memory_space = 3
8793
// CHECK: size = 8
@@ -93,6 +99,7 @@ module attributes { dlti.dl_spec = #dlti.dl_spec<
9399
// CHECK: endianness = "little"
94100
// CHECK: global_memory_space = 2
95101
// CHECK: index = 24
102+
// CHECK: mangling_mode = "e"
96103
// CHECK: preferred = 8
97104
// CHECK: program_memory_space = 3
98105
// CHECK: size = 4

mlir/test/Target/LLVMIR/Import/data-layout.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ target datalayout = ""
2929
; CHECK-DAG: !llvm.ptr<271> = dense<32> : vector<4xi64>
3030
; CHECK-DAG: !llvm.ptr<272> = dense<64> : vector<4xi64>
3131
; CHECK-DAG: "dlti.stack_alignment" = 128 : i64
32-
; CHECK-DAG: "dlti.mangling_style" = "e"
32+
; CHECK-DAG: "dlti.mangling_mode" = "e"
3333
target datalayout = "e-m:e-p270:32:64-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
3434

3535
; // -----

mlir/test/Target/LLVMIR/Import/import-failure.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ declare void @llvm.experimental.noalias.scope.decl(metadata)
355355
target datalayout = "e-ni:42-i64:64"
356356

357357
; // -----
358+
358359
; CHECK: import-failure.ll
359360
; CHECK-SAME: malformed specification, must be of the form "m:<mangling>"
360361
target datalayout = "e-m-i64:64"

mlir/test/Target/LLVMIR/data-layout.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module attributes {dlti.dl_spec = #dlti.dl_spec<
1313
#dlti.dl_entry<"dlti.endianness", "big">,
1414
#dlti.dl_entry<"dlti.alloca_memory_space", 4 : ui32>,
1515
#dlti.dl_entry<"dlti.stack_alignment", 128 : i32>,
16-
#dlti.dl_entry<"dlti.mangling_style", "e">,
16+
#dlti.dl_entry<"dlti.mangling_mode", "e">,
1717
#dlti.dl_entry<index, 64>,
1818
#dlti.dl_entry<i64, dense<[64,128]> : vector<2xi64>>,
1919
#dlti.dl_entry<f80, dense<[128,256]> : vector<2xi64>>,

mlir/test/lib/Dialect/DLTI/TestDataLayoutQuery.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct TestDataLayoutQuery
4343
uint64_t index = layout.getTypeIndexBitwidth(op.getType()).value_or(0);
4444
Attribute endianness = layout.getEndianness();
4545
Attribute allocaMemorySpace = layout.getAllocaMemorySpace();
46-
Attribute manglingStyle = layout.getManglingStyle();
46+
Attribute manglingMode = layout.getManglingMode();
4747
Attribute programMemorySpace = layout.getProgramMemorySpace();
4848
Attribute globalMemorySpace = layout.getGlobalMemorySpace();
4949
uint64_t stackAlignment = layout.getStackAlignment();
@@ -73,10 +73,9 @@ struct TestDataLayoutQuery
7373
allocaMemorySpace == Attribute()
7474
? builder.getUI32IntegerAttr(0)
7575
: allocaMemorySpace),
76-
builder.getNamedAttr("mangling_style",
77-
manglingStyle == Attribute()
78-
? builder.getStringAttr("")
79-
: manglingStyle),
76+
builder.getNamedAttr("mangling_mode", manglingMode == Attribute()
77+
? builder.getStringAttr("")
78+
: manglingMode),
8079
builder.getNamedAttr("program_memory_space",
8180
programMemorySpace == Attribute()
8281
? builder.getUI32IntegerAttr(0)

mlir/unittests/Interfaces/DataLayoutInterfacesTest.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ constexpr static llvm::StringLiteral kAttrName = "dltest.layout";
2525
constexpr static llvm::StringLiteral kEndiannesKeyName = "dltest.endianness";
2626
constexpr static llvm::StringLiteral kAllocaKeyName =
2727
"dltest.alloca_memory_space";
28-
constexpr static llvm::StringLiteral kManglingStyleKeyName = "dltest.mangling";
28+
constexpr static llvm::StringLiteral kManglingModeKeyName = "dltest.mangling";
2929
constexpr static llvm::StringLiteral kProgramKeyName =
3030
"dltest.program_memory_space";
3131
constexpr static llvm::StringLiteral kGlobalKeyName =
@@ -84,8 +84,8 @@ struct CustomDataLayoutSpec
8484
StringAttr getAllocaMemorySpaceIdentifier(MLIRContext *context) const {
8585
return Builder(context).getStringAttr(kAllocaKeyName);
8686
}
87-
StringAttr getManglingStyleIdentifier(MLIRContext *context) const {
88-
return Builder(context).getStringAttr(kManglingStyleKeyName);
87+
StringAttr getManglingModeIdentifier(MLIRContext *context) const {
88+
return Builder(context).getStringAttr(kManglingModeKeyName);
8989
}
9090
StringAttr getProgramMemorySpaceIdentifier(MLIRContext *context) const {
9191
return Builder(context).getStringAttr(kProgramKeyName);
@@ -478,6 +478,7 @@ module {}
478478
EXPECT_EQ(layout.getProgramMemorySpace(), Attribute());
479479
EXPECT_EQ(layout.getGlobalMemorySpace(), Attribute());
480480
EXPECT_EQ(layout.getStackAlignment(), 0u);
481+
EXPECT_EQ(layout.getManglingMode(), Attribute());
481482
}
482483

483484
TEST(DataLayout, NullSpec) {

0 commit comments

Comments
 (0)