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

Method AddLlvmCodegenDouble

be/src/codegen/llvm-codegen-cache-test.cc:239–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237}
238
239void LlvmCodeGenCacheTest::AddLlvmCodegenDouble(
240 LlvmCodeGen* codegen, string* module_id = nullptr, bool doFinalizeModule = true) {
241 ASSERT_TRUE(codegen != nullptr);
242 LlvmCodeGen::FnPrototype prototype(codegen, "Double", codegen->i32_type());
243 prototype.AddArgument(LlvmCodeGen::NamedVariable("n", codegen->i32_type()));
244 LlvmBuilder builder(codegen->context());
245 llvm::Value* args[1];
246 llvm::Function* fn = prototype.GeneratePrototype(&builder, args);
247 llvm::Value* mul = codegen->GetI32Constant(2);
248 args[0] = builder.CreateMul(args[0], mul);
249 builder.CreateRet(args[0]);
250 fn = codegen->FinalizeFunction(fn);
251 ASSERT_TRUE(fn != nullptr);
252 CodegenFnPtr<TestDouble> jitted_fn;
253 AddFunctionToJit(codegen, fn, &jitted_fn);
254 if (doFinalizeModule) {
255 ASSERT_OK(FinalizeModule(codegen, module_id));
256 ASSERT_TRUE(jitted_fn.load() != nullptr);
257 TestEcho test_fn = jitted_fn.load();
258 ASSERT_EQ(test_fn(1), 2);
259 }
260}
261
262/// Test the basic function of a codegen cache.
263void LlvmCodeGenCacheTest::TestBasicFunction(TCodeGenCacheMode::type mode) {

Callers

nothing calls this directly

Calls 8

NamedVariableClass · 0.85
i32_typeMethod · 0.80
AddArgumentMethod · 0.80
contextMethod · 0.80
GeneratePrototypeMethod · 0.80
GetI32ConstantMethod · 0.80
FinalizeFunctionMethod · 0.80
loadMethod · 0.45

Tested by

no test coverage detected