brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · 6f9ef07 Raw
33 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "llvm/Transforms/Vectorize/SandboxVectorizer/VecUtils.h"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 NDEBUG24template <typename T> static void dumpImpl(ArrayRef<T *> Bndl) {25  for (auto [Idx, V] : enumerate(Bndl))26    dbgs() << Idx << "." << *V << "\n";27}28void VecUtils::dump(ArrayRef<Value *> Bndl) { dumpImpl(Bndl); }29void VecUtils::dump(ArrayRef<Instruction *> Bndl) { dumpImpl(Bndl); }30#endif // NDEBUG31 32} // namespace llvm::sandboxir33