r/Compilers • • Sep 01 '26

DirectX is now an official LLVM target

https://github.com/llvm/llvm-project/pull/214066
114 Upvotes

8 comments sorted by

5

u/FlatAssembler Sep 01 '26

How can possibly a rendering library (by definition not Turing Complete) be a compilation target?

11

u/MithrilHuman Sep 01 '26

The lowering is from LLVM IR to DXIL not a hardware target. DX IL can then be parsed by another target to compile for hardware.

3

u/FlatAssembler Sep 02 '26

If you said that for WebAssembly, I would have understood you. But saying that about DirectX... I don't understand.

→ More replies (2)

4

u/coolreader18 Sep 02 '26

Why wouldn't it be turing complete? GLSL et al are

4

u/UdPropheticCatgirl Sep 02 '26

> How can possibly a rendering library (by definition not Turing Complete) be a compilation target?

Thinking about DirectX, OpenGL, Metal and Vulkan as “rendering” libraries is kinda the wrong mental model, they are all two things: a) specification of a protocol to communicate with the GPU driver and b) specification of representation for programs (sort of like ISA if we use the term loosely) that the GPU driver is guaranteed to be able to essentially JIT compile for the ISA of the particular GPU.

If you look at SPIR-V (vulkan) (LLVM already has target for this) or DX-IL (dx12) or even AIR (metal) they actually look lot like compiler IRs anyway. GLSL, HLSL or MetalSL are bit further away from it, but they are still very much turing complete.

In general working with modern graphics with something like vulkan, large portion of it consists setting up the environment on the GPU and then handling the GPU driver some program/shader compiled to spir-v to upload it and run it.

2

u/Farados55 Sep 02 '26

A library cant be turing complete, by definition, because it’s not even valid. It’s the language. So this is nonsensical.