Phase diagram of MgO from density-functional theory and molecular-dynamics simulations