2 answers
This is a virtual machine. It includes:
- set of instructions for building bytecode
- bytecode generation toolkit
- bytecode toolkit
To try llvm on Ubuntu , you can build and run a simple sample.c example.
#include <stdio.h> int main() { printf("sample\n"); return 0; }
Assembly.
clang sample.c -S -emit-llvm
File sample.ll (with abbreviations).
; ModuleID = 'sample.bc' target datalayout = "..." target triple = "i386-linux-gnu" @.str = private constant [7 x i8] c"sample\00", align 1 ; <[7 x i8]*> [#uses=1] define i32 @main() nounwind { entry: %0 = tail call i32 @puts(i8* getelementptr inbounds ([7 x i8]* @.str, i32 0, i32 0)) nounwind ; <i32> [#uses=0] ret i32 0 } declare i32 @puts(i8* nocapture) nounwind
Run
clang sample.c -c -emit-llvm lli sample.bc
- To edit, please, LLVM is not a virtual machine. An excerpt from the first paragraph of the official website:
Despite its name, LLVM has little to do with traditional virtual machines. The name "LLVM" itself is not an acronym; it is the full name of the project.
Despite its name, LLVM has little to do with traditional virtual machines. The name "LLVM" itself is not an acronym; it is the full name of the project.
- AlexDenisov - Yes, and not
байткод
there of course, but aбиткод
- AlexDenisov
I want to add to the answer that not only the byte code is generated, but also compiled into executable machine code on almost all types of processors and on almost all types of OS.
LLVM allows you to choose which code to generate.
LLVM generates intermediate assembler-like code to analyze what your high-level code is written in C, C ++, Fortran, Ada, etc.
Saw and JAVA, Python, Ruby ie LLVM makes it possible to write on whatever you want, and what you want by getting a very high-speed code that can still be optimized at the Assembler level.
The project is supported by such giants as ... and you already know from Wikipedia.