Questions tagged [gimple]

GIMPLE is an intermediate representation language used by GCC.

GIMPLE is both a high and low level, three-address, tree-based intermediate representation language derived from breaking down GENERIC expressions into tuples recursively.

It is used by the GCC backend to perform code optimization and analysis. Optimizations done in this form are listed by Wikipedia.

GCC's page on GIMPLE can be found here.

25 questions
2
votes
1 answer

How to register a GIMPLE_PASS?

I'm trying to do a simple plugin example like this: #include "gcc-plugin.h" #include "tree.h" #include "gimple.h" #include "tree-pass.h" #include extern void test(void*gcc_data, void*b) { printf("Hellow world\n"); } extern int…
Andres Tiraboschi
  • 543
  • 1
  • 7
  • 17
1
vote
0 answers

Why does the compiler need the intermediate representations for link time optimization?

My professor mentioned that gcc can be run with -flto. I am wondering why the intermediary (GIMPLE in GCC case) are needed. Why is the assembly not sufficient? He mentioned that this allows the compiler to (at link time) see from what the code was…
1
vote
0 answers

GCC GIMPLE C++ API, how to insert a call to a member-function from another member-function?

I'm trying to write a plugin that adds support for [[invariant]] contracts in classes/structs to complete the Contracts support that was added recently in GCC. This boils down to basically translating something like the below: class Heap { private: …
Gavin Ray
  • 595
  • 1
  • 3
  • 10
1
vote
1 answer

How to save a tree in gcc intermediate representation? Is it possible?

I want to save a tree (specifically the type of a tree) in a file in binary form, and I need to load this tree in other compilation unit. For example: I have a main.c with 2 function: myTypeStruct getWhatever(){ myTypeStruct my; ...…
Jordy Baylac
  • 510
  • 6
  • 18
0
votes
0 answers

Why does GCC -O0 convert bitwise AND and multiply to branching?

I was exploring when gcc uses branching vs conditional moves, and found some odd results when using bitwise ANDing on bit 0 of a variable. Specifically, if I do: int main(int argc, char** argv) { int y = (2*((~argc)&0x1)) + (1*(argc&0x3)); …
0
votes
1 answer

GCC flags to get LTO bitcode

I have been using LLVM/Clang and its Intermediate Representation(IR) for a while now. I have recently started working with GCC. I want to dump IR bitcode to a file, similar to (-flto -save-temps flag) in LLVM. I can get gimple IR using…
kshh23
  • 36
  • 6
0
votes
1 answer

GCC won`t emit my instruction, i tried to avoid branches

I need to reduce amount of branches in code. There is exist benchmark called median it have some code like: if ( A < B ) return A = foo[i]; else return B = foo[i]; I wrote a pattern in machine description file…
Alexy Khilaev
  • 415
  • 3
  • 13
0
votes
0 answers

How to find free operation in gimple?

I'm modifying GCC frontend now. And I want to check GIMPLE file with FOR_EACH_BB_FN and to detect 'free' operation, which is used to release memory allocation in C. Here is my code: basic_block bb; gimple_stmt_iterator…
李宗霖
  • 11
  • 1
0
votes
1 answer

GCC plugins API : Gimple pass

I've been looking into online resources on writing GCC plugins. I'm currently using GCC version 7.3.0. I attempted writing a simple plugin that contained a callback which would be called upon PLUGIN_FINISH_TYPE. It worked fine. Next, I'm trying to…
learnlearnlearn
  • 946
  • 1
  • 8
  • 16
0
votes
2 answers

Get the number of functions of the c++ file compiled using gcc Plugin

I am creating a pass using GCC plugins, this is my pass : static const struct pass_data calls_printer_pass_data = { .type = GIMPLE_PASS, .name = "calls_printer", …
Othman Benchekroun
  • 1,998
  • 2
  • 17
  • 36
1
2