[PATCH] D114082: [WIP] Normalize String Attributes
Yilong Guo via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 22 19:59:30 PST 2021
Nuullll added a comment.
Thanks for this. I planned something similar to turn string literal typo errors into compile errors as well.
The typos are really hard to identify :-P
Some suggestions on using tablegen.
================
Comment at: llvm/include/llvm/IR/Attributes.h:977-1133
+constexpr llvm::AttributeKey
+ AmdgpuFlatWorkGroupSizeAttr("amdgpu-flat-work-group-size");
+constexpr llvm::AttributeKey AmdgpuIeeeAttr("amdgpu-ieee");
+constexpr llvm::AttributeKey
+ AmdgpuImplicitargNumBytesAttr("amdgpu-implicitarg-num-bytes");
+constexpr llvm::AttributeKey AmdgpuNumSgprAttr("amdgpu-num-sgpr");
+constexpr llvm::AttributeKey AmdgpuNumVgprAttr("amdgpu-num-vgpr");
----------------
I think we can simplify these definitions via "Attributes.inc", by adding one more class tablegen class and defining the symbolic -> display name mapping in "Attributes.td".
```
// llvm/utils/TableGen/Attributes.cpp emitTargetsIndependentNames()
Emit({"EnumAttr", "TypeAttr", "IntAttr"}, "ATTRIBUTE_ENUM");
Emit({"StrBoolAttr"}, "ATTRIBUTE_STRBOOL");
Emit({"StrKeyAttr"}, "ATTRIBUTE_KEY");
```
================
Comment at: llvm/include/llvm/IR/Attributes.td:43
class StrBoolAttr<string S> : Attr<S, []>;
/// Target-independent enum attributes.
----------------
Define a dedicated tablegen class for AttributeKey generation.
================
Comment at: llvm/include/llvm/IR/Attributes.td:303
def UseSampleProfile : StrBoolAttr<"use-sample-profile">;
class CompatRule<string F> {
----------------
Map symbolic names with string literals.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114082/new/
https://reviews.llvm.org/D114082
More information about the cfe-commits
mailing list