//===- ConstantRange.h - Represent a range ----------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // Represent a range of possible values that may occur when the program is run // for an integral value. This keeps track of a lower and upper bound for the // constant, which MAY wrap around the end of the numeric range. To do this, it // keeps track of a [lower, upper) bound, which specifies an interval just like // STL iterators. When used with boolean values, the following are important // ranges: : // // [F, F) = {} = Empty set // [T, F) = {T} // [F, T) = {F} // [T, T) = {F, T} = Full set // // The other integral ranges use min/max values for special range values. For // example, for 8-bit types, it uses: // [0, 0) = {} = Empty set // [255, 255) = {0..255} = Full Set // // Note that ConstantRange can be used to represent either signed or // unsigned ranges. // //===----------------------------------------------------------------------===// #ifndef LLVM_IR_CONSTANTRANGE_H #define LLVM_IR_CONSTANTRANGE_H #include "llvm/ADT/APInt.h" #include "llvm/IR/InstrTypes.h" #include "llvm/IR/Instruction.h" #include "llvm/Support/Compiler.h" #include <cstdint> namespace llvm { class MDNode; class raw_ostream; struct KnownBits; /// This class represents a range of values. class [[nodiscard]] ConstantRange { … }; inline raw_ostream &operator<<(raw_ostream &OS, const ConstantRange &CR) { … } /// Parse out a conservative ConstantRange from !range metadata. /// /// E.g. if RangeMD is !{i32 0, i32 10, i32 15, i32 20} then return [0, 20). ConstantRange getConstantRangeFromMetadata(const MDNode &RangeMD); } // end namespace llvm #endif // LLVM_IR_CONSTANTRANGE_H