| 1 | //===-- TargetInfo/AMDGPUTargetInfo.cpp - TargetInfo for AMDGPU -----------===// |
| 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 | /// \file |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #include "TargetInfo/AMDGPUTargetInfo.h" |
| 14 | #include "llvm/MC/TargetRegistry.h" |
| 15 | #include "llvm/Support/Compiler.h" |
| 16 | |
| 17 | using namespace llvm; |
| 18 | |
| 19 | /// The target for R600 GPUs. |
| 20 | Target &llvm::getTheR600Target() { |
| 21 | static Target TheAMDGPUTarget; |
| 22 | return TheAMDGPUTarget; |
| 23 | } |
| 24 | |
| 25 | /// The target for GCN GPUs. |
| 26 | Target &llvm::getTheGCNTarget() { |
| 27 | static Target TheGCNTarget; |
| 28 | return TheGCNTarget; |
| 29 | } |
| 30 | |
| 31 | /// The target for GCN GPUs, registered under the legacy "amdgcn" name. This |
| 32 | /// should be removed when all tool users of "amdgcn" are migrated. |
| 33 | Target &llvm::getTheGCNLegacyTarget() { |
| 34 | static Target TheGCNLegacyTarget; |
| 35 | return TheGCNLegacyTarget; |
| 36 | } |
| 37 | |
| 38 | /// Extern function to initialize the targets for the AMDGPU backend |
| 39 | extern "C" LLVM_ABI LLVM_EXTERNAL_VISIBILITY void |
| 40 | LLVMInitializeAMDGPUTargetInfo() { |
| 41 | RegisterTarget<Triple::r600, false> R600(getTheR600Target(), "r600" , |
| 42 | "AMD GPUs HD2XXX-HD6XXX" , "AMDGPU" ); |
| 43 | Target &GCNTgt = getTheGCNTarget(); |
| 44 | RegisterTarget<Triple::amdgpu, false> GCN(GCNTgt, "amdgpu" , "AMDGPU gfx6+" , |
| 45 | "AMDGPU" ); |
| 46 | |
| 47 | // Register the legacy "amdgcn" name for use with -march. It must not take |
| 48 | // possession of the Triple::amdgpu tag, so it uses a match function that |
| 49 | // never matches a triple. This hack is copied from AArch64's handling of |
| 50 | // "arm64". |
| 51 | TargetRegistry::RegisterTarget(T&: getTheGCNLegacyTarget(), Name: "amdgcn" , |
| 52 | ShortDesc: "legacy name for amdgpu" , BackendName: "AMDGPU" , |
| 53 | ArchMatchFn: [](Triple::ArchType) { return false; }); |
| 54 | } |
| 55 | |