| 1 |
//===- SPIRVMemAliasingINTEL.h - --*- C++ -*-===// |
| 2 |
// |
| 3 |
// The LLVM/SPIR-V Translator |
| 4 |
// |
| 5 |
// This file is distributed under the University of Illinois Open Source |
| 6 |
// License. See LICENSE.TXT for details. |
| 7 |
// |
| 8 |
// Copyright (c) 2021 Intel Corporation. All rights reserved. |
| 9 |
// |
| 10 |
// Permission is hereby granted, free of charge, to any person obtaining a |
| 11 |
// copy of this software and associated documentation files (the "Software"), |
| 12 |
// to deal with the Software without restriction, including without limitation |
| 13 |
// the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 14 |
// and/or sell copies of the Software, and to permit persons to whom the |
| 15 |
// Software is furnished to do so, subject to the following conditions: |
| 16 |
// |
| 17 |
// Redistributions of source code must retain the above copyright notice, |
| 18 |
// this list of conditions and the following disclaimers. |
| 19 |
// Redistributions in binary form must reproduce the above copyright notice, |
| 20 |
// this list of conditions and the following disclaimers in the documentation |
| 21 |
// and/or other materials provided with the distribution. |
| 22 |
// Neither the names of Intel Corporation, nor the names of its contributors |
| 23 |
// may be used to endorse or promote products derived from this Software without |
| 24 |
// specific prior written permission. |
| 25 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 26 |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 27 |
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 28 |
// CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 29 |
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 30 |
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH |
| 31 |
// THE SOFTWARE. |
| 32 |
// |
| 33 |
//===----------------------------------------------------------------------===// |
| 34 |
/// \file |
| 35 |
/// |
| 36 |
/// This file defines the memory aliasing entries defined in SPIRV spec with op |
| 37 |
/// codes. |
| 38 |
/// |
| 39 |
//===----------------------------------------------------------------------===// |
| 40 |
|
| 41 |
#ifndef SPIRV_LIBSPIRV_SPIRVMEMALIASINGINTEL_H |
| 42 |
#define SPIRV_LIBSPIRV_SPIRVMEMALIASINGINTEL_H |
| 43 |
|
| 44 |
#include "SPIRVEntry.h" |
| 45 |
|
| 46 |
namespace SPIRV { |
| 47 |
|
| 48 |
template <Op TheOpCode, SPIRVWord TheFixedWordCount> |
| 49 |
class SPIRVMemAliasingINTELGeneric : public SPIRVEntry { |
| 50 |
public: |
| 51 |
SPIRVMemAliasingINTELGeneric(SPIRVModule *TheModule, SPIRVId TheId, |
| 52 |
const std::vector<SPIRVId> &TheArgs) |
| 53 |
: SPIRVEntry(TheModule, TheArgs.size() + TheFixedWordCount, TheOpCode, |
| 54 |
TheId), Args(TheArgs) { |
| 55 |
SPIRVMemAliasingINTELGeneric::validate(); |
| 56 |
assert(TheModule && "Invalid module"); |
| 57 |
} |
| 58 |
|
| 59 |
SPIRVMemAliasingINTELGeneric() : SPIRVEntry(TheOpCode) {} |
| 60 |
|
| 61 |
const std::vector<SPIRVId> &getArguments() const { return Args; } |
| 62 |
|
| 63 |
void setWordCount(SPIRVWord TheWordCount) override { |
| 64 |
SPIRVEntry::setWordCount(TheWordCount); |
| 65 |
Args.resize(TheWordCount - TheFixedWordCount); |
| 66 |
} |
| 67 |
|
| 68 |
void validate() const override { SPIRVEntry::validate(); } |
| 69 |
|
| 70 |
SPIRVCapVec getRequiredCapability() const override { |
| 71 |
return getVec(CapabilityMemoryAccessAliasingINTEL); |
| 72 |
} |
| 73 |
|
| 74 |
std::optional<ExtensionID> getRequiredExtension() const override { |
| 75 |
return ExtensionID::SPV_INTEL_memory_access_aliasing; |
| 76 |
} |
| 77 |
|
| 78 |
protected: |
| 79 |
static const SPIRVWord FixedWC = TheFixedWordCount; |
| 80 |
static const Op OC = TheOpCode; |
| 81 |
std::vector<SPIRVId> Args; |
| 82 |
_SPIRV_DEF_ENCDEC2(Id, Args) |
| 83 |
}; |
| 84 |
|
| 85 |
#define _SPIRV_OP(x, ...) \ |
| 86 |
typedef SPIRVMemAliasingINTELGeneric<Op##x, __VA_ARGS__> SPIRV##x; |
| 87 |
// Intel Memory Alasing Instructions |
| 88 |
_SPIRV_OP(AliasDomainDeclINTEL, 2) |
| 89 |
_SPIRV_OP(AliasScopeDeclINTEL, 2) |
| 90 |
_SPIRV_OP(AliasScopeListDeclINTEL, 2) |
| 91 |
#undef _SPIRV_OP |
| 92 |
|
| 93 |
} // SPIRV |
| 94 |
#endif // SPIRV_LIBSPIRV_SPIRVMEMALIASINGINTEL_H |