LLVM每日谈之十八 GEP Instruction的几点总结

In summary, here’s some things to always remember about the GetElementPtr instruction:

  1. The GEP instruction never accesses memory, it only provides pointer computations.
  2. The first operand to the GEP instruction is always a pointer and it must be indexed.
  3. There are no superfluous indices for the GEP instruction.
  4. Trailing zero indices are superfluous for pointer aliasing, but not for the types of the pointers.
  5. Leading zero indices are not superfluous for pointer aliasing nor the types of the pointers.

这几条是《The Often Misunderstood GEP Instruction》文档最后对GEP指令的总结,原文档地址为:

http://llvm.org/docs/GetElementPtr.html
这几天基本上涵盖了GEP使用中需要注意的问题,现翻译如下:
1. GEP指令绝不允许操作内存,它只能提供指针相关的计算。
2. GEP指令的第一个操作数通常是一个指针,而且它通常是可以索引的。
3. GEP指令没有多余的无用的下标索引。
4. 下标索引尾部的0对指针的混用是没区别的,但是对指针类型的混用确是有区别的。
(译者注:此处指的是下标索引尾部有0和没0的混用。)
5. 下标索引头部的0对指针的混用和指针类型的混用都是有区别的。

(译者注:此处指的是下标索引头部有0和没0的混用。)

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值