Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

222
Vistas
Is LLVM IR a machine independent language?

When I was reading LLVM IR code (transformed from C), I saw an instruction like this:

%div = sdiv i32 %add, %32

The C code of this instruction may be like this:

a = c / b;

We can see that there is a type i32 in this instruction. This is because of the type of variables a, b, c are int. And my computer is x86.

Now, if I have a machine where the integer is about 8 bits and I write the C code same as above and transform C to LLVM IR on this machine, the LLVM IR instruction might be %div = sdiv i8 %add, %32.

Is this right? If yes, how can we say that the LLVM IR is a machine independent language?

I thought that if a piece of code is in a machine independent language, then this code can run on any machine in this world, and when the code is running, the virtual machine or other things will handle the differences between architectures.

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

Yes, LLVM IR is a machine independent language.

But the IR code could not be run directly on real hardware. In order to run the IR code, a retarget process is needed. During 'retarget', the machine independent IR code is translated to machine dependent code for the target(x86, MIPS, aarch, 8bit chip and so on).

over 4 years ago · Santiago Trujillo Denunciar

0

LLVM IR is a machine independent language, but that's not enough for machine independent programs. Programs require more than just a language. LLVM has classes called TargetMachine and DataLayout, for example, that collect target-specific details such as how structs are laid out in memory and whether pointers to odd-numbered addresses are legal. You'll often see code in that machine-independent language using target-dependent numbers. On this platform the code adds 4, on that other, 8.

But in both cases the language is the same and the add instruction is the same, which simplifies life for compiler maintainers.

over 4 years ago · Santiago Trujillo Denunciar

0

Is LLVM IR a machine independent language?

If you compile source code that was written in assembly language (e.g. inline assembly) it can't be machine independent.

Therefore LLVM is machine independent (for most things) and also machine dependent (for assembly language).

Note that if you look at the LLVM reference (e.g. http://web.cs.ucla.edu/classes/spring08/cs259/llvm-2.2/docs/LangRef.html#inlineasm ) you'll see that assembly language mostly becomes/remains plain text (not byte-code, not machine code). It's the contents of the plain text that's machine dependent (for the instructions themselves, and the constraints, etc).

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda