Questions tagged [intermediate-code]

37 questions
26
votes
7 answers

What does Backpatching mean?

What does backpatching mean ? Please illustrate with a simple example.
14
votes
1 answer

Advantages of stack-based bytecodes or infinite register machines

Compilers often choose intermediate representations (IRs) that are either stack-based or infinite register. What are the advantages of these over expression trees?
J D
  • 46,493
  • 12
  • 162
  • 266
8
votes
2 answers

Generating intermediate code in a compiler. Is an AST or parse tree always necessary when dealing with conditionals?

I'm taking a compiler-design class where we have to implement our own compiler (using flex and bison). I have had experience in parsing (writing EBNF's and recursive-descent parsers), but this is my first time writing a compiler. The language design…
8
votes
1 answer

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…
ViG
  • 405
  • 4
  • 8
7
votes
4 answers

Choosing an intermediate language

I am currently playing around with programming languages. I have spent some time writing parsers and interpreters in high level languages (most notably Haxe). I have had some results, that I think are actually quite nice, but now I'd like to make…
back2dos
  • 15,346
  • 31
  • 48
6
votes
2 answers

Generating intermediate .i files (preprocessed files) when compiling Ubuntu-8.04

I'm building ubuntu-8.04 with gcc 3.4 and I need to generate the .i files, which are the output of the gcc preprocessor. I have tried adding the --save-temps flag but this only generates the .i files for the top level directory, i.e. source, and…
Sara
  • 61
  • 1
  • 2
3
votes
1 answer

What is wrong with this LLVM IR code

I have an LLVM IR code that looks something like this. %8 = load i64* @tid, align 8 %arrayidx1 = getelementptr inbounds [16 x i32]* @h, i32 0, i64 %8 ;<-- %8 works fine here .............. %OldFuncCounter7 = load i64* getelementptr…
pythonic
  • 18,049
  • 33
  • 112
  • 196
3
votes
2 answers

Is there any way to write a compiler front end without using syntax-directed translation?

My question is the same as the title. I just want to know if there are any other translation techniques to get the intermediate code that doesn't rely on embedding actions into the parser (that is, the parser will strictly create the abstract syntax…
3
votes
1 answer

How does a compiler identify its host machine's hardware? Which component?

My teacher told me that the intermediate code is generic for all systems but a component of the compiler then make it different according the system/environment the code is run on. Can someone please explain it.
3
votes
1 answer

What is the purpose of code optimization at intermediate phase in compiler?

Some code optimizations are carried out on the intermediate code because They enhance the portability of the compiler to the target processor Program analysis is more accurate on intermediate code than on machine code The information from dataflow…
3
votes
5 answers

Which is a good and simple intermediate code?

Suppose that the purpose of an assignment is to write a compiler that works on a subset of C language (you can assume a subset of whatever language, just supporting basic scripting expressiveness without having complex things as objects). What kind…
Jack
  • 125,196
  • 27
  • 216
  • 324
3
votes
0 answers

Can I call an output of LLVM backend from c++ in efficient manner?

let's say I have some logic written down in some programming language with LLVM frontend available. I would like to reuse this logic in some c++ application. Can I generate some sort of library using common LLVM backends and call it from my…
2
votes
3 answers

How to access the MSIL code of compiled .NET assemblies?

VB.NET and C# (and other language) compilers generate MSIL code. How can I see that code? What is there in that file? Where does that file reside and how can I access that? Second question: How do I compile a C# program from the cmd prompt and how…
Kishore Kumar
  • 11,843
  • 26
  • 86
  • 149
2
votes
2 answers

How to check equality of iterator?

In my llvm code, I try to check if the iterator InsertPos is pointing to the last instruction of a basic block, with the following code. BasicBlock::iterator InsertPos = BB->begin(); LLVMContext &Context = BB->getContext(); while ( !(…
MetallicPriest
  • 25,675
  • 38
  • 166
  • 299
1
vote
1 answer

Insert the getelementptr instruction

I want to insert the getelementpr instruction in my code, like the one shown below. %i1 = getelementptr inbounds [16 x i64]* @Counters, i64 0, i64 %8 How can I insert that? I can insert load and store instructions by using the constructors of…
MetallicPriest
  • 25,675
  • 38
  • 166
  • 299
1
2 3