Open timotheecour opened 3 years ago
answer: see https://github.com/nim-lang/Nim/pull/16622#discussion_r560465795
details:
refs https://github.com/nim-lang/Nim/pull/16622
conflicting types, eg:
$git_clone_D/llvm-project/clang/test/CodeGen/builtin-rotate.c
unsigned long long rotl64(unsigned long long x, long long y) {
// CHECK-LABEL: rotl64
// CHECK: [[F:%.*]] = call i64 @llvm.fshl.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]])
// CHECK-NEXT: ret i64 [[F]]
return __builtin_rotateleft64(x, y);
}
...
long long rotr64(long long x, unsigned long long y) {
// CHECK-LABEL: rotr64
// CHECK: [[F:%.*]] = call i64 @llvm.fshr.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]])
// CHECK-NEXT: ret i64 [[F]]
return __builtin_rotateright64(x, y);
}
/Library/Developer/CommandLineTools/usr/lib/clang/11.0.3/include/ia32intrin.h
#ifdef __x86_64__
static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
__rolq(unsigned long long __X, int __C) {
return __builtin_rotateleft64(__X, __C);
}
static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
__rorq(unsigned long long __X, int __C) {
return __builtin_rotateright64(__X, __C);
}
#endif /* __x86_64__ */
nim doc lib/pure/bitops.nim
on osx gives:
runnableExamples/@mbitops_examples40.nim.c:52:31: error: conflicting types for '__builtin_rotateright64'
N_NIMCALL(unsigned long long, __builtin_rotateright64)(unsigned long long value, unsigned long long shift);
^
/Users/timothee/.cache/nim/bitops_d/runnableExamples/@mbitops_examples40.nim.c:52:31: note: '__builtin_rotateright64' is a builtin with type
'unsigned long long (unsigned long long, long long)'
furthermore, I got this after changing your code:
/Users/timothee/.cache/nim/bitops_d/runnableExamples/@mbitops_examples36.nim.c:52:31: note: '__builtin_rotateleft64' is a builtin with type
'unsigned long long (unsigned long long, unsigned long long)'
so __builtin_rotateleft64 uses 'unsigned long long (unsigned long long, unsigned long long)'
__builtin_rotateright64' uses 'unsigned long long (unsigned long long, long long)'
What C compiler is used by the OSX CI? If it's not Clang than this is a matter of concern
bin/nim doc --errormax:3 --hint:Conf:off --hint:Path:off --hint:Processing:off --hint:XDeclaredButNotUsed:off --warning:UnusedImport:off -d:boot --putenv:nimversion=1.5.1 --git.commit:devel --git.url:https://github.com/nim-lang/Nim --outdir:web/upload/1.5.1 --index:on lib/pure/httpcore.nim
https://dev.azure.com/nim-lang/255dfe86-e590-40bb-a8a2-3c0295ebdeb1/_apis/build/builds/12253/logs/93 2021-01-19T17:14:43.8960280Z runCI: 2021-01-19T17:14:43.8964510Z hostOS: macosx, hostCPU: amd64, int: 8, float: 8, cpuEndian: littleEndian, cwd: /Users/runner/work/1/s
ifunc resolver
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-ifunc-function-attribute
ifunc ("resolver")
allows the resolution of the symbol value to be determined dynamically at load time, and an optimized version of the routine to be selected for the particular processor or other system characteristics determined then
here's how to find correct declaration for intrinsics/builtins
https://github.com/llvm-mirror/clang/blob/master/include/clang/Basic/Builtins.def
see definitions on top for meaning of
UWiUWiUWi
here's how to check for errors in type declarations:
-Wconversion
clang -o /tmp/z01 -Wconversion $timn_D/tests/nim/all/t11720.c /Users/timothee/git_clone//nim//timn//tests/nim/all/t11720.c:14:57: warning: implicit conversion changes signedness: 'unsigned long long' to 'long long' [-Wsign-conversion] unsigned long long x3 = __builtin_rotateright64(x1, x2);
intrinsic guide
https://software.intel.com/sites/landingpage/IntrinsicsGuide/
links
https://gitlab.itwm.fraunhofer.de/hellerm/spu-llvm-src/-/blob/af074a2a3d8912f22b1e14a1464226af8ee9bcf4/clang/docs/LanguageExtensions.rst Notifications TITLE: add a builtin function for every llvm C library intrinsic and bit manipulation instrinsics · Issue #767 · ziglang/zig Refactoring
bitops.rotateLeftBits()
andbitops.rotateRightBits()
; adding builtins and intrinsics. by rockcavera · Pull Request #16622 · nim-lang/Nim https://llvm.org/docs/LangRef.html#standard-c-c-library-intrinsics C++ Using Intrinsics in a Cross-platform Manner - Software Engineering Stack Exchange TITLE: c - Testing for builtins/intrinsics - Stack Overflow Understanding GCC Builtins to Develop Better Tools