jhuber6 created this revision. jhuber6 added reviewers: JonChesterfield, jdoerfert, tianshilei1992. Herald added subscribers: guansong, yaxunl. jhuber6 requested review of this revision. Herald added subscribers: cfe-commits, sstefan1. Herald added a project: clang.
This patch builds on the change in D117634 <https://reviews.llvm.org/D117634> that expanded the short triples when passed in by the user. This patch adds the same functionality for the `-Xopenmp-target=` flag. Previously it was unintuitive that passing `-fopenmp-targets=nvptx64 -Xopenmp-target=nvptx64 <arg>` would not forward the arg because the triples did not match on account of `nvptx64` being expanded to `nvptx64-nvidia-cuda`. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D118495 Files: clang/lib/Driver/ToolChain.cpp Index: clang/lib/Driver/ToolChain.cpp =================================================================== --- clang/lib/Driver/ToolChain.cpp +++ clang/lib/Driver/ToolChain.cpp @@ -1129,8 +1129,20 @@ A->getOption().matches(options::OPT_Xopenmp_target); if (A->getOption().matches(options::OPT_Xopenmp_target_EQ)) { + llvm::Triple TT(A->getValue(0)); + // We want to expand the shortened versions of the triples passed in to + // the values used for the bitcode libraries for convenience. + if (TT.getVendor() == llvm::Triple::UnknownVendor || + TT.getOS() == llvm::Triple::UnknownOS) { + if (TT.getArch() == llvm::Triple::nvptx) + TT = llvm::Triple("nvptx-nvidia-cuda"); + else if (TT.getArch() == llvm::Triple::nvptx64) + TT = llvm::Triple("nvptx64-nvidia-cuda"); + else if (TT.getArch() == llvm::Triple::amdgcn) + TT = llvm::Triple("amdgcn-amd-amdhsa"); + } // Passing device args: -Xopenmp-target=<triple> -opt=val. - if (A->getValue(0) == getTripleString()) + if (TT.getTriple() == getTripleString()) Index = Args.getBaseArgs().MakeIndex(A->getValue(1)); else continue;
Index: clang/lib/Driver/ToolChain.cpp =================================================================== --- clang/lib/Driver/ToolChain.cpp +++ clang/lib/Driver/ToolChain.cpp @@ -1129,8 +1129,20 @@ A->getOption().matches(options::OPT_Xopenmp_target); if (A->getOption().matches(options::OPT_Xopenmp_target_EQ)) { + llvm::Triple TT(A->getValue(0)); + // We want to expand the shortened versions of the triples passed in to + // the values used for the bitcode libraries for convenience. + if (TT.getVendor() == llvm::Triple::UnknownVendor || + TT.getOS() == llvm::Triple::UnknownOS) { + if (TT.getArch() == llvm::Triple::nvptx) + TT = llvm::Triple("nvptx-nvidia-cuda"); + else if (TT.getArch() == llvm::Triple::nvptx64) + TT = llvm::Triple("nvptx64-nvidia-cuda"); + else if (TT.getArch() == llvm::Triple::amdgcn) + TT = llvm::Triple("amdgcn-amd-amdhsa"); + } // Passing device args: -Xopenmp-target=<triple> -opt=val. - if (A->getValue(0) == getTripleString()) + if (TT.getTriple() == getTripleString()) Index = Args.getBaseArgs().MakeIndex(A->getValue(1)); else continue;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits