Kévin Petit | 617a76d | 2019-04-04 13:54:16 +0100 | [diff] [blame] | 1 | // Copyright 2019 The Clspv Authors. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
Kévin Petit | 617a76d | 2019-04-04 13:54:16 +0100 | [diff] [blame] | 15 | #include "llvm/ADT/ArrayRef.h" |
| 16 | #include "llvm/IR/Attributes.h" |
| 17 | #include "llvm/IR/Instruction.h" |
| 18 | #include "llvm/IR/Type.h" |
| 19 | #include "llvm/IR/Value.h" |
| 20 | |
alan-baker | e090260 | 2020-03-23 08:43:40 -0400 | [diff] [blame] | 21 | #include "spirv/unified1/spirv.hpp" |
Kévin Petit | 617a76d | 2019-04-04 13:54:16 +0100 | [diff] [blame] | 22 | |
| 23 | namespace clspv { |
| 24 | |
| 25 | using namespace llvm; |
| 26 | |
| 27 | // Insert a call to a specific SPIR-V instruction after Insert |
| 28 | // |
| 29 | // A function with a name guaranteed to be unique for each combination of types |
| 30 | // in Args will be used to represent the SPIR-V instruction until the |
| 31 | // SPIRVProducerPass. |
| 32 | // |
| 33 | // The attributes passed via Attributes must all be function attributes. |
| 34 | // They will be set on the function representing the SPIR-V instruction. |
| 35 | // |
| 36 | // Since this function may modify the symbol table of the module containing |
| 37 | // Insert, it shouldn't be used while iterating over the symbols of that module |
| 38 | // unless the caller knows that no new function will be created. |
Diego Novillo | a4c44fa | 2019-04-11 10:56:15 -0400 | [diff] [blame] | 39 | Instruction *InsertSPIRVOp(Instruction *Insert, spv::Op Opcode, |
Kévin Petit | 617a76d | 2019-04-04 13:54:16 +0100 | [diff] [blame] | 40 | ArrayRef<Attribute::AttrKind> Attributes, |
Diego Novillo | a4c44fa | 2019-04-11 10:56:15 -0400 | [diff] [blame] | 41 | Type *RetType, ArrayRef<Value *> Args); |
Kévin Petit | 617a76d | 2019-04-04 13:54:16 +0100 | [diff] [blame] | 42 | |
Marco Antognini | 7e33840 | 2021-03-15 12:48:37 +0000 | [diff] [blame] | 43 | } // namespace clspv |