def get_or_create_const_composite(module, type_id, operands):
    """Get an OpConstantComposite instruction with given type/operands.

    An existing instruction is returned, or a new one is created if there
    is no such instruction already."""
    for inst in module.global_instructions.type_insts:
        if (inst.op_name == 'OpConstantComposite' and
                inst.type_id == type_id and
                inst.operands == operands):
            return inst
    return module.get_global_inst('OpConstantComposite', type_id, operands[:])