Location information for null indicator bit for particular slot. For non-nullable slots, the byte_offset will be 0 and the bit_mask will be 0. This allows us to do the NullIndicatorOffset operations (tuple + byte_offset &/| bit_mask) regardless of whether the slot is nullable or not. This is more efficient than branching to check if the slot is non-nullable. ToIR() generates a constant version of
| 90 | /// ToIR() generates a constant version of this struct in LLVM IR. If the struct |
| 91 | /// layout is updated, then ToIR() must also be updated. |
| 92 | struct NullIndicatorOffset { |
| 93 | int byte_offset; |
| 94 | uint8_t bit_mask; /// to extract null indicator |
| 95 | |
| 96 | NullIndicatorOffset(int byte_offset = 0, int bit_offset = -1) |
| 97 | : byte_offset(byte_offset), |
| 98 | bit_mask(bit_offset == -1 ? 0 : 1 << bit_offset) { |
| 99 | } |
| 100 | |
| 101 | bool Equals(const NullIndicatorOffset& o) const { |
| 102 | return this->byte_offset == o.byte_offset && this->bit_mask == o.bit_mask; |
| 103 | } |
| 104 | |
| 105 | std::string DebugString() const; |
| 106 | |
| 107 | // Generates an LLVM IR constant of this offset. Needs to be updated if the layout of |
| 108 | // this struct changes. |
| 109 | llvm::Constant* ToIR(LlvmCodeGen* codegen) const; |
| 110 | |
| 111 | // Generates a packed i64 constant of this offset. This can be used when passing a |
| 112 | // constant offset to a function which expects it as a packed i64. Needs to be updated |
| 113 | // if the layout of this struct changes. |
| 114 | llvm::Constant* ToIRPacked(LlvmCodeGen* codegen) const; |
| 115 | |
| 116 | static const char* LLVM_CLASS_NAME; |
| 117 | }; |
| 118 | |
| 119 | std::ostream& operator<<(std::ostream& os, const NullIndicatorOffset& null_indicator); |
| 120 |
no outgoing calls