<div dir="ltr">It should be VectorType::get(<span style="font-size:12.8px">Type::getInt32Ty(</span><wbr style="font-size:12.8px"><span style="font-size:12.8px">Context),4).  You need the word "get" after VectorType::</span></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature">~Craig</div></div>
<br><div class="gmail_quote">On Fri, Apr 7, 2017 at 6:01 PM, Michael Choi <span dir="ltr"><<a href="mailto:choimichael103@gmail.com" target="_blank">choimichael103@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Thank you so much Craig!<br><br></div>I tried it. But still complaining. Here is the error message during compilation.<br><br>HowToUseJIT_SIMD_FuncProto.<wbr>cpp:94:55: error: expected unqualified-id<br>                              <wbr>            VectorType::(Type::getInt32Ty(<wbr>Context),4),<br> <br><div><br><br>THIS IS MY CODE:<br>  LLVMContext Context;<br><br>  std::unique_ptr<Module> Owner = make_unique<Module>("test", Context);<br>  Module *M = Owner.get();<br><br>  Function *Add1F =<br>    cast<Function>(M-><wbr>getOrInsertFunction("add1",<br>                              <wbr>            VectorType::(Type::getInt32Ty(<wbr>Context),4),<br>                              <wbr>            VectorType::(Type::getInt32Ty(<wbr>Context),4),<br><br>                              <wbr>            //Type::getInt32Ty(Context),  <wbr>          //This is working fine<br>                              <wbr>            //Type::getInt32Ty(Context),  <wbr>          //This is working fine<br><br>                              <wbr>            nullptr));<br><br><br></div><div>Any idea?<br></div><div>Please let me know what is wrong in my code.<br></div><div><br></div><div>Thanks,<br></div><div>Michael<br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 7, 2017 at 5:36 PM, Craig Topper <span dir="ltr"><<a href="mailto:craig.topper@gmail.com" target="_blank">craig.topper@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">To create a vector type you can call VectorType::get(<scalar element type>, <num of elements>) and pass the output of that to the Type argument when creating instructions. To get the scalar element type you can use the get*Ty methods in IRBuilder or the Type::get*Ty methods.</div><div class="gmail_extra"><br clear="all"><div><div class="m_2543110912896722681m_238207016304063862gmail_signature" data-smartmail="gmail_signature">~Craig</div></div>
<br><div class="gmail_quote"><div><div class="m_2543110912896722681h5">On Fri, Apr 7, 2017 at 5:20 PM, Michael Choi via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_2543110912896722681h5"><div dir="ltr"><div>I am working on AVX2 code generation by LLVM framework.<br><br></div><div>I want to generate LLVM-IR code for the following code by C/C++ API from LLVM framework. I am using LLVM3.8.<br></div><div>Basically, I want to generate TARGET (Refer to below) LLVM-IR code for SOURCE function by C/C++ API.<br></div><div>As you see below, the AVX2 data type is __m256i which is vector type. How can I indicate vector type (function return type, input parameters) for IRBuiler by C/C++ APIs?<br><br></div><div>I don't see any example online and please let me know if anybody has examples.<br></div><div><br><br></div><div><br>SOURCE:<br>#include "immintrin.h"<br>__m256i sum(__m256i a, __m256i b) {<br>    return a+b;<br>}<br><br></div><div>TARGET: <br>michael@michael-Precision-Towe<wbr>r-3420:~/Year_2017/work_DEMO$ cat avx2_add2.ll<br>; ModuleID = 'avx2_add2.c'<br>target datalayout = "e-m:w-i64:64-f80:128-n8:16:32<wbr>:64-S128"<br>target triple = "x86_64-unknown-windows-cygnus<wbr>"<br><br>; Function Attrs: nounwind<br>define <4 x i64> @sum(<4 x i64> %a, <4 x i64> %b) #0 {<br>  %1 = alloca <4 x i64>, align 32<br>  %2 = alloca <4 x i64>, align 32<br>  store <4 x i64> %a, <4 x i64>* %1, align 32<br>  store <4 x i64> %b, <4 x i64>* %2, align 32<br>  %3 = load <4 x i64>, <4 x i64>* %1, align 32<br>  %4 = load <4 x i64>, <4 x i64>* %2, align 32<br>  %5 = add <4 x i64> %3, %4<br>  ret <4 x i64> %5<br>}<br><br>attributes #0 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false<wbr>" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"=<wbr>"8" "target-features"="+mmx,+sse,+<wbr>sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }<br><br>!llvm.ident = !{!0}<br><br>!0 = !{!"clang version 3.8.1 (tags/RELEASE_381/final)"}<br><br></div><div>Thanks,<br></div><div>Michael<br></div></div>
<br></div></div>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>