diff --git a/clang/include/clang/Driver/Types.def b/clang/include/clang/Driver/Types.def index d00d520d7514..2960f0ba5e9b 100644 --- a/clang/include/clang/Driver/Types.def +++ b/clang/include/clang/Driver/Types.def @@ -42,9 +42,9 @@ TYPE("clcpp", CLCXX, PP_CXX, "clcpp", phases TYPE("cuda-cpp-output", PP_CUDA, INVALID, "cui", phases::Compile, phases::Backend, phases::Assemble, phases::Link) TYPE("cuda", CUDA, PP_CUDA, "cu", phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link) TYPE("cuda", CUDA_DEVICE, PP_CUDA, "cu", phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link) -TYPE("hip-cpp-output", PP_HIP, INVALID, "cui", phases::Compile, phases::Backend, phases::Assemble, phases::Link) -TYPE("hip", HIP, PP_HIP, "cu", phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link) -TYPE("hip", HIP_DEVICE, PP_HIP, "cu", phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link) +TYPE("hip-cpp-output", PP_HIP, INVALID, "hipi", phases::Compile, phases::Backend, phases::Assemble, phases::Link) +TYPE("hip", HIP, PP_HIP, "hip", phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link) +TYPE("hip", HIP_DEVICE, PP_HIP, "hip", phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link) TYPE("objective-c-cpp-output", PP_ObjC, INVALID, "mi", phases::Compile, phases::Backend, phases::Assemble, phases::Link) TYPE("objc-cpp-output", PP_ObjC_Alias, INVALID, "mi", phases::Compile, phases::Backend, phases::Assemble, phases::Link) TYPE("objective-c", ObjC, PP_ObjC, "m", phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, phases::Link) diff --git a/clang/lib/Driver/OffloadBundler.cpp b/clang/lib/Driver/OffloadBundler.cpp index 7cffe4008b8e..d304ea5e9281 100644 --- a/clang/lib/Driver/OffloadBundler.cpp +++ b/clang/lib/Driver/OffloadBundler.cpp @@ -847,6 +847,8 @@ CreateFileHandler(MemoryBuffer &FirstInput, return std::make_unique(/*Comment=*/"//"); if (FilesType == "cui") return std::make_unique(/*Comment=*/"//"); + if (FilesType == "hipi") + return std::make_unique(/*Comment=*/"//"); // TODO: `.d` should be eventually removed once `-M` and its variants are // handled properly in offload compilation. if (FilesType == "d") diff --git a/clang/lib/Driver/Types.cpp b/clang/lib/Driver/Types.cpp index ffbca82c98c3..a890cc58ee42 100644 --- a/clang/lib/Driver/Types.cpp +++ b/clang/lib/Driver/Types.cpp @@ -294,68 +294,69 @@ bool types::isSrcFile(ID Id) { types::ID types::lookupTypeForExtension(llvm::StringRef Ext) { return llvm::StringSwitch(Ext) - .Case("c", TY_C) - .Case("C", TY_CXX) - .Case("F", TY_Fortran) - .Case("f", TY_PP_Fortran) - .Case("h", TY_CHeader) - .Case("H", TY_CXXHeader) - .Case("i", TY_PP_C) - .Case("m", TY_ObjC) - .Case("M", TY_ObjCXX) - .Case("o", TY_Object) - .Case("S", TY_Asm) - .Case("s", TY_PP_Asm) - .Case("bc", TY_LLVM_BC) - .Case("cc", TY_CXX) - .Case("CC", TY_CXX) - .Case("cl", TY_CL) - .Case("clcpp", TY_CLCXX) - .Case("cp", TY_CXX) - .Case("cu", TY_CUDA) - .Case("hh", TY_CXXHeader) - .Case("ii", TY_PP_CXX) - .Case("ll", TY_LLVM_IR) - .Case("mi", TY_PP_ObjC) - .Case("mm", TY_ObjCXX) - .Case("rs", TY_RenderScript) - .Case("adb", TY_Ada) - .Case("ads", TY_Ada) - .Case("asm", TY_PP_Asm) - .Case("ast", TY_AST) - .Case("ccm", TY_CXXModule) - .Case("cpp", TY_CXX) - .Case("CPP", TY_CXX) - .Case("c++", TY_CXX) - .Case("C++", TY_CXX) - .Case("cui", TY_PP_CUDA) - .Case("cxx", TY_CXX) - .Case("CXX", TY_CXX) - .Case("F90", TY_Fortran) - .Case("f90", TY_PP_Fortran) - .Case("F95", TY_Fortran) - .Case("f95", TY_PP_Fortran) - .Case("for", TY_PP_Fortran) - .Case("FOR", TY_PP_Fortran) - .Case("fpp", TY_Fortran) - .Case("FPP", TY_Fortran) - .Case("gch", TY_PCH) - .Case("hip", TY_HIP) - .Case("hpp", TY_CXXHeader) - .Case("hxx", TY_CXXHeader) - .Case("iim", TY_PP_CXXModule) - .Case("iih", TY_PP_CXXHeaderUnit) - .Case("lib", TY_Object) - .Case("mii", TY_PP_ObjCXX) - .Case("obj", TY_Object) - .Case("ifs", TY_IFS) - .Case("pch", TY_PCH) - .Case("pcm", TY_ModuleFile) - .Case("c++m", TY_CXXModule) - .Case("cppm", TY_CXXModule) - .Case("cxxm", TY_CXXModule) - .Case("hlsl", TY_HLSL) - .Default(TY_INVALID); + .Case("c", TY_C) + .Case("C", TY_CXX) + .Case("F", TY_Fortran) + .Case("f", TY_PP_Fortran) + .Case("h", TY_CHeader) + .Case("H", TY_CXXHeader) + .Case("i", TY_PP_C) + .Case("m", TY_ObjC) + .Case("M", TY_ObjCXX) + .Case("o", TY_Object) + .Case("S", TY_Asm) + .Case("s", TY_PP_Asm) + .Case("bc", TY_LLVM_BC) + .Case("cc", TY_CXX) + .Case("CC", TY_CXX) + .Case("cl", TY_CL) + .Case("clcpp", TY_CLCXX) + .Case("cp", TY_CXX) + .Case("cu", TY_CUDA) + .Case("hh", TY_CXXHeader) + .Case("ii", TY_PP_CXX) + .Case("ll", TY_LLVM_IR) + .Case("mi", TY_PP_ObjC) + .Case("mm", TY_ObjCXX) + .Case("rs", TY_RenderScript) + .Case("adb", TY_Ada) + .Case("ads", TY_Ada) + .Case("asm", TY_PP_Asm) + .Case("ast", TY_AST) + .Case("ccm", TY_CXXModule) + .Case("cpp", TY_CXX) + .Case("CPP", TY_CXX) + .Case("c++", TY_CXX) + .Case("C++", TY_CXX) + .Case("cui", TY_PP_CUDA) + .Case("cxx", TY_CXX) + .Case("CXX", TY_CXX) + .Case("F90", TY_Fortran) + .Case("f90", TY_PP_Fortran) + .Case("F95", TY_Fortran) + .Case("f95", TY_PP_Fortran) + .Case("for", TY_PP_Fortran) + .Case("FOR", TY_PP_Fortran) + .Case("fpp", TY_Fortran) + .Case("FPP", TY_Fortran) + .Case("gch", TY_PCH) + .Case("hip", TY_HIP) + .Case("hipi", TY_PP_HIP) + .Case("hpp", TY_CXXHeader) + .Case("hxx", TY_CXXHeader) + .Case("iim", TY_PP_CXXModule) + .Case("iih", TY_PP_CXXHeaderUnit) + .Case("lib", TY_Object) + .Case("mii", TY_PP_ObjCXX) + .Case("obj", TY_Object) + .Case("ifs", TY_IFS) + .Case("pch", TY_PCH) + .Case("pcm", TY_ModuleFile) + .Case("c++m", TY_CXXModule) + .Case("cppm", TY_CXXModule) + .Case("cxxm", TY_CXXModule) + .Case("hlsl", TY_HLSL) + .Default(TY_INVALID); } types::ID types::lookupTypeForTypeSpecifier(const char *Name) { diff --git a/clang/test/Driver/hip-rdc-device-only.hip b/clang/test/Driver/hip-rdc-device-only.hip index 6c5b9c6de57d..740ea2179475 100644 --- a/clang/test/Driver/hip-rdc-device-only.hip +++ b/clang/test/Driver/hip-rdc-device-only.hip @@ -117,7 +117,7 @@ // SAVETEMP: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" "x86_64-unknown-linux-gnu" // SAVETEMP-SAME: "-E" // SAVETEMP-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx803" -// SAVETEMP-SAME: {{.*}} "-o" [[A_GFX803_CUI:"a.*cui"]] "-x" "hip" {{".*a.cu"}} +// SAVETEMP-SAME: {{.*}} "-o" [[A_GFX803_CUI:"a.*hipi"]] "-x" "hip" {{".*a.cu"}} // SAVETEMP-NEXT: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" "x86_64-unknown-linux-gnu" // SAVETEMP-SAME: "-emit-llvm-bc" // SAVETEMP-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx803" @@ -130,7 +130,7 @@ // SAVETEMP: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" "x86_64-unknown-linux-gnu" // SAVETEMP-SAME: "-E" // SAVETEMP-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx900" -// SAVETEMP-SAME: {{.*}} "-o" [[A_GFX900_CUI:"a.*cui"]] "-x" "hip" {{".*a.cu"}} +// SAVETEMP-SAME: {{.*}} "-o" [[A_GFX900_CUI:"a.*hipi"]] "-x" "hip" {{".*a.cu"}} // SAVETEMP-NEXT: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" "x86_64-unknown-linux-gnu" // SAVETEMP-SAME: "-emit-llvm-bc" // SAVETEMP-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx900" @@ -147,7 +147,7 @@ // SAVETEMP: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" "x86_64-unknown-linux-gnu" // SAVETEMP-SAME: "-E" // SAVETEMP-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx803" -// SAVETEMP-SAME: {{.*}} "-o" [[B_GFX803_CUI:"b.*cui"]] "-x" "hip" {{".*b.hip"}} +// SAVETEMP-SAME: {{.*}} "-o" [[B_GFX803_CUI:"b.*hipi"]] "-x" "hip" {{".*b.hip"}} // SAVETEMP-NEXT: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" "x86_64-unknown-linux-gnu" // SAVETEMP-SAME: "-emit-llvm-bc" // SAVETEMP-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx803" @@ -160,7 +160,7 @@ // SAVETEMP: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" "x86_64-unknown-linux-gnu" // SAVETEMP-SAME: "-E" // SAVETEMP-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx900" -// SAVETEMP-SAME: {{.*}} "-o" [[B_GFX900_CUI:"b.*cui"]] "-x" "hip" {{".*b.hip"}} +// SAVETEMP-SAME: {{.*}} "-o" [[B_GFX900_CUI:"b.*hipi"]] "-x" "hip" {{".*b.hip"}} // SAVETEMP-NEXT: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa" "-aux-triple" "x86_64-unknown-linux-gnu" // SAVETEMP-SAME: "-emit-llvm-bc" // SAVETEMP-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx900" diff --git a/clang/test/Driver/hip-save-temps.hip b/clang/test/Driver/hip-save-temps.hip index 30486a614b07..d92072cf6fa5 100644 --- a/clang/test/Driver/hip-save-temps.hip +++ b/clang/test/Driver/hip-save-temps.hip @@ -32,13 +32,13 @@ // UN: FileCheck -check-prefixes=CHECK,RDC,RDCL,WOUT %s // -fgpu-rdc host object path -// RDCL: "{{.*clang.*}}" "-cc1" {{.*}} "-E" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.cui" +// RDCL: "{{.*clang.*}}" "-cc1" {{.*}} "-E" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.hipi" // RDCL: "{{.*clang.*}}" "-cc1" {{.*}} "-emit-llvm-bc" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.bc" // RDCL: "{{.*clang.*}}" "-cc1" {{.*}} "-S" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.s" // RDCL: "{{.*clang.*}}" "-cc1as" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.o" // device object paths -// CHECK: {{".*clang.*"}} "-cc1" {{.*}} "-E" {{.*}} [[CPU:"-target-cpu" "gfx900"]] {{.*}} "-o" "hip-save-temps-hip-amdgcn-amd-amdhsa-gfx900.cui" +// CHECK: {{".*clang.*"}} "-cc1" {{.*}} "-E" {{.*}} [[CPU:"-target-cpu" "gfx900"]] {{.*}} "-o" "hip-save-temps-hip-amdgcn-amd-amdhsa-gfx900.hipi" // NORDC: {{".*clang.*"}} "-cc1" {{.*}} "-emit-llvm-bc" {{.*}} [[CPU]] {{.*}} "-disable-llvm-passes" {{.*}} "-o" "hip-save-temps-hip-amdgcn-amd-amdhsa-gfx900.bc" // RDC: {{".*clang.*"}} "-cc1" {{.*}} "-emit-llvm-bc" {{.*}} [[CPU]] {{.*}} "-disable-llvm-passes" {{.*}} "-o" "hip-save-temps-hip-amdgcn-amd-amdhsa-gfx900.tmp.bc" @@ -55,7 +55,7 @@ // NORDC: {{.*lld.*}}"-o" "hip-save-temps-hip-amdgcn-amd-amdhsa-gfx900.out" // RDCL: "{{.*lld.*}}" {{.*}} "-plugin-opt=-amdgpu-internalize-symbols" {{.*}}"-save-temps" // RDCL-SAME: "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx900" -// RDCC: "{{.*clang.*}}" "-cc1" {{.*}} "-E" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.cui" +// RDCC: "{{.*clang.*}}" "-cc1" {{.*}} "-E" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.hipi" // RDCC: "{{.*clang.*}}" "-cc1" {{.*}} "-emit-llvm-bc" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.bc" // RDCC: "{{.*clang.*}}" "-cc1" {{.*}} "-S" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.s" // RDCC: "{{.*clang.*}}" "-cc1as" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.o" @@ -64,7 +64,7 @@ // RDCL: {{.*}}llvm-mc{{.*}}"-o" "hip-save-temps-hip-amdgcn-amd-amdhsa.o" "hip-save-temps-hip-amdgcn-amd-amdhsa.mcin" "--filetype=obj" // -fno-gpu-rdc host object path -// NORDC: "{{.*clang.*}}" "-cc1" {{.*}} "-E" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.cui" +// NORDC: "{{.*clang.*}}" "-cc1" {{.*}} "-E" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.hipi" // NORDC: "{{.*clang.*}}" "-cc1" {{.*}} "-emit-llvm-bc" {{.*}} "-fcuda-include-gpubinary" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.bc" // NORDC: "{{.*clang.*}}" "-cc1" {{.*}} "-S" {{.*}} "-o" "hip-save-temps-host-x86_64-unknown-linux-gnu.s" // NORDC: "{{.*clang.*}}" "-cc1as" {{.*}} "-o" "hip-save-temps{{.*}}.o" diff --git a/clang/test/Driver/hip-unbundle-preproc.hip b/clang/test/Driver/hip-unbundle-preproc.hipi similarity index 81% rename from clang/test/Driver/hip-unbundle-preproc.hip rename to clang/test/Driver/hip-unbundle-preproc.hipi index 2c470fa1d2c9..fecdfdbe7d14 100644 --- a/clang/test/Driver/hip-unbundle-preproc.hip +++ b/clang/test/Driver/hip-unbundle-preproc.hipi @@ -4,7 +4,11 @@ // RUN: --offload-arch=gfx803 -nogpulib \ // RUN: -x hip-cpp-output %s 2>&1 | FileCheck %s -// CHECK: {{".*clang-offload-bundler.*"}} {{.*}}"-output=[[HOST_PP:.*cui]]" "-output=[[DEV_PP:.*cui]]" "-unbundle" +// RUN: %clang -### --target=x86_64-unknown-linux-gnu \ +// RUN: --offload-arch=gfx803 -nogpulib \ +// RUN: %s 2>&1 | FileCheck %s + +// CHECK: {{".*clang-offload-bundler.*"}} {{.*}}"-output=[[HOST_PP:.*hipi]]" "-output=[[DEV_PP:.*hipi]]" "-unbundle" // CHECK: {{".*clang.*"}} "-cc1" {{.*}}"-target-cpu" "gfx803" {{.*}}"-o" "[[DEV_O:.*o]]" {{.*}}"[[DEV_PP]]" // CHECK: {{".*lld.*"}} {{.*}}"-o" "[[DEV_ISA:.*]]" "[[DEV_O]]" // CHECK: {{".*clang-offload-bundler.*"}} {{.*}}"-input={{.*}}" "-input=[[DEV_ISA]]" "-output=[[FATBIN:.*]]" @@ -13,11 +17,11 @@ // RUN: %clang -### --target=x86_64-unknown-linux-gnu \ // RUN: --offload-arch=gfx803 -nogpulib -fgpu-rdc \ -// RUN: -x hip-cpp-output %s 2>&1 | FileCheck -check-prefix=RDC %s +// RUN: %s 2>&1 | FileCheck -check-prefix=RDC %s -// RDC: {{".*clang-offload-bundler.*"}} {{.*}}"-output=[[HOST_PP:.*cui]]" "-output=[[DEV_PP:.*cui]]" "-unbundle" +// RDC: {{".*clang-offload-bundler.*"}} {{.*}}"-output=[[HOST_PP:.*hipi]]" "-output=[[DEV_PP:.*hipi]]" "-unbundle" // RDC: {{".*clang.*"}} {{.*}}"-triple" "x86_64-unknown-linux-gnu"{{.*}} "-o" "[[HOST_O:.*o]]" {{.*}}"[[HOST_PP]]" -// RDC: {{".*clang-offload-bundler.*"}} {{.*}}"-output=[[HOST_PP:.*cui]]" "-output=[[DEV_PP:.*cui]]" "-unbundle" +// RDC: {{".*clang-offload-bundler.*"}} {{.*}}"-output=[[HOST_PP:.*hipi]]" "-output=[[DEV_PP:.*hipi]]" "-unbundle" // RDC: {{".*clang.*"}} "-cc1" {{.*}}"-target-cpu" "gfx803" {{.*}}"-o" "[[DEV_BC:.*bc]]" {{.*}}"[[DEV_PP]]" // RDC: {{".*lld.*"}} {{.*}}"-o" "[[DEV_ISA:.*]]" "[[DEV_BC]]" // RDC: {{".*clang-offload-bundler.*"}} {{.*}}"-input={{.*}}" "-input=[[DEV_ISA]]" "-output=[[FATBIN:.*]]" diff --git a/clang/test/Driver/lit.local.cfg b/clang/test/Driver/lit.local.cfg index 3eefff7bfedc..d29c7987e38c 100644 --- a/clang/test/Driver/lit.local.cfg +++ b/clang/test/Driver/lit.local.cfg @@ -1,7 +1,7 @@ from lit.llvm import llvm_config config.suffixes = ['.c', '.cpp', '.h', '.m', '.mm', '.S', '.s', '.f90', '.F90', '.f95', - '.cu', '.rs', '.cl', '.clcpp', '.hip', '.hlsl'] + '.cu', '.rs', '.cl', '.clcpp', '.hip', '.hipi', '.hlsl'] config.substitutions = list(config.substitutions) config.substitutions.insert(0, ('%clang_cc1', diff --git a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp index 4c615b7d310d..04ad545f19c8 100644 --- a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp +++ b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp @@ -93,22 +93,23 @@ int main(int argc, const char **argv) { TargetNames("targets", cl::CommaSeparated, cl::desc("[-,...]"), cl::cat(ClangOffloadBundlerCategory)); - cl::opt - FilesType("type", cl::Required, - cl::desc("Type of the files to be bundled/unbundled.\n" - "Current supported types are:\n" - " i - cpp-output\n" - " ii - c++-cpp-output\n" - " cui - cuda/hip-output\n" - " d - dependency\n" - " ll - llvm\n" - " bc - llvm-bc\n" - " s - assembler\n" - " o - object\n" - " a - archive of objects\n" - " gch - precompiled-header\n" - " ast - clang AST file"), - cl::cat(ClangOffloadBundlerCategory)); + cl::opt FilesType( + "type", cl::Required, + cl::desc("Type of the files to be bundled/unbundled.\n" + "Current supported types are:\n" + " i - cpp-output\n" + " ii - c++-cpp-output\n" + " cui - cuda-cpp-output\n" + " hipi - hip-cpp-output\n" + " d - dependency\n" + " ll - llvm\n" + " bc - llvm-bc\n" + " s - assembler\n" + " o - object\n" + " a - archive of objects\n" + " gch - precompiled-header\n" + " ast - clang AST file"), + cl::cat(ClangOffloadBundlerCategory)); cl::opt Unbundle("unbundle", cl::desc("Unbundle bundled file into several output files.\n"),