I will start with that i am vary grateful for your time.
And continue with, i am sorry if my Qs aren’t quite accurate( i just started with the LLVM compiler).
I need to add a new optimization to the LLVM compiler.
Knowing what the optimization does would be very helpful here.
The optimization ALREADY written for x86 IR (i mean that the code that
handles the optimization is designated to work on assembly 86) .
It’s designed to work on x86 assembly, or “x86 IR”?
Its not x86 IR nor x86 assembly. I have x86 IR “like” instructions ( add R1, R2, R3 and so…)
If it’s really
x86 assembly, you can use LLVM’s code generator to get x86 assembly,
Do you mean the “llvm-gcc -S file.c” , or can i have the same effect with C++ code (API) ?
but it’s extremely difficult to get back to LLVM IR.
Please, its vary important for me that you elaborate why it will be extremely difficult ( i can imagine it would hard, but if you inlight me i would probably create a better design…)?
something higher-level, it might not be so bad.
Do you mean, higher than IR ? like c or C++ code …
So, this is what i think -
I will add a Basic Block Pass to the LLVM, the code of the pass will iterate
etch instruction and convert it to x86 IR, now the optimization will take
place, after the optimization i will convert the x86 IR code back into LLVM
To the question(s):
Do you think my idea is a good one (if yes, do you see any
problems implementing this)?
Do you have another idea?
If you’re going to need conversions both ways, my guess is that it’ll
be faster to just rewrite the pass as an LLVM IR pass.
Can you tall me where can i fined more information about the LLVM IR pass?
It depends on
how complicated the pass is, though.
Lets say its only a project (academic) …
Is the LLVM have such built in capability ( converting LLVM IR to other IRs
If you need a different IR, I think you’ll have to write your own
converter. Converting from LLVM IR to another language generally
isn’t very difficult if you don’t care about the quality of the
generated code too much,
Again, lets say its only a project (academic) …
but it’s a lot of work, and it seems like
code quality is important here.
If i have a pointer to Instruction, how can i get or set the VALUE of Instruction’s operands ?