| 65 | } |
| 66 | |
| 67 | llvm::Type * toNativeType(llvm::IRBuilderBase & builder, const IDataType & type) |
| 68 | { |
| 69 | WhichDataType data_type(type); |
| 70 | |
| 71 | if (data_type.isNullable()) |
| 72 | { |
| 73 | const auto & data_type_nullable = static_cast<const DataTypeNullable&>(type); |
| 74 | auto * nested_type = toNativeType(builder, *data_type_nullable.getNestedType()); |
| 75 | return toNullableType(builder, nested_type); |
| 76 | } |
| 77 | |
| 78 | /// LLVM doesn't have unsigned types, it has unsigned instructions. |
| 79 | if (data_type.isInt8() || data_type.isUInt8()) |
| 80 | return builder.getInt8Ty(); |
| 81 | if (data_type.isInt16() || data_type.isUInt16() || data_type.isDate()) |
| 82 | return builder.getInt16Ty(); |
| 83 | if (data_type.isInt32() || data_type.isUInt32() || data_type.isDate32() || data_type.isDateTime() || data_type.isDecimal32() || data_type.isTime()) |
| 84 | return builder.getInt32Ty(); |
| 85 | if (data_type.isInt64() || data_type.isUInt64() || data_type.isDecimal64() || data_type.isDateTime64() || data_type.isTime64()) |
| 86 | return builder.getInt64Ty(); |
| 87 | if (data_type.isInt128() || data_type.isUInt128() || data_type.isDecimal128()) |
| 88 | return builder.getInt128Ty(); |
| 89 | if (data_type.isInt256() || data_type.isUInt256() || data_type.isDecimal256()) |
| 90 | return builder.getIntNTy(256); |
| 91 | if (data_type.isFloat32()) |
| 92 | return builder.getFloatTy(); |
| 93 | if (data_type.isFloat64()) |
| 94 | return builder.getDoubleTy(); |
| 95 | if (data_type.isEnum8()) |
| 96 | return builder.getInt8Ty(); |
| 97 | if (data_type.isEnum16()) |
| 98 | return builder.getInt16Ty(); |
| 99 | throw Exception(ErrorCodes::LOGICAL_ERROR, "Invalid cast from {} to native type", type.getName()); |
| 100 | } |
| 101 | |
| 102 | llvm::Type * toNativeType(llvm::IRBuilderBase & builder, const DataTypePtr & type) |
| 103 | { |
no test coverage detected