1 //===-- llvm/Support/MathExtras.h - Useful math functions -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains some functions that are useful for math stuff.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_SUPPORT_MATHEXTRAS_H
15 #define LLVM_SUPPORT_MATHEXTRAS_H
17 #include "llvm/Support/DataTypes.h"
25 inline unsigned log2(uint64_t C) {
27 for (getPow = 0; C > 1; ++getPow)
32 inline unsigned log2(unsigned C) {
34 for (getPow = 0; C > 1; ++getPow)
39 inline bool isPowerOf2(int64_t C, unsigned &getPow) {
41 if (C > 0 && C == (C & ~(C - 1))) {
42 getPow = log2(static_cast<uint64_t>(C));
49 // Platform-independent wrappers for the C99 isnan() function.
53 // Platform-independent wrappers for the C99 isinf() function.
57 } // End llvm namespace