变量的offset

2 views
Skip to first unread message

Jianzhang Peng

unread,
Dec 14, 2009, 10:44:55 PM12/14/09
to hell...@googlegroups.com
大家好,


怎样查看变量相对栈指针的offset?

谢谢!

--
Jianzhang Peng

Peng Jianzhang

unread,
Dec 14, 2009, 10:53:22 PM12/14/09
to HelloGcc Workshop
例如下面是一个数组的debug信息
(gdb) debug_tree attr->expr
<var_decl 0x2a96140a00 b
type <array_type 0x2a96154f00
type <real_type 0x2a9608c6c0 float sizes-gimplified SF
size <integer_cst 0x2a96066900 constant 32>
unit size <integer_cst 0x2a96066570 constant 4>
align 32 symtab 0 alias set 2 canonical type 0x2a9608c6c0
precision 32
pointer_to_this <pointer_type 0x2a9608c900>>
sizes-gimplified BLK
size <integer_cst 0x2a9617e390 constant 327680>
unit size <integer_cst 0x2a9617e3c0 constant 40960>
align 32 symtab 0 alias set 2 canonical type 0x2a96154f00
domain <integer_type 0x2a96154e40 type <integer_type
0x2a9607d000 unsigned int>
sizes-gimplified SI size <integer_cst 0x2a96066900 32>
unit size <integer_cst 0x2a96066570 4>
align 32 symtab 0 alias set -1 canonical type 0x2a96154e40
precision 32 min <integer_cst 0x2a960665a0 0> max <integer_cst
0x2a9617e300 10239>>
pointer_to_this <pointer_type 0x2a961806c0>>
addressable used BLK file loop.c line 8 col 13 size <integer_cst
0x2a9617e390 327680> unit size <integer_cst 0x2a9617e3c0 40960>
align 128 context <function_decl 0x2a96155f00 test>
(mem/s/c:BLK (reg/f:SI 78 $frame) [2 b+0 S40960 A128]) chain
<var_decl 0x2a96140aa0 c>>

Eric Fisher

unread,
Dec 15, 2009, 12:19:57 AM12/15/09
to hell...@googlegroups.com
在tree阶段,还没有栈信息的吧?要到rtl时候,会用到TARGET_ASM_FUNCTION_PROLOGUE和TARGET_ASM_FUNCTION_EPILOGUE这些函数来处理函数压栈。

2009/12/15 Peng Jianzhang <pengji...@gmail.com>:
> --
>
> 您收到此邮件是因为您订阅了 Google 网上论坛的"HelloGcc Workshop"论坛。
> 要向此网上论坛发帖,请发送电子邮件至 hell...@googlegroups.com
> 要取消订阅此网上论坛,请发送电子邮件至 hellogcc+u...@googlegroups.com
> 若有更多问题,请通过 http://groups.google.com/group/hellogcc?hl=zh-CN 访问此网上论坛。
>
>
>

Jianzhang Peng

unread,
Dec 15, 2009, 2:01:19 AM12/15/09
to hell...@googlegroups.com
在rtl指令调度的时候(pass-sched)的时候知道offset吗?

在上编译原理的时候,变量的offset和size属性在语法分析的时候就给出了。

MIPS标准规定栈指针是128位对齐,要判断某个变量是不是128位对齐,只需要判断它的offset就可以。

谢谢你
2009/12/15 Eric Fisher <joefo...@gmail.com>



--
Jianzhang Peng

Amker.Cheng

unread,
Dec 15, 2009, 2:15:07 AM12/15/09
to hell...@googlegroups.com
只有到寄存器分配后才知道吧?

--
Best Regards.

Eric Fisher

unread,
Dec 15, 2009, 2:19:48 AM12/15/09
to hell...@googlegroups.com
> 在上编译原理的时候,变量的offset和size属性在语法分析的时候就给出了。

这个offset有点悬。在寄存器分配前,所有的变量都认为是在伪寄存器中。

2009/12/15 Jianzhang Peng <pengji...@gmail.com>:

Jianzhang Peng

unread,
Dec 15, 2009, 3:28:24 AM12/15/09
to hell...@googlegroups.com
谢谢!

2009/12/15 Eric Fisher <joefo...@gmail.com>



--
Jianzhang Peng

Jianzhang Peng

unread,
Dec 16, 2009, 3:26:19 AM12/16/09
to hell...@googlegroups.com
m_expt = mem_attrs->expr
DECL_RTL(m_expr)描述它在栈上的位置
DECL_ALIGNA(m_expr)描述对齐的bit

2009/12/15 Jianzhang Peng <pengji...@gmail.com>



--
Jianzhang Peng
Reply all
Reply to author
Forward
0 new messages