| 1 | //===--- AMDGPU.cpp - AMDGPU Helpers for Tools ----------------------------===// |
|---|---|
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "AMDGPU.h" |
| 10 | #include "clang/Driver/Driver.h" |
| 11 | #include "clang/Options/Options.h" |
| 12 | |
| 13 | using namespace clang::driver; |
| 14 | using namespace clang::driver::tools; |
| 15 | using namespace clang; |
| 16 | using namespace llvm::opt; |
| 17 | |
| 18 | void AMDGPU::setArchNameInTriple(const Driver &D, const ArgList &Args, |
| 19 | types::ID InputType, llvm::Triple &Triple) { |
| 20 | StringRef MArch; |
| 21 | AMDGPU::getAMDGPUArchCPUFromArgs(Triple, Args, Arch&: MArch); |
| 22 | |
| 23 | if (MArch == "amdgcnspirv") { |
| 24 | Triple.setArch(Kind: llvm::Triple::ArchType::spirv64); |
| 25 | return; |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | void AMDGPU::getAMDGPUArchCPUFromArgs(const llvm::Triple &Triple, |
| 30 | const llvm::opt::ArgList &Args, |
| 31 | llvm::StringRef &Arch) { |
| 32 | if (const Arg *MCPU = Args.getLastArg(Ids: options::OPT_mcpu_EQ)) |
| 33 | Arch = MCPU->getValue(); |
| 34 | } |
| 35 |