All Questions
Tagged with compiler-construction compilation
187 questions
2
votes
0
answers
155
views
Can't translating out of SSA be more trivial?
I'm reading about how to translate out of SSA form from different sources and I'm having hard time about the necessity of different techniques.
First of all looking at Cytron's SSA paper at section 7 ...
-3
votes
2
answers
78
views
does new compilers turn the source code into a binary or do they just transpile and hand it over to another compiler [closed]
does new compilers (e.g. the rust compiler or zig compiler) turn the source code into another language (e.g. C) and let that languages compiler (e.g. gcc) spit out the exe or do they do everything all ...
0
votes
3
answers
144
views
When inlining a C function, can an optimizing compiler dereference a pointer more times than explicitly written in the source code?
Consider the following code:
int y = 1;
int* p = &y;
inline int f(int x) {
return x + x;
}
int g(void) {
return f(*p);
}
In this code, there is one explicit dereference.
Is a C compiler ...
0
votes
0
answers
267
views
How to compile to RISC-V?
I'm writing the final stage for my compiler to riscv; however, I have run into a minor issue of figuring out what the start point of the program is. Are we guaranteed that the PC starts execution with ...
0
votes
1
answer
268
views
In bootstrapping, how is the compiler written in the other langauge such that it can then compile the original language i.e. the bootstrap compiler?
I am not exactly what you would call familiar with programming, so I guess I am trying to think of this more conceptually.
So I know there are already posts about this:
what is the initial step to ...
0
votes
0
answers
106
views
How do I JIT-compile a function called through a pointer?
I am writing a JIT compiler for an extension of Brainfuck that has functions. Functions are referred through a function pointer that you can increment/decrement and call it.
My approach is that it ...
0
votes
1
answer
32
views
Typing /0 (not \0) into a lex program causes unexpected behavior
I made a simple lex program for school, and for some reason it has an unexpected behavior while reading "/0".
The program is as following:
%%
[a-z] printf("char %c", yytext[0]-32);
...
0
votes
1
answer
60
views
How to remove left recursion in a grammar with both left recursion and right recursion existing?
The grammar is as follows:
E->a
E->E+E
E->S,E
E->(E)
S-> bS'
S'-> ;bS'
S'->
I have no idea how to remove the left recursion cause E contain terminals and non-terminals. And ...
2
votes
1
answer
363
views
How does a JIT compiler compile a function that contains a call to another non-jitted function or virtual call
I understand what JIT compilers do, it uses counters to detect hot codes and compiles them, and stores them in the code cache, so that next time the function won't need to be interpreted. But this ...
0
votes
0
answers
363
views
Modify rustc's AST and continue the compilation with the modified AST
Is it possible to modify the AST generated by rustc's parser, then continue the compilation with the modified AST?
To be specific, I am looking for a function like rustc_driver::Callbacks::...
1
vote
1
answer
893
views
What is the best way to compile a Rust project on-the-fly with another Rust program?
I am exploring the idea of using Rust to dynamically compile a program with specific changes to the source code based on each user’s needs.
My idea was to have the “compiler” program load the main.rs ...
1
vote
1
answer
338
views
Should tokens be part of AST Nodes
Some background why I ask this question.
I'm reading Writing An Interpreter In Go, in the book, Token struct is inside of AST Nodes. Node is a type that can be fulfilled by implementing tokenLiteral() ...
0
votes
1
answer
246
views
How to implement the parse tree?
I started writing a DBMS as a learning project, and now I'm implementing the lexer/parser for the language used in the DBMS.
I'm learning on my own from various different resources, and managed to ...
1
vote
1
answer
423
views
Do basic block parameters mean code locality?
Most modern compilers use some form of SSA for internal representation, which needs some notation for variables whose values can come from more than one source. The classic version uses phi nodes. ...
2
votes
1
answer
661
views
Simplifying grammar via operator precedence
I am trying to parse C. I have been consulting some free-context C grammars and I have observed they usually model expressions by using "chained" production rules, for example [here][1] ...