You don't legislate slavery, you abolish it.
So to summarize my point of view as previously discussed:
You abolish the type that involves kidnapping an innocent person and forcing them to work for you, yes.
There are circumstances where forms of slavery can be justified (and therefore must be legislated for); for example, we might legislate that when someone commits murder, they should be imprisoned for life and do some sort of labour and earning their own money and possessions. Considering that they deserve to forfeit their life, this would be a concession. Or, in a culture where sex before marriage is considered wrong, when a man seduces and sleeps with an unmarried woman he should be forced to marry her, as in the OT law.
Or if someone pledges his labour to someone for life in return for food and housing, in order to stay alive.
Or (a typical OT scenario) where a person becomes a slave for life when a neighboring country attacks Israel and gets beaten, and Israel takes prisoners of war and enslaves them. Or if someone from a neighboring country is already a slave and is sold to an Israelite.
Bear in mind, they could get out of this situation if their master mistreated them.
The word 'slave' was associated with cruelty during the Egyptian captivity, and this type of slavery was not permitted in Israel.