Register storage class is used to quicky access the variable and its memory is allocated in CPU. But the registers in the cpu are limited. I use an intel Core i5-4260U Processor. I've visited intel website for the details of the register. But I couldn't find any of such specification of how many registers does the cpu contain (to visit website click here). Even if i could find that the number of registers((from How many registers are there in 8086/8088?)) but I couldn't figure out how many of these are used by c storage classes.
相关问题
- AMD CPU versus Intel CPU openCL
- OpenCL on Linux with integrated intel graphic chip
- Counting number of allocations into the Write Pend
- Can I use rsp as a general purpose register?
- Which registers are protected from user space in l
相关文章
- Why does the latency of the sqrtsd instruction cha
- What are fast LEA and slow LEA unit in the microar
- Intel chipset - GPIO programming
- ADC instruction in asm
- Store forwarding Address vs Data: What the differe
- Java 8 Swing rendering problem with Intel HD 3700
- Intel MSR frequency scaling per - thread
- Bypass delays when switching execution unit domain
Just look for "ia32 programming model" or "amd64 programming model".
That is implementation dependent. A compiler can even ignore that. Some of them use automatic register mapping if invoked with a high level of optimization, regardless of the way the variable has been declared.
For example: the programming model for user-mode applications on IA32 is composed of the registers
EAX
,EBX
,ECX
,EDX
,ESI
,EDI
,EBP
,ESP
andEIP
.EAX
andEDX
are used as accumulators, they are implicit operands for some instructions (MUL
,DIV
) and they hold the return value of a function.EBP
andESP
are reserved for stack and frame management.EIP
is the instruction pointer. So this leaves us withEBX
,ECX
,EDI
andESI
for register mapping. Depending upon the code generated, one or more of these registers may be needed, so reducing even more the number of available registers for mapping variables.The register keyword in C was included because when C was created, compilers did not always do a good job of register allocation. Register allocation is the the part of the compiler which maps program variables to CPU registers.
Nowadays, the algorithms compilers use for register allocation are on the whole excellent. So much so that compilers often ignore the register keyword, reasoning that the compiler knows better then the programmer on how to map registers to maximize performance.
I'm not sure what compiler 'mcleod_ideafix' is referring to when he writes that
EAX
andEDX
are not available for register allocation. The gcc compiler uses 6 integer registers in 32 bit x86 code (EAX
,EBX
,ECX
,EDX
,ESI
, andEDI
). It will even useEBP
if the function does not make any function calls and you give the proper compiler option. 64 bit mode adds 8 more registersR8
throughR15
. If you are using gcc just compile your file with the-S
option then look at the generated code to see what registers are used.Another thing to consider is that Intel processors use a feature called register renaming to reduce the performance penalty of having not enough registers.