Specifically in Cortex-M4 (if that matters), when doing GPIO you need to write and/or read from GPIO's memory-mapped registers.
Before diving deeper into library code that handled this for me, I thought it was pure-hardware (say I wanted to set some pin HIGH, then there's a physical wire going from whatever bit in RAM that I toggle, to that pin. This way that bit would act as a switch). But after learning about the way it's done (activating some bit to set the pin HIGH, but activating some other bit to set the pin LOW), makes it feel a bit arbitrary, almost as if there's some parsing logic involved to understand what to do when some certain bit is activated.
So which is the case? Is this still pure-hardware with some complex circuitry or is there some sort-of a "nano-controller" within the peripheral that parses registers? (which just sets the problem back one-bit, how does this "nano-controller" communicate with real-world if microcontroller requires a peripheral to do so?)