]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/Support/KnownBits.h
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r301441, and update
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / Support / KnownBits.h
1 //===- llvm/Support/KnownBits.h - Stores known zeros/ones -------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains a class for representing known zeros and ones used by
11 // computeKnownBits.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_SUPPORT_KNOWNBITS_H
16 #define LLVM_SUPPORT_KNOWNBITS_H
17
18 #include "llvm/ADT/APInt.h"
19
20 namespace llvm {
21
22 // For now this is a simple wrapper around two APInts.
23 struct KnownBits {
24   APInt Zero;
25   APInt One;
26
27   // Default construct Zero and One.
28   KnownBits() {}
29
30   /// Create a known bits object of BitWidth bits initialized to unknown.
31   KnownBits(unsigned BitWidth) : Zero(BitWidth, 0), One(BitWidth, 0) {}
32
33   /// Get the bit width of this value.
34   unsigned getBitWidth() const {
35     assert(Zero.getBitWidth() == One.getBitWidth() &&
36            "Zero and One should have the same width!");
37     return Zero.getBitWidth();
38   }
39 };
40
41 } // end namespace llvm
42
43 #endif