Getting SELECT_CC and BR_CC DAG nodes

Hello,

I’d like to write some unit tests which verifies SELECT_CC and BR_CC lowering for ARM target, but I’m almost completely unfamiliar with llvm/Target. How can I get this nodes in DAG?

Thanks.

Hello,

I figure out by myself how to generate select_cc. I’ve written simple C code:

int f(int a) {

return (a != 0) ? 0 : 1;

}

generate ir from it

and got select_cc node with llc -view-legalize-dags. But I got it almost randomly: I saw comment in the sources that a ? b : c corresponds somehow with select_cc and then customizing constness of parameters gives me node I needed. It’s low priority by now – I got what I wanted but I’ll be grateful if somebody answer me: Does any better algorithm of figuring out how to generate specific DAG node exists? Thank you.

Does any better algorithm of figuring out how to generate specific DAG node exists?

Not really, I'm afraid. Some suggestions, in order of desperation:

+ Read include/llvm/CodeGen/ISDOpcodes.h and write IR that would
produce the node as described.
+ Scan through SelectionDAGBuilder.cpp and/or the combiner &
legalizers, trying to work out why they're formed.
+ Put an assert somewhere definitely on the path and run "make check".
New failures will contain IR exercising the node.
+ Read files in step 2 with a fine tooth comb, cursing the person who
added a node without any tests.

Cheers.

Tim.