(original) (raw)
Fantastic! It's working! Thank you so much Craig!!!
On Fri, Apr 7, 2017 at 6:05 PM, Craig Topper <craig.topper@gmail.com> wrote:
It should be VectorType::get(Type::getInt32Ty(Context),4). You need the word "get" after VectorType:: \~CraigOn Fri, Apr 7, 2017 at 6:01 PM, Michael Choi <choimichael103@gmail.com> wrote:Thank you so much Craig!I tried it. But still complaining. Here is the error message during compilation.
HowToUseJIT\_SIMD\_FuncProto.cpp:94:55: error: expected unqualified-id
VectorType::(Type::getInt32Ty( Context),4),
THIS IS MY CODE:
LLVMContext Context;
std::unique\_ptr Owner = make\_unique("test", Context);
Module \*M = Owner.get();
Function \*Add1F =
cast(M->getOrInsertFunction("add1",
VectorType::(Type::getInt32Ty( Context),4),
VectorType::(Type::getInt32Ty( Context),4),
//Type::getInt32Ty(Context), //This is working fine
//Type::getInt32Ty(Context), //This is working fine
nullptr)); Any idea?Please let me know what is wrong in my code.Thanks,MichaelOn Fri, Apr 7, 2017 at 5:36 PM, Craig Topper <craig.topper@gmail.com> wrote:To create a vector type you can call VectorType::get(, ) 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.\~CraigOn Fri, Apr 7, 2017 at 5:20 PM, Michael Choi via llvm-dev <llvm-dev@lists.llvm.org> wrote:\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_I am working on AVX2 code generation by LLVM framework.I want to generate LLVM-IR code for the following code by C/C++ API from LLVM framework. I am using LLVM3.8.Basically, I want to generate TARGET (Refer to below) LLVM-IR code for SOURCE function by C/C++ API.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?I don't see any example online and please let me know if anybody has examples.
SOURCE:
#include "immintrin.h"
\_\_m256i sum(\_\_m256i a, \_\_m256i b) {
return a+b;
}TARGET:
michael@michael-Precision-Tower-3420:\~/Year\_2017/work\_DEMO$ cat avx2\_add2.ll
; ModuleID = 'avx2\_add2.c'
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86\_64-unknown-windows-cygnus"
; Function Attrs: nounwind
define <4 x i64> @sum(<4 x i64> %a, <4 x i64> %b) #0 {
%1 = alloca <4 x i64>, align 32
%2 = alloca <4 x i64>, align 32
store <4 x i64> %a, <4 x i64>\* %1, align 32
store <4 x i64> %b, <4 x i64>\* %2, align 32
%3 = load <4 x i64>, <4 x i64>\* %1, align 32
%4 = load <4 x i64>, <4 x i64>\* %2, align 32
%5 = add <4 x i64> %3, %4
ret <4 x i64> %5
}
attributes #0 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"= "8" "target-features"="+mmx,+sse,+ sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
!llvm.ident = !{!0}
!0 = !{!"clang version 3.8.1 (tags/RELEASE\_381/final)"}Thanks,Michael\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
LLVM Developers mailing list
llvm-dev@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev