MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / toNativeType

Function toNativeType

src/DataTypes/Native.cpp:67–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67llvm::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
102llvm::Type * toNativeType(llvm::IRBuilderBase & builder, const DataTypePtr & type)
103{

Callers 15

compileAddMethod · 0.85
compileMergeMethod · 0.85
compileGetResultMethod · 0.85
compileCreateMethod · 0.85
compileAddMethod · 0.85
compileMergeMethod · 0.85
compileGetResultMethod · 0.85
compileAddMethod · 0.85
compileMergeMethod · 0.85
compileGetResultMethod · 0.85
compileGetResultMethod · 0.85
nativeCastFunction · 0.85

Calls 15

toNullableTypeFunction · 0.85
getNestedTypeMethod · 0.80
isInt8Method · 0.80
isUInt8Method · 0.80
isInt16Method · 0.80
isUInt16Method · 0.80
isInt32Method · 0.80
isUInt32Method · 0.80
isDate32Method · 0.80
isDecimal32Method · 0.80
isDecimal64Method · 0.80
isDateTime64Method · 0.80

Tested by

no test coverage detected