[PATCH] D123702: [NVPTX] Disable parens for identifiers starting with '$'
Andrew Savonichev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 14 11:08:09 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG78d70a1c9769: [NVPTX] Disable parens for identifiers starting with '$' (authored by asavonic).
Herald added a subscriber: gchakrabarti.
Changed prior to commit:
https://reviews.llvm.org/D123702?vs=422597&id=422919#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D123702/new/
https://reviews.llvm.org/D123702
Files:
llvm/include/llvm/MC/MCAsmInfo.h
llvm/lib/MC/MCExpr.cpp
llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.cpp
llvm/test/CodeGen/NVPTX/no-extra-parens.ll
Index: llvm/test/CodeGen/NVPTX/no-extra-parens.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/no-extra-parens.ll
@@ -0,0 +1,14 @@
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_20 | FileCheck %s
+
+; ptxas has no special meaning for '$' character, so it should be used
+; without parens.
+
+@"$str" = private addrspace(1) constant [4 x i8] c"str\00"
+
+declare void @str2(i8* %str)
+define void @str1() {
+entry:
+;; CHECK: mov.u64 %rd{{[0-9]+}}, $str;
+ tail call void @str2(i8* getelementptr ([4 x i8], [4 x i8]* addrspacecast ([4 x i8] addrspace(1)* @"$str" to [4 x i8]*), i64 0, i64 0))
+ ret void
+}
Index: llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.cpp
===================================================================
--- llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.cpp
+++ llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.cpp
@@ -54,4 +54,8 @@
GlobalDirective = "\t// .globl\t";
UseIntegratedAssembler = false;
+
+ // Avoid using parens for identifiers starting with $ - ptxas does
+ // not expect them.
+ UseParensForDollarSignNames = false;
}
Index: llvm/lib/MC/MCExpr.cpp
===================================================================
--- llvm/lib/MC/MCExpr.cpp
+++ llvm/lib/MC/MCExpr.cpp
@@ -75,8 +75,9 @@
const MCSymbol &Sym = SRE.getSymbol();
// Parenthesize names that start with $ so that they don't look like
// absolute names.
- bool UseParens =
- !InParens && !Sym.getName().empty() && Sym.getName()[0] == '$';
+ bool UseParens = MAI && MAI->useParensForDollarSignNames() && !InParens &&
+ !Sym.getName().empty() && Sym.getName()[0] == '$';
+
if (UseParens) {
OS << '(';
Sym.print(OS, MAI);
Index: llvm/include/llvm/MC/MCAsmInfo.h
===================================================================
--- llvm/include/llvm/MC/MCAsmInfo.h
+++ llvm/include/llvm/MC/MCAsmInfo.h
@@ -478,6 +478,10 @@
/// For example, foo(plt) instead of foo at plt. Defaults to false.
bool UseParensForSymbolVariant = false;
+ /// True if the target uses parens for symbol names starting with
+ /// '$' character to distinguish them from absolute names.
+ bool UseParensForDollarSignNames = true;
+
/// True if the target supports flags in ".loc" directive, false if only
/// location is allowed.
bool SupportsExtendedDwarfLocDirective = true;
@@ -789,6 +793,9 @@
bool doDwarfFDESymbolsUseAbsDiff() const { return DwarfFDESymbolsUseAbsDiff; }
bool useDwarfRegNumForCFI() const { return DwarfRegNumForCFI; }
bool useParensForSymbolVariant() const { return UseParensForSymbolVariant; }
+ bool useParensForDollarSignNames() const {
+ return UseParensForDollarSignNames;
+ }
bool supportsExtendedDwarfLocDirective() const {
return SupportsExtendedDwarfLocDirective;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123702.422919.patch
Type: text/x-patch
Size: 2865 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220414/b777a172/attachment.bin>
More information about the llvm-commits
mailing list