MCPcopy Create free account
hub / github.com/apache/impala / CodegenAnyVal

Class CodegenAnyVal

be/src/codegen/codegen-anyval.h:63–304  ·  view source on GitHub ↗

Class for handling AnyVal subclasses during codegen. Codegen functions should use this wrapper instead of creating or manipulating *Val values directly in most cases. This is because the struct types must be lowered to integer types in many cases in order to conform to the standard calling convention (e.g., { i8, i32 } => i64). This class wraps the lowered types for each *Val struct. This class c

Source from the content-addressed store, hash-verified

61/// TODO:
62/// - unit tests
63class CodegenAnyVal {
64 public:
65 static const char* LLVM_ANYVAL_NAME;
66 static const char* LLVM_BOOLEANVAL_NAME;
67 static const char* LLVM_TINYINTVAL_NAME;
68 static const char* LLVM_SMALLINTVAL_NAME;
69 static const char* LLVM_INTVAL_NAME;
70 static const char* LLVM_BIGINTVAL_NAME;
71 static const char* LLVM_FLOATVAL_NAME;
72 static const char* LLVM_DOUBLEVAL_NAME;
73 static const char* LLVM_STRINGVAL_NAME;
74 static const char* LLVM_TIMESTAMPVAL_NAME;
75 static const char* LLVM_DECIMALVAL_NAME;
76 static const char* LLVM_DATEVAL_NAME;
77 static const char* LLVM_COLLECTIONVAL_NAME;
78
79 /// Creates a call to 'fn', which should return a (lowered) *Val, and returns the result.
80 /// This abstracts over the x64 calling convention, in particular for functions returning
81 /// a DecimalVal, which pass the return value as an output argument.
82 //
83 /// If 'result_ptr' is non-NULL, it should be a pointer to the lowered return type of
84 /// 'fn' (e.g. if 'fn' returns a BooleanVal, 'result_ptr' should have type i16*). The
85 /// result of calling 'fn' will be stored in 'result_ptr' and this function will return
86 /// NULL. If 'result_ptr' is NULL, this function will return the result (note that the
87 /// result will not be a pointer in this case).
88 //
89 /// 'name' optionally specifies the name of the returned value.
90 static llvm::Value* CreateCall(LlvmCodeGen* cg, LlvmBuilder* builder,
91 llvm::Function* fn, llvm::ArrayRef<llvm::Value*> args, const char* name = "",
92 llvm::Value* result_ptr = nullptr);
93
94 /// Same as above but wraps the result in a CodegenAnyVal.
95 static CodegenAnyVal CreateCallWrapped(LlvmCodeGen* cg, LlvmBuilder* builder,
96 const ColumnType& type, llvm::Function* fn, llvm::ArrayRef<llvm::Value*> args,
97 const char* name = "");
98
99 /// Returns the lowered AnyVal type associated with 'type'.
100 /// E.g.: TYPE_BOOLEAN (which corresponds to a BooleanVal) => i16
101 static llvm::Type* GetLoweredType(LlvmCodeGen* cg, const ColumnType& type);
102
103 /// Returns the lowered AnyVal pointer type associated with 'type'.
104 /// E.g.: TYPE_BOOLEAN => i16*
105 static llvm::PointerType* GetLoweredPtrType(LlvmCodeGen* cg, const ColumnType& type);
106
107 /// Returns the unlowered AnyVal type associated with 'type'.
108 /// E.g.: TYPE_BOOLEAN => %"struct.impala_udf::BooleanVal"
109 static llvm::Type* GetUnloweredType(LlvmCodeGen* cg, const ColumnType& type);
110
111 /// Returns the unlowered AnyVal pointer type associated with 'type'.
112 /// E.g.: TYPE_BOOLEAN => %"struct.impala_udf::BooleanVal"*
113 static llvm::PointerType* GetUnloweredPtrType(LlvmCodeGen* cg, const ColumnType& type);
114
115 /// Returns the pointer type to the AnyVal base class (AnyVal*).
116 static llvm::PointerType* GetAnyValPtrType(LlvmCodeGen* cg);
117
118 /// Return the constant type-lowered value corresponding to a null *Val.
119 /// E.g.: passing TYPE_DOUBLE (corresponding to the lowered DoubleVal { i8, double })
120 /// returns the constant struct { 1, 0.0 }

Callers 3

CreateCallWrappedMethod · 0.70
GetNonNullValMethod · 0.70
StructToReadWriteInfoMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected