[PATCH] D127668: [NVPTX] Fix pointer type for short 32-bit pointers
Andrew Savonichev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 13 09:46:40 PDT 2022
asavonic created this revision.
asavonic added reviewers: tra, jholewinski.
Herald added subscribers: mattd, gchakrabarti, hiraditya.
Herald added a project: All.
asavonic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Global variables used to be printed as u64/b64 even when -nvptx-short-ptr is set.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D127668
Files:
llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
llvm/test/CodeGen/NVPTX/short-ptr.ll
Index: llvm/test/CodeGen/NVPTX/short-ptr.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/short-ptr.ll
@@ -0,0 +1,18 @@
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_20 | FileCheck %s --check-prefix CHECK-DEFAULT
+; RUN: llc < %s -march=nvptx -mcpu=sm_20 | FileCheck %s --check-prefix CHECK-DEFAULT-32
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_20 -nvptx-short-ptr | FileCheck %s --check-prefixes CHECK-SHORT-SHARED,CHECK-SHORT-CONST,CHECK-SHORT-LOCAL
+
+; CHECK-DEFAULT: .visible .shared .align 8 .u64 s
+; CHECK-DEFAULT-32: .visible .shared .align 8 .u32 s
+; CHECK-SHORT-SHARED: .visible .shared .align 8 .u32 s
+ at s = local_unnamed_addr addrspace(3) global i32 addrspace(3)* null, align 8
+
+; CHECK-DEFAULT: .visible .const .align 8 .u64 c
+; CHECK-DEFAULT-32: .visible .const .align 8 .u32 c
+; CHECK-SHORT-CONST: .visible .const .align 8 .u32 c
+ at c = local_unnamed_addr addrspace(4) global i32 addrspace(4)* null, align 8
+
+; CHECK-DEFAULT: .visible .local .align 8 .u64 l
+; CHECK-DEFAULT-32: .visible .local .align 8 .u32 l
+; CHECK-SHORT-LOCAL: .visible .local .align 8 .u32 l
+ at l = local_unnamed_addr addrspace(5) global i32 addrspace(5)* null, align 8
Index: llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
===================================================================
--- llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
+++ llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
@@ -1277,8 +1277,11 @@
return "f32";
case Type::DoubleTyID:
return "f64";
- case Type::PointerTyID:
- if (static_cast<const NVPTXTargetMachine &>(TM).is64Bit())
+ case Type::PointerTyID: {
+ unsigned PtrSize = TM.getPointerSizeInBits(Ty->getPointerAddressSpace());
+ assert((PtrSize == 64 || PtrSize == 32) && "Unexpected pointer size");
+
+ if (PtrSize == 64)
if (useB4PTR)
return "b64";
else
@@ -1287,6 +1290,7 @@
return "b32";
else
return "u32";
+ }
default:
break;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127668.436448.patch
Type: text/x-patch
Size: 1982 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220613/b89b1a63/attachment.bin>
More information about the llvm-commits
mailing list