[coreboot] log2c, log2f and fms

ron minnich rminnich at gmail.com
Thu Sep 4 17:42:40 CEST 2008

On Thu, Sep 4, 2008 at 8:08 AM, Carl-Daniel Hailfinger
<c-d.hailfinger.devel.2006 at gmx.net> wrote:
> Hi,
> unless I'm mistaken, the fms() function is equivalent to log2f(), but
> the former is in asm while the latter is in C.

Let's get rid of fms then.

> Generally, I'd like to have a libmath.c with all these mathematical
> functions. Having a file only for log2 variants is not exactly the most
> optimal tree organization.
> How do we treat functions which have an optimized asm version but also
> exist as C code?
> - Weak functions?
> - Macro tricks like #ifdef _HAVE_ARCH_LOG2C ?
> - Kill the optimized asm completely?

(3). If you can do it in C, then asm goes away. I'd like to shoot all
asm in the head.

Also, please, let's minimize code in .h files. It just adds to (my)
the confusion :-)

The type of gratuitous use of assembly we sometimes see is Clever. This:
has an important point about Clever:

"# Try not to write clever code. Try to write well-organized code."

"# Inevitably, you will write clever, poorly-organized code. If
someone comes along asking questions about it, use that as a sign that
perhaps the code is probably too clever or not well enough organized.
Rewrite it to be simpler and easier to understand."

"# Avoid voodoo code. "

optimizing log2 in assembly when we call it almost never is, well,
Clever. Let's avoid it.


More information about the coreboot mailing list