# Intro to the LLVM MC Project

DevFeed: [Intro to the LLVM MC Project](<https://devfeed.tech/articles/intro-to-the-llvm-mc-project-42848.md>)

Original publisher: [Read original article](<https://blog.llvm.org/2010/04/intro-to-llvm-mc-project.html>)

Author: Chris Lattner

Published: 2010-04-09T23:27:00Z

Content type: article

Language: en

Sources: [The LLVM Project Blog](<https://devfeed.tech/sources/the-llvm-project-blog.md>)

Topics: [Assembly](<https://devfeed.tech/topics/assembly.md>), [LLVM](<https://devfeed.tech/topics/llvm.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>), [JIT](<https://devfeed.tech/topics/jit.md>), [cpu](<https://devfeed.tech/topics/cpu.md>), [x86](<https://devfeed.tech/topics/x86.md>)

Tags: [assembler](<https://devfeed.tech/tags/assembler.md>), [assembly](<https://devfeed.tech/tags/assembly.md>), [clang](<https://devfeed.tech/tags/clang.md>), [compilation](<https://devfeed.tech/tags/compilation.md>), [cpu](<https://devfeed.tech/tags/cpu.md>), [freebsd](<https://devfeed.tech/tags/freebsd.md>), [jit](<https://devfeed.tech/tags/jit.md>), [llvm](<https://devfeed.tech/tags/llvm.md>), [mc](<https://devfeed.tech/tags/mc.md>), [x86](<https://devfeed.tech/tags/x86.md>)

## AI overview

This article introduces LLVM's Machine Code (MC) project, explaining its history, integration with assembly and disassembly tooling, object file handling, and relationship to static and JIT compilation. It describes the project's goals, capabilities, and current status.

## Source excerpt

The LLVM Machine Code (aka MC) sub-project of LLVM was created to solve a number of problems in the realm of assembly, disassembly, object file format handling, and a number of other related areas that CPU instruction-set level tools work in. It is a sub-project of LLVM which provides it with a number of advantages over other compilers that do not have tightly integrated assembly-level tools. This blog post talks about how the MC project evolved, describes a few different aspects of it , talks about the improvements/capabilities it brings to LLVM, and finishes off with the current status of the project. History and Background Before MC came around, LLVM was already a mature compiler system that support both static compilation (through a normal assembler) and as well as JIT compilation (which emitted encoded instruction bytes directly to memory) on many different targets and sub-targets. However, despite these capabilities, the implementation of these subsystems was not designed wonderfully: why should the X86 instruction encoder (used by the JIT) have to know how to encode the weird pseudo instructions that the X86 code generator uses for its convenience? Why was this code emitter specific to the one code model used by the JIT? Beyond lack of elegance, it has been a goal for quite a while (for example, see Bruno's 2009 devmtg talk) to directly integrate an assembler into the compiler. Doing so would solve a number of problems: For fast compiles, it is incredibly wasteful for the compiler to carefully format a massive text file, then fork/exec an assembler, which then has to lex/parse/validate the file. In fact, since the rest of Clang is so fast, the assembler takes ~20% of compile time for C code at -O0 -g. In addition to winning back this performance, not relying on an external assembler is attractive for several other reasons: the compiler doesn't have to worry about lots of different buggy assemblers which have similar but inconsistent syntax, Windows users typi