diff --git a/builtins/target-avx11-x2.ll b/builtins/target-avx11-x2.ll index cdb83726..1aa6345c 100644 --- a/builtins/target-avx11-x2.ll +++ b/builtins/target-avx11-x2.ll @@ -31,7 +31,9 @@ include(`target-avx-x2.ll') -rdrand_definition() +ifelse(LLVM_VERSION, `LLVM_3_0', `rdrand_decls()', + LLVM_VERSION, `LLVM_3_1', `rdrand_decls()', + `rdrand_definition()') ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; int min/max @@ -73,6 +75,9 @@ gen_gather(double) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; float/half conversions +ifelse(LLVM_VERSION, `LLVM_3_0', ` +;; nothing to define... +', ` declare <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16>) nounwind readnone ; 0 is round nearest even declare <8 x i16> @llvm.x86.vcvtps2ph.256(<8 x float>, i32) nounwind readnone @@ -123,4 +128,5 @@ define i16 @__float_to_half_uniform(float %v) nounwind readnone { %r = extractelement <8 x i16> %rv, i32 0 ret i16 %r } - +' +) diff --git a/builtins/target-avx11.ll b/builtins/target-avx11.ll index d3ab9f13..fea0a7c2 100644 --- a/builtins/target-avx11.ll +++ b/builtins/target-avx11.ll @@ -31,7 +31,9 @@ include(`target-avx.ll') -rdrand_definition() +ifelse(LLVM_VERSION, `LLVM_3_0', `rdrand_decls()', + LLVM_VERSION, `LLVM_3_1', `rdrand_decls()', + `rdrand_definition()') ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; int min/max @@ -73,6 +75,9 @@ gen_gather(double) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; float/half conversions +ifelse(LLVM_VERSION, `LLVM_3_0', ` +;; nothing to define... +', ` declare <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16>) nounwind readnone ; 0 is round nearest even declare <8 x i16> @llvm.x86.vcvtps2ph.256(<8 x float>, i32) nounwind readnone @@ -107,3 +112,4 @@ define i16 @__float_to_half_uniform(float %v) nounwind readnone { %r = extractelement <8 x i16> %rv, i32 0 ret i16 %r } +') diff --git a/builtins/target-avx2-x2.ll b/builtins/target-avx2-x2.ll index 1d2a2093..6572783f 100644 --- a/builtins/target-avx2-x2.ll +++ b/builtins/target-avx2-x2.ll @@ -31,7 +31,9 @@ include(`target-avx-x2.ll') -rdrand_definition() +ifelse(LLVM_VERSION, `LLVM_3_0', `rdrand_decls()', + LLVM_VERSION, `LLVM_3_1', `rdrand_decls()', + `rdrand_definition()') ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; int min/max @@ -68,6 +70,9 @@ define <16 x i32> @__max_varying_uint32(<16 x i32>, <16 x i32>) nounwind readonl ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; float/half conversions +ifelse(LLVM_VERSION, `LLVM_3_0', ` +;; nothing to define... +', ` declare <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16>) nounwind readnone ; 0 is round nearest even declare <8 x i16> @llvm.x86.vcvtps2ph.256(<8 x float>, i32) nounwind readnone @@ -118,7 +123,7 @@ define i16 @__float_to_half_uniform(float %v) nounwind readnone { %r = extractelement <8 x i16> %rv, i32 0 ret i16 %r } - +') ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; gather diff --git a/builtins/target-avx2.ll b/builtins/target-avx2.ll index 45496779..e36a74de 100644 --- a/builtins/target-avx2.ll +++ b/builtins/target-avx2.ll @@ -31,7 +31,9 @@ include(`target-avx.ll') -rdrand_definition() +ifelse(LLVM_VERSION, `LLVM_3_0', `rdrand_decls()', + LLVM_VERSION, `LLVM_3_1', `rdrand_decls()', + `rdrand_definition()') ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; int min/max @@ -68,6 +70,9 @@ define <8 x i32> @__max_varying_uint32(<8 x i32>, <8 x i32>) nounwind readonly a ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; float/half conversions +ifelse(LLVM_VERSION, `LLVM_3_0', ` +;; nothing to define... +', ` declare <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16>) nounwind readnone ; 0 is round nearest even declare <8 x i16> @llvm.x86.vcvtps2ph.256(<8 x float>, i32) nounwind readnone @@ -102,6 +107,7 @@ define i16 @__float_to_half_uniform(float %v) nounwind readnone { %r = extractelement <8 x i16> %rv, i32 0 ret i16 %r } +') ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; gather diff --git a/ispc.cpp b/ispc.cpp index 15c8d4ae..636dfdd4 100644 --- a/ispc.cpp +++ b/ispc.cpp @@ -328,8 +328,14 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa, t->attributes = "+avx,+popcnt,+cmov,+f16c,+rdrand"; t->maskingIsFree = false; t->maskBitCount = 32; +#if !defined(LLVM_3_0) + // LLVM 3.1+ only t->hasHalf = true; + #if !defined(LLVM_3_1) + // LLVM 3.2+ only t->hasRand = true; + #endif +#endif } else if (!strcasecmp(isa, "avx1.1-x2")) { t->isa = Target::AVX11; @@ -338,8 +344,14 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa, t->attributes = "+avx,+popcnt,+cmov,+f16c,+rdrand"; t->maskingIsFree = false; t->maskBitCount = 32; +#if !defined(LLVM_3_0) + // LLVM 3.1+ only t->hasHalf = true; + #if !defined(LLVM_3_1) + // LLVM 3.2+ only t->hasRand = true; + #endif +#endif } #ifndef LLVM_3_0 else if (!strcasecmp(isa, "avx2")) { @@ -350,7 +362,10 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa, t->maskingIsFree = false; t->maskBitCount = 32; t->hasHalf = true; +#if !defined(LLVM_3_1) + // LLVM 3.2+ only t->hasRand = true; +#endif } else if (!strcasecmp(isa, "avx2-x2")) { t->isa = Target::AVX2; @@ -360,7 +375,10 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa, t->maskingIsFree = false; t->maskBitCount = 32; t->hasHalf = true; +#if !defined(LLVM_3_1) + // LLVM 3.2+ only t->hasRand = true; +#endif } #endif // !LLVM_3_0 else {