My experiences only relate to travelling as a foot passenger:
Dublin has several ferry terminals - the Irish Ferries one at Terminal 1 has a full, almost 'Airport Style' passport control when arriving from the UK from Holyhead. I have never not been required to show ID here and I believe they will issue entry stamps here, though I've never needed one personally.
The Stena Line terminal (arriving from Holyhead in the UK) at Terminal 2 is more rudimentary and seems to have ad-hoc passport checking. You more or less walk off the ferry here into the car park. When they do (random?) passport checks here it is usually just a couple of guards, so you may not be guaranteed to get an entry stamp. A couple of times here I've had no entry check at all and the terminal seems relatively low-staffed.
You could always ask at the port, or if no one was available and it was really necessary, there is the Guarda Immigration office on Burgh Quay in the centre of Dublin.
There are more often than not Police asking for ID on arrival from Dublin into Holyhead, but I don't believe there is still any formal permanent border control here - I don't recall seeing anyone getting a passport stamped here. I'm sure the staff there would be happy to advise though. I believe this is similar to the other Welsh ports, as most passenger traffic is arrivals from Ireland, which is in the UK-Ireland common travel area.
I would imagine similar set-ups in Fishguard and Birkenhead (Liverpool), i.e. non-permanent border controls on the UK side.