summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2018-05-14Allow to build LLVMSPIRV lib as static libraryAlexey Sotkin1-1/+3
2018-05-03Rename the installed header and install it in a prefixPierre Moreau3-3/+3
Also, the version was bumped to 0.2.1 (from 0.2.0) due to the changes. Fix: https://github.com/KhronosGroup/SPIRV-LLVM-Translator/issues/15
2018-04-24Rename all variables and functions to match LLVM guidelinesPierre Moreau34-817/+815
The project version was also changed as the entrypoints to the library have been modified. Command used: /usr/share/clang/run-clang-tidy.py -header-filter "(./include/SPIRV.h|./lib/SPIRV/Mangler/FunctionDescriptor.h|./lib/SPIRV/Mangler/ManglingUtils.h|./lib/SPIRV/Mangler/NameMangleAPI.h|./lib/SPIRV/Mangler/ParameterType.h|./lib/SPIRV/Mangler/Refcount.h|./lib/SPIRV/libSPIRV/libSPIRV.h|./lib/SPIRV/libSPIRV/SPIRVBasicBlock.h|./lib/SPIRV/libSPIRV/SPIRVDebug.h|./lib/SPIRV/libSPIRV/SPIRVDecorate.h|./lib/SPIRV/libSPIRV/SPIRVEntry.h|./lib/SPIRV/libSPIRV/SPIRVEnum.h|./lib/SPIRV/libSPIRV/SPIRVError.h|./lib/SPIRV/libSPIRV/SPIRVErrorEnum.h|./lib/SPIRV/libSPIRV/SPIRVExtInst.h|./lib/SPIRV/libSPIRV/SPIRVFunction.h|./lib/SPIRV/libSPIRV/SPIRVInstruction.h|./lib/SPIRV/libSPIRV/SPIRVIsValidEnum.h|./lib/SPIRV/libSPIRV/SPIRVModule.h|./lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h|./lib/SPIRV/libSPIRV/SPIRVOpCode.h|./lib/SPIRV/libSPIRV/SPIRVOpCodeEnum.h|./lib/SPIRV/libSPIRV/SPIRVStream.h|./lib/SPIRV/libSPIRV/SPIRVType.h|./lib/SPIRV/libSPIRV/SPIRVUtil.h|./lib/SPIRV/libSPIRV/SPIRVValue.h|./lib/SPIRV/runtime/OpenCL/inc/spirv.h|./lib/SPIRV/runtime/OpenCL/inc/spirv_convert.h|./lib/SPIRV/OCLUtil.h|./lib/SPIRV/OCLTypeToSPIRV.h|./lib/SPIRV/SPIRVInternal.h|./lib/SPIRV/SPIRVMDBuilder.h|./lib/SPIRV/SPIRVMDWalker.h|./lib/SPIRV/SPIRVWriterPass.h)" -checks="-*,readability-identifier-naming" `find . -iname "*.cpp"` Manual edits: * lib/SPIRV/Mangler/FunctionDescriptor.cpp * lib/SPIRV/libSPIRV/SPIRVEntry.h * lib/SPIRV/libSPIRV/SPIRVDecorate.h * lib/SPIRV/libSPIRV/SPIRVValue.h * lib/SPIRV/libSPIRV/SPIRVStream.h * lib/SPIRV/libSPIRV/SPIRVInstruction.h * lib/SPIRV/Mangler/ParameterType.cpp * lib/SPIRV/Mangler/Mangler.cpp * lib/SPIRV/OCL20ToSPIRV.cpp * lib/SPIRV/Mangler/ParameterType.h * lib/SPIRV/SPIRVLowerOCLBlocks.cpp * lib/SPIRV/SPIRVUtil.cpp * lib/SPIRV/Mangler/Refcount.h
2018-04-24Manually remove “m_” prefix used on some class attributesPierre Moreau5-87/+87
clang-tidy does not properly remove when run, so let’s remove it before running clang-tidy. Command used: sed -i -e 's/\<m_\([a-zA-Z0-9_]\+\)\>/\u\1/g' `find . -iname "*.cpp"` `find . -iname "*.h"`
2018-04-24Rename RefCount::m_refCount to CountPierre Moreau1-15/+15
m_refCount does not follow LLVM’s naming guidelines as it uses the “m_” prefix and does not start with a capital letter. Removing the prefix and changing the first letter to be a capital letter would result in “RefCount” which is the class name and causes compilation issues. Hence why the rename to “Count”. Command used: sed -i 's/m_refCount/Count/g' `find . -iname "*.cpp"` `find . -iname "*.h"`
2018-04-24Convert integers to string before adding to stringPierre Moreau2-3/+4
Adding an integer to a string literal does not append it to the string.
2018-04-24Run clang-tidy without the readability-identifier-naming enabledPierre Moreau36-145/+173
Command used: /usr/share/clang/run-clang-tidy.py -fix -format -header-filter "(./include/SPIRV.h|./lib/SPIRV/Mangler/FunctionDescriptor.h|./lib/SPIRV/Mangler/ManglingUtils.h|./lib/SPIRV/Mangler/NameMangleAPI.h|./lib/SPIRV/Mangler/ParameterType.h|./lib/SPIRV/Mangler/Refcount.h|./lib/SPIRV/libSPIRV/libSPIRV.h|./lib/SPIRV/libSPIRV/SPIRVBasicBlock.h|./lib/SPIRV/libSPIRV/SPIRVDebug.h|./lib/SPIRV/libSPIRV/SPIRVDecorate.h|./lib/SPIRV/libSPIRV/SPIRVEntry.h|./lib/SPIRV/libSPIRV/SPIRVEnum.h|./lib/SPIRV/libSPIRV/SPIRVError.h|./lib/SPIRV/libSPIRV/SPIRVErrorEnum.h|./lib/SPIRV/libSPIRV/SPIRVExtInst.h|./lib/SPIRV/libSPIRV/SPIRVFunction.h|./lib/SPIRV/libSPIRV/SPIRVInstruction.h|./lib/SPIRV/libSPIRV/SPIRVIsValidEnum.h|./lib/SPIRV/libSPIRV/SPIRVModule.h|./lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h|./lib/SPIRV/libSPIRV/SPIRVOpCode.h|./lib/SPIRV/libSPIRV/SPIRVOpCodeEnum.h|./lib/SPIRV/libSPIRV/SPIRVStream.h|./lib/SPIRV/libSPIRV/SPIRVType.h|./lib/SPIRV/libSPIRV/SPIRVUtil.h|./lib/SPIRV/libSPIRV/SPIRVValue.h|./lib/SPIRV/runtime/OpenCL/inc/spirv.h|./lib/SPIRV/runtime/OpenCL/inc/spirv_convert.h|./lib/SPIRV/OCLUtil.h|./lib/SPIRV/OCLTypeToSPIRV.h|./lib/SPIRV/SPIRVInternal.h|./lib/SPIRV/SPIRVMDBuilder.h|./lib/SPIRV/SPIRVMDWalker.h|./lib/SPIRV/SPIRVWriterPass.h)" -checks="-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters" `find . -iname "*.cpp"` Manual edits: * lib/SPIRV/libSPIRV/SPIRVStream.h: remove parentheses around `Type` on line 178; * lib/SPIRV/libSPIRV/SPIRVStream.cpp: remove parentheses around `Type` on line 123 * lib/SPIRV/libSPIRV/SPIRVOpCodeEnum.h: remove added header guard
2018-04-24Remove unneeded semi-colon for TypeVisitor constructorPierre Moreau1-1/+1
2018-04-24Add a virtual destructor to TypeVisitor, as it has virtual functionsPierre Moreau1-0/+1
2018-04-24Add missing “override” keywords in SPIRVEntry.hPierre Moreau1-22/+28
2018-04-24Use clang-tidy to add missing “override” keywordsPierre Moreau23-413/+419
Command used: /usr/share/clang/run-clang-tidy.py -fix -format -header-filter "(./include/SPIRV.h|./lib/SPIRV/Mangler/FunctionDescriptor.h|./lib/SPIRV/Mangler/ManglingUtils.h|./lib/SPIRV/Mangler/NameMangleAPI.h|./lib/SPIRV/Mangler/ParameterType.h|./lib/SPIRV/Mangler/Refcount.h|./lib/SPIRV/libSPIRV/libSPIRV.h|./lib/SPIRV/libSPIRV/SPIRVBasicBlock.h|./lib/SPIRV/libSPIRV/SPIRVDebug.h|./lib/SPIRV/libSPIRV/SPIRVDecorate.h|./lib/SPIRV/libSPIRV/SPIRVEntry.h|./lib/SPIRV/libSPIRV/SPIRVEnum.h|./lib/SPIRV/libSPIRV/SPIRVError.h|./lib/SPIRV/libSPIRV/SPIRVErrorEnum.h|./lib/SPIRV/libSPIRV/SPIRVExtInst.h|./lib/SPIRV/libSPIRV/SPIRVFunction.h|./lib/SPIRV/libSPIRV/SPIRVInstruction.h|./lib/SPIRV/libSPIRV/SPIRVIsValidEnum.h|./lib/SPIRV/libSPIRV/SPIRVModule.h|./lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h|./lib/SPIRV/libSPIRV/SPIRVOpCode.h|./lib/SPIRV/libSPIRV/SPIRVOpCodeEnum.h|./lib/SPIRV/libSPIRV/SPIRVStream.h|./lib/SPIRV/libSPIRV/SPIRVType.h|./lib/SPIRV/libSPIRV/SPIRVUtil.h|./lib/SPIRV/libSPIRV/SPIRVValue.h|./lib/SPIRV/runtime/OpenCL/inc/spirv.h|./lib/SPIRV/runtime/OpenCL/inc/spirv_convert.h|./lib/SPIRV/OCLUtil.h|./lib/SPIRV/OCLTypeToSPIRV.h|./lib/SPIRV/SPIRVInternal.h|./lib/SPIRV/SPIRVMDBuilder.h|./lib/SPIRV/SPIRVMDWalker.h|./lib/SPIRV/SPIRVWriterPass.h)" -checks="-*,modernize-use-override" `find . -iname "*.cpp"`
2018-04-24Reformat all .cpp and .h files using clang-formatPierre Moreau60-8550/+7871
Commands run: * clang-format -i `find . -iname "*.cpp"` * clang-format -i `find . -iname "*.h"` Files manually reverted: * lib/SPIRV/libSPIRV/OpenCL.std.h * lib/SPIRV/runtime/OpenCL/inc/spirv.h * lib/SPIRV/runtime/OpenCL/inc/spirv_convert.h Files manually edited (to fix their first line): * lib/SPIRV/OCL20ToSPIRV.cpp * lib/SPIRV/OCL21ToSPIRV.cpp * lib/SPIRV/SPIRVInternal.h * lib/SPIRV/SPIRVLowerBool.cpp * lib/SPIRV/SPIRVLowerMemmove.cpp * lib/SPIRV/SPIRVToOCL20.cpp * lib/SPIRV/libSPIRV/SPIRVBasicBlock.cpp * lib/SPIRV/libSPIRV/SPIRVBasicBlock.h * lib/SPIRV/libSPIRV/SPIRVDebug.cpp * lib/SPIRV/libSPIRV/SPIRVDebug.h * lib/SPIRV/libSPIRV/SPIRVDecorate.cpp * lib/SPIRV/libSPIRV/SPIRVDecorate.h * lib/SPIRV/libSPIRV/SPIRVEntry.cpp * lib/SPIRV/libSPIRV/SPIRVEntry.h * lib/SPIRV/libSPIRV/SPIRVError.h * lib/SPIRV/libSPIRV/SPIRVExtInst.h (also added missing include to SPIRVEnum.h) * lib/SPIRV/libSPIRV/SPIRVFunction.cpp * lib/SPIRV/libSPIRV/SPIRVFunction.h * lib/SPIRV/libSPIRV/SPIRVInstruction.cpp * lib/SPIRV/libSPIRV/SPIRVInstruction.h * lib/SPIRV/libSPIRV/SPIRVModule.cpp * lib/SPIRV/libSPIRV/SPIRVModule.h * lib/SPIRV/libSPIRV/SPIRVStream.cpp * lib/SPIRV/libSPIRV/SPIRVStream.h * lib/SPIRV/libSPIRV/SPIRVType.cpp * lib/SPIRV/libSPIRV/SPIRVUtil.h * lib/SPIRV/libSPIRV/SPIRVValue.cpp * lib/SPIRV/libSPIRV/SPIRVValue.h
2018-04-24Change all line endings to UNIX-stylePierre Moreau37-19338/+19338
The code was currently using a mix of DOS-style and UNIX-style; LLVM itself uses UNIX-style. Commands used: * dos2unix `find include -iname "*"` * dos2unix `find lib -iname "*"` * dos2unix `find test -iname "*"` * dos2unix `find tools -iname "*"`
2018-04-16cmake: rework to be able to build outside LLVMKarol Herbst1-12/+19
v2: convert to lower case
2018-04-11Update SPIR-V/LLVM Translator to use new MemIntrinsics APIAlexey Sotkin2-8/+10
Fixes #1
2018-04-03Upgrade SPIRV translator from LLVM 4.0 to the curent SVN revision 327279Alexey Sotkin23-269/+232
Change-Id: I10dc4476c2851a54434a47406fff0840da0b9951
2018-04-03Upgrade SPIRV translator from LLVM 3.8 to LLVM 4.0Alexey Sotkin1-112/+317
Change-Id: I28e88c5b38463e14a4af4fc0e49e8b95c8debef0
2018-04-03Upgrade SPIRV translator from LLVM 3.6 to LLVM 3.8Alexey Sotkin15-114/+230
Change-Id: I97247b6472ff75ea83e12a485e06809ad2d2061c
2018-04-03Reorganizing the SPIR-V/LLVM Translator treeAlexey Sotkin1-2/+4
Before this commit the SPIR-V/LLVM Translator was part of the LLVM tree. The history has been rewritten before this commit, so everything not related to SPIR-V was removed with git filter-branch. Some directories were moved around to be in accordance with http://llvm.org/docs/Projects.html#source-tree-layout Also adding CMakeLists.txt and LIT config files.
2018-03-27Fix for intel_sub_group_block_read with short type.Jurek, Pawel1-4/+6
With previous code, when intel_sub_group_block_read_us scalar function was being used, we generated __builtin_spirv_intel_sub_group_block_read_p1i16 built-in name. For naming consistency with OpenCL functions, it should have the "us" included, i.e. __builtin_spirv_intel_sub_group_block_read_us_p1i16
2018-03-16Fixes for memory leaks in SPIR-V library.Jurek, Pawel9-38/+27
In few places in the SPIR-V library a pattern of “dropAllReferences + removeFromParent” calls was used on values like functions and instructions, that were not meant to be reused. These lead to memory leaks, as these functions do not destruct the objects. The fix is to use “eraseFromParent” instead. SPIRVDecorate objects were also not deallocated, as they were not added to owning module’s SPIRVEntry list. The fix is to add them, as all other similar entries, e.g. SPIRVDecorationGroup.
2018-03-01add the Vector16 capability for both vec8 and vec16 types (#229)Ben Ashbaugh1-1/+3
* add the Vector16 capability for both vec8 and vec16 types * added test to verify Vector16 capability is added for vectors with eight elements
2018-02-06[SPIRV] Fix capabilities for Atomic instructions (#227)Alexey Sotkin1-2/+24
2017-12-26LLVM SPIR-V changes for SPV_INTEL_subgroupsbashbaug10-12/+286
2017-10-24Decoder.getEntry() may returns NULL (#224)Lifeng Pan2-3/+6
* Decoder.getEntry() may returns NULL This happens when SPIR-V binary contains useless word which does not belong to any instruction. Its high 16-bit is 0, and the decoder discards it. * Decoder.getEntry() may returns NULL Add a test which contains 2 useless words. * Use nullptr instead of NULL test/SPIRV/useless_word.spt -> test/SPIRV/redundant_word.spt
2017-10-18~SPIRVModuleImpl() crashes when delete id entries (#223)Lifeng Pan2-5/+3
A forwarded entry has 2 duplicate elements in "IdEntryMap", one element is at map slot of old id, and another is at forward id.
2017-10-17~SPIRVModuleImpl() crashes when delete no-id entries (#222)Lifeng Pan3-13/+15
* ~SPIRVModuleImpl() crashes when delete no-id entries It crashes because it tries to delete some no-id entry (OpStore) twice, which is pushed into vector "EntryNoId" twice. Do not add entries of SPIRVBasicBlock and SPIRVInstruction into Module when call Decoder.getEntry(). They will be added at addBasicBlock() and addInstruction(). * ~SPIRVModuleImpl() crashes when delete no-id entries No-id entries of OpGroupDecorate and OpGroupMemberDecorate are pushed into vector "EntryNoId" twice. See SPIRVGroupDecorateGeneric::decode(std::istream &I). No-id entry of OpLine will be deleted by std::shared_ptr automatically. * ~SPIRVModuleImpl() crashes when delete no-id entries Use type std::set for "EntryNoId" to avoid duplicate elements.The elements in std:set are sorted by memory pointer, not by creation order. An entry of OpLine (A) can be deleted because of deletion of another entry (B) which refers to A. If A is placed after B, it will try to access invalid A when it frees "EntryNoId". Therefore, not insert entry of OpLine to "EntryNoId", and it will be deleted by std::shared_ptr automatically.
2017-08-16Fix typo in an assert message (#220)Lifeng Pan3-4/+4
* Fix typo in an assert message and get rid of build warnings. Value of size_t type is always >= 0; Use explicit conversion from uint64_t to unsigned.
2017-07-13Insert bitcast during translation of llvm.memset (#219)Alexey Sotkin3-14/+21
This commit supplements 94ed068c81cac48eed41e8851115520949664e2c "Changing translation of llvm.memset intrinsic (#217)" With arguments bitcasted to i8* OpCopyMemorySized can be correctly translated to llvm.memcpy, i.e. llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, ...) instead of llvm.memcpy.p0i8.p0i8.i32(i8*, [n x i8]*, ...)
2017-06-29Squashed the lower-memmove pass (#209)doe3004-2/+142
2017-05-25Changing translation of llvm.memset intrinsic (#217)Alexey Sotkin4-19/+61
In most cases llvm.memset is emitted by Clang to do zero-initialization in default constructors. With this commit this case is handled as followed: 1. Create global variable initialized by a null constant array. Type of array's element is i8, length of the array is `len` operand of the llvm.memset intrinsic. 2. Copy the array to the target by OpCopyMemorySized, keeping alignment and isvolatile arguments. Translation from SPIR-V to LLVM is updated as well. Fixes #203
2017-05-03Fixed a warning (#211)Abel Bernabeu1-1/+1
2016-12-02Add declaration of Int8 capability (#198)Alexey Sotkin1-2/+11
2016-11-14Revert "Change ordering of blocks as required by SPIRV Spec (#195)" (#197)kkyzylov1-38/+0
This reverts commit 53688bd35ed4c279ec93b7229e3b741b7ab98b2c.
2016-11-10Change ordering of blocks as required by SPIRV Spec (#195)kkyzylov1-0/+38
2016-11-04Fix fox OpenCL C++ built-ins translation (#196)kkyzylov1-0/+8
2016-10-19Implemented method for mapping function arguments without metadata. (#194)Egor Churaev2-0/+33
2016-10-19Default access qualifier for OpTypeImage (#193)kkyzylov1-2/+5
2016-10-12Translation of OpLoopMerge (#192)kkyzylov5-11/+87
2016-10-05Support translation of OpLifetimeStart and OpLifetimeStop instructions (#191)kkyzylov7-2/+159
2016-10-04Changing placement of lowered constant expressions (#188)Alexey Sotkin1-6/+7
According to SPIRV specification (p2.4): "All OpVariable instructions in a function must be in the first block in the function. These instructions, together with any immediately preceding OpLine instructions, must be the first instructions in that block." Therefore, lowered constant expressions must not be inserted at the beginig of the basic block. Insert it before the current instruction if the current basic block is the first one in the function. Otherwise insert it at the end of the first basic block in the function. This partially fixes #50
2016-09-30Support translation of OpUnreachable instruction (#190)kkyzylov6-1/+14
2016-09-30Fix for translation of OpFMod instruction (#187)kkyzylov4-24/+30
2016-09-29OpVariable in OpSpecConstantOp. (#186)Egor Churaev1-7/+6
* Fixed problem with OpSpecConstantOp. In one of last change of spirv spec was added following change: "Public SPIRV-Headers issues #12 and #13 and Khronos SPIR-V issue #65: Allow OpVariable as an initializer for another OpVariable instruction or the Base of an OpSpecConstantOp with an AccessChain opcode." In this way, OpVariable can be initialize before OpSpecConstantOp. To do this, it's necessary add OpSpecConstantOp in one container with OpVariable in TopologicalSort. After this change, OpSpecConstantOp and OpVariable instructions will be add to spirv file in the right order. * Renamed InstructionVec to ConstAndVarVec and fixed indentation
2016-09-26Translation of LLVM intrinsics (#185)Alexey Sotkin2-27/+87
An LLVM intrinsic should not be transalated to SPIRV as a function call. Either it's semantics is represented via SPIRV instruction(s) or an error is reported.
2016-09-23Fixing encoding/decoding of OpLine instruction (#184)Alexey Sotkin8-63/+107
Changed wordcount to 4. Changing layout of OpLine in module according to the specification requirements.
2016-09-13OpVariable <id> Initializer can be optional (#182)Egor2-1/+3
* OpVariable <id> Initializer can be optional * Fix problem with initializer for external linked type
2016-09-13Support translation of OpSelectionMerge instruction (#183)kkyzylov5-1/+44
2016-09-08Fix error with adding capability for 1D images (#181)Egor1-2/+2
2016-09-07Support translation of OpCompositeConstruct instruction (#178)kkyzylov6-1/+71