Skip to content

Commit aeea2ce

Browse files
committed
Introduction constexpr literal for section name
1 parent 08adf38 commit aeea2ce

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

mlir/include/mlir/Dialect/GPU/IR/CompilationInterfaces.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class ModuleTranslation;
2727
}
2828
namespace gpu {
2929
enum class CompilationTarget : uint32_t;
30+
constexpr StringLiteral elfSectionName = "section";
3031

3132
/// This class indicates that the attribute associated with this trait is a GPU
3233
/// offloading translation attribute. These kinds of attributes must implement

mlir/lib/Target/LLVM/NVVM/Target.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include "mlir/Target/LLVM/NVVM/Target.h"
1515

16+
#include "mlir/Dialect/GPU/IR/CompilationInterfaces.h"
1617
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
1718
#include "mlir/Dialect/LLVMIR/NVVMDialect.h"
1819
#include "mlir/Target/LLVM/NVVM/Utils.h"
@@ -669,9 +670,9 @@ NVVMTargetAttrImpl::createObject(Attribute attribute, Operation *module,
669670
properties.push_back(
670671
builder.getNamedAttr("O", builder.getI32IntegerAttr(target.getO())));
671672

672-
if (auto section = options.getELFSection(); !section.empty())
673-
properties.push_back(
674-
builder.getNamedAttr("section", builder.getStringAttr(section)));
673+
if (StringRef section = options.getELFSection(); !section.empty())
674+
properties.push_back(builder.getNamedAttr(gpu::elfSectionName,
675+
builder.getStringAttr(section)));
675676

676677
if (!properties.empty())
677678
objectProps = builder.getDictionaryAttr(properties);

mlir/lib/Target/LLVMIR/Dialect/GPU/SelectObjectAttr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//
1212
//===----------------------------------------------------------------------===//
1313

14+
#include "mlir/Dialect/GPU/IR/CompilationInterfaces.h"
1415
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
1516

1617
#include "mlir/Target/LLVMIR/Dialect/GPU/GPUToLLVMIRTranslation.h"
@@ -124,7 +125,7 @@ LogicalResult SelectObjectAttrImpl::embedBinary(
124125

125126
if (object.getProperties()) {
126127
if (auto section = mlir::dyn_cast_or_null<mlir::StringAttr>(
127-
object.getProperties().get("section"))) {
128+
object.getProperties().get(gpu::elfSectionName))) {
128129
serializedObj->setSection(section.getValue());
129130
}
130131
}

0 commit comments

Comments
 (0)