Modals in the third conditional
Main clause
We can use modals other than would in the main clause of a sentence in the third conditional:
If I had had the right tools, I could have fixed my bike. (ability)
If the weather had been worse, they might not have reached the top. (possibility)
If-clause
We can use could + perfect infinitive in the if-clause to express ability or possibility:
If he could have got to the station on time, he might have caught the train. (ability)
If I could have known this would happen, I'd never have started dating him. (possibility)
Were to + perfect infinitive is also possible in the if-clause; however, it is less common:
If he were to have asked me, I would have said yes.