We can use 'if + past perfect, would + have + past participle' to talk about things that are not real in the past.
- If I had studied more, I would have passed the exam. (But really, I failed the exam.)
- If it hadn't rained, we would have gone to the beach. (But it rained, so we didn't go.)
- If he had made a cake, we would have eaten it. (But he didn't make a cake.)