This is an archive of the discontinued LLVM Phabricator instance.

[flang][nfc] Clarify the frontend/backend distinction
AcceptedPublic

Authored by awarzynski on Dec 10 2021, 8:26 AM.

Details

Summary

This addition was requested in #1262. It probably makes more sense to add to the driver documentation rather than somewhere inside the code.

Does this make sense? Thank you!

Diff Detail

Event Timeline

awarzynski created this revision.Dec 10 2021, 8:26 AM
Herald added a project: Restricted Project. · View Herald Transcript
awarzynski requested review of this revision.Dec 10 2021, 8:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 10 2021, 8:26 AM

IMHO, MLIR is part of the mid-end/optimizer. From a conceptual point, drawing the line between LLVM-IR and MLIR is arbitrary, and optimizations are done on the MLIR/FIR-level as well. Eg. Open64 has six different intermediate representations. "all the stages implemented in the Flang sub-project" is also blurry since MLIR other than the FIR dialect is not part of the flang project. Consistency with Clang can also not claimed since Clang has no MLIR or language-specific IR stage.

Generally, I'd prefer to introduce different meanings for front-end/mid-end/back-end for different parts. IMHO renaming EmitObjAction to BackendAction is still fine since emitting assembly and object code both go through the actual LLVM backends.

flang/docs/FlangDriver.md
340

I think the doc uses American English

PeteSteinfeld accepted this revision.Dec 10 2021, 11:15 AM

Aside from a couple of nits, looks good to me. Thanks for doing this.

flang/docs/FlangDriver.md
360

I think you mean "may refer" rather than "my refer".

361

In American English, at least, the usual phrase is "distinction between" rather than "distinction into".

This revision is now accepted and ready to land.Dec 10 2021, 11:15 AM

I agree with the comment that calling MLIR and/or FIR a "front end" is arbitrary and, I suspect, mostly based on a directory structure.

In the flang project/directory, there is a pretty clear and obvious distinction between the front end of parsing and semantics checking and the high-level semantic representation of FIR and optimizations. Indeed the distinction between these in the vernacular of the Flang project is "front end" vs. "lowering" or "optimizer". Flang has an Optimizer directory, mostly upstreamed, of its own, so the definitions given here seem confusing. In short, LLVM target independent optimizations won't be the only optimizations and do not define the entirety of "the optimizer" for Flang. (For completeness, the LLVM target independent optimizations and code generation parts are often referred to as "the backend" in Flang.)

flang/docs/FlangDriver.md
350

optimizer. You'll want to search and replace as both the British 's' and the American 'z' are used here.

361

backaned / backend

I agree with the comment that calling MLIR and/or FIR a "front end" is arbitrary and, I suspect, mostly based on a directory structure.

In the flang project/directory, there is a pretty clear and obvious distinction between the front end of parsing and semantics checking and the high-level semantic representation of FIR and optimizations. Indeed the distinction between these in the vernacular of the Flang project is "front end" vs. "lowering" or "optimizer". Flang has an Optimizer directory, mostly upstreamed, of its own, so the definitions given here seem confusing. In short, LLVM target independent optimizations won't be the only optimizations and do not define the entirety of "the optimizer" for Flang. (For completeness, the LLVM target independent optimizations and code generation parts are often referred to as "the backend" in Flang.)

Eric hints at the fact that it would be good for the high-level description of the compiler to mimic the structure of the code.