Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is LLVM Intermediate representation?

I have tried the LLVM demo from the link http://llvm.org/demo/ What kind of IR is this? HIR, MIR or LIR? The SSA representation is usually used in MIR, I think. So, is it an MIR? But it can store the informations for dependence analysis. Hence can it be an HIR?

What file extention actually represent the LLVM IR, .ll or .bc?

How can I get the symbol table used in LLVM?

like image 272
ViG Avatar asked Oct 17 '12 07:10

ViG


People also ask

What is an LLVM IR?

LLVM IR is a low-level intermediate representation used by the LLVM compiler framework. You can think of LLVM IR as a platform-independent assembly language with an infinite number of function local registers.

Is LLVM IR stable?

Answer to your first question: No. It's not stable.

Is LLVM IR target independent?

LLVM IR aims to be a universal IR of a kind, by being at a low enough level that high-level ideas may be cleanly mapped to it. Ideally the LLVM IR should have been target-independent, but it is not so because of the inherent target dependence in some of the programming languages itself.

Is LLVM IR a programming language?

LLVM IR is a simple language designed for compiler engineers. I think of it like a blank slate for them to write on. Most LLVM instructions are quite simple and easy to understand; as we saw above, understanding the basic syntax of the call instruction wasn't hard at all.


1 Answers

I'm not familiar with a single, strict definition of what differentiates one level of IR from another, but from what I know it would fall under the MIR category.

  • It has SSA form and doesn't have explicit registers, so I would definitely not categorize it as low-level.
  • It doesn't have named subelement reference or advanced flow-control constructs, so it wouldn't really fit into HIR, either.

In any case, LLVM IR is typically stored on disk in either text files with .ll extension or in binary files with .bc extension. Conversion between the two is trivial, and you can just use llvm-dis for bc -> ll and llvm-as for ll -> bc. The binary format is more memory-efficient, while the textual format is human-readable.

like image 173
Oak Avatar answered Oct 23 '22 16:10

Oak