Questions tagged [intermediate-language]

An intermediate language, in compiler design, is a low-level language that typically resembles an idealized assembly language, often a textual representation of bytecode for a virtual machine. For .NET's CIL, use the [cil] tag.

An intermediate language, in compiler design, is a translation stage after the syntax tree and before the machine code. The term is usually used for final stages of the translation, after high-level optimizations have been performed, but at a stage when the translation is still independent of the target machine.

In particular, “intermediate language” often means a low-level, assembly-like language for a virtual machine such as the JVM, .NET, Prolog's WAM, etc.

For example, the .NET Common Intermediate Language is the assembly language for the virtual machine that is the target of and other compilers.

144 questions
1
vote
1 answer

How to represent structure in a C like language in 3-address code?

What is the three address code IR for a C code-snippet declaring a structure? struct name{ char c; int i; }
1
vote
1 answer

What are those symbols in IL code?

What is this symbol ( IL_0000 etc) in the IL code. its this the real memory heap address? IL_0000: nop IL_0001: ldstr "here is something" IL_0006: call void [mscorlib]System.Console::WriteLine(string) IL_000b: nop IL_000c: …
RollRoll
  • 8,133
  • 20
  • 76
  • 135
1
vote
3 answers

Mechanism to extract specific IL (.NET Intermediate Language) signatures from an assembly

I have a list of about 25 types found in the Microsoft .NET assembly mscorlib.dll where I need to extract the IL signatures of the class and its members. I want one file per type, with each signature on one line. So, for example, take the…
Joel Marcey
  • 1,748
  • 14
  • 13
1
vote
1 answer

Three-address code and symbol tables

I am working on a hobby retargetable C compiler in OCaml and I'm building it bottom up. So far I have an annotated AST type, abridged: type 'e expr = | Int of 'e * int | Var of 'e * var | Neg of 'e * 'e expr | Add of 'e * 'e expr *…
1
vote
0 answers

Intermediate code to target code emulator

I've been working on a compiler for an object oriented language called Cool (Classroom Object Oriented Language). I need to choose an intermediate code representation now. I was thinking maybe p-code or three address-code. For code generation, as…
1
vote
2 answers

Variable comparison

The following C#-snippet: var x = 1; var y = 1; if (x == y) Console.Write("True"); Generates this MSIL: .locals init ( [0] int32 x, [1] int32 y, [2] bool CS$4$0000) L_0000: nop L_0001: ldc.i4.1 L_0002:…
alexn
  • 57,867
  • 14
  • 111
  • 145
1
vote
3 answers

Are there alternate libraries to LLVM that are built for compiling a specific IR to architecture specfic code?

I'm asking if there are libraries that provide a specification for the IR that they require and provide programs for compiling a file containing that IR down to machine code. The reasons I don't want to use LLVM are: I want to write the code that…
kjh
  • 3,407
  • 8
  • 42
  • 79
1
vote
2 answers

How to estimate a variable's value with static analysis?

I want to write a program to do this, based on Soot's build-in Reaching-Definition analysis. Now I'm wondering is this the correct approach? I searched and found nobody seems to ever be interested in this direction. Any suggestions?
Elderry
  • 1,902
  • 5
  • 31
  • 45
1
vote
1 answer

Field getter using Reflection.Emit Opcodes - usage of IL local variables

I'm learning IL and I thought of writing kind of a high-performance hack to access a field values of any object (like a reflection but faster). So I made this class for testing: public class CrashTestDummy { public int Number { get; set; } …
1
vote
3 answers

Advantage of intermediate representations after compilation

Whats the point of having an intermediate representation after compilation (for eg Java has bytecode) if you still have to design a separate software (JVM in this case) for every platform ? I mean platform dependency is still there!!
ishan3243
  • 1,870
  • 4
  • 30
  • 49
1
vote
1 answer

Larger .maxstack when not storing a reference?

I am no IL master of any sort, I just use it sometimes to check what the compiler makes of the code that I write. One thing that I have been wondering about is why .maxstack gets the value it gets sometimes. Consider the following class: public…
Fredrik Mörk
  • 155,851
  • 29
  • 291
  • 343
1
vote
0 answers

Is it possible to execute a gcc .ssa file directly? If not, how to compile?

This question is a bit quaint, but I'm having difficulty finding the answer in this section of the manual. If I dump the SSA of a C program into a file, like: ~$ gcc -fdump-tree-ssa program_name.c How do I execute from the ssa intermediate…
d0rmLife
  • 4,112
  • 7
  • 24
  • 33
1
vote
2 answers

Converting a CFG to IL

I build a CFG out of an arbitrary IL and want to convert that CFG back to IL. The order of the vertices in the CFG is of course not equal to the order of the original IL instructions. This is fine but overcomplicates some stuff. Imagine: Jump…
Joa Ebert
  • 6,565
  • 7
  • 33
  • 47
1
vote
1 answer

Does PL/SQL perform tail call optimization?

I'm fairly new to the language, and I was wondering if tail calls were optimized. In other language I could examinate the machine code or an intermediate representation and figure it for myself but I have no idea about how to do that in…
0
votes
1 answer

Logical expressions and intermediate code generation

I managed to get the lexer, syntax checker and semantics and now I want to move on intermediate code generation. The problem is that i don't know how to handle logical expressions. I read something about E.true and E.false. This example is…