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 compile a .NET Core C# project to raw IL code?

I'm trying to set-up a C# project that outputs raw IL code instead of a .EXE. The output file should either look something like this: IL_0000: nop IL_0001: ldc.i4.5 IL_0002: stloc.0 // a IL_0003: ldc.i4.s 18 IL_0005: …
boooba
  • 149
  • 2
  • 12
1
vote
1 answer

Why is callvirt used to call a method on a readonly field of generic type

Consider the following: interface ISomething { void Call(string arg); } sealed class A : ISomething { public void Call(string arg) => Console.WriteLine($"A, {arg}"); } sealed class Caller where T : ISomething { private readonly T…
Bogey
  • 4,926
  • 4
  • 32
  • 57
1
vote
0 answers

Is managed code generated after compilation?

NOTE: Just want to clarify if my current understanding is correct after I came across a MSDN doc which seems to contradicts another MSDN doc. Also I have already been through the following links - Is C# unsafe code managed? What is difference…
phougatv
  • 881
  • 2
  • 12
  • 29
1
vote
1 answer

Using nvdisasm to generate control flow image of PTX code

I have a single file of CUDA code compiled to intermediate language PTX code, example.ptx. I would be interested to start poking around with this short file, trying to understand how it works. I don't have previous experience fiddling around with…
Toothery
  • 155
  • 1
  • 1
  • 10
1
vote
1 answer

Change C# code inside DLL programmatically

I got .net dll (originally, written in C#) which is being updated / released from time to time. There's a small part of code I need to modify inside this dll which suits my usage needs. I'm able to do these changes every time using dnSpy but I don't…
WhiteAngel
  • 2,594
  • 2
  • 21
  • 35
1
vote
0 answers

How to design an intermediate representation for language with a nested functions?

I am writing a compiler for language with nested functions. I decided to use display to access local variables of outer functions from inner ones, I don't know how to represent writing of activation record to display array in intermediate…
1
vote
1 answer

ECMA CLI spec: stack transition diagram notation for CIL instructions

I have been reading the ECMA CLI spec: http://www.ecma-international.org/publications/standards/Ecma-335.htm and I'm puzzled by the use of commas within the stack transition diagrams for some of the instructions. For example, here is the documented…
1
vote
0 answers

Expected relocatable expression

I'm trying to compile a sample from Multiboot 2 specification on MacOS using LLVM but I failed at the start. I want to create an object file from boot.S with included multiboot2.h so I call gcc -m32 boot.S but it crashes with error: boot.S:57:15:…
Denis Sologub
  • 7,277
  • 11
  • 56
  • 123
1
vote
1 answer

Where can I find QEMU (TCG)'s / LLVM IR operational semantics?

Is anyone aware pf any public QEMU's TCG operational semantics description? I rather found something about LLVM, but I'm not sure if these two are quite similar? especially that TCGs use sometimes custom helper functions rather than micro-ops. Any…
noureddine-as
  • 453
  • 4
  • 12
1
vote
1 answer

how to use mono.cecil to inject a function call having optional parameters?

I am trying to weave an assembly by using mono.cecil library. I am injecting a function call at a place in the assembly. The function call has some optional parameters. But when I inject without loading any value for optional parameters, I get…
1
vote
1 answer

System Field Acess Exception from Reflection.Emit derived class

I have a dynamically generated class that needs to access a field from the base class. I keep getting this exception: Exception System.FieldAccessException: 'Attempt by method 'AutoGenRelay.SetAsync(System.String, redius.Cell, System.Nullable`1,…
Bercovici Adrian
  • 8,794
  • 17
  • 73
  • 152
1
vote
2 answers

In .NET, is the call stack inextricably tied to a thread?

Is it at all possible in the middle of a function execution to set a pointer to the current stack (to be picked up later) and then release the current thread (without unwinding the call stack) and give it back to the thread pool? And then, have…
skb
  • 30,624
  • 33
  • 94
  • 146
1
vote
1 answer

Why does SPIR-V use a "4 byte" code, or "Word code"?

According to the SPIR-V 1.3 specification, as I understand it, all instructions are segmented in 4 byte words. This is different from traditional byte code IR languages like Pythons byte code and Java's JVM bytecode, which if I understand correctly…
Krupip
  • 4,404
  • 2
  • 32
  • 54
1
vote
1 answer

Automatically convert code from one representation to another?

Is there a way to convert code from one high-level representation to another? For example, in Javascript, a popular way of maintaining state is with a third-party library called Redux. VueJS on the other hand, has its own version of Redux, which is…
U Avalos
  • 6,538
  • 7
  • 48
  • 81
1
vote
0 answers

Consume Scala syntax-trees from external tool

I would like to develop a tool that would consume scala syntax-trees (as the title suggests). More specifically it would be great if I could consume the trees after each compilation phase. My research led me to Dotty's TASTY interchange format which…
Than21
  • 321
  • 1
  • 2
  • 10