# \[LLVM Flang\] Code gen option: \`-emit-fir\` vs \`-emit-mlir\`

**URL:** <https://discourse.llvm.org/t/llvm-flang-code-gen-option-emit-fir-vs-emit-mlir/58894>\
**Category:** Flang\
**Created:** [September 9, 2021, 2:03pm UTC](https://discourse.llvm.org/t/llvm-flang-code-gen-option-emit-fir-vs-emit-mlir/58894 "2021-09-09T14:03:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![banach-space](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/banach-space/32/209_2.png) [@banach-space](https://discourse.llvm.org/u/banach-space)\
**Post date:** [September 9, 2021, 2:03pm UTC](https://discourse.llvm.org/t/llvm-flang-code-gen-option-emit-fir-vs-emit-mlir/58894/1 "2021-09-09T14:03:14Z")

</div>

Hello,

We have recently started working on adding code-gen support in the Flang driver. Our first PR is available on GitHub [1] and implements the "parse tree --\> MLIR" step.

What should be the corresponding option in `flang-new`? `bbc` uses `-emit-fir` [2], but `-emit-mlir` would probably be more accurate. Indeed, currently the generated output uses multiple MLIR dialects (rather than just FIR).

Please comment either here or on GitHub.

Thank you,  
-Andrzej

[1] [https://github.com/flang-compiler/f18-llvm-project/pull/1008](https://github.com/flang-compiler/f18-llvm-project/pull/1008)  
[2] [https://github.com/flang-compiler/f18-llvm-project/blob/fir-dev/flang/tools/bbc/bbc.cpp#L87-L90](https://github.com/flang-compiler/f18-llvm-project/blob/fir-dev/flang/tools/bbc/bbc.cpp#L87-L90)

---

<div class="post-metadata">

**Author:** ![AlexisPerry](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/alexisperry/32/1999_2.png) [@AlexisPerry](https://discourse.llvm.org/u/AlexisPerry)\
**Post date:** [September 9, 2021, 3:22pm UTC](https://discourse.llvm.org/t/llvm-flang-code-gen-option-emit-fir-vs-emit-mlir/58894/2 "2021-09-09T15:22:52Z")

</div>

Hi Andrzej,

For my two cents, I have a mild preference for -emit-fir. When I see -emit-mlir I think it implies that only the standard dialect will be present (i.e. no fir in there). That could just be me though. Like I said, mine is a mild preference and switching wouldn't cause me much issue.

-- Alexis

---

<div class="post-metadata">

**Author:** ![mehdi\_amini](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/mehdi_amini/32/25595_2.png) [@mehdi\_amini](https://discourse.llvm.org/u/mehdi_amini)\
**Post date:** [September 9, 2021, 4:01pm UTC](https://discourse.llvm.org/t/llvm-flang-code-gen-option-emit-fir-vs-emit-mlir/58894/3 "2021-09-09T16:01:14Z")

</div>

> Hi Andrzej,
> 
> For my two cents, I have a mild preference for -emit-fir. When I see -emit-mlir I think it implies that only the standard dialect will be present (i.e. no fir in there).

FYI: the standard dialect is shrinking and the goal is for it to disappear entirely.

---

<div class="post-metadata">

**Author:** ![AlexisPerry](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/alexisperry/32/1999_2.png) [@AlexisPerry](https://discourse.llvm.org/u/AlexisPerry)\
**Post date:** [September 9, 2021, 4:13pm UTC](https://discourse.llvm.org/t/llvm-flang-code-gen-option-emit-fir-vs-emit-mlir/58894/4 "2021-09-09T16:13:08Z")

</div>

Interesting, I did not know that. In light of this new information, perhaps -emit-mlir does fit better.

---

<div class="post-metadata">

**Author:** ![banach-space](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/banach-space/32/209_2.png) [@banach-space](https://discourse.llvm.org/u/banach-space)\
**Post date:** [September 9, 2021, 7:10pm UTC](https://discourse.llvm.org/t/llvm-flang-code-gen-option-emit-fir-vs-emit-mlir/58894/5 "2021-09-09T19:10:44Z")

</div>

Thank you both for your comments! One other minor point in favour of `-emit-mlir` - `bbc` already uses `mlir` for file extensions.

-Andrzej
