[llvm] [DirectX] Move triple/DL compat to bitcode writer (PR #163587)
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 15 10:40:42 PDT 2025
================
@@ -1165,12 +1165,15 @@ void DXILBitcodeWriter::writeValueSymbolTableForwardDecl() {}
/// Returns the bit offset to backpatch with the location of the real VST.
void DXILBitcodeWriter::writeModuleInfo() {
// Emit various pieces of data attached to a module.
- if (!M.getTargetTriple().empty())
- writeStringRecord(Stream, bitc::MODULE_CODE_TRIPLE,
- M.getTargetTriple().str(), 0 /*TODO*/);
- const std::string &DL = M.getDataLayoutStr();
- if (!DL.empty())
- writeStringRecord(Stream, bitc::MODULE_CODE_DATALAYOUT, DL, 0 /*TODO*/);
+
+ // We need to hardcode a triple and datalayout that's compatible with the
+ // historical DXIL triple and datalayout from DXC.
+ StringRef Triple = "dxil-ms-dx";
+ StringRef DL = "e-m:e-p:32:32-i1:8-i8:8-i16:32-i32:32-i64:64-"
+ "f16:32-f32:32-f64:64-n8:16:32:64";
----------------
bogner wrote:
Yes, this is intentional. This datalayout matches what DXC emits exactly, whereas the other one is the datalayout we're using to manipulate the IR in modern LLVM. That is, here we have the `datalayout` from something like https://hlsl.godbolt.org/z/vv7rjf3GK, and the intent is to match the historical datalayout of dxc so as not to upset various graphics drivers.
https://github.com/llvm/llvm-project/pull/163587
More information about the llvm-commits
mailing list