Drunkandalone, from your employer's POV you are not an ideal employee. FWIW, I would initiate rehab through HR, but if you think they're going to fire you, resign first.
I would also make a sincere apology to your supervisor regarding your work, if you feel he/she will be receptive, and you have successfully completed rehab.