LLVM 20.0.0git
VecUtils.cpp
Go to the documentation of this file.
1//===- VecUtils.cpp -------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
11namespace llvm::sandboxir {
12
13unsigned VecUtils::getFloorPowerOf2(unsigned Num) {
14 if (Num == 0)
15 return Num;
16 unsigned Mask = Num;
17 Mask >>= 1;
18 for (unsigned ShiftBy = 1; ShiftBy < sizeof(Num) * 8; ShiftBy <<= 1)
19 Mask |= Mask >> ShiftBy;
20 return Num & ~Mask;
21}
22
23#ifndef NDEBUG
24template <typename T> static void dumpImpl(ArrayRef<T *> Bndl) {
25 for (auto [Idx, V] : enumerate(Bndl))
26 dbgs() << Idx << "." << *V << "\n";
27}
30#endif // NDEBUG
31
32} // namespace llvm::sandboxir
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
static LLVM_DUMP_METHOD void dump(ArrayRef< Value * > Bndl)
Helper dump function for debugging.
Definition: VecUtils.cpp:28
static unsigned getFloorPowerOf2(unsigned Num)
\Returns the first integer power of 2 that is <= Num.
Definition: VecUtils.cpp:13
static void dumpImpl(ArrayRef< T * > Bndl)
Definition: VecUtils.cpp:24
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
Definition: STLExtras.h:2448
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163