[SPIR-V] Introduce SPIR-V global entities tracking and deduplication infra.
authorAleksandr Bezzubikov <zuban32s@gmail.com>
Sat, 18 Jun 2022 19:10:54 +0000 (22:10 +0300)
committerAleksandr Bezzubikov <zuban32s@gmail.com>
Thu, 7 Jul 2022 15:15:10 +0000 (18:15 +0300)
commitfa2a7a25c9893b2cee2a4cf4fe92531979ef523e
treecb511ae4e2de0a336d7ae2d750b7d5c1c93570e0
parent438ffdb821bb930b4b4e18fcd863ba37dc23bf16
[SPIR-V] Introduce SPIR-V global entities tracking and deduplication infra.

SPIR-V module typically contains some global entities that were not
global before made it to SPIR-V, e.g. types and constants are not usually
declared globally in LLVM. By design SPIR-V requires such stuff to be declared
once and in the module's global section. Since MIR is not able to represent
such things properly they were generated per-function, and then at the very end
of the backend's pipeline hoisted into some 'meta' function minding possible
duplicates.

New SPIRVDuplicatesTracker keeps mapping of the original LLVM entities such
as types, constant, global variables, etc to their MIR counterparts -
(MachineFunction, Register). Later SPIRVModuleAnalysis (apart from other
thing it's responsible for) performs topological sorting of the
tracker's entries to ensure proper ordering before the hoisting,
and actually performs the hoisting in a duplicates-free manner
by the tracker's nature.

Differential Revision: https://reviews.llvm.org/D128471
llvm/lib/Target/SPIRV/CMakeLists.txt
llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.cpp [new file with mode: 0644]
llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.h [new file with mode: 0644]
llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.h
llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp
llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h
llvm/test/CodeGen/SPIRV/transcoding/RelationalOperators.ll [new file with mode: 0644]
llvm/test/CodeGen/SPIRV/transcoding/fcmp.ll [new file with mode: 0644]