[llvm] c12a9fc - [ELF] Correctly set the `nvptx` triple from `makeTriple()` (#76970)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 4 09:14:50 PST 2024


Author: Joseph Huber
Date: 2024-01-04T11:14:46-06:00
New Revision: c12a9fc2798cc74a6ea6a8c71826047f47c815ea

URL: https://github.com/llvm/llvm-project/commit/c12a9fc2798cc74a6ea6a8c71826047f47c815ea
DIFF: https://github.com/llvm/llvm-project/commit/c12a9fc2798cc74a6ea6a8c71826047f47c815ea.diff

LOG: [ELF] Correctly set the `nvptx` triple from `makeTriple()` (#76970)

Summary:
The ELFObject file should be able to handle `nvptx` objects but we
currently list them as unknown. This patch should now make it return
`nvptx64--` correctly.

Added: 
    

Modified: 
    llvm/include/llvm/Object/ELFObjectFile.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Object/ELFObjectFile.h b/llvm/include/llvm/Object/ELFObjectFile.h
index 99477644de4de7..da78e11b678d99 100644
--- a/llvm/include/llvm/Object/ELFObjectFile.h
+++ b/llvm/include/llvm/Object/ELFObjectFile.h
@@ -1349,6 +1349,13 @@ template <class ELFT> Triple::ArchType ELFObjectFile<ELFT>::getArch() const {
     return Triple::UnknownArch;
   }
 
+  case ELF::EM_CUDA: {
+    if (EF.getHeader().e_ident[ELF::EI_CLASS] == ELF::ELFCLASS32)
+      return Triple::nvptx;
+    else
+      return Triple::nvptx64;
+  }
+
   case ELF::EM_BPF:
     return IsLittleEndian ? Triple::bpfel : Triple::bpfeb;
 


        


More information about the llvm-commits mailing list