<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Thanks,
<div class=""><br class="">
</div>
<div class="">I’m still busy until the start of July (franticly writing my Honours thesis), but I’d be very interested in moving this forward after my thesis is handed in.</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On 21 Jun 2017, at 5:41 am, Neil Hickey <<a href="mailto:Neil.Hickey@arm.com" class="">Neil.Hickey@arm.com</a>> wrote:</div>
<div class="">
<div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif;" class="">
<div style="margin-top: 0px; margin-bottom: 0px;" class=""><span style="color: rgb(33, 33, 33); font-size: 15px;" class="">Firstly, there are a number of benefits to having SPIR-V in LLVM as a backend, both to SPIR-V, the ecosystem and to LLVM.</span><br style="color: rgb(33, 33, 33); font-size: 15px;" class="">
<br style="color: rgb(33, 33, 33); font-size: 15px;" class="">
<span style="color: rgb(33, 33, 33); font-size: 15px;" class=""> * Allows any frontend targeting llvm to also target SPIR-V</span><br style="color: rgb(33, 33, 33); font-size: 15px;" class="">
<span style="color: rgb(33, 33, 33); font-size: 15px;" class=""> * Improves robustness of open source tooling for SPIR-V</span><br style="color: rgb(33, 33, 33); font-size: 15px;" class="">
<span style="color: rgb(33, 33, 33); font-size: 15px;" class=""> * Single place for toolchain - People don't need to knit repositories together from multiple locations</span><br style="color: rgb(33, 33, 33); font-size: 15px;" class="">
<span style="color: rgb(33, 33, 33); font-size: 15px;" class=""> * Compatibility between LLVM and SPIR-V - As SPIR-V is integrated it will always track top of tree</span><br style="color: rgb(33, 33, 33); font-size: 15px;" class="">
<span style="color: rgb(33, 33, 33); font-size: 15px;" class=""> * We can create a target triple to subset what dialect of SPIR-V we are targeting</span><br style="color: rgb(33, 33, 33); font-size: 15px;" class="">
<span style="color: rgb(33, 33, 33); font-size: 15px;" class=""> * Using the aforementioned triple we can guide optimisations that take target information</span><br style="color: rgb(33, 33, 33); font-size: 15px;" class="">
<span style="color: rgb(33, 33, 33); font-size: 15px;" class=""> * Challenges of implementing SPIR-V backend can influence LLVM backend development, to improve LLVM usability by less conventional targets</span><br style="color: rgb(33, 33, 33); font-size: 15px;" class="">
<span style="color: rgb(33, 33, 33); font-size: 15px;" class=""> * Benefits LLVM by improving support for GPU code generation specifically</span><br style="color: rgb(33, 33, 33); font-size: 15px;" class="">
<br style="color: rgb(33, 33, 33); font-size: 15px;" class="">
<span style="color: rgb(33, 33, 33); font-size: 15px;" class="">I'd also like to touch specifically on a point that I believe was originally made by Tom.</span><br style="color: rgb(33, 33, 33); font-size: 15px;" class="">
<br style="color: rgb(33, 33, 33); font-size: 15px;" class="">
<span style="color: rgb(33, 33, 33); font-size: 15px;" class="">If the initial implementation of the SPIR-V backend went straight for GlobalISel and only GlobalISel then we would remove the need to worry about SelectionDAG and would remove some of the complexity
 from the translation step.</span><br style="color: rgb(33, 33, 33); font-size: 15px;" class="">
<br style="color: rgb(33, 33, 33); font-size: 15px;" class="">
<span style="color: rgb(33, 33, 33); font-size: 15px;" class="">So as a proposal, could I suggest the following next steps?</span><br style="color: rgb(33, 33, 33); font-size: 15px;" class="">
<span style="color: rgb(33, 33, 33); font-size: 15px;" class="">1) Add a dummy SPIR-V target machine to llvm, replete with target triple</span><br style="color: rgb(33, 33, 33); font-size: 15px;" class="">
<span style="color: rgb(33, 33, 33); font-size: 15px;" class="">2) Implement an experimental backend making use of globalisel to target SPIR-V code generation</span><br style="color: rgb(33, 33, 33); font-size: 15px;" class="">
<span style="color: rgb(33, 33, 33); font-size: 15px;" class="">3) Add tests to verify correct execution</span><br style="color: rgb(33, 33, 33); font-size: 15px;" class="">
</div>
</div>
</div>
</div>
</blockquote>
<br class="">
<div>1) Should be doable by lifting files straight out of my fork of LLVM[1,2,3]. Probably a good idea to double check them, I had very little idea what I was doing when I wrote them. Also will need a separate for vulkan (currently spirvl, for SPIRV logical
 see non merge commits on the compute branch of [1])</div>
<div>3) I haven’t transferred the tests over from Khronos’ SPIRV-LLVM[4], but they will very likely need updating although sill a good starting point.</div>
<div>2) Sigh… this will require work. </div>
<div>Before figuring out what to copy verbatim across and what needs to use GlobalIsel, as the current implementation goes straight from the IR, please consider that using intrinsics is some thing I want to have happen, not the least of which is so I can kill
 of the mangling code and have proper windows support with LDC’s compilation pipeline (so the frontend doesn’t have to mangle some as Itanium and sone as MS C++).</div>
<div><br class="">
</div>
<div>I have a mostly complete SPIRV Core tablegen files[2], although it currently lacks a tablegen backend for itself, still required would be the instruction extension sets for OpenCL and Vulkan. N.B. they are constructed from the pdfs of the spec not the
 machine readable json, it has way less useful information w.r.t the intricacies for the format.</div>
<div><br class="">
</div>
<div>If anyone with knowledge of tablegen wants to get the tablegen files working that would be great. Also any work on the extension instruction sets would be very much appriciated, warning: its mind numbingly boring. </div>
</div>
<div><br class="">
</div>
<div>[1] LLVM <a href="https://github.com/thewilsonator/llvm" class="">https://github.com/thewilsonator/llvm</a></div>
<div>[2]  the SPIR-V target <a href="https://github.com/thewilsonator/llvm-target-spirv" class="">https://github.com/thewilsonator/llvm-target-spirv</a> </div>
<div>[3] the interconversion command line utility <a href="https://github.com/thewilsonator/llvm-tool-spirv" class="">https://github.com/thewilsonator/llvm-tool-spirv</a></div>
<div>[4] <a href="https://github.com/KhronosGroup/SPIRV-LLVM" class="">https://github.com/KhronosGroup/SPIRV-LLVM</a></div>
<br class="">
</div>
</body>
</html>