[LLVMdev] A question.

Gordon Henriksen gordonhenriksen at me.com
Mon Sep 22 14:12:43 PDT 2008


On Sep 22, 2008, at 13:36, 罗勇刚 wrote:

> I found that LLVM were using Binutils to assemble the Assembly Code  
> to the Machine Code, so I have a question, why LLVM don't direct  
> generate the machine code?

There was a protracted and rather uninteresting discussion of this  
matter on this list some months ago. I'll summarize the outcome of  
that thread briefly:

LLVM does generate machine code directly in the JIT.

For static compilation, no contributor has felt the need to eliminate  
the dependency on an external assembler. Why is this? First and  
foremost, an LLVM assembler would not materially advance the state of  
the art. At the same time, it would require significant platform- 
specific knowledge to author. It could easily constitute a  
considerable maintenance burden.

On Windows, where an assembler is not generally installed, a built-in  
assembler would be seen by some as a valuable component. However, when  
distributing a static compiler, bundling an assembler with it is a  
perfectly reasonable option. If GPL licensing is an issue, consult a  
lawyer. But I do observe that many closed-source compilers exist which  
use the system assembler, which is often gas.

There do exist partial implementations of direct machine code  
generators if you find this to be an area important enough to  
contribute. You can find them in lib/CodeGen/{ELF,MachO}Writer.cpp.

Please review the list archives if you want more detail.

-- Gordon





More information about the llvm-dev mailing list