forked from KhronosGroup/SPIRV-LLVM-Translator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accept intrinsic namings into -spirv-allow-unknown-intrinsics (Khrono…
…sGroup#912) Previously, enabling the option would let all intrinsics through the translator. From now on, the option can be configured so that only specific intrinsic calls with the given prefix are allowed, while those not matching the prefix will result in an error as if no option was given. The allowed intrinsic prefixes are fed into the option as a comma-separated list, akin to `--spirv-ext`. The list can also be left unspecified, which, as before, will accept all intrinsic calls into SPIR-V. One of the relevant use cases involves llvm.genx.* intrinsics, which stem from SYCL ESIMD code, but can also mix with common LLVM intrinsics that stem from regular SYCL code. It would be desirable to allow ESIMD-specific intrinsics, but still error out on other unknown ones, To better highlight this case, all ESIMD-specific tests have been switched to passing an explicit prefix to the CLI option.
- Loading branch information
Artem Gindinson
authored
Feb 19, 2021
1 parent
b89b25f
commit 1dbc09c
Showing
12 changed files
with
141 additions
and
25 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,71 @@ | ||
//===- LLVMSPIRVOpts.cpp - Defines LLVM/SPIR-V options ----------*- C++ -*-===// | ||
// | ||
// The LLVM/SPIR-V Translator | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
// Copyright (c) 2021 Intel Corporation. All rights reserved. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a | ||
// copy of this software and associated documentation files (the "Software"), | ||
// to deal with the Software without restriction, including without limitation | ||
// the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
// and/or sell copies of the Software, and to permit persons to whom the | ||
// Software is furnished to do so, subject to the following conditions: | ||
// | ||
// Redistributions of source code must retain the above copyright notice, | ||
// this list of conditions and the following disclaimers. | ||
// Redistributions in binary form must reproduce the above copyright notice, | ||
// this list of conditions and the following disclaimers in the documentation | ||
// and/or other materials provided with the distribution. | ||
// Neither the names of Advanced Micro Devices, Inc., nor the names of its | ||
// contributors may be used to endorse or promote products derived from this | ||
// Software without specific prior written permission. | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH | ||
// THE SOFTWARE. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
/// \file | ||
/// | ||
/// This file provides definitions for LLVM/SPIR-V Translator's CLI | ||
/// functionality. | ||
/// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "LLVMSPIRVOpts.h" | ||
|
||
#include <llvm/ADT/Optional.h> | ||
#include <llvm/ADT/SmallVector.h> | ||
#include <llvm/ADT/StringRef.h> | ||
#include <llvm/IR/IntrinsicInst.h> | ||
|
||
using namespace llvm; | ||
using namespace SPIRV; | ||
|
||
bool TranslatorOpts::isUnknownIntrinsicAllowed(IntrinsicInst *II) const | ||
noexcept { | ||
if (!SPIRVAllowUnknownIntrinsics.hasValue()) | ||
return false; | ||
const auto &IntrinsicPrefixList = SPIRVAllowUnknownIntrinsics.getValue(); | ||
StringRef IntrinsicName = II->getCalledOperand()->getName(); | ||
for (const auto Prefix : IntrinsicPrefixList) { | ||
if (IntrinsicName.startswith(Prefix)) // Also true if `Prefix` is empty | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
bool TranslatorOpts::isSPIRVAllowUnknownIntrinsicsEnabled() const noexcept { | ||
return SPIRVAllowUnknownIntrinsics.hasValue(); | ||
} | ||
|
||
void TranslatorOpts::setSPIRVAllowUnknownIntrinsics( | ||
TranslatorOpts::ArgList IntrinsicPrefixList) noexcept { | ||
SPIRVAllowUnknownIntrinsics = IntrinsicPrefixList; | ||
} |
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
2 changes: 1 addition & 1 deletion
2
test/transcoding/SPV_INTEL_vector_compute/decoration_byte_offset.ll
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
2 changes: 1 addition & 1 deletion
2
test/transcoding/SPV_INTEL_vector_compute/decoration_simt_call.ll
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
2 changes: 1 addition & 1 deletion
2
test/transcoding/SPV_INTEL_vector_compute/decoration_single_element_vector.ll
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
2 changes: 1 addition & 1 deletion
2
test/transcoding/SPV_INTEL_vector_compute/decoration_volatile.ll
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
2 changes: 1 addition & 1 deletion
2
test/transcoding/SPV_INTEL_vector_compute/extension_vector_compute_stability.ll
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