注册参数 [英] Register parameters

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

问题描述

嗨再次!


我最近遇到了K& R风格的旧代码,它声明了

函数参数作为寄存器。这让我很困惑,而且我知道这是实现定义的b $ b实现,并且取决于体系结构,编译器等等。

on。但我的问题是,如何使参数变得更快。 (6.7.1,

,附注103)。


在英特尔和类似的实现中,所有参数都是,尽管我是
知道,推入堆栈。在PPC上,他们可以通过

寄存器。


有人可以澄清这个关键字的使用以及它如何起作用

具有更快访问的实际例子中的功能参数。比一个

正常参数?


我知道这又是实现定义的,但我不感兴趣

in a特别是编译器或架构,我很好奇*有些*

它们的例子,如果有的话。


谢谢!

- -


Sensei *< Sensei'的电子邮件是在Mac-dot-com>


有三件事是肯定的/>
死亡,税收和遗失数据

猜猜发生了什么。 (计算机的Haiku)

Hi again!

I have recently encountered an old code in K&R style which declared
function parameters as register. That puzzles me, and I know this is
implementation defined, and depends on architecture, compiler and so
on. But my question is, how can be a parameter made "faster" (6.7.1,
with note 103).

On Intel and similar implementations all parameters are, as far as I
know, pushed into the stack. On PPC they can be passed through
registers.

Can someone clarify the use of this keyword and how it may work for
function parameters in a real-world example with "faster access" than a
normal parameter?

I know this is, again, implementation defined, but I am not interested
in a particular compiler or architecture, I am curious about *some*
examples of them, if any.

Thanks!
--

Sensei*<Sensei''s e-mail is at Mac-dot-com>

Three things are certain
Death, taxes, and lost data
Guess which has occurred. (Computer''s Haiku)

推荐答案

Sensei写道:
Sensei wrote:

你好!


我最近遇到了K& R风格的旧代码,它声明了

函数参数作为寄存器。这让我很困惑,我知道这是实现定义的b
依赖于体系结构,编译器等等。

但我的问题是,如何制作参数? ;更快" (6.7.1,附:

note 103)。


在英特尔和类似的实现中,所有参数都是,尽管我是
知道,推入堆栈。在PPC上,它们可以通过寄存器传递。


有人可以澄清这个关键字的使用以及它如何在真实世界中用于

函数参数具有更快访问的示例比一个

正常参数?


我知道这又是实现定义的,但我不感兴趣

in a特别是编译器或体系结构,我很好奇*有些*

它们的例子,如果有的话。
Hi again!

I have recently encountered an old code in K&R style which declared
function parameters as register. That puzzles me, and I know this is
implementation defined, and depends on architecture, compiler and so on.
But my question is, how can be a parameter made "faster" (6.7.1, with
note 103).

On Intel and similar implementations all parameters are, as far as I
know, pushed into the stack. On PPC they can be passed through registers.

Can someone clarify the use of this keyword and how it may work for
function parameters in a real-world example with "faster access" than a
normal parameter?

I know this is, again, implementation defined, but I am not interested
in a particular compiler or architecture, I am curious about *some*
examples of them, if any.



我效果,函数参数是只是

函数中的另一个局部变量。


旧的编译器在演绎哪些变量时应该不如现在的变量那么好?
变量应该是被分配到寄存器,因此您将在旧代码中更频繁地看到注册




-

Ian柯林斯。

I effect, a function parameter is just another local variable in the
function.

Older compiler were not as good as modern ones at deducing which
variables should be assigned to registers, hence you will see "register"
more often in old code.

--
Ian Collins.


Sensei< Sensei'的电子邮件是Mac-dot-comwrote:
Sensei <Sensei''s e-mail is at Mac-dot-comwrote:

嗨再次!


我最近遇到了K& R风格的旧代码,它声明了

函数参数作为寄存器。这让我很困惑,而且我知道这是实现定义的b $ b实现,并且取决于体系结构,编译器等等。

on。但我的问题是,如何使参数变得更快。 (6.7.1,

,附注103)。


在英特尔和类似的实现中,所有参数都是,尽管我是
知道,推入堆栈。
Hi again!

I have recently encountered an old code in K&R style which declared
function parameters as register. That puzzles me, and I know this is
implementation defined, and depends on architecture, compiler and so
on. But my question is, how can be a parameter made "faster" (6.7.1,
with note 103).

On Intel and similar implementations all parameters are, as far as I
know, pushed into the stack.



仅当禁用优化时。

Only when optimisations are disabled.


在PPC上,它们可以通过寄存器传递。
On PPC they can be passed through registers.



它们可以通过任何具有足够金额
金额的机器上的寄存器传递。

They can be passed through registers on any machines that has sufficient
amounts of them.


有人可以澄清这个关键字的使用,以及它如何在一个真实世界的例子中使用更快的访问来实现

函数参数。比

一个正常的参数?
Can someone clarify the use of this keyword and how it may work for
function parameters in a real-world example with "faster access" than
a normal parameter?



使用寄存器限定参数向编译器指示对象不会出现别名。

。这可以使它执行一些它可能无法做到的优化
优化。请记住

当时无法使用restrict关键字。


< snip>

Qualifying a parameter with register indicates to the compiler that such
an object will not be aliased. This can enable it perform some
optimisations that it might otherwise not be able to do. Remember that
the restrict keyword was not available back then.

<snip>

在文章< g5 ********** @ registered.motzarella.org>中,

santosh< sa ********* @ gmail .comwrote:
In article <g5**********@registered.motzarella.org>,
santosh <sa*********@gmail.comwrote:

>在英特尔和类似的实现中,据我所知,所有参数都被推入堆栈。
>On Intel and similar implementations all parameters are, as far as I
know, pushed into the stack.


>仅在禁用优化时。
>Only when optimisations are disabled.



更改不同

优化级别的调用约定是否可行?这会使用不同的优化编译的模块与b $ b优化不相容。


- 理查德


-

请记得提及我/你留下的录音带。

Is it practical to change the calling convention for different
optimisation levels? This would make modules compiled with different
optimisation incompatible.

-- Richard

--
Please remember to mention me / in tapes you leave behind.


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

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