| 1 | //===--- AMDGPUMachineModuleInfo.cpp ----------------------------*- C++ -*-===// |
| 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 | /// AMDGPU Machine Module Info. |
| 11 | /// |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "AMDGPUMachineModuleInfo.h" |
| 16 | #include "llvm/IR/Module.h" |
| 17 | #include "llvm/Target/TargetMachine.h" |
| 18 | #include "llvm/TargetParser/AtomicScope.h" |
| 19 | |
| 20 | using namespace llvm; |
| 21 | |
| 22 | AMDGPUMachineModuleInfo::AMDGPUMachineModuleInfo(const MachineModuleInfo &MMI) |
| 23 | : MachineModuleInfoELF(MMI) { |
| 24 | LLVMContext &CTX = MMI.getModule()->getContext(); |
| 25 | const Triple &TT = MMI.getTarget().getTargetTriple(); |
| 26 | |
| 27 | auto InsertScope = [&](AtomicScope Scope, bool OneAS) { |
| 28 | return CTX.getOrInsertSyncScopeID( |
| 29 | SSN: *getAtomicScopeIRString(T: TT, S: Scope, IsSingleAddressSpace: OneAS)); |
| 30 | }; |
| 31 | AgentSSID = InsertScope(AtomicScope::Device, /*OneAS=*/false); |
| 32 | WorkgroupSSID = InsertScope(AtomicScope::Workgroup, /*OneAS=*/false); |
| 33 | WavefrontSSID = InsertScope(AtomicScope::Wavefront, /*OneAS=*/false); |
| 34 | ClusterSSID = InsertScope(AtomicScope::Cluster, /*OneAS=*/false); |
| 35 | SystemOneAddressSpaceSSID = InsertScope(AtomicScope::System, /*OneAS=*/true); |
| 36 | AgentOneAddressSpaceSSID = InsertScope(AtomicScope::Device, /*OneAS=*/true); |
| 37 | WorkgroupOneAddressSpaceSSID = |
| 38 | InsertScope(AtomicScope::Workgroup, /*OneAS=*/true); |
| 39 | WavefrontOneAddressSpaceSSID = |
| 40 | InsertScope(AtomicScope::Wavefront, /*OneAS=*/true); |
| 41 | SingleThreadOneAddressSpaceSSID = |
| 42 | InsertScope(AtomicScope::Single, /*OneAS=*/true); |
| 43 | ClusterOneAddressSpaceSSID = |
| 44 | InsertScope(AtomicScope::Cluster, /*OneAS=*/true); |
| 45 | } |
| 46 | |