[LLVMdev] SelectionDAGISel::CodeGenAndEmitDAG() confusion.

Joseph Reddington joseph at cs.rhul.ac.uk
Tue Aug 21 05:56:02 PDT 2012


Hello everybody,

Following on from the excellent help I received at
http://comments.gmane.org/gmane.comp.compilers.llvm.devel/52591 - I
have a follow up question.

I've been editing the SelectionDAGiSel.cpp to try and print out the
operations in the nodes, to this end I have modified the
SelectionDAGISel::CodeGenAndEmitDAG()  function as follows

void SelectionDAGISel::CodeGenAndEmitDAG() {
  std::string GroupName;
//JOE'S EDITS START
    std::cout<<"Hello everybody Joe was here!"<<std::endl;
    for (SelectionDAG::allnodes_iterator I =
CurDAG->allnodes_begin(),E = CurDAG->allnodes_end(); I != E; ++I)
    {
        std::cout<<"start"<<I->getOperationName(CurDAG)<<std::endl;

    }
//JOE'S EDITS END

...and, for santity checking purposes, I've added similar code at the end...


 // Free the SelectionDAG state, now that we're finished with it.
//JOE'S EDITS START
    for (SelectionDAG::allnodes_iterator I =
CurDAG->allnodes_begin(),E = CurDAG->allnodes_end(); I != E; ++I)
    {
        std::cout<<"hey"<<I->getOperationName(CurDAG)<<std::endl;
    }

    HandleSDNode Dummy(CurDAG->getRoot());
//JOE'S EDITS END
  CurDAG->clear();
}

The files make fine but when I run clang on an input file I get

Cobrakai$./clang temp.c
temp.c:4:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
main()
^~~~
Hello everybody Joe was here!
startEntryToken
heyEntryToken
1 warning generated.
Cobrakai$

...which implies that either my itterator is not working as I expect
it would (I expect many more than one node), or the selectionDAG has
only one node... which would be odd - can anyone point me in the right
direction for this?

PS -  here is my test file, in case it's useful.

Cobrakai$more temp.c
/* Fibonacci Series c language */
#include<stdio.h>

main()
{
int n, first = 0, second = 1, next, c;

printf("Enter the number of terms\n");
scanf("%d",&n);

printf("First %d terms of Fibonacci series are :-\n",n);

for ( c = 0 ; c < n ; c++ )
{
if ( c <= 1 )
next = c;
else
{
next = first + second;
first = second;
second = next;
}
printf("%d\n",next);
}
return 0;
}
Cobrakai$




-- 
Dr Joseph Reddington
Computer Science, Royal Holloway
For 2012 I have a resolution to write all my email responses within
24-hours - no exceptions. If you've not had a response, there's been a
misunderstanding somewhere, and it's worth reminding me.



More information about the llvm-dev mailing list