| 105 | } |
| 106 | |
| 107 | llvm::Value * nativeBoolCast(llvm::IRBuilderBase & b, const DataTypePtr & from_type, llvm::Value * value) |
| 108 | { |
| 109 | if (from_type->isNullable()) |
| 110 | { |
| 111 | auto * inner = nativeBoolCast(b, removeNullable(from_type), b.CreateExtractValue(value, {0})); |
| 112 | return b.CreateAnd(b.CreateNot(b.CreateExtractValue(value, {1})), inner); |
| 113 | } |
| 114 | |
| 115 | auto * zero = llvm::Constant::getNullValue(value->getType()); |
| 116 | |
| 117 | if (value->getType()->isIntegerTy()) |
| 118 | return b.CreateICmpNE(value, zero); |
| 119 | if (value->getType()->isFloatingPointTy()) |
| 120 | return b.CreateFCmpUNE(value, zero); |
| 121 | |
| 122 | throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Cannot cast non-number {} to bool", from_type->getName()); |
| 123 | } |
| 124 | |
| 125 | llvm::Value * nativeBoolCast(llvm::IRBuilderBase & b, const ValueWithType & value_with_type) |
| 126 | { |
no test coverage detected