Detectability of HD and non-equilibrium species in the upper atmospheres of the giant planets from their submillimeter spectrum