Spin–orbit torque reconfigurable diffraction gratings