This is an archive of the discontinued LLVM Phabricator instance.

Define GNU clz builtins equivalents for MSVC
ClosedPublic

Authored by angelsl on Oct 3 2015, 10:45 AM.

Details

Reviewers
compnerd

Diff Detail

Event Timeline

angelsl updated this revision to Diff 36442.Oct 3 2015, 10:45 AM
angelsl retitled this revision from to Define GNU clz builtins equivalents for MSVC.
angelsl updated this object.
angelsl added a reviewer: compnerd.
angelsl added subscribers: compnerd, llvm-commits.
angelsl updated this revision to Diff 36444.EditedOct 3 2015, 10:55 AM

Put the functions in int_lib.h instead, since some of the functions that use them only include that

compnerd edited edge metadata.Oct 4 2015, 11:33 AM

Why is it insufficient to do this?

#if defined(_MSC_VER) && !defined(__clang__)
#define __builtin_clz __builtin_clzl
#define __builtin_ctz __builtin_ctzl
#define __builtin_clzl __builtin_ctzll
#endif

I don't understand the definition of __builtin_clzll. _BitScanReverse64 it is implemented in terms of __builtin_clzll for clang.

lib/builtins/int_lib.h
82

This should be:

#if defined(_MSC_VER) && !defined(__clang__)

_BitScanReverse gives the index of the first set bit starting from the most significant bit, where the index is zero from the LSB.

angelsl updated this revision to Diff 36485.Oct 4 2015, 11:50 PM
angelsl edited edge metadata.

Corrections made.

compnerd added inline comments.Oct 5 2015, 7:11 PM
lib/builtins/int_lib.h
101

You should be able to drop the braces; use 2-space indents as per the LLVM style.

angelsl updated this revision to Diff 36579.Oct 5 2015, 7:20 PM

Corrections made.

angelsl marked an inline comment as done.Oct 5 2015, 7:21 PM
compnerd accepted this revision.Oct 5 2015, 7:35 PM
compnerd edited edge metadata.
This revision is now accepted and ready to land.Oct 5 2015, 7:35 PM
compnerd closed this revision.Oct 6 2015, 8:01 PM

SVN r249515.