寄存器存储类说明符的缺点 [英] Disadvantages of register storage class specifier

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

问题描述

使用注册表

存储类说明符的缺点是什么?

What is the disadvantage of using register
storage class specifier?

推荐答案

aruna写道:
aruna wrote:
使用register
存储类说明符的缺点是什么?
What is the disadvantage of using register
storage class specifier?




做自己的功课,你会得到更好的答案<书中的
比你来到这里。


-

托马斯。



Do your own homework, you will get better answers
in a book than you will get here.

--
Thomas.


----- BEGIN PGP签名消息-----

哈希:SHA1


aruna写道:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

aruna wrote:
使用register
存储类说明符的缺点是什么?
What is the disadvantage of using register
storage class specifier?




在我看来,主要的缺点是你不能拿一个寄存器变量的

地址。


再一次,我的意见,但''注册''存储类没有'使用它时,不会提供很多

的优势:允许编译器使用i gnore它

当选择变量的位置时,编译器优化

生成的代码可能比优化

程序员可以做得更好,并且该语言对使用定义为注册的

变量施加了限制。


- -


Lew Pitcher,IT顾问,企业应用程序架构

企业技术解决方案,道明银行金融集团


(此处表达的意见是我自己的,不是我的雇主的)

-----开始PGP签名-----

版本:GnuPG v1.2.4(MingW32)


iD8DBQFAj9fCagVFX4UWr64RApRVAKCfs0M3p2yECKZbWJd4Yp w0fj91vwCfRlsu

IT1RBBQIMrWWkTLjc1yVdTY =

= L0q5

----- END PGP SIGNATURE -----



In my opinion, the primary disadvantage is that you can''t take the
address of a register variable.

Again, my opinion, but the ''register'' storage class doesn''t provide much
of an advantage when it is used: the compiler is permitted to ignore it
when selecting placement of variables, compiler optimization of
generated code may do a better job of optimizing placement than the
programmer can, and the language imposes restrictions on the use of
variables defined as register.

- --

Lew Pitcher, IT Consultant, Enterprise Application Architecture
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer''s)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFAj9fCagVFX4UWr64RApRVAKCfs0M3p2yECKZbWJd4Yp w0fj91vwCfRlsu
IT1RBBQIMrWWkTLjc1yVdTY=
=L0q5
-----END PGP SIGNATURE-----


Lew Pitcher< Le ********* @ td.com>写道:
Lew Pitcher <Le*********@td.com> writes:
aruna写道:
使用register
存储类说明符有什么缺点?
在我看来,主要的缺点是你不能拿一个寄存器变量的
地址。
What is the disadvantage of using register
storage class specifier?
In my opinion, the primary disadvantage is that you can''t take the
address of a register variable.




有人可能会说这是一个优势。 寄存器说明符是

一种向编译器断言给定变量不具有其地址的
的方法。从理论上讲,编译器可以使用

信息进行优化,即使它没有将它用于其原始意图(将变量存储在CPU寄存器中)。 br />

如果我的目标是给编译器尽可能多的信息,

我甚至可以使用寄存器 *每个*变量的说明符,其

地址未被取消。但结果并不漂亮,而且它可能不会带来太多好处;任何体面的现代优化编译器

应该能够自己解决这个问题。

再次,我的意见,但''注册''存储类没有提供使用它时有一个优点:编译器被允许忽略它当选择放置变量时,编译器优化生成的代码可能比优化<程序员可以,并且语言对定义为寄存器的变量的使用施加限制。



One could argue that that''s an advantage. The "register" specifier is
a way of asserting to the compiler that a given variable won''t have
its address taken. Theoretically a compiler could use that
information for optimization, even if it doesn''t use it for its
original intent (storing the variable in a CPU register).

If my goal were to give the compiler as much information as possible,
I might even use a "register" specifier on *every* variable whose
address isn''t taken. But the result wouldn''t be pretty, and it
probably wouldn''t do much good; any decent modern optimizing compiler
should be able to figure this out for itself.
Again, my opinion, but the ''register'' storage class doesn''t provide much
of an advantage when it is used: the compiler is permitted to ignore it
when selecting placement of variables, compiler optimization of
generated code may do a better job of optimizing placement than the
programmer can, and the language imposes restrictions on the use of
variables defined as register.




这当然是常识,并且我怀疑编译器

实施者在决定支付注册时需要多少注意力时才考虑到这一点。说明者(即,不多)。我甚至读过

" register"可以通过干扰编译器的b
自己的分析来损害优化,但我不知道这是否真的如此。


- -

Keith Thompson(The_Other_Keith) ks***@mib.org < http:// www .ghoti.net / ~kst>

圣地亚哥超级计算机中心< *> < http://users.sdsc.edu/~kst>

Schroedinger做莎士比亚:要*和*不要



That''s certainly the common wisdom, and I suspect compiler
implementers take that into account when deciding how much attention
to pay to "register" specifiers (i.e., not much). I''ve even read that
"register" can hurt optimization by interfering with the compiler''s
own analysis, but I don''t know if that''s actually true.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"


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

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