Services and Modeling for Embedded Software Development
Embecosm divider strip
Prev  Next

Chapter 2. Integrated Assembler within LLVM

2.1. llvm-mc

The integrated assembler when used with the rest of the LLVM system allows source to be compiled directly to a native object file without the need of outputting assembly instructions to a file and then parsing them back in order to encode them.

This provides the benefit of faster compiling, and when combined with the C language compiler clang, allows C/C++ to native object file compilation in one step ready for linking.

This application note focuses on the LLVM assembler in the case where its intended use is as part of the clang C compiler. As such, assembly parsing, encoding and decoding is restricted to the case where purely instructions are given to the llvm-mc tool described below. It is however possible to extend the assembler to accept and reconstruct assembly directives, allowing llvm-mc to behave more like a standalone compiler.

No special steps/changes are required to allow clang to use the integrated assembler, once it is set up and functioning, it can be invoked by using the -integrated-as as one of the arguments, alongside with the target architecture, as demonstrated below.

clang -target or1k -O3 -integrated-as helloworld.c
Embecosm divider strip