[flang-commits] [flang] [flang] Updating drivers to create data layout before semantics (PR #73301)

Andrzej WarzyƄski via flang-commits flang-commits at lists.llvm.org
Sun Nov 26 12:23:43 PST 2023


banach-space wrote:

I've quickly scanned through and have one high level comment - would it be possible to keep the logic related to `TargetMachine` in `FrontendAction`?

This change is driven by the need to access `TargetMachine` during the semantic analysis. So, it makes to move `TargetMachine` from `CodeGenAction` somewhere higher up in the class hierarchy. As in, it's no longer a detail specific to `CodeGenAction`. However, this should be possible by moving it to the base class of `CodeGenAction` (shared with other actions that run semantic checks) rather than all the way to `CompilerInvocation`. 

One reason for this ask would be to make these changes less intrusive. But that's secondary. The main reason would be to stick to the original design principles behind these classes. `CompilerInvocation` merely represents ... the compiler invocation with all the options requested by the user and/or dictated by the environment (and a few other details). While `TargetMachine` can be configured based on some input from `CompilerInvocation`, it isn't really needed until the compiler is actually run - and that's represented/encapsulated by `FrontendAction` and its various sub-classes (e.g. `CodeGenAction`).

I think that my suggestion could be implemented by extracting `TargetMachine` logic out of `setUpTargetCharacteristics`? Hopefully that wouldn't be too much work. 

@jeanPerier would that still work for you? 

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


More information about the flang-commits mailing list