[llvm] [llvm] Move data layout string computation to TargetParser (PR #157612)

Rolf Morel via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 11 03:41:33 PDT 2025


rolfmorel wrote:

Great!

Though to check: this enables us to obtain the right data layout string (and in turn the DataLayout struct) from a triple. So w.r.t. https://github.com/llvm/llvm-project/pull/145899, this means that on the MLIR side we do not have to go through TargetMachine. It doesn't help with regard to the triples needing to be registered by the backends, right?

If so, on the MLIR side, I don't think this enables us to get rid of all the `AllTargets...` CMake targets in https://github.com/llvm/llvm-project/blob/9334ef98984f53f344cf5953ab74cdc29a0675de/mlir/lib/Target/LLVMIR/Transforms/CMakeLists.txt#L13-L16
and the request for backends to register their triples:
https://github.com/llvm/llvm-project/blob/94d5c54a4f63636b6ea2c49c385928dcfc08dd6d/mlir/lib/Target/LLVMIR/Transforms/TargetUtils.cpp#L25-L34

Also on the MLIR side, we now have https://github.com/llvm/llvm-project/pull/154938/files#diff-14efa88fcf2e1013f43154bb29e5f9e75d1b0e544ecebadaf2806a04729ec23aR47-R64, i.e. obtaining the right / default feature flags from a target triple & CPU string. It seems unavoidable that this goes through TargetMachine. Though here too, this information can/should be independent of codegen. It is probably harder to break this information out of the backends.

Does anybody have any suggestions for minimizing the dependencies for 

1. checking that a triple str & cpu str & features str combination is valid?
2. obtain the corresponding data layout?
3. minimize dependencies in case we are interested in obtaining info through the MCSubtargetInfo interface for target specified as a triple & cpu str & features str?

https://github.com/llvm/llvm-project/pull/157612


More information about the llvm-commits mailing list