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 5, // GlobalDevice
25 6, // GlobalHost
26};
27
28class SPIRVTargetLoweringInfo : public TargetLoweringInfo {
29public:
30 unsigned getTargetAddrSpaceFromCIRAddrSpace(
31 cir::LangAddressSpace addrSpace) const override {
32 auto idx = static_cast<unsigned>(addrSpace);
33 assert(idx < std::size(SPIRVAddrSpaceMap) &&
34 "Unknown CIR address space for SPIR-V target");
35 return SPIRVAddrSpaceMap[idx];
36 }
37};
38
39} // namespace
40
41std::unique_ptr<TargetLoweringInfo> createSPIRVTargetLoweringInfo() {
42 return std::make_unique<SPIRVTargetLoweringInfo>();
43}
44
45} // namespace cir
std::unique_ptr< TargetLoweringInfo > createSPIRVTargetLoweringInfo()
Definition SPIRV.cpp:41