clang 23.0.0git
AMDGPU.cpp
Go to the documentation of this file.
1//===- AMDGPU.cpp - Emit CIR 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
11#include "llvm/Support/AMDGPUAddrSpace.h"
12
13namespace cir {
14
15namespace {
16
17// Address space mapping from:
18// https://llvm.org/docs/AMDGPUUsage.html#address-spaces
19//
20// Indexed by cir::LangAddressSpace enum values.
21constexpr unsigned AMDGPUAddrSpaceMap[] = {
22 llvm::AMDGPUAS::FLAT_ADDRESS, // Default
23 llvm::AMDGPUAS::PRIVATE_ADDRESS, // OffloadPrivate
24 llvm::AMDGPUAS::LOCAL_ADDRESS, // OffloadLocal
25 llvm::AMDGPUAS::GLOBAL_ADDRESS, // OffloadGlobal
26 llvm::AMDGPUAS::CONSTANT_ADDRESS, // OffloadConstant
27 llvm::AMDGPUAS::FLAT_ADDRESS, // OffloadGeneric
28};
29
30class AMDGPUTargetLoweringInfo : public TargetLoweringInfo {
31public:
32 unsigned getTargetAddrSpaceFromCIRAddrSpace(
33 cir::LangAddressSpace addrSpace) const override {
34 auto idx = static_cast<unsigned>(addrSpace);
35 assert(idx < std::size(AMDGPUAddrSpaceMap) &&
36 "Unknown CIR address space for AMDGPU target");
37 return AMDGPUAddrSpaceMap[idx];
38 }
39};
40
41} // namespace
42
43std::unique_ptr<TargetLoweringInfo> createAMDGPUTargetLoweringInfo() {
44 return std::make_unique<AMDGPUTargetLoweringInfo>();
45}
46
47} // namespace cir
std::unique_ptr< TargetLoweringInfo > createAMDGPUTargetLoweringInfo()
Definition AMDGPU.cpp:43