Formation of magnesium silicides on amorphous silicon by deposition of Mg at room temperature is studied by electron energy loss spectroscopy, differential reflectance spectroscopy and high resolution transmission electron microscopy. Optimal crystal structures of Mg silicides under high pressure are found by ab initio DFT calculations. These structures are related to the particular minima of enthalpy. Dielectric functions are calculated for these structures. The transitions from the cubic phase c-Mg2Si to orthorhombic o-Mg2Si at 5.6 GPa and then from o-Mg2Si to hexagonal h-Mg2Si at 22.3 GPa are predicted using the USPEX code. The experimental spectra and the data obtained from the calculated dielectric functions are mutually consistent. Optical reflectance is suitable for monitoring the growth and transformations of the phases during experiments. During Mg deposition onto amorphous Si, the o-Mg2Si phase forms first, then the c-Mg2Si phase grows upon it. The observed sequence of phase formation is related with the compression stress arising in the depth of the Mg-Si mixture.