Index: include/clang/Driver/Options.td =================================================================== --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1496,6 +1496,14 @@ def mzvector : Flag<["-"], "mzvector">, Alias; def mno_zvector : Flag<["-"], "mno-zvector">, Alias; +def mamdgpu_tools_insert_nops : Flag<["-"], "mamdgpu-tools-insert-nops">, + Flags<[HelpHidden]>, + Group, + HelpText<"Insert two nop instructions for each high level source statement (AMDGPU only)">; +def mamdgpu_tools_reserve_trap_vgprs : Flag<["-"], "mamdgpu-tools-reserve-trap-vgprs">, + Flags<[HelpHidden]>, + Group, + HelpText<"Reserve vector registers for trap handler (AMDGPU only)">; def mno_warn_nonportable_cfstrings : Flag<["-"], "mno-warn-nonportable-cfstrings">, Group; def mno_omit_leaf_frame_pointer : Flag<["-"], "mno-omit-leaf-frame-pointer">, Group; def momit_leaf_frame_pointer : Flag<["-"], "momit-leaf-frame-pointer">, Group, Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -2355,6 +2355,16 @@ handleTargetFeaturesGroup(Args, Features, options::OPT_m_wasm_Features_Group); } +static void getAMDGPUTargetFeatures(const ArgList &Args, + std::vector &Features) { + if (Args.hasArg(options::OPT_mamdgpu_tools_insert_nops)) { + Features.push_back("+amdgpu-tools-insert-nops"); + } + if (Args.hasArg(options::OPT_mamdgpu_tools_reserve_trap_vgprs)) { + Features.push_back("+amdgpu-tools-reserve-trap-vgprs"); + } +} + static void getTargetFeatures(const ToolChain &TC, const llvm::Triple &Triple, const ArgList &Args, ArgStringList &CmdArgs, bool ForAS) { @@ -2400,6 +2410,10 @@ case llvm::Triple::wasm64: getWebAssemblyTargetFeatures(Args, Features); break; + case llvm::Triple::r600: + case llvm::Triple::amdgcn: + getAMDGPUTargetFeatures(Args, Features); + break; } // Find the last of each feature. Index: test/Driver/amdgpu-features.c =================================================================== --- /dev/null +++ test/Driver/amdgpu-features.c @@ -0,0 +1,11 @@ +// Check handling of AMDGPU specific features. +// +// -mamdgpu-tools-insert-nops +// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri -mamdgpu-tools-insert-nops %s -o 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MAMDGPU-TOOLS-INSERT-NOPS %s +// CHECK-MAMDGPU-TOOLS-INSERT-NOPS: "-target-feature" "+amdgpu-tools-insert-nops" +// +// -mamdgpu-tools-reserve-trap-vgprs +// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri -mamdgpu-tools-reserve-trap-vgprs %s -o 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MAMDGPU-TOOLS-RESERVE-TRAP-VGPRS %s +// CHECK-MAMDGPU-TOOLS-RESERVE-TRAP-VGPRS: "-target-feature" "+amdgpu-tools-reserve-trap-vgprs"