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