r266133 - [AMDGPU] Add debugger related target options

Konstantin Zhuravlyov via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 12 14:42:15 PDT 2016


Author: kzhuravl
Date: Tue Apr 12 16:42:15 2016
New Revision: 266133

URL: http://llvm.org/viewvc/llvm-project?rev=266133&view=rev
Log:
[AMDGPU] Add debugger related target options

Differential Revision: http://reviews.llvm.org/D18748

Added:
    cfe/trunk/test/Driver/amdgpu-features.c
Modified:
    cfe/trunk/include/clang/Driver/Options.td
    cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=266133&r1=266132&r2=266133&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Apr 12 16:42:15 2016
@@ -95,6 +95,8 @@ def m_ppc_Features_Group : OptionGroup<"
                            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>">;
@@ -1446,6 +1448,16 @@ def ffixed_x18 : Flag<["-"], "ffixed-x18
 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">,

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=266133&r1=266132&r2=266133&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Apr 12 16:42:15 2016
@@ -2391,6 +2391,22 @@ static void getWebAssemblyTargetFeatures
   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 @@ static void getTargetFeatures(const Tool
   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.

Added: cfe/trunk/test/Driver/amdgpu-features.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/amdgpu-features.c?rev=266133&view=auto
==============================================================================
--- cfe/trunk/test/Driver/amdgpu-features.c (added)
+++ cfe/trunk/test/Driver/amdgpu-features.c Tue Apr 12 16:42:15 2016
@@ -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"




More information about the cfe-commits mailing list