  Twisted compactification of the 6d N=(2,0) theories on a punctured Riemann
surface give a large class of 4d N=1 and N=2 gauge theories, called class S. We
argue that nonperturbative dynamics of class S theories are described by 5d
maximal Super-Yang-Mills (SYM) twisted on the Riemann surface. In a sense,
twisted 5d SYM might be regarded as a "Lagrangian" for class S theories on
R^{1,2} times S^1. First, we show that twisted 5d SYM gives generalized
Hitchin's equations which was proposed recently. Then, we discuss how to
identify chiral operators with quantities in twisted 5d SYM. Mesons, or
holomorphic moment maps, are identified with operators at punctures which are
realized as 3d superconformal theories T_rho[G] coupled to twisted 5d SYM.
"Baryons" are identified qualitatively through a study of 4d N=2 Higgs
branches. We also derive a simple formula for dynamical superpotential vev
which is relevant for BPS domain wall tensions. With these tools, we examine
many examples of 4d N=1 theories with several phases such as confining, Higgs,
and Coulomb phases, and show perfect agreements between field theories and
twisted 5d SYM. Spectral curve is an essential tool to solve generalized
Hitchin's equations, and our results clarify the physical information encoded
in the curve.
