<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/mlir/lib/Conversion/MathToEmitC/MathToEmitC.cpp, branch main</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>[mlir][EmitC] Add MathToEmitC pass for math function lowering to EmitC (#113799)</title>
<updated>2025-01-20T08:26:41+00:00</updated>
<author>
<name>Tomer Solomon</name>
<email>tomsol2009@gmail.com</email>
</author>
<published>2025-01-20T08:26:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=c0055ec434cbb132d7776f8b4c39e99b69fa97ea'/>
<id>c0055ec434cbb132d7776f8b4c39e99b69fa97ea</id>
<content type='text'>
This commit introduces a new MathToEmitC conversion pass that lowers
selected math operations from the Math dialect to the emitc.call_opaque
operation in the EmitC dialect.

**Supported Math Operations:**
The following operations are converted:

- math.floor -&gt; emitc.call_opaque&lt;"floor"&gt;
- math.round -&gt; emitc.call_opaque&lt;"round"&gt;
- math.exp -&gt; emitc.call_opaque&lt;"exp"&gt;
- math.cos -&gt; emitc.call_opaque&lt;"cos"&gt;
- math.sin -&gt; emitc.call_opaque&lt;"sin"&gt;
- math.acos -&gt; emitc.call_opaque&lt;"acos"&gt;
- math.asin -&gt; emitc.call_opaque&lt;"asin"&gt;
- math.atan2 -&gt; emitc.call_opaque&lt;"atan2"&gt;
- math.ceil -&gt; emitc.call_opaque&lt;"ceil"&gt;
- math.absf -&gt; emitc.call_opaque&lt;"fabs"&gt;
- math.powf -&gt; emitc.call_opaque&lt;"pow"&gt;

**Target Language Standards:**
The pass supports targeting different language standards:

- C99: Generates calls with suffixes (e.g., floorf, fabsf) for
single-precision floats.
- CPP11: Prepends std:: to functions (e.g., std::floor, std::fabs).

**Design Decisions:**
The pass uses emitc.call_opaque instead of emitc.call to better emulate
C-style function overloading.
emitc.call_opaque does not require a unique type signature, making it
more suitable for operations like &lt;math.h&gt; functions that may be
overloaded for different types.
This design choice ensures compatibility with C/C++ conventions.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit introduces a new MathToEmitC conversion pass that lowers
selected math operations from the Math dialect to the emitc.call_opaque
operation in the EmitC dialect.

**Supported Math Operations:**
The following operations are converted:

- math.floor -&gt; emitc.call_opaque&lt;"floor"&gt;
- math.round -&gt; emitc.call_opaque&lt;"round"&gt;
- math.exp -&gt; emitc.call_opaque&lt;"exp"&gt;
- math.cos -&gt; emitc.call_opaque&lt;"cos"&gt;
- math.sin -&gt; emitc.call_opaque&lt;"sin"&gt;
- math.acos -&gt; emitc.call_opaque&lt;"acos"&gt;
- math.asin -&gt; emitc.call_opaque&lt;"asin"&gt;
- math.atan2 -&gt; emitc.call_opaque&lt;"atan2"&gt;
- math.ceil -&gt; emitc.call_opaque&lt;"ceil"&gt;
- math.absf -&gt; emitc.call_opaque&lt;"fabs"&gt;
- math.powf -&gt; emitc.call_opaque&lt;"pow"&gt;

**Target Language Standards:**
The pass supports targeting different language standards:

- C99: Generates calls with suffixes (e.g., floorf, fabsf) for
single-precision floats.
- CPP11: Prepends std:: to functions (e.g., std::floor, std::fabs).

**Design Decisions:**
The pass uses emitc.call_opaque instead of emitc.call to better emulate
C-style function overloading.
emitc.call_opaque does not require a unique type signature, making it
more suitable for operations like &lt;math.h&gt; functions that may be
overloaded for different types.
This design choice ensures compatibility with C/C++ conventions.</pre>
</div>
</content>
</entry>
</feed>
