kzhuravl created this revision. kzhuravl added a reviewer: arsenm. kzhuravl added subscribers: cfe-commits, bpurnomo. Herald added a reviewer: tstellarAMD.
-mamdgpu-debugger-abi=<version>: sets all needed debugger related target features for given debugger abi <version> -mamdgpu-debugger-insert-nops: sets +amdgpu-debugger-insert-nops target feature -mamdgpu-debugger-reserve-trap-regs: sets +amdgpu-debugger-reserve-trap-regs target feature http://reviews.llvm.org/D18748 Files: include/clang/Driver/Options.td lib/Driver/Tools.cpp test/Driver/amdgpu-features.c Index: test/Driver/amdgpu-features.c =================================================================== --- test/Driver/amdgpu-features.c +++ test/Driver/amdgpu-features.c @@ -0,0 +1,21 @@ +// Check handling of AMDGPU target features. +// +// -mamdgpu-debugger-abi=0.0 +// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri -mamdgpu-debugger-abi=0.0 %s -o 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-ABI-0-0 %s +// CHECK-MAMDGPU-DEBUGGER-ABI-0-0: the clang compiler does not support '-mamdgpu-debugger-abi=0.0' +// +// -mamdgpu-debugger-abi=1.0 +// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri -mamdgpu-debugger-abi=1.0 %s -o 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-ABI-1-0 %s +// CHECK-MAMDGPU-DEBUGGER-ABI-1-0: "-target-feature" "+amdgpu-debugger-insert-nops" "-target-feature" "+amdgpu-debugger-reserve-trap-regs" +// +// -mamdgpu-debugger-insert-nops +// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri -mamdgpu-debugger-insert-nops %s -o 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-INSERT-NOPS %s +// CHECK-MAMDGPU-DEBUGGER-INSERT-NOPS: "-target-feature" "+amdgpu-debugger-insert-nops" +// +// -mamdgpu-debugger-reserve-trap-regs +// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri -mamdgpu-debugger-reserve-trap-regs %s -o 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-RESERVE-TRAP-REGS %s +// CHECK-MAMDGPU-DEBUGGER-RESERVE-TRAP-REGS: "-target-feature" "+amdgpu-debugger-reserve-trap-regs" Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -2391,6 +2391,22 @@ handleTargetFeaturesGroup(Args, Features, options::OPT_m_wasm_Features_Group); } +static void getAMDGPUTargetFeatures(const Driver &D, const ArgList &Args, + std::vector<const char *> &Features) { + if (const Arg *dAbi = Args.getLastArg(options::OPT_mamdgpu_debugger_abi)) { + StringRef value = dAbi->getValue(); + if (value == "1.0") { + Features.push_back("+amdgpu-debugger-insert-nops"); + Features.push_back("+amdgpu-debugger-reserve-trap-regs"); + } else { + D.Diag(diag::err_drv_clang_unsupported) << dAbi->getAsString(Args); + } + } + + handleTargetFeaturesGroup( + Args, Features, options::OPT_m_amdgpu_Features_Group); +} + static void getTargetFeatures(const ToolChain &TC, const llvm::Triple &Triple, const ArgList &Args, ArgStringList &CmdArgs, bool ForAS) { @@ -2436,6 +2452,10 @@ case llvm::Triple::wasm64: getWebAssemblyTargetFeatures(Args, Features); break; + case llvm::Triple::r600: + case llvm::Triple::amdgcn: + getAMDGPUTargetFeatures(D, Args, Features); + break; } // Find the last of each feature. Index: include/clang/Driver/Options.td =================================================================== --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -95,6 +95,8 @@ Group<m_Group>; def m_wasm_Features_Group : OptionGroup<"<wasm features group>">, Group<m_Group>; +def m_amdgpu_Features_Group : OptionGroup<"<amdgpu features group>">, + Group<m_Group>; def m_libc_Group : OptionGroup<"<m libc group>">, Group<m_Group>; def u_Group : OptionGroup<"<u group>">; @@ -1438,6 +1440,16 @@ def msimd128 : Flag<["-"], "msimd128">, Group<m_wasm_Features_Group>; def mno_simd128 : Flag<["-"], "mno-simd128">, Group<m_wasm_Features_Group>; +def mamdgpu_debugger_abi : Joined<["-"], "mamdgpu-debugger-abi=">, + Flags<[HelpHidden]>, + Group<m_Group>, + HelpText<"Generate additional code for specified <version> of debugger ABI (AMDGPU only)">, + MetaVarName<"<version>">; +def mamdgpu_debugger_insert_nops : Flag<["-"], "mamdgpu-debugger-insert-nops">, + Group<m_amdgpu_Features_Group>; +def mamdgpu_debugger_reserve_trap_regs : Flag<["-"], "mamdgpu-debugger-reserve-trap-regs">, + Group<m_amdgpu_Features_Group>; + def mvsx : Flag<["-"], "mvsx">, Group<m_ppc_Features_Group>; def mno_vsx : Flag<["-"], "mno-vsx">, Group<m_ppc_Features_Group>; def mpower8_vector : Flag<["-"], "mpower8-vector">,
Index: test/Driver/amdgpu-features.c =================================================================== --- test/Driver/amdgpu-features.c +++ test/Driver/amdgpu-features.c @@ -0,0 +1,21 @@ +// Check handling of AMDGPU target features. +// +// -mamdgpu-debugger-abi=0.0 +// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri -mamdgpu-debugger-abi=0.0 %s -o 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-ABI-0-0 %s +// CHECK-MAMDGPU-DEBUGGER-ABI-0-0: the clang compiler does not support '-mamdgpu-debugger-abi=0.0' +// +// -mamdgpu-debugger-abi=1.0 +// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri -mamdgpu-debugger-abi=1.0 %s -o 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-ABI-1-0 %s +// CHECK-MAMDGPU-DEBUGGER-ABI-1-0: "-target-feature" "+amdgpu-debugger-insert-nops" "-target-feature" "+amdgpu-debugger-reserve-trap-regs" +// +// -mamdgpu-debugger-insert-nops +// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri -mamdgpu-debugger-insert-nops %s -o 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-INSERT-NOPS %s +// CHECK-MAMDGPU-DEBUGGER-INSERT-NOPS: "-target-feature" "+amdgpu-debugger-insert-nops" +// +// -mamdgpu-debugger-reserve-trap-regs +// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri -mamdgpu-debugger-reserve-trap-regs %s -o 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-RESERVE-TRAP-REGS %s +// CHECK-MAMDGPU-DEBUGGER-RESERVE-TRAP-REGS: "-target-feature" "+amdgpu-debugger-reserve-trap-regs" Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -2391,6 +2391,22 @@ handleTargetFeaturesGroup(Args, Features, options::OPT_m_wasm_Features_Group); } +static void getAMDGPUTargetFeatures(const Driver &D, const ArgList &Args, + std::vector<const char *> &Features) { + if (const Arg *dAbi = Args.getLastArg(options::OPT_mamdgpu_debugger_abi)) { + StringRef value = dAbi->getValue(); + if (value == "1.0") { + Features.push_back("+amdgpu-debugger-insert-nops"); + Features.push_back("+amdgpu-debugger-reserve-trap-regs"); + } else { + D.Diag(diag::err_drv_clang_unsupported) << dAbi->getAsString(Args); + } + } + + handleTargetFeaturesGroup( + Args, Features, options::OPT_m_amdgpu_Features_Group); +} + static void getTargetFeatures(const ToolChain &TC, const llvm::Triple &Triple, const ArgList &Args, ArgStringList &CmdArgs, bool ForAS) { @@ -2436,6 +2452,10 @@ case llvm::Triple::wasm64: getWebAssemblyTargetFeatures(Args, Features); break; + case llvm::Triple::r600: + case llvm::Triple::amdgcn: + getAMDGPUTargetFeatures(D, Args, Features); + break; } // Find the last of each feature. Index: include/clang/Driver/Options.td =================================================================== --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -95,6 +95,8 @@ Group<m_Group>; def m_wasm_Features_Group : OptionGroup<"<wasm features group>">, Group<m_Group>; +def m_amdgpu_Features_Group : OptionGroup<"<amdgpu features group>">, + Group<m_Group>; def m_libc_Group : OptionGroup<"<m libc group>">, Group<m_Group>; def u_Group : OptionGroup<"<u group>">; @@ -1438,6 +1440,16 @@ def msimd128 : Flag<["-"], "msimd128">, Group<m_wasm_Features_Group>; def mno_simd128 : Flag<["-"], "mno-simd128">, Group<m_wasm_Features_Group>; +def mamdgpu_debugger_abi : Joined<["-"], "mamdgpu-debugger-abi=">, + Flags<[HelpHidden]>, + Group<m_Group>, + HelpText<"Generate additional code for specified <version> of debugger ABI (AMDGPU only)">, + MetaVarName<"<version>">; +def mamdgpu_debugger_insert_nops : Flag<["-"], "mamdgpu-debugger-insert-nops">, + Group<m_amdgpu_Features_Group>; +def mamdgpu_debugger_reserve_trap_regs : Flag<["-"], "mamdgpu-debugger-reserve-trap-regs">, + Group<m_amdgpu_Features_Group>; + def mvsx : Flag<["-"], "mvsx">, Group<m_ppc_Features_Group>; def mno_vsx : Flag<["-"], "mno-vsx">, Group<m_ppc_Features_Group>; def mpower8_vector : Flag<["-"], "mpower8-vector">,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits