寄存器 [英] register

查看:106
本文介绍了寄存器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我想知道是否有一种方法可以确保在缓存中使用

"寄存器" ;? Tks!

解决方案

>大家好,我想知道是否有办法确定

变量在缓存中分配后,用
register声明? Tks!




在我听说过的所有处理器上都有缓存,实际的CPU

寄存器从不是缓存的一部分。实际的CPU寄存器

通常比缓存快得多。


你永远无法确定关键字''register''是否会影响

完全代码。如果你使用它足够,你*将*用完实际CPU寄存器的
。如果您可以将变量强制转换为
CPU寄存器,则可能会降低代码速度,因为寄存器

可能更适合用作不可见的临时值。编译器

通常比你聪明。


Gordon L. Burditt


2005年-11-09,Gordon Burditt< go *********** @ burditt.org>写道:

大家好,我想知道是否有办法确保在缓存后在缓存中分配了一个
变量用
注册? Tks!



在我听说过的所有处理器上都有缓存,实际的CPU寄存器永远不会是缓存的一部分。实际的CPU寄存器通常比缓存快得多。

您永远无法确定关键字注册是否会影响代码。如果你足够使用它,你*会*耗尽实际的CPU寄存器。如果您可以将变量强制转换为CPU寄存器,则可能会降低代码速度,因为寄存器可能更适合用作不可见的临时变量。编译器
通常比你聪明。




编译器也不需要听你的。全部注册意味着

是编译器可以自由地不给变量一个地址。这个

否则可以通过代码分析来确定,我敢肯定,但关键字

更简单。


< blockquote>文章< 11 ********************* @ z14g2000cwz.googlegroups。 com>,

< or ***** @ gmail.com>写道:

大家好,我想知道是否有办法确保在缓存中使用
register声明后在缓存中分配了一个
变量;? Tks!




您将获得的答案将归结为您不能知道而且您

不应该想知道。


但是,底线是:用一个选项调用编译器导致它输出汇编(例如, gcc -S")然后查看生成的

程序集。您应该能够弄明白它对您的

寄存器做了什么。指令。


hi everyone, i''m wondering if there is a way to have sure that a
variable is allocated in the cache, after its declaration with
"register"? Tks!

解决方案

>hi everyone, i''m wondering if there is a way to have sure that a

variable is allocated in the cache, after its declaration with
"register"? Tks!



On all processors I have ever heard of with a cache, actual CPU
registers are never part of the cache. Actual CPU registers
are normally much faster than the cache.

You can never be sure that the keyword ''register'' will affect
the code at all. And if you use it enough, you *WILL* run out
of actual CPU registers. If you could force a variable into a
CPU register, it might slow down the code because the register
might be better used as an invisible temporary. The compiler
is often smarter than you are.

Gordon L. Burditt


On 2005-11-09, Gordon Burditt <go***********@burditt.org> wrote:

hi everyone, i''m wondering if there is a way to have sure that a
variable is allocated in the cache, after its declaration with
"register"? Tks!



On all processors I have ever heard of with a cache, actual CPU
registers are never part of the cache. Actual CPU registers
are normally much faster than the cache.

You can never be sure that the keyword ''register'' will affect
the code at all. And if you use it enough, you *WILL* run out
of actual CPU registers. If you could force a variable into a
CPU register, it might slow down the code because the register
might be better used as an invisible temporary. The compiler
is often smarter than you are.



The compiler also isn''t required to listen to you. All "register" means
is that the compiler is free to not give the variable an address. This
could otherwise be determined by code analysis, i''m sure, but a keyword
is simpler.


In article <11*********************@z14g2000cwz.googlegroups. com>,
<or*****@gmail.com> wrote:

hi everyone, i''m wondering if there is a way to have sure that a
variable is allocated in the cache, after its declaration with
"register"? Tks!



The answers you will get will all boil down to "You can''t know and you
shouldn''t want to know."

However, the bottom line is: Invoke the compiler with an option that causes
it to output assembly (e.g., "gcc -S") and then look at the generated
assembly. You should be able to figure out what it did with your
"register" directive.


这篇关于寄存器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆