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
2
votes
1 answer

Efficiency of load-value instructions versus load-address instructions for fields of structs

Consider the following C# struct definitions: public struct A { public B B; } public struct B { public int C; } Also consider the following static method: public static int Method(A a) => a.B.C; Calling this method will result in a copy…
Wizard Brony
  • 111
  • 5
2
votes
0 answers

Generate IL-Code / DLL and persistently save it

Currently I am developing a programming language and a compiler. I use antlr as a parser generator and I am implementing everything in C# targeting .Net Core 3.1 At the moment I am compiling my language into x86 GNU Assembler, but I have been…
Lars Behl
  • 253
  • 2
  • 8
2
votes
1 answer

Integration Test for All References of a Method Invocation

So, I've been searching around on the internet for a bit, trying to see if someone has already invented the wheel here. What I want to do is write an integration test that will parse the current project, find all references to a certain method, find…
Tejs
  • 40,736
  • 10
  • 68
  • 86
2
votes
1 answer

How to use conditional in Reflection.Emit

Hello i am generating a class using Reflection.Emit and i want to know how do you use brfalse command for conditionals. Specifically i do not know how do i translate the IL to OPCODES for the brfalse.s command. My method has the following…
Bercovici Adrian
  • 8,794
  • 17
  • 73
  • 152
2
votes
1 answer

Pros and cons of graphical and linear intermediate representation in compiler design?

There are two kinds of intermediate representation (IR) in compiler design, briefly introduced here: graphical (e.g. abstract syntax tree) and linear (e.g. LLVM IR). What are the pros and cons of the two? I noticed Clang implemented both, but it…
Leedehai
  • 3,660
  • 3
  • 21
  • 44
2
votes
1 answer

.NET IL Property setter

Consider this class: public class Foo { // Fields private string _bar; // Properties private string Bar { get { return this._bar; } set { this._bar = value; …
Anemoia
  • 7,928
  • 7
  • 46
  • 71
2
votes
1 answer

Questions about C as an intermediate language

I'm writing a language that compiles to C right now, and when I say IL I mean as in C is the language I write the code as to then generate assembly by another c compiler, e.g. gcc or clang. The C code I generate, will it be more beneficial to: If I…
Jon Flow
  • 495
  • 3
  • 11
2
votes
1 answer

In .NET, how is access to private methods restricted?

In .NET, are private methods and properties enforced by the runtime or just by the compiler? If you try to call another object's private methods, the compiler will throw an access exception. What if you manually manipulate the IL or try to call via…
Dinah
  • 52,922
  • 30
  • 133
  • 149
2
votes
2 answers

IL if-comparision reversed

I'm just trying to get into IL because I'm working with code-injection. I'm required to analyze code and cover various cases. Sadly it doesn't work to inject a method call at the end if the last instructions are inside an if-clause, because the call…
SharpShade
  • 1,761
  • 2
  • 32
  • 45
2
votes
1 answer

ldloc var vs. ldloc.n

Do someone know if there is even a small difference using ldloc var CIL instruction and ldloc.n ? Considering this local var table in a method scope : .locals init ([0] int32 a, [1] int32 b) Are those…
G. Ghez
  • 3,429
  • 2
  • 21
  • 18
2
votes
2 answers

Minimal set of Assembly Instructions for an Intermediate Language?

I was wondering the following: Is it possible to create a small set of Assembly Instructions that together can do all operations possible? Or maybe asked differently what are the Must-Have assembly instructions for about any architecture? (For…
user896326
1
vote
2 answers

Does .NET intermediate language have stack manipulation functions?

Probably a dumb question, but does MSIL have general Forth-like functions for manipulating data on its stack? (For example, DUP, SWAP, etc.)
J Cooper
  • 16,891
  • 12
  • 65
  • 110
1
vote
4 answers

Compile C++ code into assembly and then de-assemble

Does anyone know how convert C++ code to assembly code and then do the reverse? The forward way is very easy: g++ -S I want to analyze the output and see if it has been compiled correctly (Just for curiosity now, but it can have some applications).…
Shayan Pooya
  • 1,049
  • 1
  • 13
  • 22
1
vote
1 answer

Will assembly which targets .netstandard2.0 but runs on .NET 7 get all the performance boost from the latest runtime?

I have a choice for the assembly to target .netstandard2.0 or .net7.0. If I do not need latest features of C#, will it eventually make any performance difference when running my application on .NET ? AFAIK, JIT and types from BCL are provided by the…
Pavel Voronin
  • 13,503
  • 7
  • 71
  • 137
1
vote
1 answer

Unrecoverable IL error, but the IL looks fine

I'm getting errors with the following IL. Any idea why? It looks fine to me! The issue is with the lines stloc.4/ldloc.4 that are highlighted in bold. The syntax highlighting is from Rider, but I get the same issue with ilasm as well. I'm running…
Andrew Matthews
  • 3,006
  • 2
  • 29
  • 42