This is an archive of the discontinued LLVM Phabricator instance.

[DirectX] Add DXILAsmPrinter
ClosedPublic

Authored by beanz on Jun 6 2022, 2:18 PM.

Details

Summary

The DXILAsmPrinter will just write globals into sections, so the
DXILAsmPrinter only needs support for emitting global variables, and is
otherwise a stub.

Depends on D127147

Diff Detail

Event Timeline

beanz created this revision.Jun 6 2022, 2:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 6 2022, 2:18 PM
beanz requested review of this revision.Jun 6 2022, 2:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 6 2022, 2:18 PM
kuhar added a comment.Jun 6 2022, 7:52 PM

Would it be possible to test this as-is, or are other changes necessary to meaningfully exercise this code?

beanz added a comment.Jun 7 2022, 7:15 AM

Would it be possible to test this as-is, or are other changes necessary to meaningfully exercise this code?

Sadly no. Until there is an object streamer in place, the ASMPrinter doesn't have anywhere to write to. I had considered getting the DirectX backend to emit dxil into an existing object file format, however the changes to make that work are also significant and would be removed promptly in subsequent commits.

Is this the only thing the Asm Printer will ever do? Does it mean you'll never emit asm files or is there another way to get it out (and if there is, why aren't the constants there, too)?

beanz added a comment.Jun 9 2022, 8:30 AM

At least for DXIL, the assembly is just LLVM IR, so we use the IR printer. I'm modeling how we put bitcode into the final object off how we embed bitcode in other object formats, so the AsmPrinter really only needs to be able to emit globals into sections.

Eventually I hope to add DXBC support to the DirectX target too. DXBC is much more like a virtual ISA, and it will have a more functional ASM printer.

I don't know much about DirectX but I'm assuming all of those (what, dialects?) will be coming through the same printers/parsers, right?

beanz added a comment.Jun 9 2022, 8:43 AM

My intent was to do a separate parser & printer for DXBC (DirectX byte code) when we get there. The final output has very little in common with DXIL (DirectX Intermediate Language) other than the binary container format, but the intrinsics, lowering paths, and some optimizations will be shared. My plan is to treat them as different architectures coming out of the same target.

For DXIL, handling asm files is going to just be wrapping around the LLVM IR parser and printer, but we need some stubs to emit into object files so the MC layer doesn't get upset. For DXBC we'll eventually need a proper parser & printer and will add full support through MC.

beanz added a comment.Jun 16 2022, 9:22 AM

@rengolin are you okay with this as-is or are there any changes you would suggest or request?

rengolin accepted this revision.Jun 16 2022, 9:35 AM

No requests, this looks simple enough for me, thanks!

This revision is now accepted and ready to land.Jun 16 2022, 9:35 AM
This revision was automatically updated to reflect the committed changes.