Wiener criterion for X-elliptic operators