<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi Jia<br>
<br>
I don't think this is a problem with the ExecutionEngine. Your
problem comes from the confusion of the "Vector Type" in LLVM IR [1]
with the "std::vector" data structure in the C++ STL. While there is
no direct relation between the two, you should be able to use a
std::vector to provide the input for the <4 x i61> Vector Type
by passing the std::vector's raw data [3].<br>
<br>
However, it would be easier with something like this:<br>
<br>
using VecInt = int64[4];<br>
VecInt args0 { 0, 1, 2, 3 };<br>
...<br>
VecInt result = function(args0, ...);<br>
<br>
Btw.: Note that you may need to set target-feature attributes for
your function like so: [3]<br>
<br>
Hope it helps.<br>
<br>
Cheers,<br>
Stefan<br>
<br>
[1] <a class="moz-txt-link-freetext" href="https://llvm.org/docs/LangRef.html#vector-type">https://llvm.org/docs/LangRef.html#vector-type</a><br>
[2] <a class="moz-txt-link-freetext" href="https://en.cppreference.com/w/cpp/container/vector">https://en.cppreference.com/w/cpp/container/vector</a><br>
[3] <a class="moz-txt-link-freetext" href="https://en.cppreference.com/w/cpp/container/vector/data">https://en.cppreference.com/w/cpp/container/vector/data</a><br>
[4]
<a class="moz-txt-link-freetext" href="https://github.com/weliveindetail/DecisionTreeCompiler/blob/master/compiler/DecisionTreeCompiler.cpp#L83">https://github.com/weliveindetail/DecisionTreeCompiler/blob/master/compiler/DecisionTreeCompiler.cpp#L83</a><br>
<br>
<div class="moz-cite-prefix">Am 20.07.18 um 02:02 schrieb Jia Yu via
llvm-dev:<br>
</div>
<blockquote type="cite"
cite="mid:CAN7JVgWFVuCm+hRC1PQ-1gq2yfN61ds5H7fqnAWpsEn+Bh198w@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<div dir="ltr">Dear all,
<div><br>
</div>
<div>I am using LLVM C++ API to generate some code. In
particular, I am dealing with AVX2 SIMD API which uses
__m256i.</div>
<div><br>
</div>
<div>My function input types a set of vectors and return type is
also a vector.</div>
<div><br>
</div>
<div>///////////////////////////////////////////////////////////////////////////////////////////</div>
<div>
<div>
arguments.push_back(VectorType::get(IntegerType::getIntNTy(TheContext,
64), 4));//int64*4 = __m256i</div>
<div> FunctionType * proto =
FunctionType::get(VectorType::get(IntegerType::getIntNTy(TheContext,
64), 4),//int64*4 = __m256i<br>
</div>
<div>
arguments, false);</div>
</div>
<div>
<div
style="font-size:small;text-decoration-style:initial;text-decoration-color:initial">///////////////////////////////////////////////////////////////////////////////////////////</div>
<div
style="font-size:small;text-decoration-style:initial;text-decoration-color:initial"><br
class="gmail-Apple-interchange-newline">
</div>
I can successfully use this way to produce the IR of my
function properly like this:</div>
<div>
<div
style="font-size:small;text-decoration-style:initial;text-decoration-color:initial">///////////////////////////////////////////////////////////////////////////////////////////</div>
<div
style="text-decoration-style:initial;text-decoration-color:initial">
<p
style="margin-top:0pt;margin-bottom:0pt;direction:ltr;unicode-bidi:embed;vertical-align:baseline"><font
color="#000000" face="Arial"><span
style="font-size:16px">define <4 x i64>
@tpchq6(<4 x i64> %leaf7, <4 x i64>
%leaf8, <4 x i64> %leaf9, <4 x i64>
%leaf10, <4 x i64> %leaf11, <4 x i64>
%leaf12, <4 x i64> %leaf13, <4 x i64>
%leaf14) {</span></font></p>
<p
style="margin-top:0pt;margin-bottom:0pt;direction:ltr;unicode-bidi:embed;vertical-align:baseline"><font
color="#000000" face="Arial"><span
style="font-size:16px">entry:</span></font></p>
<p
style="margin-top:0pt;margin-bottom:0pt;direction:ltr;unicode-bidi:embed;vertical-align:baseline"><font
color="#000000" face="Arial"><span
style="font-size:16px"> %addtmp = add <4 x i64>
%leaf14, %leaf13</span></font></p>
<p
style="margin-top:0pt;margin-bottom:0pt;direction:ltr;unicode-bidi:embed;vertical-align:baseline"><font
color="#000000" face="Arial"><span
style="font-size:16px"> %leaf8.neg = sub <4 x
i64> zeroinitializer, %leaf8</span></font></p>
<p
style="margin-top:0pt;margin-bottom:0pt;direction:ltr;unicode-bidi:embed;vertical-align:baseline"><font
color="#000000" face="Arial"><span
style="font-size:16px"> %xortmp = xor <4 x i64>
%addtmp, %leaf11</span></font></p>
<p
style="margin-top:0pt;margin-bottom:0pt;direction:ltr;unicode-bidi:embed;vertical-align:baseline"><font
color="#000000" face="Arial"><span
style="font-size:16px"> %addtmp1 = add <4 x
i64> %leaf8.neg, %leaf7</span></font></p>
<p
style="margin-top:0pt;margin-bottom:0pt;direction:ltr;unicode-bidi:embed;vertical-align:baseline"><font
color="#000000" face="Arial"><span
style="font-size:16px"> %subtmp = add <4 x i64>
%addtmp1, %leaf9</span></font></p>
<p
style="margin-top:0pt;margin-bottom:0pt;direction:ltr;unicode-bidi:embed;vertical-align:baseline"><font
color="#000000" face="Arial"><span
style="font-size:16px"> %addtmp2 = add <4 x
i64> %subtmp, %leaf10</span></font></p>
<p
style="margin-top:0pt;margin-bottom:0pt;direction:ltr;unicode-bidi:embed;vertical-align:baseline"><font
color="#000000" face="Arial"><span
style="font-size:16px"> %addtmp3 = add <4 x
i64> %addtmp2, %xortmp</span></font></p>
<p
style="margin-top:0pt;margin-bottom:0pt;direction:ltr;unicode-bidi:embed;vertical-align:baseline"><font
color="#000000" face="Arial"><span
style="font-size:16px"> ret <4 x i64> %addtmp3</span></font></p>
<p
style="margin-top:0pt;margin-bottom:0pt;direction:ltr;unicode-bidi:embed;vertical-align:baseline"><font
color="#000000" face="Arial"><span
style="font-size:16px">}</span></font></p>
<br class="gmail-Apple-interchange-newline">
</div>
<div
style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">///////////////////////////////////////////////////////////////////////////////////////////</div>
<div><br>
</div>
However, when I use JIT ExectionEngine to run it, it cannot
return the Vector type properly. I tried the jit execution
engine with non-vector return like int64, it works fine.</div>
<div><br>
</div>
<div>My code is as follows: It always tells me segment fault</div>
<div>
<div
style="font-size:small;text-decoration-style:initial;text-decoration-color:initial;background-color:rgb(255,255,255)">///////////////////////////////////////////////////////////////////////////////////////////</div>
<div>// Define the input/output data type in LLVM function</div>
<div> typedef std::vector<int64_t> VecInt;</div>
</div>
<div><br>
</div>
<div>
<div>auto function = reinterpret_cast<VecInt (*)(VecInt ,
VecInt, VecInt, VecInt, VecInt, VecInt, VecInt,
VecInt)>(TheExecutionEngine->getFunctionAddress(TheFunction->getName().str()));</div>
<div>VecInt result =
function(functionCallArgs[0],functionCallArgs[1],functionCallArgs[2],functionCallArgs[3],</div>
<div>
functionCallArgs[4],functionCallArgs[5],functionCallArgs[6],functionCallArgs[7]);</div>
</div>
<div><br>
</div>
<div>std::cout<<"result size "<<
<span
style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">result</span>.size()<<"\n";<br>
</div>
<div>
<div
style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">///////////////////////////////////////////////////////////////////////////////////////////</div>
<div
style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><br
class="gmail-Apple-interchange-newline">
</div>
<br class="gmail-Apple-interchange-newline">
Can someone tell me whether this is the correct way to
retrieve the vector return type? Or is the vector type return
supported?</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Jia Yu<br clear="all">
<div>
<div dir="ltr" class="gmail_signature">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<p style="margin:0in 0in
0.0001pt"><br>
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="https://weliveindetail.github.io/blog/">https://weliveindetail.github.io/blog/</a>
<a class="moz-txt-link-freetext" href="https://cryptup.org/pub/stefan.graenitz@gmail.com">https://cryptup.org/pub/stefan.graenitz@gmail.com</a></pre>
</body>
</html>