<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:415783997;
        mso-list-type:hybrid;
        mso-list-template-ids:181020464 -763839680 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l0:level1
        {mso-level-start-at:0;
        mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;
        mso-fareast-font-family:Calibri;
        mso-bidi-font-family:"Times New Roman";}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level3
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l0:level4
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l0:level5
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level6
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l0:level7
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l0:level8
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Greetings:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Microsoft team members have implemented a new DirectX Shader Compiler based on LLVM and Clang. We would like to make sure that the LLVM community is kept fully aware of it from now on:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The new compiler both includes and modifies the original clang to support HLSL (a C/C++-flavored GPU programming language), and sets LLVM up to produce a constrained form of LLVM IR. We call this output DXIL, where the specific serialization
 conforms to a number of constraints that make it useful/usable by GPU drivers when used with the Direct3D 12 runtime.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">There are also a number of tweaks done to make it a suitable replacement for the prior HLSL compiler which shipped as a dynamic library.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Originally we were hoping to contribute our changes back to clang and LLVM, but as we implemented more and more of HLSL, it became clear that this is of questionable value at this point in time. The code is still marked with various conditional
 checks on whether LangOpts supports HLSL, a legacy of those early days. At first it was an accumulation of small changes that made us start to question whether this was a good idea, but after resolving all differences in type promotions and conversion in various
 contexts, overload resolution and handling of template-type constructs, it became clear this isn’t a good idea at the time – the changes are very intrusive and not a very good fit with the current style of per-language handling.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">We hope to evolve the language over time to a form where constructs are much better aligned with C/C++, and hopefully we’ll be able to revisit the idea of contribution then.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Most of the other changes made were to align with other specific criteria:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<ul style="margin-top:0in" type="disc">
<li class="MsoNormal" style="mso-list:l0 level1 lfo1">We’re working on cleaning up many of the uses of global variables, to allow for better use in multithreaded scenarios, which we see our customers use in custom tooling.<o:p></o:p>
<ul style="margin-top:0in" type="circle">
<li class="MsoNormal" style="mso-list:l0 level2 lfo1">For example, different passes can now be run with different options within each, and the dynamic library provides enough information that both passes and their options can be described to build a user interface
 to visualize and potentially manage them.<o:p></o:p></li></ul>
</li><li class="MsoNormal" style="mso-list:l0 level1 lfo1">We’ve shimmed access to many operating system APIs, with an important focus on file access, to improve some hosting / tooling scenarios. Still in progress is proper use of memory allocators.<o:p></o:p></li><li class="MsoNormal" style="mso-list:l0 level1 lfo1">We’ve worked to develop an API exported by the dynamic library that allows component-sized access to various pieces of functionality (compilation, optimization, validation, language services), which allowed
 most command-line utilities to run by going through the dynamic library and avoid statically linking in some of the larger core libraries.<o:p></o:p></li><li class="MsoNormal" style="mso-list:l0 level1 lfo1">We’ve done work to reduce the disk space requirements of the library, via a combination of “slicing off” libraries, preprocessor directives and compile-time constants to dead-code large areas of code (a
 nifty trick with a fixed/constant LangOpts took us a fair amount of the way on the clang side of things).<o:p></o:p></li><li class="MsoNormal" style="mso-list:l0 level1 lfo1">To improve cross-referencing documentation and code, we’ve written a handful of scripts to generate both from documentation. The tradeoff with TableGen was less regularity in the structures built, but higher
 expressiveness in how we’ve built them (“intrinsics that are named with some regex get some attribute set on them” type of things). Not a particularly impressive bit of code generation, but we’ve gotten a bunch of value of out that, so we thought it was worth
 mentioning.<o:p></o:p></li></ul>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">In closing, we stand on the shoulders of giants, and would like to thank the LLVM and clang communities and express our hope that we may at some point contribute back to the mainline whatever changes may be deemed of interest.
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Marcelo & Chas.<o:p></o:p></p>
</div>
</body>
</html>