Re: a modest proposal



Craig Powers wrote:
.... Inline asm is where
you have a snippet of code written asm embedded in the body of code written in some other language. I'd expect it to only be applicable in two cases: first, writing low-level code (like a device driver), and second, where something can be hand-optimized in asm better than the compiler's own optimizer.

Count me as dubious.

With a general asm facility, the compiler has to first save all the
registers and whatnot into some known state. And afterwards, it has
to reload them all. Just like an ordinary procedure call. So it seems
like for short snippets of asm code, you pay a larger price than it may
be worth. For longer code sequences, why bother with inline code?
Just make them self-contained asm procedures.

If there are a few useful machine instructions that the compiler is
incapable of generating, then a set of cpu-specific intrinsic functions
seems like the Right Way to go. The compiler can 'inline' the desired
instruction and optimize its integration into the surrounding code. Many
compilers have used this technique over the past few decades with good
results.

W.
.



Relevant Pages

  • Re: a modest proposal
    ... where something can be hand-optimized in asm better than the ... why bother with inline code? ... This enabled the compiler to use the assembly snippet just like any ...
    (comp.lang.fortran)
  • new codegen thoughts...
    ... C was parsed into an XML-based AST; ... the ASM was assembled and linked. ... compiler frontend to the codegen to make this work). ... CPU registers will be mapped to the tvars behind the scenes (the AST ...
    (comp.compilers)
  • optimizers are overrated
    ... I started learning ASM not long ago to improve my understanding of the ... The first function uses a typical C style loop to ... which one is more efficient all you guys would reply "the compiler will most ... so my "write C like ASM" optimization worked. ...
    (comp.lang.c)
  • Re: Hiring Advice
    ... I still need to know ASM or at least know how to read ... what the Compiler does to figure out what went wrong. ... If, instead, you stuff all your globals into a struct, then the compiled code only fetches the base address from the constant pool once, then uses the free constant offset to get to the individual parts. ... And so the idea that you can get away without any ability to work at the assembly level is worrisome, and that the schools seem to be teaching it now as a given even more so. ...
    (comp.arch.embedded)
  • Re: Hiring Advice
    ... Ability to work in assembly for at least one processor preferred. ... I still need to know ASM or at least know how to read ... what the Compiler does to figure out what went wrong. ... If, instead, you stuff all your globals ...
    (comp.arch.embedded)