<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="246827" data-post-id="246827">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jackalcooper" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jackalcooper/120/5647_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jackalcooper
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Is it possible to get this SSA IR of an Elixir module?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="246827" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/decompile-beam-files-to-elixir-source-code/14081/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-246827" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="246827"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="246852" data-post-id="246852">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="al2o3cr" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/al2o3cr/120/3457_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  al2o3cr
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>It’s possible to generate it for an Elixir file using <code>@compile</code> (tip from <a href="https://github.com/elixir-lang/elixir/issues/2665" rel="nofollow">this issue</a>):</p>
<pre data-code-wrap="elixir"><code class="lang-elixir"># in foo.ex
defmodule Foo do
  @compile :dprecg

  def foo(a, b) do
    a + b
  end
end
</code></pre>
<p>then compiling with <code>elixir foo.ex</code> complains:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">$ elixir foo.ex
** (CompileError) foo.ex: could not compile module Foo. We expected the compiler to return a .beam binary but got something else. This usually happens because ERL_COMPILER_OPTIONS or @compile was set to change the compilation outcome in a way that is incompatible with Elixir
</code></pre>
<p>but <em>does</em> produce a <code>foo.ex.precodegen</code> file:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir"># foo.ex.precodegen
module 'Elixir.Foo'.
exports [{'__info__',1},{foo,2},{module_info,0},{module_info,1}].
attributes [].

%% Counter = 16
function `'Elixir.Foo'`:`'__info__'`(x0/_0) {
  %% _0: 0..1 0..2 10..11 14..15
0:
  [1] switch x0/_0, ^3, [
    { `attributes`, ^13 },
    { `compile`, ^13 },
    { `deprecated`, ^8 },
    { `exports_md5`, ^10 },
    { `functions`, ^9 },
    { `macros`, ^8 },
    { `md5`, ^13 },
    { `module`, ^7 }
  ]

7:
  [3] ret `'Elixir.Foo'`

9:
  [5] ret `[{foo,2}]`

10:
  [7] ret `&lt;&lt;63,179,243,139,216,207,23,209,142,119,33,235,17,74,57,60&gt;&gt;`

8:
  [9] ret `[]`

13:
  %% @ssa_ret:6: 11..13
  [11] x0/@ssa_ret:6 = call (`erlang`:`get_module_info`/2), `'Elixir.Foo'`, x0/_0
  [13] ret x0/@ssa_ret:6

3:
  %% @ssa_ret:14: 15..17
  [15] x0/@ssa_ret:14 = match_fail `function_clause`, x0/_0
  [17] ret x0/@ssa_ret:14
}

%% foo.ex:4
%% Counter = 4
function `'Elixir.Foo'`:`foo`(x0/_0, x1/_1) {
  %% _0: 0..1
  %% _1: 0..1
0:
  %% foo.ex:5
  %% _2: 1..7
  [1] x0/_2 = bif:'+' x0/_0, x1/_1

  %% @ssa_bool: 3..5
  [3] z0/@ssa_bool = succeeded x0/_2
  [5] br z0/@ssa_bool, ^3, ^1

3:
  [7] ret x0/_2

1:
  %% @ssa_ret: 9..11
  [9] x0/@ssa_ret = call (`erlang`:`error`/1), `badarg`
  [11] ret x0/@ssa_ret
}

%% Counter = 4
function `'Elixir.Foo'`:`module_info`() {
0:
  %% @ssa_ret:3: 1..3
  [1] x0/@ssa_ret:3 = call (`erlang`:`get_module_info`/1), `'Elixir.Foo'`
  [3] ret x0/@ssa_ret:3
}

%% Counter = 4
function `'Elixir.Foo'`:`module_info`(x0/_0) {
  %% _0: 0..1
0:
  %% @ssa_ret:3: 1..3
  [1] x0/@ssa_ret:3 = call (`erlang`:`get_module_info`/2), `'Elixir.Foo'`, x0/_0
  [3] ret x0/@ssa_ret:3
}
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="246852" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/decompile-beam-files-to-elixir-source-code/14081/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-246852" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="246852"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="246885" data-post-id="246885">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="olafura" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/olafura/120/12420_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  olafura
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Of course but the further you get away from something similar to Erlang the harder it is to have Elixir code that makes sense. That is why I choose to translate the Erlang AST to Elixir and even then there are some things that is hard to create nice code from.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="246885" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/decompile-beam-files-to-elixir-source-code/14081/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-246885" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="246885"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="246895" data-post-id="246895">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jackalcooper" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jackalcooper/120/5647_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jackalcooper
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Agree. What I want to explore is to represent the Erlang SSA IR in MLIR. So that I can lower it to LLVM and further anything LLVM supports.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="246895" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/decompile-beam-files-to-elixir-source-code/14081/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-246895" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="246895"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>