Hi,
I'd like to reuse the IR-level predicate scheme for GlobalISel. As far as I can tell there are 3 possible ways to do this:
- Use the CmpInst enums directly. This feels close to a layering violation. ISel has to know *something* about IR, but you'd hope to minimize that after the first translation.
- Copy/paste the definitions into include/CodeGen/GlobalISel somewhere. Long term this isn't viable, though it might be a reasonable short-term hack until we know GlobalISel works.
- Refactor the predicates out of lib/IR into lib/Support (or elsewhere).
I decided to try and avoid hacks so took the 3rd option, giving us this large diff. I think it's actually a reasonable change on its own and the interfaces are slightly nicer afterwards, though I wouldn't have called it worth the time without GlobalISel's wider intent.
One thing worth thinking about is whether a single Predicate is the best choice. Passes had been (somewhat haphazardly, but not completely without reason) using either CmpInst, ICmpInst or FCmpInst to refer to the enum values.
There's not really any loss of expressiveness with a single Predicate, since the names are still ICMP_*/FCMP_*, but I could alternatively split it into IPredicate and FPredicate which would allow IPredicate::EQ, FPredicate::OEQ and so on.
Opinions?
Just noticed these are redundant now. I'll remove them.