LLVM源码--PointerIntPairInfo类

来源:互联网 发布:php图片上传 编辑:程序博客网 时间:2024/06/05 12:55

PointerIntPairInfo类是个比较特殊的类,这个类没有成员,是辅助PointerIntPair类,而PointerIntPair只有一个成员,这个成员的类型是个unsigned int Value,   PointerIntPairInfo定义了了几个枚举值,这几个枚举值类型是unsigned int。它们的作用是用来提取Value中的信息,Value是个unsigned int ,Value的信息分布 高位->低位:指针->整数->其他作用的位

enum : uintptr_t {
    /// PointerBitMask - The bits that come from the pointer.

   NumLowBitsAvailable表示一个unsigned int除去指针的位数后剩下的位数,unsigned int有32位,比如NumLowBitsAvailable=5,那么PointerBitMask=1(27个)0(5个)

  表示高位的27位表示指针,后面的5位有其他用处
    PointerBitMask =
        ~(uintptr_t)(((intptr_t)1 << PtrTraits::NumLowBitsAvailable) - 1),


    /// IntShift - The number of low bits that we reserve for other uses, and
    /// keep zero.

    比如NumLowBitsAvailable=5,表示指针用了27位,IntBits表示整数用了多少位, IntShift表示除了 指针,整数   后的位数
    IntShift = (uintptr_t)PtrTraits::NumLowBitsAvailable - IntBits,


    /// IntMask - This is the unshifted mask for valid bits of the int type.

    比如 IntBits=3,IntMask =0(29个)1(3个)
    IntMask = (uintptr_t)(((intptr_t)1 << IntBits) - 1),


    // ShiftedIntMask - This is the bits for the integer shifted in place.

    这个主要是用来获取一个unsigned int整数的部分
    ShiftedIntMask = (uintptr_t)(IntMask << IntShift)
  };