1 //===-- 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 SUPPORT_MATHEXTRAS_H
15 #define SUPPORT_MATHEXTRAS_H
17 #include "Support/DataTypes.h"
25 inline unsigned log2(uint64_t C) {
27 for (getPow = 0; C > 1; ++getPow)
32 inline bool isPowerOf2(int64_t C, unsigned &getPow) {
34 if (C > 0 && C == (C & ~(C - 1))) {
35 getPow = log2(static_cast<uint64_t>(C));
42 } // End llvm namespace