如何使用SSA形式处理数据流分析中的别名寄存器? (例如 x86 中的 EAX/AX/AH/AL)
例如:
在 SSA form 中表示以下 x86:
xor eax, eax
inc ax
如何 引入一些伪函数,我想出:
eax@1 = eax@0 ^ eax@0
ax@1 = LOWORD(eax@1)
al@1 = LOBYTE(ax@1)
ah@1 = HIBYTE(ax@1)
hax@1 = HIWORD(eax@1)
ax@2 = ax@1 + 1
eax@2 = MAKEDWORD(ax@2, HIWORD(eax@1))
al@2 = LOBYTE(ax@2)
ah@2 = HIBYTE(ax@2)
但我认为它太冗长了
For exmaple:
How to represent the following x86 in SSA form:
xor eax, eax
inc ax
By introducing some pseudo functions, I come up with:
eax@1 = eax@0 ^ eax@0
ax@1 = LOWORD(eax@1)
al@1 = LOBYTE(ax@1)
ah@1 = HIBYTE(ax@1)
hax@1 = HIWORD(eax@1)
ax@2 = ax@1 + 1
eax@2 = MAKEDWORD(ax@2, HIWORD(eax@1))
al@2 = LOBYTE(ax@2)
ah@2 = HIBYTE(ax@2)
But I think it's too much verbose
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用您的符号:
之间有一个隐式步骤
步骤 2 因为任何数字与其自身异或都是 0.. eax@0 此时已死,因此 eax@1 可以重命名(使用 ebx 进行重命名,使其可读;显然您将使用虚拟寄存器,而不是真实的寄存器):
然后您可以注意到,因为步骤 3 是一个常量函数,所以步骤 4(将常量添加到常量)也是如此,并将两者压缩在一起(即常量折叠)
如果 ebx 的高 16 位不支配下面的任何内容,您也可以删除步骤 2。
Using your notation:
Because eax contains ax, there's an implicit step in between 2 and 3
Step 2 because any number xor'ed with itself is 0... eax@0 is dead at that point, and thus eax@1 can be renamed (using ebx as renaming so it's readable; obviously you would use a virtual register, not a real one):
You could then note that because step 3 is a constant function, so is step 4 (adding a constant to a constant) and compress the two together (i.e. constant folding)
If the upper 16 bits of ebx don't dominate anything below this, you could also delete step 2.