Aviate!
Navigate!
Communicate!
In that order!
In an emergency situation you as PIC may do whatever you need to do to ensure safety, including deviating from flight plans if required.
You are NOT required to first "declare an emergency", say "MAYDAY" or "PAN PAN", etc., to exercise your authority as PIC. That comes later (if ever).