-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #218 from frasercrmck/spirv-ll-ext-handlers
[spirv-ll] Add an interface for OpExtInstImport handlers
- Loading branch information
Showing
10 changed files
with
231 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (C) Codeplay Software Limited | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License") with LLVM | ||
// Exceptions; you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://github.com/codeplaysoftware/oneapi-construction-kit/blob/main/LICENSE.txt | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
// License for the specific language governing permissions and limitations | ||
// under the License. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#ifndef SPIRV_LL_SPV_BUILDER_GLSL_H_INCLUDED | ||
#define SPIRV_LL_SPV_BUILDER_GLSL_H_INCLUDED | ||
|
||
#include <spirv-ll/builder.h> | ||
|
||
namespace spirv_ll { | ||
|
||
class GLSLBuilder : public ExtInstSetHandler { | ||
public: | ||
/// @brief Constructor. | ||
/// | ||
/// @param builder `Builder` object that will own this object. | ||
/// @param module The module being translated. | ||
GLSLBuilder(Builder &builder, Module &module) | ||
: ExtInstSetHandler(builder, module) {} | ||
|
||
/// @see ExtendedInstrSet::create | ||
virtual llvm::Error create(OpExtInst const &opc) override; | ||
|
||
private: | ||
/// @brief Create a GLSL extended instruction transformation to LLVM IR. | ||
/// | ||
/// @tparam inst The GLSL extended instruction to create. | ||
/// @param opc The OpCode object to translate. | ||
/// | ||
/// @return Returns an `llvm::Error` object representing either success, or | ||
/// an error value. | ||
template <enum GLSLstd450 inst> | ||
llvm::Error create(OpExtInst const &opc); | ||
}; | ||
|
||
} // namespace spirv_ll | ||
|
||
#endif // SPIRV_LL_SPV_BUILDER_GLSL_H_INCLUDED |
62 changes: 62 additions & 0 deletions
62
modules/compiler/spirv-ll/include/spirv-ll/builder_group_async_copies.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (C) Codeplay Software Limited | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License") with LLVM | ||
// Exceptions; you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://github.com/codeplaysoftware/oneapi-construction-kit/blob/main/LICENSE.txt | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
// License for the specific language governing permissions and limitations | ||
// under the License. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#ifndef SPIRV_LL_SPV_BUILDER_GROUP_ASYNC_COPIES_H_INCLUDED | ||
#define SPIRV_LL_SPV_BUILDER_GROUP_ASYNC_COPIES_H_INCLUDED | ||
|
||
#include <spirv-ll/builder.h> | ||
|
||
namespace spirv_ll { | ||
|
||
/// @brief builder for the Codeplay.GroupAsyncCopies extended instruction set. | ||
class GroupAsyncCopiesBuilder : public ExtInstSetHandler { | ||
public: | ||
/// @brief Constructor. | ||
/// | ||
/// @param[in] builder spirv_ll::Builder object that will own this object. | ||
/// @param[in] module The module being translated. | ||
GroupAsyncCopiesBuilder(Builder &builder, Module &module) | ||
: ExtInstSetHandler(builder, module) {} | ||
|
||
/// @brief Enumeration of instruction ID's in the Codeplay.GroupAsyncCopies | ||
/// extended instruction set. | ||
// TODO(CA-4119): If this vendor extension lives beyond any official Khronos | ||
// extension, these definitions should be defined upstream in SPIRV-Headers. | ||
enum Instruction { | ||
GroupAsyncCopy2D2D = 1, ///< Represents async_work_group_copy_2D2D. | ||
GroupAsyncCopy3D3D = 2, ///< Represents async_work_group_copy_3D3D. | ||
}; | ||
|
||
/// @see ExtInstSetHandler::create | ||
virtual llvm::Error create(OpExtInst const &opc) override; | ||
|
||
private: | ||
/// @brief Create a Codeplay.GroupAsyncCopies extended instruction | ||
/// transformation to LLVM IR. | ||
/// | ||
/// @tparam inst The Codeplay.GroupAsyncCopies extended instruction to | ||
/// create. | ||
/// @param opc The spirv_ll::OpCode object to translate. | ||
/// | ||
/// @return Returns an `llvm::Error` object representing either success, or | ||
/// an error value. | ||
template <Instruction inst> | ||
llvm::Error create(OpExtInst const &opc); | ||
}; | ||
|
||
} // namespace spirv_ll | ||
|
||
#endif // SPIRV_LL_SPV_BUILDER_GROUP_ASYNC_COPIES_H_INCLUDED |
61 changes: 61 additions & 0 deletions
61
modules/compiler/spirv-ll/include/spirv-ll/builder_opencl.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (C) Codeplay Software Limited | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License") with LLVM | ||
// Exceptions; you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://github.com/codeplaysoftware/oneapi-construction-kit/blob/main/LICENSE.txt | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
// License for the specific language governing permissions and limitations | ||
// under the License. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#ifndef SPIRV_LL_SPV_BUILDER_OPENCL_H_INCLUDED | ||
#define SPIRV_LL_SPV_BUILDER_OPENCL_H_INCLUDED | ||
|
||
#include <spirv-ll/builder.h> | ||
|
||
namespace spirv_ll { | ||
|
||
class OpenCLBuilder : public spirv_ll::ExtInstSetHandler { | ||
public: | ||
/// @brief Constructor. | ||
/// | ||
/// @param builder `Builder` object that will own this object. | ||
/// @param module The module being translated. | ||
OpenCLBuilder(Builder &builder, Module &module) | ||
: ExtInstSetHandler(builder, module) {} | ||
|
||
/// @see ExtInstSetHandler::create | ||
virtual llvm::Error create(OpExtInst const &opc) override; | ||
|
||
private: | ||
/// @brief Create an OpenCL extended instruction transformation to LLVM IR. | ||
/// | ||
/// @tparam T The OpenCL extended instruction class template to create. | ||
/// @param opc The OpCode object to translate. | ||
/// | ||
/// @return Returns an `llvm::Error` object representing either success, or | ||
/// an error value. | ||
template <typename T> | ||
llvm::Error create(OpExtInst const &opc); | ||
|
||
/// @brief Create a vector OpenCL extended instruction transformation to LLVM | ||
/// IR. | ||
/// | ||
/// @tparam inst The OpenCL extended instruction to create. | ||
/// @param opc The OpCode object to translate. | ||
/// | ||
/// @return Returns an `llvm::Error` object representing either success, or | ||
/// an error value. | ||
template <OpenCLLIB::Entrypoints inst> | ||
llvm::Error createVec(OpExtInst const &opc); | ||
}; | ||
|
||
} // namespace spirv_ll | ||
|
||
#endif // SPIRV_LL_SPV_BUILDER_OPENCL_H_INCLUDED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.