9

I have tried the LLVM demo from Try out LLVM and Clang in your browser!.

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 information for dependence analysis. Hence can it be an HIR?

What filename extension actually represents the LLVM IR, .ll or .bc?

How can I get the symbol table used in LLVM?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ViG
  • 455
  • 5
  • 8
  • http://llvm.org/docs/LangRef.html – CAFxX Oct 17 '12 at 08:13
  • Files with textual representation of LLVM IR have `.ll` extension, binary one - `.bc` – arrowd Oct 17 '12 at 09:41
  • What are HIR, MIR, and LIR? – Peter Mortensen Oct 28 '22 at 15:08
  • HIR = high-level [intermediate representation](https://en.wikipedia.org/wiki/Intermediate_representation). MIR = mid-level intermediate representation. LIR = low-level intermediate representation. [MLIR](https://blog.tensorflow.org/2019/04/mlir-new-intermediate-representation.html) = multi-level intermediate representation. [Some elaboration](https://www.reddit.com/r/rust/comments/8d9i32/hir_vs_mir_vs_lir/) (but note some of the links are broken). – Peter Mortensen Oct 28 '22 at 15:24
  • And [VLIR](https://www.ida.liu.se/~chrke55/courses/ACC/PDF-2012/F1-Multilevel-IR.pdf) = very low-level intermediate representation – Peter Mortensen Oct 28 '22 at 16:09

1 Answers1

8

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.

Oak
  • 26,231
  • 8
  • 93
  • 152