Index: cfe/trunk/include/clang/Driver/Options.td =================================================================== --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -95,6 +95,8 @@ Group; def m_wasm_Features_Group : OptionGroup<"">, Group; +def m_amdgpu_Features_Group : OptionGroup<"">, + Group; def m_libc_Group : OptionGroup<"">, Group; def u_Group : OptionGroup<"">; @@ -1446,6 +1448,16 @@ def msimd128 : Flag<["-"], "msimd128">, Group; def mno_simd128 : Flag<["-"], "mno-simd128">, Group; +def mamdgpu_debugger_abi : Joined<["-"], "mamdgpu-debugger-abi=">, + Flags<[HelpHidden]>, + Group, + HelpText<"Generate additional code for specified of debugger ABI (AMDGPU only)">, + MetaVarName<"">; +def mamdgpu_debugger_insert_nops : Flag<["-"], "mamdgpu-debugger-insert-nops">, + Group; +def mamdgpu_debugger_reserve_trap_regs : Flag<["-"], "mamdgpu-debugger-reserve-trap-regs">, + Group; + def mvsx : Flag<["-"], "mvsx">, Group; def mno_vsx : Flag<["-"], "mno-vsx">, Group; def mpower8_vector : Flag<["-"], "mpower8-vector">, Index: cfe/trunk/lib/Driver/Tools.cpp =================================================================== --- cfe/trunk/lib/Driver/Tools.cpp +++ cfe/trunk/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 &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: cfe/trunk/test/Driver/amdgpu-features.c =================================================================== --- cfe/trunk/test/Driver/amdgpu-features.c +++ cfe/trunk/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"