4 ms·
How does C do what hardware does and store things in registers when it can?
by wbl 3y ago
How does C do what hardware does and store things in registers when it can?
- pjmlp 3y agoIt doesn't, it is up to the compiler and optimizer to decide how to go at it. Vector instructions, replacing library functions with compiler intrisics, splitting structs across registers and stack, unrolling loops are all examples absent from the language standard.
- JonChesterfield 3y agoTwo ways. One is the platform ABI sometimes says specific arguments are passed in specific registers. The second is (essentially) assigning local variables offsets on a machine stack where some offsets are stored in registers.