diff options
Diffstat (limited to 'include/llvm/Support/KnownBits.h')
-rw-r--r-- | include/llvm/Support/KnownBits.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/include/llvm/Support/KnownBits.h b/include/llvm/Support/KnownBits.h new file mode 100644 index 0000000000000..08d4dedd0ac82 --- /dev/null +++ b/include/llvm/Support/KnownBits.h @@ -0,0 +1,43 @@ +//===- llvm/Support/KnownBits.h - Stores known zeros/ones -------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains a class for representing known zeros and ones used by +// computeKnownBits. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_KNOWNBITS_H +#define LLVM_SUPPORT_KNOWNBITS_H + +#include "llvm/ADT/APInt.h" + +namespace llvm { + +// For now this is a simple wrapper around two APInts. +struct KnownBits { + APInt Zero; + APInt One; + + // Default construct Zero and One. + KnownBits() {} + + /// Create a known bits object of BitWidth bits initialized to unknown. + KnownBits(unsigned BitWidth) : Zero(BitWidth, 0), One(BitWidth, 0) {} + + /// Get the bit width of this value. + unsigned getBitWidth() const { + assert(Zero.getBitWidth() == One.getBitWidth() && + "Zero and One should have the same width!"); + return Zero.getBitWidth(); + } +}; + +} // end namespace llvm + +#endif |