ir: Add some util functions.