Backend: move the IR2 type check stuff to backend-specific files