A representation formula for large deviations rate functionals of invariant measures on the one dimensional torus