Upgrade CPU for Lenovo Ideapad W580?

Does having a specific laptop determine what cpu you can put into it?

Yes.

Laptop CPU upgrading is more difficult than Desktop.
It is called tampering by the laptop manufacturer, and they provide zero support for a cpu change in a laptop.

First, it has to be a socketed and not directly soldered CPU on the motherboard.
Second, the socket has to compatible
Third, the core logic of the motherboard (used to be called chipset) has to be compatible
Fourth, the system Bios needs to be written to recognize the CPU. In laptops, the bootup software contained on the motherboard is programmed to only recognize certain CPUs. The list is unavailable to the public and not provided by the laptop brand.
Fifth, the CPU has to be available. They are generally sold only as a repair item by service centers. You might find one on ebay or amazon or direct order from China sometimes. A few are sold retail.
Sixth, it is a difficult upgrade. You have to get to the motherboard, remove the CPU cooling assembly, remove the CPU, clean off all thermal pastes, apply thermal paste to the replacement CPU, reassemble it.
In laptops, assembly and disassembly is not easy.

And, I find no record of a Lenovo W580 ever being released in either Thinkpad or Ideapad.

Check online at Lenova for the type of motherboard of your specific model or check your motherboard directly. Then go to that manufacturer for compatible upgrades.