clang 23.0.0git
SPIRV.cpp
Go to the documentation of this file.
1//===- SPIRV.cpp - Emit CIR for SPIR/SPIR-V -------------------------------===//
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
12namespace cir {
13
14namespace {
15
16// SPIR-V OpenCL storage classes, indexed by cir::LangAddressSpace.
17constexpr unsigned SPIRVAddrSpaceMap[] = {
18 0, // Function
19 0, // Function
20 3, // Workgroup
21 1, // CrossWorkgroup
22 2, // UniformConstant
23 4, // Generic
24};
25
26class SPIRVTargetLoweringInfo : public TargetLoweringInfo {
27public:
28 unsigned getTargetAddrSpaceFromCIRAddrSpace(
29 cir::LangAddressSpace addrSpace) const override {
30 auto idx = static_cast<unsigned>(addrSpace);
31 assert(idx < std::size(SPIRVAddrSpaceMap) &&
32 "Unknown CIR address space for SPIR-V target");
33 return SPIRVAddrSpaceMap[idx];
34 }
35};
36
37} // namespace
38
39std::unique_ptr<TargetLoweringInfo> createSPIRVTargetLoweringInfo() {
40 return std::make_unique<SPIRVTargetLoweringInfo>();
41}
42
43} // namespace cir
std::unique_ptr< TargetLoweringInfo > createSPIRVTargetLoweringInfo()
Definition SPIRV.cpp:39