blob: 69e31ebec480586ae7d84ed554b0cd154149003f [file] [log] [blame]
Kévin Petit617a76d2019-04-04 13:54:16 +01001// 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 Petit617a76d2019-04-04 13:54:16 +010015#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-bakere0902602020-03-23 08:43:40 -040021#include "spirv/unified1/spirv.hpp"
Kévin Petit617a76d2019-04-04 13:54:16 +010022
23namespace clspv {
24
25using 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 Novilloa4c44fa2019-04-11 10:56:15 -040039Instruction *InsertSPIRVOp(Instruction *Insert, spv::Op Opcode,
Kévin Petit617a76d2019-04-04 13:54:16 +010040 ArrayRef<Attribute::AttrKind> Attributes,
Diego Novilloa4c44fa2019-04-11 10:56:15 -040041 Type *RetType, ArrayRef<Value *> Args);
Kévin Petit617a76d2019-04-04 13:54:16 +010042
Marco Antognini7e338402021-03-15 12:48:37 +000043} // namespace clspv