llvm.org GIT mirror llvm / 94c2271
Revert 'Fix a typo 'iff' => 'if''. iff is an abreviation of if and only if. See: http://en.wikipedia.org/wiki/If_and_only_if Commit 164767 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164768 91177308-0d34-0410-b5e6-96231b3b80d8 Sylvestre Ledru 6 years ago
84 changed file(s) with 295 addition(s) and 295 deletion(s). Raw diff Collapse all Expand all
60816081 *)
60826082 # The compiler driver will combine linker options so we
60836083 # cannot just pass the convience library names through
6084 # without $wl, if we do not link with $LD.
6084 # without $wl, iff we do not link with $LD.
60856085 # Luckily, gcc supports the same syntax we need for Sun Studio.
60866086 # Supported since Solaris 2.6 (maybe 2.5.1?)
60876087 case $wlarc in
199199
200200 /// getNaN - Factory for QNaN values.
201201 ///
202 /// \param Negative - True if the NaN generated should be negative.
202 /// \param Negative - True iff the NaN generated should be negative.
203203 /// \param type - The unspecified fill bits for creating the NaN, 0 by
204204 /// default. The value is truncated as necessary.
205205 static APFloat getNaN(const fltSemantics &Sem, bool Negative = false,
229229 /// getLargest - Returns the largest finite number in the given
230230 /// semantics.
231231 ///
232 /// \param Negative - True if the number should be negative
232 /// \param Negative - True iff the number should be negative
233233 static APFloat getLargest(const fltSemantics &Sem, bool Negative = false);
234234
235235 /// getSmallest - Returns the smallest (by magnitude) finite number
236236 /// in the given semantics. Might be denormalized, which implies a
237237 /// relative loss of precision.
238238 ///
239 /// \param Negative - True if the number should be negative
239 /// \param Negative - True iff the number should be negative
240240 static APFloat getSmallest(const fltSemantics &Sem, bool Negative = false);
241241
242242 /// getSmallestNormalized - Returns the smallest (by magnitude)
243243 /// normalized finite number in the given semantics.
244244 ///
245 /// \param Negative - True if the number should be negative
245 /// \param Negative - True iff the number should be negative
246246 static APFloat getSmallestNormalized(const fltSemantics &Sem,
247247 bool Negative = false);
248248
9595 return vector_[n];
9696 }
9797
98 /// @returns true if the element was inserted into the SetVector.
98 /// @returns true iff the element was inserted into the SetVector.
9999 /// @brief Insert a new element into the SetVector.
100100 bool insert(const value_type &X) {
101101 bool result = set_.insert(X);
762762 return false;
763763 }
764764
765 // Return true if all bits set in this SparseBitVector are
765 // Return true iff all bits set in this SparseBitVector are
766766 // also set in RHS.
767767 bool contains(const SparseBitVector &RHS) const {
768768 SparseBitVector Result(*this);
345345 DomTreeNodeBase *getRootNode() { return RootNode; }
346346 const DomTreeNodeBase *getRootNode() const { return RootNode; }
347347
348 /// properlyDominates - Returns true if this dominates N and this != N.
348 /// properlyDominates - Returns true iff this dominates N and this != N.
349349 /// Note that this is not a constant time operation!
350350 ///
351351 bool properlyDominates(const DomTreeNodeBase *A,
371371 return A;
372372 }
373373
374 /// dominates - Returns true if A dominates B. Note that this is not a
374 /// dominates - Returns true iff A dominates B. Note that this is not a
375375 /// constant time operation!
376376 ///
377377 inline bool dominates(const DomTreeNodeBase *A,
3030 /// pointer is the result of a call to "__error()".
3131 ///
3232 /// Locations can also be defined in a constant-sensitive way. For example,
33 /// it is possible to define a location that returns true if it is passed
33 /// it is possible to define a location that returns true iff it is passed
3434 /// into the call as a specific argument. This is useful for modeling things
3535 /// like "printf", which can store to memory, but only through pointers passed
3636 /// with a '%n' constraint.
830830 const SCEV *LHS, const SCEV *RHS);
831831
832832 /// SimplifyICmpOperands - Simplify LHS and RHS in a comparison with
833 /// predicate Pred. Return true if any changes were made. If the
833 /// predicate Pred. Return true iff any changes were made. If the
834834 /// operands are provably equal or inequal, LHS and RHS are set to
835835 /// the same value and Pred is set to either ICMP_EQ or ICMP_NE.
836836 ///
317317 /// an expressions A+B*x where A and B are loop invariant values.
318318 bool isAffine() const {
319319 // We know that the start value is invariant. This expression is thus
320 // affine if the step is also invariant.
320 // affine iff the step is also invariant.
321321 return getNumOperands() == 2;
322322 }
323323
107107 /// @brief Get the data content of the archive member
108108 const char* getData() const { return data; }
109109
110 /// @returns true if the member is a SVR4 (non-LLVM) symbol table
110 /// @returns true iff the member is a SVR4 (non-LLVM) symbol table
111111 /// @brief Determine if this member is a SVR4 symbol table.
112112 bool isSVR4SymbolTable() const { return flags&SVR4SymbolTableFlag; }
113113
114 /// @returns true if the member is a BSD4.4 (non-LLVM) symbol table
114 /// @returns true iff the member is a BSD4.4 (non-LLVM) symbol table
115115 /// @brief Determine if this member is a BSD4.4 symbol table.
116116 bool isBSD4SymbolTable() const { return flags&BSD4SymbolTableFlag; }
117117
118 /// @returns true if the archive member is the LLVM symbol table
118 /// @returns true iff the archive member is the LLVM symbol table
119119 /// @brief Determine if this member is the LLVM symbol table.
120120 bool isLLVMSymbolTable() const { return flags&LLVMSymbolTableFlag; }
121121
122 /// @returns true if the archive member is the ar(1) string table
122 /// @returns true iff the archive member is the ar(1) string table
123123 /// @brief Determine if this member is the ar(1) string table.
124124 bool isStringTable() const { return flags&StringTableFlag; }
125125
126 /// @returns true if the archive member is a bitcode file.
126 /// @returns true iff the archive member is a bitcode file.
127127 /// @brief Determine if this member is a bitcode file.
128128 bool isBitcode() const { return flags&BitcodeFlag; }
129129
130 /// @returns true if the file name contains a path (directory) component.
130 /// @returns true iff the file name contains a path (directory) component.
131131 /// @brief Determine if the member has a path
132132 bool hasPath() const { return flags&HasPathFlag; }
133133
136136 /// separator character (/). To avoid this, a "long format" member name is
137137 /// allowed that doesn't have this restriction. This method determines if
138138 /// that "long format" is used for this member.
139 /// @returns true if the file name uses the long form
139 /// @returns true iff the file name uses the long form
140140 /// @brief Determine if the member has a long file name
141141 bool hasLongFilename() const { return flags&HasLongFilenameFlag; }
142142
5757 MachineFunction *MF;
5858 MachineRegisterInfo *RegInfo;
5959 BranchProbabilityInfo *BPI;
60 /// CanLowerReturn - true if the function's return value can be lowered to
60 /// CanLowerReturn - true iff the function's return value can be lowered to
6161 /// registers.
6262 bool CanLowerReturn;
6363
339339 /// condition code in op #4, a CondCodeSDNode.
340340 SELECT_CC,
341341
342 /// SetCC operator - This evaluates to a true value if the condition is
342 /// SetCC operator - This evaluates to a true value iff the condition is
343343 /// true. If the result value type is not i1 then the high bits conform
344344 /// to getBooleanContents. The operands to this are the left and right
345345 /// operands to compare (ops #0, and #1) and the condition code to compare
6868
6969 // Return a probability as a fraction between 0 (0% probability) and
7070 // 1 (100% probability), however the value is never equal to 0, and can be 1
71 // only if SRC block has only one successor.
71 // only iff SRC block has only one successor.
7272 // NB: This routine's complexity is linear on the number of successors of
7373 // Src. Querying sequentially for each successor's probability is a quadratic
7474 // query pattern.
7676 MachineBasicBlock *Dst) const;
7777
7878 // Print value between 0 (0% probability) and 1 (100% probability),
79 // however the value is never equal to 0, and can be 1 only if SRC block
79 // however the value is never equal to 0, and can be 1 only iff SRC block
8080 // has only one successor.
8181 raw_ostream &printEdgeProbability(raw_ostream &OS, MachineBasicBlock *Src,
8282 MachineBasicBlock *Dst) const;
10201020 /// ISD::ADD with a ConstantSDNode on the right-hand side, or if it is an
10211021 /// ISD::OR with a ConstantSDNode that is guaranteed to have the same
10221022 /// semantics as an ADD. This handles the equivalence:
1023 /// X|Cst == X+Cst if X&Cst = 0.
1023 /// X|Cst == X+Cst iff X&Cst = 0.
10241024 bool isBaseWithConstantOffset(SDValue Op) const;
10251025
10261026 /// isKnownNeverNan - Test whether the given SDValue is known to never be NaN.
169169 return Val == 1;
170170 }
171171
172 /// This function will return true if every bit in this constant is set
172 /// This function will return true iff every bit in this constant is set
173173 /// to true.
174 /// @returns true if this constant's bits are all set to true.
174 /// @returns true iff this constant's bits are all set to true.
175175 /// @brief Determine if the value is all ones.
176176 bool isMinusOne() const {
177177 return Val.isAllOnesValue();
178178 }
179179
180 /// This function will return true if this constant represents the largest
180 /// This function will return true iff this constant represents the largest
181181 /// value that may be represented by the constant's type.
182 /// @returns true if this is the largest value that may be represented
182 /// @returns true iff this is the largest value that may be represented
183183 /// by this type.
184184 /// @brief Determine if the value is maximal.
185185 bool isMaxValue(bool isSigned) const {
189189 return Val.isMaxValue();
190190 }
191191
192 /// This function will return true if this constant represents the smallest
192 /// This function will return true iff this constant represents the smallest
193193 /// value that may be represented by this constant's type.
194194 /// @returns true if this is the smallest value that may be represented by
195195 /// this type.
201201 return Val.isMinValue();
202202 }
203203
204 /// This function will return true if this constant represents a value with
204 /// This function will return true iff this constant represents a value with
205205 /// active bits bigger than 64 bits or a value greater than the given uint64_t
206206 /// value.
207 /// @returns true if this constant is greater or equal to the given number.
207 /// @returns true iff this constant is greater or equal to the given number.
208208 /// @brief Determine if the value is greater or equal to the given number.
209209 bool uge(uint64_t Num) const {
210210 return Val.getActiveBits() > 64 || Val.getZExtValue() >= Num;
546546 /// There are several places where we need to know if a cast instruction
547547 /// only deals with integer source and destination types. To simplify that
548548 /// logic, this method is provided.
549 /// @returns true if the cast has only integral typed operand and dest type.
549 /// @returns true iff the cast has only integral typed operand and dest type.
550550 /// @brief Determine if this is an integer-only cast.
551551 bool isIntegerCast() const;
552552
553553 /// A lossless cast is one that does not alter the basic value. It implies
554554 /// a no-op cast but is more stringent, preventing things like int->float,
555555 /// long->double, or int->ptr.
556 /// @returns true if the cast is lossless.
556 /// @returns true iff the cast is lossless.
557557 /// @brief Determine if this is a lossless cast.
558558 bool isLosslessCast() const;
559559
605605
606606 /// This method can be used to determine if a cast from S to DstTy using
607607 /// Opcode op is valid or not.
608 /// @returns true if the proposed cast is valid.
608 /// @returns true iff the proposed cast is valid.
609609 /// @brief Determine if a cast is valid without creating one.
610610 static bool castIsValid(Instruction::CastOps op, Value *S, Type *DstTy);
611611
9393 void setPreservesAll() { PreservesAll = true; }
9494 bool getPreservesAll() const { return PreservesAll; }
9595
96 /// setPreservesCFG - This function should be called by the pass, if they do
96 /// setPreservesCFG - This function should be called by the pass, iff they do
9797 /// not:
9898 ///
9999 /// 1. Add or remove basic blocks from the function
231231 /// determine if the current value of \p this is a syntactically valid
232232 /// path name for the operating system. The path name does not need to
233233 /// exist, validity is simply syntactical. Empty paths are always invalid.
234 /// @returns true if the path name is syntactically legal for the
234 /// @returns true iff the path name is syntactically legal for the
235235 /// host operating system.
236236 /// @brief Determine if a path is syntactically valid or not.
237237 bool isValid() const;
241241 /// if the file is empty. To get the length of the file itself, Use the
242242 /// PathWithStatus::getFileStatus() method and then the getSize() method
243243 /// on the returned FileStatus object.
244 /// @returns true if the path is empty.
244 /// @returns true iff the path is empty.
245245 /// @brief Determines if the path name is empty (invalid).
246246 bool isEmpty() const { return path.empty(); }
247247
129129 }
130130
131131 /// Determine if \p this is less than \p that.
132 /// @returns True if *this < that.
132 /// @returns True iff *this < that.
133133 /// @brief True if this < that.
134134 int operator < (const TimeValue &that) const { return that > *this; }
135135
136136 /// Determine if \p this is greather than \p that.
137 /// @returns True if *this > that.
137 /// @returns True iff *this > that.
138138 /// @brief True if this > that.
139139 int operator > (const TimeValue &that) const {
140140 if ( this->seconds_ > that.seconds_ ) {
146146 }
147147
148148 /// Determine if \p this is less than or equal to \p that.
149 /// @returns True if *this <= that.
149 /// @returns True iff *this <= that.
150150 /// @brief True if this <= that.
151151 int operator <= (const TimeValue &that) const { return that >= *this; }
152152
153153 /// Determine if \p this is greater than or equal to \p that.
154 /// @returns True if *this >= that.
154 /// @returns True iff *this >= that.
155155 int operator >= (const TimeValue &that) const {
156156 if ( this->seconds_ > that.seconds_ ) {
157157 return 1;
162162 }
163163
164164 /// Determines if two TimeValue objects represent the same moment in time.
165 /// @returns True if *this == that.
165 /// @returns True iff *this == that.
166166 int operator == (const TimeValue &that) const {
167167 return (this->seconds_ == that.seconds_) &&
168168 (this->nanos_ == that.nanos_);
170170
171171 /// Determines if two TimeValue objects represent times that are not the
172172 /// same.
173 /// @returns True if *this != that.
173 /// @returns True iff *this != that.
174174 int operator != (const TimeValue &that) const { return !(*this == that); }
175175
176176 /// Adds two TimeValue objects together.
397397
398398 private:
399399 /// isSizedDerivedType - Derived types like structures and arrays are sized
400 /// if all of the members of the type are sized as well. Since asking for
400 /// iff all of the members of the type are sized as well. Since asking for
401401 /// their size is relatively uncommon, move this operation out of line.
402402 bool isSizedDerivedType() const;
403403 };
6969 /// @brief Lookup a named Value.
7070 Value *lookup(StringRef Name) const { return vmap.lookup(Name); }
7171
72 /// @returns true if the symbol table is empty
72 /// @returns true iff the symbol table is empty
7373 /// @brief Determine if the symbol table is empty
7474 inline bool empty() const { return vmap.empty(); }
7575
20032003 // LHS >u RHS.
20042004 case ICmpInst::ICMP_UGT:
20052005 case ICmpInst::ICMP_UGE:
2006 // Comparison is true if the LHS
2006 // Comparison is true iff the LHS
20072007 if (MaxRecurse)
20082008 if (Value *V = SimplifyICmpInst(ICmpInst::ICMP_SLT, SrcOp,
20092009 Constant::getNullValue(SrcTy),
20122012 break;
20132013 case ICmpInst::ICMP_ULT:
20142014 case ICmpInst::ICMP_ULE:
2015 // Comparison is true if the LHS >=s 0.
2015 // Comparison is true iff the LHS >=s 0.
20162016 if (MaxRecurse)
20172017 if (Value *V = SimplifyICmpInst(ICmpInst::ICMP_SGE, SrcOp,
20182018 Constant::getNullValue(SrcTy),
21702170 // Simplify comparisons involving max/min.
21712171 Value *A, *B;
21722172 CmpInst::Predicate P = CmpInst::BAD_ICMP_PREDICATE;
2173 CmpInst::Predicate EqP; // Chosen so that "A == max/min(A,B)" if "A EqP B".
2173 CmpInst::Predicate EqP; // Chosen so that "A == max/min(A,B)" iff "A EqP B".
21742174
21752175 // Signed variants on "max(a,b)>=a -> true".
21762176 if (match(LHS, m_SMax(m_Value(A), m_Value(B))) && (A == RHS || B == RHS)) {
21772177 if (A != RHS) std::swap(A, B); // smax(A, B) pred A.
2178 EqP = CmpInst::ICMP_SGE; // "A == smax(A, B)" if "A sge B".
2178 EqP = CmpInst::ICMP_SGE; // "A == smax(A, B)" iff "A sge B".
21792179 // We analyze this as smax(A, B) pred A.
21802180 P = Pred;
21812181 } else if (match(RHS, m_SMax(m_Value(A), m_Value(B))) &&
21822182 (A == LHS || B == LHS)) {
21832183 if (A != LHS) std::swap(A, B); // A pred smax(A, B).
2184 EqP = CmpInst::ICMP_SGE; // "A == smax(A, B)" if "A sge B".
2184 EqP = CmpInst::ICMP_SGE; // "A == smax(A, B)" iff "A sge B".
21852185 // We analyze this as smax(A, B) swapped-pred A.
21862186 P = CmpInst::getSwappedPredicate(Pred);
21872187 } else if (match(LHS, m_SMin(m_Value(A), m_Value(B))) &&
21882188 (A == RHS || B == RHS)) {
21892189 if (A != RHS) std::swap(A, B); // smin(A, B) pred A.
2190 EqP = CmpInst::ICMP_SLE; // "A == smin(A, B)" if "A sle B".
2190 EqP = CmpInst::ICMP_SLE; // "A == smin(A, B)" iff "A sle B".
21912191 // We analyze this as smax(-A, -B) swapped-pred -A.
21922192 // Note that we do not need to actually form -A or -B thanks to EqP.
21932193 P = CmpInst::getSwappedPredicate(Pred);
21942194 } else if (match(RHS, m_SMin(m_Value(A), m_Value(B))) &&
21952195 (A == LHS || B == LHS)) {
21962196 if (A != LHS) std::swap(A, B); // A pred smin(A, B).
2197 EqP = CmpInst::ICMP_SLE; // "A == smin(A, B)" if "A sle B".
2197 EqP = CmpInst::ICMP_SLE; // "A == smin(A, B)" iff "A sle B".
21982198 // We analyze this as smax(-A, -B) pred -A.
21992199 // Note that we do not need to actually form -A or -B thanks to EqP.
22002200 P = Pred;
22452245 P = CmpInst::BAD_ICMP_PREDICATE;
22462246 if (match(LHS, m_UMax(m_Value(A), m_Value(B))) && (A == RHS || B == RHS)) {
22472247 if (A != RHS) std::swap(A, B); // umax(A, B) pred A.
2248 EqP = CmpInst::ICMP_UGE; // "A == umax(A, B)" if "A uge B".
2248 EqP = CmpInst::ICMP_UGE; // "A == umax(A, B)" iff "A uge B".
22492249 // We analyze this as umax(A, B) pred A.
22502250 P = Pred;
22512251 } else if (match(RHS, m_UMax(m_Value(A), m_Value(B))) &&
22522252 (A == LHS || B == LHS)) {
22532253 if (A != LHS) std::swap(A, B); // A pred umax(A, B).
2254 EqP = CmpInst::ICMP_UGE; // "A == umax(A, B)" if "A uge B".
2254 EqP = CmpInst::ICMP_UGE; // "A == umax(A, B)" iff "A uge B".
22552255 // We analyze this as umax(A, B) swapped-pred A.
22562256 P = CmpInst::getSwappedPredicate(Pred);
22572257 } else if (match(LHS, m_UMin(m_Value(A), m_Value(B))) &&
22582258 (A == RHS || B == RHS)) {
22592259 if (A != RHS) std::swap(A, B); // umin(A, B) pred A.
2260 EqP = CmpInst::ICMP_ULE; // "A == umin(A, B)" if "A ule B".
2260 EqP = CmpInst::ICMP_ULE; // "A == umin(A, B)" iff "A ule B".
22612261 // We analyze this as umax(-A, -B) swapped-pred -A.
22622262 // Note that we do not need to actually form -A or -B thanks to EqP.
22632263 P = CmpInst::getSwappedPredicate(Pred);
22642264 } else if (match(RHS, m_UMin(m_Value(A), m_Value(B))) &&
22652265 (A == LHS || B == LHS)) {
22662266 if (A != LHS) std::swap(A, B); // A pred umin(A, B).
2267 EqP = CmpInst::ICMP_ULE; // "A == umin(A, B)" if "A ule B".
2267 EqP = CmpInst::ICMP_ULE; // "A == umin(A, B)" iff "A ule B".
22682268 // We analyze this as umax(-A, -B) pred -A.
22692269 // Note that we do not need to actually form -A or -B thanks to EqP.
22702270 P = Pred;
2626 // isLoop - Find out if there is a back edge in this interval...
2727 //
2828 bool Interval::isLoop() const {
29 // There is a loop in this interval if one of the predecessors of the header
29 // There is a loop in this interval iff one of the predecessors of the header
3030 // node lives in the interval.
3131 for (::pred_iterator I = ::pred_begin(HeaderNode), E = ::pred_end(HeaderNode);
3232 I != E; ++I)
11081108 // If this is an equality comparison, we can try to fold it knowing that
11091109 // "V != C1".
11101110 if (Pred == ICmpInst::ICMP_EQ) {
1111 // !C1 == C -> false if C1 == C.
1111 // !C1 == C -> false iff C1 == C.
11121112 Res = ConstantFoldCompareInstOperands(ICmpInst::ICMP_NE,
11131113 Result.getNotConstant(), C, TD,
11141114 TLI);
11151115 if (Res->isNullValue())
11161116 return False;
11171117 } else if (Pred == ICmpInst::ICMP_NE) {
1118 // !C1 != C -> true if C1 == C.
1118 // !C1 != C -> true iff C1 == C.
11191119 Res = ConstantFoldCompareInstOperands(ICmpInst::ICMP_NE,
11201120 Result.getNotConstant(), C, TD,
11211121 TLI);
13661366 /// This form often exposes folding opportunities that are hidden in
13671367 /// the original operand list.
13681368 ///
1369 /// Return true if it appears that any interesting folding opportunities
1369 /// Return true iff it appears that any interesting folding opportunities
13701370 /// may be exposed. This helps getAddRecExpr short-circuit extra work in
13711371 /// the common case where no interesting opportunities are present, and
13721372 /// is also used as a check to avoid infinite recursion.
55975597 }
55985598
55995599 /// SimplifyICmpOperands - Simplify LHS and RHS in a comparison with
5600 /// predicate Pred. Return true if any changes were made.
5600 /// predicate Pred. Return true iff any changes were made.
56015601 ///
56025602 bool ScalarEvolution::SimplifyICmpOperands(ICmpInst::Predicate &Pred,
56035603 const SCEV *&LHS, const SCEV *&RHS,
469469 return;
470470 }
471471 case Instruction::Shl:
472 // (shl X, C1) & C2 == 0 if (X & C2 >>u C1) == 0
472 // (shl X, C1) & C2 == 0 iff (X & C2 >>u C1) == 0
473473 if (ConstantInt *SA = dyn_cast(I->getOperand(1))) {
474474 uint64_t ShiftAmt = SA->getLimitedValue(BitWidth);
475475 ComputeMaskedBits(I->getOperand(0), KnownZero, KnownOne, TD, Depth+1);
481481 }
482482 break;
483483 case Instruction::LShr:
484 // (ushr X, C1) & C2 == 0 if (-1 >> C1) & C2 == 0
484 // (ushr X, C1) & C2 == 0 iff (-1 >> C1) & C2 == 0
485485 if (ConstantInt *SA = dyn_cast(I->getOperand(1))) {
486486 // Compute the new bits that are at the top now.
487487 uint64_t ShiftAmt = SA->getLimitedValue(BitWidth);
497497 }
498498 break;
499499 case Instruction::AShr:
500 // (ashr X, C1) & C2 == 0 if (-1 >> C1) & C2 == 0
500 // (ashr X, C1) & C2 == 0 iff (-1 >> C1) & C2 == 0
501501 if (ConstantInt *SA = dyn_cast(I->getOperand(1))) {
502502 // Compute the new bits that are at the top now.
503503 uint64_t ShiftAmt = SA->getLimitedValue(BitWidth-1);
577577 return DAG.getNode(Opc, DL, VT, N0.getOperand(0), OpNode);
578578 }
579579 if (N0.hasOneUse()) {
580 // reassoc. (op (op x, c1), y) -> (op (op x, y), c1) if x+c1 has one use
580 // reassoc. (op (op x, c1), y) -> (op (op x, y), c1) iff x+c1 has one use
581581 SDValue OpNode = DAG.getNode(Opc, N0.getDebugLoc(), VT,
582582 N0.getOperand(0), N1);
583583 AddToWorkList(OpNode.getNode());
595595 return DAG.getNode(Opc, DL, VT, N1.getOperand(0), OpNode);
596596 }
597597 if (N1.hasOneUse()) {
598 // reassoc. (op y, (op x, c1)) -> (op (op x, y), c1) if x+c1 has one use
598 // reassoc. (op y, (op x, c1)) -> (op (op x, y), c1) iff x+c1 has one use
599599 SDValue OpNode = DAG.getNode(Opc, N0.getDebugLoc(), VT,
600600 N1.getOperand(0), N0);
601601 AddToWorkList(OpNode.getNode());
14541454 if (!VT.isVector() && SimplifyDemandedBits(SDValue(N, 0)))
14551455 return SDValue(N, 0);
14561456
1457 // fold (a+b) -> (a|b) if a and b share no bits.
1457 // fold (a+b) -> (a|b) iff a and b share no bits.
14581458 if (VT.isInteger() && !VT.isVector()) {
14591459 APInt LHSZero, LHSOne;
14601460 APInt RHSZero, RHSOne;
15481548 return CombineTo(N, N0, DAG.getNode(ISD::CARRY_FALSE,
15491549 N->getDebugLoc(), MVT::Glue));
15501550
1551 // fold (addc a, b) -> (or a, b), CARRY_FALSE if a and b share no bits.
1551 // fold (addc a, b) -> (or a, b), CARRY_FALSE iff a and b share no bits.
15521552 APInt LHSZero, LHSOne;
15531553 APInt RHSZero, RHSOne;
15541554 DAG.ComputeMaskedBits(N0, LHSZero, LHSOne);
19361936 return DAG.getNode(ISD::SRL, N->getDebugLoc(), VT, N0,
19371937 DAG.getConstant(N1C->getAPIntValue().logBase2(),
19381938 getShiftAmountTy(N0.getValueType())));
1939 // fold (udiv x, (shl c, y)) -> x >>u (log2(c)+y) if c is power of 2
1939 // fold (udiv x, (shl c, y)) -> x >>u (log2(c)+y) iff c is power of 2
19401940 if (N1.getOpcode() == ISD::SHL) {
19411941 if (ConstantSDNode *SHC = dyn_cast(N1.getOperand(0))) {
19421942 if (SHC->getAPIntValue().isPowerOf2()) {
26412641 return SDValue(N, 0); // Return N so it doesn't get rechecked!
26422642 }
26432643 }
2644 // fold (zext_inreg (sextload x)) -> (zextload x) if load has one use
2644 // fold (zext_inreg (sextload x)) -> (zextload x) iff load has one use
26452645 if (ISD::isSEXTLoad(N0.getNode()) && ISD::isUNINDEXEDLoad(N0.getNode()) &&
26462646 N0.hasOneUse()) {
26472647 LoadSDNode *LN0 = cast(N0);
30373037 // fold (or x, -1) -> -1
30383038 if (N1C && N1C->isAllOnesValue())
30393039 return N1;
3040 // fold (or x, c) -> c if (x & ~c) == 0
3040 // fold (or x, c) -> c iff (x & ~c) == 0
30413041 if (N1C && DAG.MaskedValueIsZero(N0, ~N1C->getAPIntValue()))
30423042 return N1;
30433043
30543054 if (ROR.getNode() != 0)
30553055 return ROR;
30563056 // Canonicalize (or (and X, c1), c2) -> (and (or X, c2), c1|c2)
3057 // if (c1 & c2) == 0.
3057 // iff (c1 & c2) == 0.
30583058 if (N1C && N0.getOpcode() == ISD::AND && N0.getNode()->hasOneUse() &&
30593059 isa(N0.getOperand(1))) {
30603060 ConstantSDNode *C1 = cast(N0.getOperand(1));
33913391 return DAG.getNode(ISD::ZERO_EXTEND, N->getDebugLoc(), VT, V);
33923392 }
33933393
3394 // fold (not (or x, y)) -> (and (not x), (not y)) if x or y are setcc
3394 // fold (not (or x, y)) -> (and (not x), (not y)) iff x or y are setcc
33953395 if (N1C && N1C->getAPIntValue() == 1 && VT == MVT::i1 &&
33963396 (N0.getOpcode() == ISD::OR || N0.getOpcode() == ISD::AND)) {
33973397 SDValue LHS = N0.getOperand(0), RHS = N0.getOperand(1);
34033403 return DAG.getNode(NewOpcode, N->getDebugLoc(), VT, LHS, RHS);
34043404 }
34053405 }
3406 // fold (not (or x, y)) -> (and (not x), (not y)) if x or y are constants
3406 // fold (not (or x, y)) -> (and (not x), (not y)) iff x or y are constants
34073407 if (N1C && N1C->isAllOnesValue() &&
34083408 (N0.getOpcode() == ISD::OR || N0.getOpcode() == ISD::AND)) {
34093409 SDValue LHS = N0.getOperand(0), RHS = N0.getOperand(1);
38813881 return DAG.getNode(ISD::SRL, N->getDebugLoc(), VT, N0.getOperand(0), N1);
38823882 }
38833883
3884 // fold (srl (ctlz x), "5") -> x if x has one bit set (the low bit).
3884 // fold (srl (ctlz x), "5") -> x iff x has one bit set (the low bit).
38853885 if (N1C && N0.getOpcode() == ISD::CTLZ &&
38863886 N1C->getAPIntValue() == Log2_32(VT.getSizeInBits())) {
38873887 APInt KnownZero, KnownOne;
48154815 if (N0.getOpcode() == ISD::TRUNCATE) {
48164816 SDValue TruncOp = N0.getOperand(0);
48174817 if (TruncOp.getValueType() == VT)
4818 return TruncOp; // x if x size == zext size.
4818 return TruncOp; // x iff x size == zext size.
48194819 if (TruncOp.getValueType().bitsGT(VT))
48204820 return DAG.getNode(ISD::TRUNCATE, N->getDebugLoc(), VT, TruncOp);
48214821 return DAG.getNode(ISD::ANY_EXTEND, N->getDebugLoc(), VT, TruncOp);
51675167 return NarrowLoad;
51685168
51695169 // fold (sext_in_reg (srl X, 24), i8) -> (sra X, 24)
5170 // fold (sext_in_reg (srl X, 23), i8) -> (sra X, 23) if possible.
5170 // fold (sext_in_reg (srl X, 23), i8) -> (sra X, 23) iff possible.
51715171 // We already fold "(sext_in_reg (srl X, 25), i8) -> srl X, 25" above.
51725172 if (N0.getOpcode() == ISD::SRL) {
51735173 if (ConstantSDNode *ShAmt = dyn_cast(N0.getOperand(1)))
51745174 if (ShAmt->getZExtValue()+EVTBits <= VTBits) {
5175 // We can turn this into an SRA if the input to the SRL is already sign
5175 // We can turn this into an SRA iff the input to the SRL is already sign
51765176 // extended enough.
51775177 unsigned InSignBits = DAG.ComputeNumSignBits(N0.getOperand(0));
51785178 if (VTBits-(ShAmt->getZExtValue()+EVTBits) < InSignBits)
51985198 CombineTo(N0.getNode(), ExtLoad, ExtLoad.getValue(1));
51995199 return SDValue(N, 0); // Return N so it doesn't get rechecked!
52005200 }
5201 // fold (sext_inreg (zextload x)) -> (sextload x) if load has one use
5201 // fold (sext_inreg (zextload x)) -> (sextload x) iff load has one use
52025202 if (ISD::isZEXTLoad(N0.getNode()) && ISD::isUNINDEXEDLoad(N0.getNode()) &&
52035203 N0.hasOneUse() &&
52045204 EVT == cast(N0)->getMemoryVT() &&
55055505 }
55065506 }
55075507
5508 // bitconvert(build_pair(ld, ld)) -> ld if load locations are consecutive.
5508 // bitconvert(build_pair(ld, ld)) -> ld iff load locations are consecutive.
55095509 if (N0.getOpcode() == ISD::BUILD_PAIR) {
55105510 SDValue CombineLD = CombineConsecutiveLoads(N0.getNode(), VT);
55115511 if (CombineLD.getNode())
61506150
61516151 if (N1CFP) {
61526152 const APFloat& V = N1CFP->getValueAPF();
6153 // copysign(x, c1) -> fabs(x) if ispos(c1)
6154 // copysign(x, c1) -> fneg(fabs(x)) if isneg(c1)
6153 // copysign(x, c1) -> fabs(x) iff ispos(c1)
6154 // copysign(x, c1) -> fneg(fabs(x)) iff isneg(c1)
61556155 if (!V.isNegative()) {
61566156 if (!LegalOperations || TLI.isOperationLegal(ISD::FABS, VT))
61576157 return DAG.getNode(ISD::FABS, N->getDebugLoc(), VT, N0);
87638763 EVT XType = N0.getValueType();
87648764 EVT AType = N2.getValueType();
87658765 if (XType.bitsGE(AType)) {
8766 // and (sra X, size(X)-1, A) -> "and (srl X, C2), A" if A is a
8766 // and (sra X, size(X)-1, A) -> "and (srl X, C2), A" iff A is a
87678767 // single-bit constant.
87688768 if (N2C && ((N2C->getAPIntValue() & (N2C->getAPIntValue()-1)) == 0)) {
87698769 unsigned ShCtV = N2C->getAPIntValue().logBase2();
446446 if (ResNo == 1)
447447 return PromoteIntRes_Overflow(N);
448448
449 // The operation overflowed if the result in the larger type is not the
449 // The operation overflowed iff the result in the larger type is not the
450450 // sign extension of its truncation to the original type.
451451 SDValue LHS = SExtPromotedInteger(N->getOperand(0));
452452 SDValue RHS = SExtPromotedInteger(N->getOperand(1));
609609 if (ResNo == 1)
610610 return PromoteIntRes_Overflow(N);
611611
612 // The operation overflowed if the result in the larger type is not the
612 // The operation overflowed iff the result in the larger type is not the
613613 // zero extension of its truncation to the original type.
614614 SDValue LHS = ZExtPromotedInteger(N->getOperand(0));
615615 SDValue RHS = ZExtPromotedInteger(N->getOperand(1));
654654 }
655655 SDValue Mul = DAG.getNode(ISD::MUL, DL, LHS.getValueType(), LHS, RHS);
656656
657 // Overflow occurred if the high part of the result does not
657 // Overflow occurred iff the high part of the result does not
658658 // zero/sign-extend the low part.
659659 SDValue Overflow;
660660 if (N->getOpcode() == ISD::UMULO) {
661 // Unsigned overflow occurred if the high part is non-zero.
661 // Unsigned overflow occurred iff the high part is non-zero.
662662 SDValue Hi = DAG.getNode(ISD::SRL, DL, Mul.getValueType(), Mul,
663663 DAG.getIntPtrConstant(SmallVT.getSizeInBits()));
664664 Overflow = DAG.getSetCC(DL, N->getValueType(1), Hi,
665665 DAG.getConstant(0, Hi.getValueType()), ISD::SETNE);
666666 } else {
667 // Signed overflow occurred if the high part does not sign extend the low.
667 // Signed overflow occurred iff the high part does not sign extend the low.
668668 SDValue SExt = DAG.getNode(ISD::SIGN_EXTEND_INREG, DL, Mul.getValueType(),
669669 Mul, DAG.getValueType(SmallVT));
670670 Overflow = DAG.getSetCC(DL, N->getValueType(1), SExt, Mul, ISD::SETNE);
22392239 LHS, RHS);
22402240 SplitInteger(Sum, Lo, Hi);
22412241
2242 // Calculate the overflow: addition overflows if a + b < a, and subtraction
2243 // overflows if a - b > a.
2242 // Calculate the overflow: addition overflows iff a + b < a, and subtraction
2243 // overflows iff a - b > a.
22442244 SDValue Ofl = DAG.getSetCC(dl, N->getValueType(1), Sum, LHS,
22452245 N->getOpcode () == ISD::UADDO ?
22462246 ISD::SETULT : ISD::SETUGT);
18241824 KnownZero |= APInt::getHighBitsSet(BitWidth, BitWidth - 1);
18251825 return;
18261826 case ISD::SHL:
1827 // (shl X, C1) & C2 == 0 if (X & C2 >>u C1) == 0
1827 // (shl X, C1) & C2 == 0 iff (X & C2 >>u C1) == 0
18281828 if (ConstantSDNode *SA = dyn_cast(Op.getOperand(1))) {
18291829 unsigned ShAmt = SA->getZExtValue();
18301830
18411841 }
18421842 return;
18431843 case ISD::SRL:
1844 // (ushr X, C1) & C2 == 0 if (-1 >> C1) & C2 == 0
1844 // (ushr X, C1) & C2 == 0 iff (-1 >> C1) & C2 == 0
18451845 if (ConstantSDNode *SA = dyn_cast(Op.getOperand(1))) {
18461846 unsigned ShAmt = SA->getZExtValue();
18471847
23552355 /// ISD::ADD with a ConstantSDNode on the right-hand side, or if it is an
23562356 /// ISD::OR with a ConstantSDNode that is guaranteed to have the same
23572357 /// semantics as an ADD. This handles the equivalence:
2358 /// X|Cst == X+Cst if X&Cst = 0.
2358 /// X|Cst == X+Cst iff X&Cst = 0.
23592359 bool SelectionDAG::isBaseWithConstantOffset(SDValue Op) const {
23602360 if ((Op.getOpcode() != ISD::ADD && Op.getOpcode() != ISD::OR) ||
23612361 !isa(Op.getOperand(1)))
28812881 assert(VT.isFloatingPoint() && EVT.isFloatingPoint() &&
28822882 "Cannot FP_ROUND_INREG integer types");
28832883 assert(EVT.isVector() == VT.isVector() &&
2884 "FP_ROUND_INREG type should be vector if the operand "
2884 "FP_ROUND_INREG type should be vector iff the operand "
28852885 "type is vector!");
28862886 assert((!EVT.isVector() ||
28872887 EVT.getVectorNumElements() == VT.getVectorNumElements()) &&
29172917 assert(VT.isInteger() && EVT.isInteger() &&
29182918 "Cannot *_EXTEND_INREG FP types");
29192919 assert(EVT.isVector() == VT.isVector() &&
2920 "SIGN_EXTEND_INREG type should be vector if the operand "
2920 "SIGN_EXTEND_INREG type should be vector iff the operand "
29212921 "type is vector!");
29222922 assert((!EVT.isVector() ||
29232923 EVT.getVectorNumElements() == VT.getVectorNumElements()) &&
13291329
13301330 // If all of the unknown bits are known to be zero on one side or the other
13311331 // (but not both) turn this into an *inclusive* or.
1332 // e.g. (A & C1)^(B & C2) -> (A & C1)|(B & C2) if C1&C2 == 0
1332 // e.g. (A & C1)^(B & C2) -> (A & C1)|(B & C2) iff C1&C2 == 0
13331333 if ((NewMask & ~KnownZero & ~KnownZero2) == 0)
13341334 return TLO.CombineTo(Op, TLO.DAG.getNode(ISD::OR, dl, Op.getValueType(),
13351335 Op.getOperand(0),
13431343 // If all of the demanded bits on one side are known, and all of the set
13441344 // bits on that side are also known to be set on the other side, turn this
13451345 // into an AND, as we know the bits will be cleared.
1346 // e.g. (X | C1) ^ C2 --> (X | C1) & ~C2 if (C1&C2) == C2
1346 // e.g. (X | C1) ^ C2 --> (X | C1) & ~C2 iff (C1&C2) == C2
13471347 // NB: it is okay if more bits are known than are requested
13481348 if ((NewMask & (KnownZero|KnownOne)) == NewMask) { // all known on one side
13491349 if (KnownOne == KnownOne2) { // set bits are the same on both sides
19691969 return DAG.getSetCC(dl, VT, And, DAG.getConstant(0, CTVT), CC);
19701970 }
19711971
1972 // TODO: (ctpop x) == 1 -> x && (x & x-1) == 0 if ctpop is illegal.
1972 // TODO: (ctpop x) == 1 -> x && (x & x-1) == 0 iff ctpop is illegal.
19731973 }
19741974
19751975 // (zext x) == C --> x == (trunc C)
25022502 N0.getValueType()), Cond);
25032503 }
25042504
2505 // Turn (X^C1) == C2 into X == C1^C2 if X&~C1 = 0.
2505 // Turn (X^C1) == C2 into X == C1^C2 iff X&~C1 = 0.
25062506 if (N0.getOpcode() == ISD::XOR)
25072507 // If we know that all of the inverted bits are zero, don't bother
25082508 // performing the inversion.
288288 return Data.size();
289289 }
290290
291 /// Add String to the table if it is not already there.
291 /// Add String to the table iff it is not already there.
292292 /// @returns the index into the string table where the string is now located.
293293 size_t StringTable::insert(llvm::StringRef String) {
294294 map::iterator i = Map.find(String);
18591859 // 0 / X ===> 0
18601860 return APInt(BitWidth, 0);
18611861 else if (lhsWords < rhsWords || this->ult(RHS)) {
1862 // X / Y ===> 0, if X < Y
1862 // X / Y ===> 0, iff X < Y
18631863 return APInt(BitWidth, 0);
18641864 } else if (*this == RHS) {
18651865 // X / X ===> 1
18961896 // 0 % Y ===> 0
18971897 return APInt(BitWidth, 0);
18981898 } else if (lhsWords < rhsWords || this->ult(RHS)) {
1899 // X % Y ===> X, if X < Y
1899 // X % Y ===> X, iff X < Y
19001900 return *this;
19011901 } else if (*this == RHS) {
19021902 // X % X == 0;
19281928 }
19291929
19301930 if (lhsWords < rhsWords || LHS.ult(RHS)) {
1931 Remainder = LHS; // X % Y ===> X, if X < Y
1932 Quotient = 0; // X / Y ===> 0, if X < Y
1931 Remainder = LHS; // X % Y ===> X, iff X < Y
1932 Quotient = 0; // X / Y ===> 0, iff X < Y
19331933 return;
19341934 }
19351935
9595
9696 }
9797
98 // Print information when destroyed, if command line option is specified.
98 // Print information when destroyed, iff command line option is specified.
9999 StatisticInfo::~StatisticInfo() {
100100 llvm::PrintStatistics();
101101 }
275275 if (TII.isPredicable(MI) || isARMNEONPred(MI))
276276 AddDefaultPred(MIB);
277277
278 // Do we optionally set a predicate? Preds is size > 0 if the predicate
278 // Do we optionally set a predicate? Preds is size > 0 iff the predicate
279279 // defines CPSR. All other OptionalDefines in ARM are the CCR register.
280280 bool CPSR = false;
281281 if (DefinesOptionalPredicate(MI, &CPSR)) {
21162116 if (N->getOpcode() == ISD::AND) {
21172117 if (isOpcWithIntImmediate(N, ISD::AND, And_imm)) {
21182118
2119 // The immediate is a mask of the low bits if imm & (imm+1) == 0
2119 // The immediate is a mask of the low bits iff imm & (imm+1) == 0
21202120 if (And_imm & (And_imm + 1))
21212121 return NULL;
21222122
726726 if (!TM.Options.UseSoftFloat && Subtarget->hasVFP2() &&
727727 !Subtarget->isThumb1Only()) {
728728 // Turn f64->i64 into VMOVRRD, i64 -> f64 to VMOVDRR
729 // if target supports vfp2.
729 // iff target supports vfp2.
730730 setOperationAction(ISD::BITCAST, MVT::i64, Custom);
731731 setOperationAction(ISD::FLT_ROUNDS_, MVT::i32, Custom);
732732 }
76917691
76927692 DebugLoc DL = N->getDebugLoc();
76937693 // 1) or (and A, mask), val => ARMbfi A, val, mask
7694 // if (val & mask) == val
7694 // iff (val & mask) == val
76957695 //
76967696 // 2) or (and A, mask), (and B, mask2) => ARMbfi A, (lsr B, amt), mask
7697 // 2a) if isBitFieldInvertedMask(mask) && isBitFieldInvertedMask(~mask2)
7697 // 2a) iff isBitFieldInvertedMask(mask) && isBitFieldInvertedMask(~mask2)
76987698 // && mask == ~mask2
7699 // 2b) if isBitFieldInvertedMask(~mask) && isBitFieldInvertedMask(mask2)
7699 // 2b) iff isBitFieldInvertedMask(~mask) && isBitFieldInvertedMask(mask2)
77007700 // && ~mask == mask2
77017701 // (i.e., copy a bitfield value into another bitfield of the same width)
77027702
697697 }
698698
699699 // Writeback version is just a pseudo, as there's no encoding difference.
700 // Writeback happens if the base register is not in the destination register
700 // Writeback happens iff the base register is not in the destination register
701701 // list.
702702 def tLDMIA_UPD :
703703 InstTemplate
53155315 // instruction. We'll make the transformation in processInstruction()
53165316 // if necessary.
53175317 //
5318 // Thumb LDM instructions are writeback if the base register is not
5318 // Thumb LDM instructions are writeback iff the base register is not
53195319 // in the register list.
53205320 unsigned Rn = Inst.getOperand(0).getReg();
53215321 bool hasWritebackToken =
70227022 Inst.addOperand(MCOperand::CreateReg(0)); // cc_out
70237023 break;
70247024 case ARM::tADDi8:
7025 // If the immediate is in the range 0-7, we want tADDi3 if Rd was
7025 // If the immediate is in the range 0-7, we want tADDi3 iff Rd was
70267026 // explicitly specified. From the ARM ARM: "Encoding T1 is preferred
70277027 // to encoding T2 if is specified and encoding T2 is preferred
70287028 // to encoding T1 if is omitted."
70327032 }
70337033 break;
70347034 case ARM::tSUBi8:
7035 // If the immediate is in the range 0-7, we want tADDi3 if Rd was
7035 // If the immediate is in the range 0-7, we want tADDi3 iff Rd was
70367036 // explicitly specified. From the ARM ARM: "Encoding T1 is preferred
70377037 // to encoding T2 if is specified and encoding T2 is preferred
70387038 // to encoding T1 if is omitted."
220220 }
221221
222222 case ISD::OR:
223 // Handle "X | C" as "X + C" if X is known to have C bits clear.
223 // Handle "X | C" as "X + C" iff X is known to have C bits clear.
224224 if (ConstantSDNode *CN = dyn_cast(N.getOperand(1))) {
225225 MSP430ISelAddressMode Backup = AM;
226226 uint64_t Offset = CN->getSExtValue();
7373 return CurDAG->getTargetConstant(Imm, PPCLowering.getPointerTy());
7474 }
7575
76 /// isRunOfOnes - Returns true if Val consists of one contiguous run of 1s
76 /// isRunOfOnes - Returns true iff Val consists of one contiguous run of 1s
7777 /// with any number of 0s on either side. The 1s are allowed to wrap from
7878 /// LSB to MSB, so 0x000FFF0, 0x0000FFFF, and 0xFF0000FF are all runs.
7979 /// 0x0F0F0000 is not, since all 1s are not contiguous.
12791279 }
12801280
12811281 /// handleCondMovFP - Handle two address conditional move instructions. These
1282 /// instructions move a st(i) register to st(0) if a condition is true. These
1282 /// instructions move a st(i) register to st(0) iff a condition is true. These
12831283 /// instructions require that the first operand is at the top of the stack, but
12841284 /// otherwise don't modify the stack at all.
12851285 void FPS::handleCondMovFP(MachineBasicBlock::iterator &I) {
12011201 }
12021202
12031203 case ISD::OR:
1204 // Handle "X | C" as "X + C" if X is known to have C bits clear.
1204 // Handle "X | C" as "X + C" iff X is known to have C bits clear.
12051205 if (CurDAG->isBaseWithConstantOffset(N)) {
12061206 X86ISelAddressMode Backup = AM;
12071207 ConstantSDNode *CN = cast(N.getOperand(1));
16511651 Iter = I;
16521652 for (unsigned i = 0; i < 4; ++i) {
16531653 // If we make it to the beginning of the block, it's safe to clobber
1654 // EFLAGS if EFLAGS is not live-in.
1654 // EFLAGS iff EFLAGS is not live-in.
16551655 if (Iter == B)
16561656 return !MBB.isLiveIn(X86::EFLAGS);
16571657
13601360 return DAG.getMergeValues(Ops, 2, dl);
13611361 }
13621362
1363 // fold (ladd x, 0, y) -> 0, add x, y if carry is unused and y has only the
1363 // fold (ladd x, 0, y) -> 0, add x, y iff carry is unused and y has only the
13641364 // low bit set
13651365 if (N1C && N1C->isNullValue() && N->hasNUsesOfValue(0, 0)) {
13661366 APInt KnownZero, KnownOne;
13841384 ConstantSDNode *N1C = dyn_cast(N1);
13851385 EVT VT = N0.getValueType();
13861386
1387 // fold (lsub 0, 0, x) -> x, -x if x has only the low bit set
1387 // fold (lsub 0, 0, x) -> x, -x iff x has only the low bit set
13881388 if (N0C && N0C->isNullValue() && N1C && N1C->isNullValue()) {
13891389 APInt KnownZero, KnownOne;
13901390 APInt Mask = APInt::getHighBitsSet(VT.getSizeInBits(),
13991399 }
14001400 }
14011401
1402 // fold (lsub x, 0, y) -> 0, sub x, y if borrow is unused and y has only the
1402 // fold (lsub x, 0, y) -> 0, sub x, y iff borrow is unused and y has only the
14031403 // low bit set
14041404 if (N1C && N1C->isNullValue() && N->hasNUsesOfValue(0, 0)) {
14051405 APInt KnownZero, KnownOne;
4242 // duplicate constants.
4343 bool runOnModule(Module &M);
4444
45 // Return true if we can determine the alignment of this global variable.
45 // Return true iff we can determine the alignment of this global variable.
4646 bool hasKnownAlignment(GlobalVariable *GV) const;
4747
4848 // Return the alignment of the global, including converting the default
171171 return (AtomicOrdering)std::max(X, Y);
172172 }
173173
174 /// SafeToDestroyConstant - It is safe to destroy a constant if it is only used
174 /// SafeToDestroyConstant - It is safe to destroy a constant iff it is only used
175175 /// by constants itself. Note that constants cannot be cyclic, so this test is
176176 /// pretty easy to implement recursively.
177177 ///
77 //===----------------------------------------------------------------------===//
88 //
99 // This file implements a simple interprocedural pass which walks the
10 // call-graph, turning invoke instructions into calls, if the callee cannot
10 // call-graph, turning invoke instructions into calls, iff the callee cannot
1111 // throw an exception, and marking functions 'nounwind' if they cannot throw.
1212 // It implements this as a bottom-up traversal of the call-graph.
1313 //
199199 if (dyn_castFoldableMul(RHS, C2) == LHS)
200200 return BinaryOperator::CreateMul(LHS, AddOne(C2));
201201
202 // A+B --> A|B if A and B have no bits set in common.
202 // A+B --> A|B iff A and B have no bits set in common.
203203 if (IntegerType *IT = dyn_cast(I.getType())) {
204204 APInt LHSKnownOne(IT->getBitWidth(), 0);
205205 APInt LHSKnownZero(IT->getBitWidth(), 0);
215215 }
216216 }
217217
218 // W*X + Y*Z --> W * (X+Z) if W == Y
218 // W*X + Y*Z --> W * (X+Z) iff W == Y
219219 {
220220 Value *W, *X, *Y, *Z;
221221 if (match(LHS, m_Mul(m_Value(W), m_Value(X))) &&
314314 return Builder->CreateICmpUGT(Add, LowerBound);
315315 }
316316
317 // isRunOfOnes - Returns true if Val consists of one contiguous run of 1s with
317 // isRunOfOnes - Returns true iff Val consists of one contiguous run of 1s with
318318 // any number of 0s on either side. The 1s are allowed to wrap from LSB to
319319 // MSB, so 0x000FFF0, 0x0000FFFF, and 0xFF0000FF are all runs. 0x0F0F0000 is
320320 // not, since all 1s are not contiguous.
334334 /// where isSub determines whether the operator is a sub. If we can fold one of
335335 /// the following xforms:
336336 ///
337 /// ((A & N) +/- B) & Mask -> (A +/- B) & Mask if N&Mask == Mask
338 /// ((A | N) +/- B) & Mask -> (A +/- B) & Mask if N&Mask == 0
339 /// ((A ^ N) +/- B) & Mask -> (A +/- B) & Mask if N&Mask == 0
337 /// ((A & N) +/- B) & Mask -> (A +/- B) & Mask iff N&Mask == Mask
338 /// ((A | N) +/- B) & Mask -> (A +/- B) & Mask iff N&Mask == 0
339 /// ((A ^ N) +/- B) & Mask -> (A +/- B) & Mask iff N&Mask == 0
340340 ///
341341 /// return (A +/- B).
342342 ///
751751
752752 // (trunc x) == C1 & (and x, CA) == C2 -> (and x, CA|CMAX) == C1|C2
753753 // where CMAX is the all ones value for the truncated type,
754 // if the lower bits of C2 and CA are zero.
754 // iff the lower bits of C2 and CA are zero.
755755 if (LHSCC == ICmpInst::ICMP_EQ && LHSCC == RHSCC &&
756756 LHS->hasOneUse() && RHS->hasOneUse()) {
757757 Value *V;
10611061 break;
10621062 }
10631063 case Instruction::Add:
1064 // ((A & N) + B) & AndRHS -> (A + B) & AndRHS if N&AndRHS == AndRHS.
1065 // ((A | N) + B) & AndRHS -> (A + B) & AndRHS if N&AndRHS == 0
1066 // ((A ^ N) + B) & AndRHS -> (A + B) & AndRHS if N&AndRHS == 0
1064 // ((A & N) + B) & AndRHS -> (A + B) & AndRHS iff N&AndRHS == AndRHS.
1065 // ((A | N) + B) & AndRHS -> (A + B) & AndRHS iff N&AndRHS == 0
1066 // ((A ^ N) + B) & AndRHS -> (A + B) & AndRHS iff N&AndRHS == 0
10671067 if (Value *V = FoldLogicalPlusAnd(Op0LHS, Op0RHS, AndRHS, false, I))
10681068 return BinaryOperator::CreateAnd(V, AndRHS);
10691069 if (Value *V = FoldLogicalPlusAnd(Op0RHS, Op0LHS, AndRHS, false, I))
10711071 break;
10721072
10731073 case Instruction::Sub:
1074 // ((A & N) - B) & AndRHS -> (A - B) & AndRHS if N&AndRHS == AndRHS.
1075 // ((A | N) - B) & AndRHS -> (A - B) & AndRHS if N&AndRHS == 0
1076 // ((A ^ N) - B) & AndRHS -> (A - B) & AndRHS if N&AndRHS == 0
1074 // ((A & N) - B) & AndRHS -> (A - B) & AndRHS iff N&AndRHS == AndRHS.
1075 // ((A | N) - B) & AndRHS -> (A - B) & AndRHS iff N&AndRHS == 0
1076 // ((A ^ N) - B) & AndRHS -> (A - B) & AndRHS iff N&AndRHS == 0
10771077 if (Value *V = FoldLogicalPlusAnd(Op0LHS, Op0RHS, AndRHS, true, I))
10781078 return BinaryOperator::CreateAnd(V, AndRHS);
10791079
1080 // (A - N) & AndRHS -> -N & AndRHS if A&AndRHS==0 and AndRHS
1080 // (A - N) & AndRHS -> -N & AndRHS iff A&AndRHS==0 and AndRHS
10811081 // has 1's for all bits that the subtraction with A might affect.
10821082 if (Op0I->hasOneUse() && !match(Op0LHS, m_Zero())) {
10831083 uint32_t BitWidth = AndRHSMask.getBitWidth();
14711471 }
14721472
14731473 // (icmp ult (X + CA), C1) | (icmp eq X, C2) -> (icmp ule (X + CA), C1)
1474 // if C2 + CA == C1.
1474 // iff C2 + CA == C1.
14751475 if (LHSCC == ICmpInst::ICMP_ULT && RHSCC == ICmpInst::ICMP_EQ) {
14761476 ConstantInt *AddCst;
14771477 if (match(Val, m_Add(m_Specific(Val2), m_ConstantInt(AddCst))))
17341734 if (ConstantInt *RHS = dyn_cast(Op1)) {
17351735 ConstantInt *C1 = 0; Value *X = 0;
17361736 // (X & C1) | C2 --> (X | C2) & (C1|C2)
1737 // if (C1 & C2) == 0.
1737 // iff (C1 & C2) == 0.
17381738 if (match(Op0, m_And(m_Value(X), m_ConstantInt(C1))) &&
17391739 (RHS->getValue() & C1->getValue()) != 0 &&
17401740 Op0->hasOneUse()) {
17781778 return BSwap;
17791779 }
17801780
1781 // (X^C)|Y -> (X|Y)^C if Y&C == 0
1781 // (X^C)|Y -> (X|Y)^C iff Y&C == 0
17821782 if (Op0->hasOneUse() &&
17831783 match(Op0, m_Xor(m_Value(A), m_ConstantInt(C1))) &&
17841784 MaskedValueIsZero(Op1, C1->getValue())) {
17871787 return BinaryOperator::CreateXor(NOr, C1);
17881788 }
17891789
1790 // Y|(X^C) -> (X|Y)^C if Y&C == 0
1790 // Y|(X^C) -> (X|Y)^C iff Y&C == 0
17911791 if (Op1->hasOneUse() &&
17921792 match(Op1, m_Xor(m_Value(A), m_ConstantInt(C1))) &&
17931793 MaskedValueIsZero(Op0, C1->getValue())) {
18291829
18301830 if ((C1->getValue() & C2->getValue()) == 0) {
18311831 // ((V | N) & C1) | (V & C2) --> (V|N) & (C1|C2)
1832 // if (C1&C2) == 0 and (N&~C1) == 0
1832 // iff (C1&C2) == 0 and (N&~C1) == 0
18331833 if (match(A, m_Or(m_Value(V1), m_Value(V2))) &&
18341834 ((V1 == B && MaskedValueIsZero(V2, ~C1->getValue())) || // (V|N)
18351835 (V2 == B && MaskedValueIsZero(V1, ~C1->getValue())))) // (N|V)
18451845 C1->getValue()|C2->getValue()));
18461846
18471847 // ((V|C3)&C1) | ((V|C4)&C2) --> (V|C3|C4)&(C1|C2)
1848 // if (C1&C2) == 0 and (C3&~C1) == 0 and (C4&~C2) == 0.
1848 // iff (C1&C2) == 0 and (C3&~C1) == 0 and (C4&~C2) == 0.
18491849 ConstantInt *C3 = 0, *C4 = 0;
18501850 if (match(A, m_Or(m_Value(V1), m_ConstantInt(C3))) &&
18511851 (C3->getValue() & ~C1->getValue()) == 0 &&
21452145
21462146 }
21472147 } else if (Op0I->getOpcode() == Instruction::Or) {
2148 // (X|C1)^C2 -> X^(C1|C2) if X&~C1 == 0
2148 // (X|C1)^C2 -> X^(C1|C2) iff X&~C1 == 0
21492149 if (MaskedValueIsZero(Op0I->getOperand(0), Op0CI->getValue())) {
21502150 Constant *NewRHS = ConstantExpr::getOr(Op0CI, RHS);
21512151 // Anything in both C1 and C2 is known to be zero, remove it from
380380 break;
381381 case Instruction::LShr:
382382 // If this is a truncate of a logical shr, we can truncate it to a smaller
383 // lshr if we know that the bits we would otherwise be shifting in are
383 // lshr iff we know that the bits we would otherwise be shifting in are
384384 // already zeros.
385385 if (ConstantInt *CI = dyn_cast(I->getOperand(1))) {
386386 uint32_t OrigBitWidth = OrigTy->getScalarSizeInBits();
526526 return ReplaceInstUsesWith(CI, In);
527527 }
528528
529 // zext (X == 0) to i32 --> X^1 if X has only the low bit set.
530 // zext (X == 0) to i32 --> (X>>1)^1 if X has only the 2nd bit set.
531 // zext (X == 1) to i32 --> X if X has only the low bit set.
532 // zext (X == 2) to i32 --> X>>1 if X has only the 2nd bit set.
533 // zext (X != 0) to i32 --> X if X has only the low bit set.
534 // zext (X != 0) to i32 --> X>>1 if X has only the 2nd bit set.
535 // zext (X != 1) to i32 --> X^1 if X has only the low bit set.
536 // zext (X != 2) to i32 --> (X>>1)^1 if X has only the 2nd bit set.
529 // zext (X == 0) to i32 --> X^1 iff X has only the low bit set.
530 // zext (X == 0) to i32 --> (X>>1)^1 iff X has only the 2nd bit set.
531 // zext (X == 1) to i32 --> X iff X has only the low bit set.
532 // zext (X == 2) to i32 --> X>>1 iff X has only the 2nd bit set.
533 // zext (X != 0) to i32 --> X iff X has only the low bit set.
534 // zext (X != 0) to i32 --> X>>1 iff X has only the 2nd bit set.
535 // zext (X != 1) to i32 --> X^1 iff X has only the low bit set.
536 // zext (X != 2) to i32 --> (X>>1)^1 iff X has only the 2nd bit set.
537537 if ((Op1CV == 0 || Op1CV.isPowerOf2()) &&
538538 // This only works for EQ and NE
539539 ICI->isEquality()) {
367367 LI.setAlignment(EffectiveLoadAlign);
368368 }
369369
370 // load (cast X) --> cast (load X) if safe.
370 // load (cast X) --> cast (load X) iff safe.
371371 if (isa(Op))
372372 if (Instruction *Res = InstCombineLoadCast(*this, LI, TD))
373373 return Res;
549549 APInt Mask(APInt::getSignBit(I.getType()->getPrimitiveSizeInBits()));
550550 if (MaskedValueIsZero(Op0, Mask)) {
551551 if (MaskedValueIsZero(Op1, Mask)) {
552 // X sdiv Y -> X udiv Y, if X and Y don't have sign bit set
552 // X sdiv Y -> X udiv Y, iff X and Y don't have sign bit set
553553 return BinaryOperator::CreateUDiv(Op0, Op1, I.getName());
554554 }
555555
691691 if (I.getType()->isIntegerTy()) {
692692 APInt Mask(APInt::getSignBit(I.getType()->getPrimitiveSizeInBits()));
693693 if (MaskedValueIsZero(Op1, Mask) && MaskedValueIsZero(Op0, Mask)) {
694 // X srem Y -> X urem Y, if X and Y don't have sign bit set
694 // X srem Y -> X urem Y, iff X and Y don't have sign bit set
695695 return BinaryOperator::CreateURem(Op0, Op1, I.getName());
696696 }
697697 }
3636 if (Instruction *Res = FoldShiftByConstant(Op0, CUI, I))
3737 return Res;
3838
39 // X shift (A srem B) -> X shift (A and B-1) if B is a power of 2.
39 // X shift (A srem B) -> X shift (A and B-1) iff B is a power of 2.
4040 // Because shifts by negative values (which could occur if A were negative)
4141 // are undefined.
4242 Value *A; const APInt *B;
8484 // TODO: Check that the input bits are already zero with MaskedValueIsZero
8585 #if 0
8686 // If this is a truncate of a logical shr, we can truncate it to a smaller
87 // lshr if we know that the bits we would otherwise be shifting in are
87 // lshr iff we know that the bits we would otherwise be shifting in are
8888 // already zeros.
8989 uint32_t OrigBitWidth = OrigTy->getScalarSizeInBits();
9090 uint32_t BitWidth = Ty->getScalarSizeInBits();
303303
304304 // If all of the demanded bits are known to be zero on one side or the
305305 // other, turn this into an *inclusive* or.
306 // e.g. (A & C1)^(B & C2) -> (A & C1)|(B & C2) if C1&C2 == 0
306 // e.g. (A & C1)^(B & C2) -> (A & C1)|(B & C2) iff C1&C2 == 0
307307 if ((DemandedMask & ~RHSKnownZero & ~LHSKnownZero) == 0) {
308308 Instruction *Or =
309309 BinaryOperator::CreateOr(I->getOperand(0), I->getOperand(1),
314314 // If all of the demanded bits on one side are known, and all of the set
315315 // bits on that side are also known to be set on the other side, turn this
316316 // into an AND, as we know the bits will be cleared.
317 // e.g. (X | C1) ^ C2 --> (X | C1) & ~C2 if (C1&C2) == C2
317 // e.g. (X | C1) ^ C2 --> (X | C1) & ~C2 iff (C1&C2) == C2
318318 if ((DemandedMask & (RHSKnownZero|RHSKnownOne)) == DemandedMask) {
319319 // all known
320320 if ((RHSKnownOne & LHSKnownOne) == RHSKnownOne) {
17231723 continue;
17241724 // At this point we know that LFilter has at least one element.
17251725 if (isa(LFilter)) { // LFilter only contains zeros.
1726 // Filter is a subset of LFilter if Filter contains only zeros (as we
1726 // Filter is a subset of LFilter iff Filter contains only zeros (as we
17271727 // already know that Filter is not longer than LFilter).
17281728 if (isa(Filter)) {
17291729 assert(FElts <= LElts && "Should have handled this case earlier!");
17371737 ConstantArray *LArray = cast(LFilter);
17381738 if (isa(Filter)) { // Filter only contains zeros.
17391739 // Since Filter is non-empty and contains only zeros, it is a subset of
1740 // LFilter if LFilter contains a zero.
1740 // LFilter iff LFilter contains a zero.
17411741 assert(FElts > 0 && "Should have eliminated the empty filter earlier!");
17421742 for (unsigned l = 0; l != LElts; ++l)
17431743 if (LArray->getOperand(l)->isNullValue()) {
468468 _increment = increment;
469469 }
470470
471 // True if the edge has already been instrumented.
471 // True iff the edge has already been instrumented.
472472 bool BLInstrumentationEdge::hasInstrumentation() {
473473 return(_hasInstrumentation);
474474 }
200200 break;
201201 }
202202 //case Instruction::Or:
203 // TODO: We can handle "Or Val, Imm" if this OR is equivalent to an ADD.
203 // TODO: We can handle "Or Val, Imm" iff this OR is equivalent to an ADD.
204204 //break;
205205 case Instruction::Mul:
206206 case Instruction::Shl: {
103103 return I != E;
104104
105105 // If AllowIdenticalEdges is true, then we allow this edge to be considered
106 // non-critical if all preds come from TI's block.
106 // non-critical iff all preds come from TI's block.
107107 while (I != E) {
108108 const BasicBlock *P = *I;
109109 if (P != FirstPred)
556556 // Now we have a map of all of the pairable instructions and we need to
557557 // select the best possible pairing. A good pairing is one such that the
558558 // users of the pair are also paired. This defines a (directed) forest
559 // over the pairs such that two pairs are connected if the second pair
559 // over the pairs such that two pairs are connected iff the second pair
560560 // uses the first.
561561
562562 // Note that it only matters that both members of the second pair use some
192192 // . NormalDest
193193 // .
194194 //
195 // Given the definition of dominance, NormalDest is dominated by X if X
195 // Given the definition of dominance, NormalDest is dominated by X iff X
196196 // dominates all of NormalDest's predecessors (X, B, C in the example). X
197197 // trivially dominates itself, so we only have to find if it dominates the
198198 // other predecessors. Since the only way out of X is via NormalDest, X can
257257 };
258258 }
259259
260 // setPreservesCFG - This function should be called to by the pass, if they do
260 // setPreservesCFG - This function should be called to by the pass, iff they do
261261 // not:
262262 //
263263 // 1. Add or remove basic blocks from the function
16991699 void TimingInfo::createTheTimeInfo() {
17001700 if (!TimePassesIsEnabled || TheTimeInfo) return;
17011701
1702 // Constructed the first time this is called, if -time-passes is enabled.
1702 // Constructed the first time this is called, iff -time-passes is enabled.
17031703 // This guarantees that the object will be constructed before static globals,
17041704 // thus it will be destroyed before them.
17051705 static ManagedStatic TTI;
169169 }
170170
171171 /// isSizedDerivedType - Derived types like structures and arrays are sized
172 /// if all of the members of the type are sized as well. Since asking for
172 /// iff all of the members of the type are sized as well. Since asking for
173173 /// their size is relatively uncommon, move this operation out of line.
174174 bool Type::isSizedDerivedType() const {
175175 if (this->isIntegerTy())
60816081 *)
60826082 # The compiler driver will combine linker options so we
60836083 # cannot just pass the convience library names through
6084 # without $wl, if we do not link with $LD.
6084 # without $wl, iff we do not link with $LD.
60856085 # Luckily, gcc supports the same syntax we need for Sun Studio.
60866086 # Supported since Solaris 2.6 (maybe 2.5.1?)
60876087 case $wlarc in
0 ; RUN: opt < %s -basicaa -gvn -asan -S | FileCheck %s
1 ; ASAN conflicts with load widening if the widened load accesses data out of bounds
1 ; ASAN conflicts with load widening iff the widened load accesses data out of bounds
22 ; (while the original unwidened loads do not).
33 ; http://code.google.com/p/address-sanitizer/issues/detail?id=20#c1
44
4848 ret i32 %C
4949 }
5050
51 ; (A & C1)+(B & C2) -> (A & C1)|(B & C2) if C1&C2 == 0
51 ; (A & C1)+(B & C2) -> (A & C1)|(B & C2) iff C1&C2 == 0
5252 define i32 @test8(i32 %A, i32 %B) {
5353 %A1 = and i32 %A, 7 ; [#uses=1]
5454 %B1 = and i32 %B, 128 ; [#uses=1]
44
55
66 define i47 @test1(i47 %A, i47 %B) {
7 ;; (A & C1)^(B & C2) -> (A & C1)|(B & C2) if C1&C2 == 0
7 ;; (A & C1)^(B & C2) -> (A & C1)|(B & C2) iff C1&C2 == 0
88 %A1 = and i47 %A, 70368744177664
99 %B1 = and i47 %B, 70368744177661
1010 %C1 = xor i47 %A1, %B1
4242 }
4343
4444 define i47 @test7(i47 %A) {
45 ;; (A | C1) ^ C2 -> (A | C1) & ~C2 if (C1&C2) == C2
45 ;; (A | C1) ^ C2 -> (A | C1) & ~C2 iff (C1&C2) == C2
4646 %B1 = or i47 %A, 70368744177663
4747 %C1 = xor i47 %B1, 703687463
4848 ret i47 %C1
55
66
77 define i447 @test1(i447 %A, i447 %B) {
8 ;; (A & C1)^(B & C2) -> (A & C1)|(B & C2) if C1&C2 == 0
8 ;; (A & C1)^(B & C2) -> (A & C1)|(B & C2) iff C1&C2 == 0
99 %A1 = and i447 %A, 70368744177664
1010 %B1 = and i447 %B, 70368744177663
1111 %C1 = xor i447 %A1, %B1
4343 }
4444
4545 define i1023 @test7(i1023 %A) {
46 ;; (A | C1) ^ C2 -> (A | C1) & ~C2 if (C1&C2) == C2
46 ;; (A | C1) ^ C2 -> (A | C1) & ~C2 iff (C1&C2) == C2
4747 %B1 = or i1023 %A, 70368744177663
4848 %C1 = xor i1023 %B1, 703687463
4949 ret i1023 %C1
4747 public:
4848 ReducePassList(BugDriver &bd) : BD(bd) {}
4949
50 // doTest - Return true if running the "removed" passes succeeds, and
50 // doTest - Return true iff running the "removed" passes succeeds, and
5151 // running the "Kept" passes fail when run on the output of the "removed"
5252 // passes. If we return true, we update the current module of bugpoint.
5353 //
0 #! /usr/bin/python
11
22 #this is a script to extract given named nodes from a dot file, with
3 #the associated edges. An edge is kept if for edge x -> y
3 #the associated edges. An edge is kept iff for edge x -> y
44 # x and y are both nodes specified to be kept.
55
66 #known issues: if a line contains '->' and is not an edge line
531531 //
532532 // Alternatively:
533533 //
534 // overlap(A, B) if there exists:
534 // overlap(A, B) iff there exists:
535535 // A' in { A, subregs(A) } and B' in { B, subregs(B) } such that:
536536 // A' = B' or A' in aliases(B') or B' in aliases(A').
537537 //
182182 bool inheritRegUnits(CodeGenRegBank &RegBank);
183183
184184 // Adopt a register unit for pressure tracking.
185 // A unit is adopted if its unit number is >= NumNativeRegUnits.
185 // A unit is adopted iff its unit number is >= NumNativeRegUnits.
186186 void adoptRegUnit(unsigned RUID) { RegUnits.push_back(RUID); }
187187
188188 // Get the sum of this register's register unit weights.
483483 // status_ok: true if exit_status is acceptable in the context of
484484 // this particular death test, which fails if it is false
485485 //
486 // Returns true if all of the above conditions are met. Otherwise, the
486 // Returns true iff all of the above conditions are met. Otherwise, the
487487 // first failing condition, in the order given above, is the one that is
488488 // reported. Also sets the last death test message string.
489489 bool DeathTestImpl::Passed(bool status_ok) {
123123 free(const_cast(pattern_));
124124 }
125125
126 // Returns true if regular expression re matches the entire str.
126 // Returns true iff regular expression re matches the entire str.
127127 bool RE::FullMatch(const char* str, const RE& re) {
128128 if (!re.is_valid_) return false;
129129
131131 return regexec(&re.full_regex_, str, 1, &match, 0) == 0;
132132 }
133133
134 // Returns true if regular expression re matches a substring of str
134 // Returns true iff regular expression re matches a substring of str
135135 // (including str itself).
136136 bool RE::PartialMatch(const char* str, const RE& re) {
137137 if (!re.is_valid_) return false;
172172
173173 #elif GTEST_USES_SIMPLE_RE
174174
175 // Returns true if ch appears anywhere in str (excluding the
175 // Returns true iff ch appears anywhere in str (excluding the
176176 // terminating '\0' character).
177177 bool IsInSet(char ch, const char* str) {
178178 return ch != '\0' && strchr(str, ch) != NULL;
179179 }
180180
181 // Returns true if ch belongs to the given classification. Unlike
181 // Returns true iff ch belongs to the given classification. Unlike
182182 // similar functions in , these aren't affected by the
183183 // current locale.
184184 bool IsAsciiDigit(char ch) { return '0' <= ch && ch <= '9'; }
192192 ('0' <= ch && ch <= '9') || ch == '_';
193193 }
194194
195 // Returns true if "\\c" is a supported escape sequence.
195 // Returns true iff "\\c" is a supported escape sequence.
196196 bool IsValidEscape(char c) {
197197 return (IsAsciiPunct(c) || IsInSet(c, "dDfnrsStvwW"));
198198 }
199199
200 // Returns true if the given atom (specified by escaped and pattern)
200 // Returns true iff the given atom (specified by escaped and pattern)
201201 // matches ch. The result is undefined if the atom is invalid.
202202 bool AtomMatchesChar(bool escaped, char pattern_char, char ch) {
203203 if (escaped) { // "\\p" where p is pattern_char.
239239
240240 bool is_valid = true;
241241
242 // True if ?, *, or + can follow the previous atom.
242 // True iff ?, *, or + can follow the previous atom.
243243 bool prev_repeatable = false;
244244 for (int i = 0; regex[i]; i++) {
245245 if (regex[i] == '\\') { // An escape sequence
315315 return false;
316316 }
317317
318 // Returns true if regex matches a prefix of str. regex must be a
318 // Returns true iff regex matches a prefix of str. regex must be a
319319 // valid simple regular expression and not start with "^", or the
320320 // result is undefined.
321321 bool MatchRegexAtHead(const char* regex, const char* str) {
346346 }
347347 }
348348
349 // Returns true if regex matches any substring of str. regex must be
349 // Returns true iff regex matches any substring of str. regex must be
350350 // a valid simple regular expression, or the result is undefined.
351351 //
352352 // The algorithm is recursive, but the recursion depth doesn't exceed
376376 free(const_cast(full_pattern_));
377377 }
378378
379 // Returns true if regular expression re matches the entire str.
379 // Returns true iff regular expression re matches the entire str.
380380 bool RE::FullMatch(const char* str, const RE& re) {
381381 return re.is_valid_ && MatchRegexAnywhere(re.full_pattern_, str);
382382 }
383383
384 // Returns true if regular expression re matches a substring of str
384 // Returns true iff regular expression re matches a substring of str
385385 // (including str itself).
386386 bool RE::PartialMatch(const char* str, const RE& re) {
387387 return re.is_valid_ && MatchRegexAnywhere(re.pattern_, str);
706706 // Reads and returns the Boolean environment variable corresponding to
707707 // the given flag; if it's not set, returns default_value.
708708 //
709 // The value is considered true if it's not "0".
709 // The value is considered true iff it's not "0".
710710 bool BoolFromGTestEnv(const char* flag, bool default_value) {
711711 const String env_var = FlagToEnvVar(flag);
712712 const char* const string_value = posix::GetEnv(env_var.c_str());
172172 // stack trace.
173173 const char kStackTraceMarker[] = "\nStack trace:\n";
174174
175 // g_help_flag is true if the --help flag or an equivalent form is
175 // g_help_flag is true iff the --help flag or an equivalent form is
176176 // specified on the command line.
177177 bool g_help_flag = false;
178178
186186 GTEST_DEFINE_bool_(
187187 break_on_failure,
188188 internal::BoolFromGTestEnv("break_on_failure", false),
189 "True if a failed assertion should be a debugger break-point.");
189 "True iff a failed assertion should be a debugger break-point.");
190190
191191 GTEST_DEFINE_bool_(
192192 catch_exceptions,
193193 internal::BoolFromGTestEnv("catch_exceptions", true),
194 "True if " GTEST_NAME_
194 "True iff " GTEST_NAME_
195195 " should catch exceptions and treat them as test failures.");
196196
197197 GTEST_DEFINE_string_(
229229 GTEST_DEFINE_bool_(
230230 print_time,
231231 internal::BoolFromGTestEnv("print_time", true),
232 "True if " GTEST_NAME_
232 "True iff " GTEST_NAME_
233233 " should display elapsed time in text output.");
234234
235235 GTEST_DEFINE_int32_(
246246
247247 GTEST_DEFINE_bool_(
248248 show_internal_stack_frames, false,
249 "True if " GTEST_NAME_ " should include internal stack frames when "
249 "True iff " GTEST_NAME_ " should include internal stack frames when "
250250 "printing test failure stack traces.");
251251
252252 GTEST_DEFINE_bool_(
253253 shuffle,
254254 internal::BoolFromGTestEnv("shuffle", false),
255 "True if " GTEST_NAME_
255 "True iff " GTEST_NAME_
256256 " should randomize tests' order on every run.");
257257
258258 GTEST_DEFINE_int32_(
296296 return state_ % range;
297297 }
298298
299 // GTestIsInitialized() returns true if the user has initialized
299 // GTestIsInitialized() returns true iff the user has initialized
300300 // Google Test. Useful for catching the user mistake of not initializing
301301 // Google Test before calling RUN_ALL_TESTS().
302302 //
319319 return sum;
320320 }
321321
322 // Returns true if the test case passed.
322 // Returns true iff the test case passed.
323323 static bool TestCasePassed(const TestCase* test_case) {
324324 return test_case->should_run() && test_case->Passed();
325325 }
326326
327 // Returns true if the test case failed.
327 // Returns true iff the test case failed.
328328 static bool TestCaseFailed(const TestCase* test_case) {
329329 return test_case->should_run() && test_case->Failed();
330330 }
331331
332 // Returns true if test_case contains at least one test that should
332 // Returns true iff test_case contains at least one test that should
333333 // run.
334334 static bool ShouldRunTestCase(const TestCase* test_case) {
335335 return test_case->should_run();
424424 return result.ToString();
425425 }
426426
427 // Returns true if the wildcard pattern matches the string. The
427 // Returns true iff the wildcard pattern matches the string. The
428428 // first ':' or '\0' character in pattern marks the end of it.
429429 //
430430 // This recursive algorithm isn't very efficient, but is clear and
468468
469469 // TODO(keithray): move String function implementations to gtest-string.cc.
470470
471 // Returns true if the user-specified filter matches the test case
471 // Returns true iff the user-specified filter matches the test case
472472 // name and the test name.
473473 bool UnitTestOptions::FilterMatchesTest(const String &test_case_name,
474474 const String &test_name) {
886886
887887 #endif // GTEST_OS_WINDOWS_MOBILE
888888
889 // Compares two C strings. Returns true if they have the same content.
889 // Compares two C strings. Returns true iff they have the same content.
890890 //
891891 // Unlike strcmp(), this function can handle NULL argument(s). A NULL
892892 // C string is considered different to any non-NULL C string,
991991 // expected_value: "5"
992992 // actual_value: "6"
993993 //
994 // The ignoring_case parameter is true if the assertion is a
994 // The ignoring_case parameter is true iff the assertion is a
995995 // *_STRCASEEQ*. When it's true, the string " (ignoring case)" will
996996 // be inserted into the message.
997997 AssertionResult EqFailure(const char* expected_expression,
12231223
12241224 // Helper functions for implementing IsSubString() and IsNotSubstring().
12251225
1226 // This group of overloaded functions return true if needle is a
1226 // This group of overloaded functions return true iff needle is a
12271227 // substring of haystack. NULL is considered a substring of itself
12281228 // only.
12291229
15411541 String::ShowWideCString(wide_c_str).c_str());
15421542 }
15431543
1544 // Compares two wide C strings. Returns true if they have the same
1544 // Compares two wide C strings. Returns true iff they have the same
15451545 // content.
15461546 //
15471547 // Unlike wcscmp(), this function can handle NULL argument(s). A NULL
15861586 << " vs " << String::ShowWideCStringQuoted(s2);
15871587 }
15881588
1589 // Compares two C strings, ignoring case. Returns true if they have
1589 // Compares two C strings, ignoring case. Returns true iff they have
15901590 // the same content.
15911591 //
15921592 // Unlike strcasecmp(), this function can handle NULL argument(s). A
16001600 return posix::StrCaseCmp(lhs, rhs) == 0;
16011601 }
16021602
1603 // Compares two wide C strings, ignoring case. Returns true if they
1603 // Compares two wide C strings, ignoring case. Returns true iff they
16041604 // have the same content.
16051605 //
16061606 // Unlike wcscasecmp(), this function can handle NULL argument(s).
16601660 (length() > rhs.length()) ? 1 : 0;
16611661 }
16621662
1663 // Returns true if this String ends with the given suffix. *Any*
1663 // Returns true iff this String ends with the given suffix. *Any*
16641664 // String is considered to end with a NULL or empty suffix.
16651665 bool String::EndsWith(const char* suffix) const {
16661666 if (suffix == NULL || CStringEquals(suffix, "")) return true;
16731673 CStringEquals(c_str() + this_len - suffix_len, suffix);
16741674 }
16751675
1676 // Returns true if this String ends with the given suffix, ignoring case.
1676 // Returns true iff this String ends with the given suffix, ignoring case.
16771677 // Any String is considered to end with a NULL or empty suffix.
16781678 bool String::EndsWithCaseInsensitive(const char* suffix) const {
16791679 if (suffix == NULL || CStringEquals(suffix, "")) return true;
18481848 elapsed_time_ = 0;
18491849 }
18501850
1851 // Returns true if the test failed.
1851 // Returns true iff the test failed.
18521852 bool TestResult::Failed() const {
18531853 for (int i = 0; i < total_part_count(); ++i) {
18541854 if (GetTestPartResult(i).failed())
18571857 return false;
18581858 }
18591859
1860 // Returns true if the test part fatally failed.
1860 // Returns true iff the test part fatally failed.
18611861 static bool TestPartFatallyFailed(const TestPartResult& result) {
18621862 return result.fatally_failed();
18631863 }
18641864
1865 // Returns true if the test fatally failed.
1865 // Returns true iff the test fatally failed.
18661866 bool TestResult::HasFatalFailure() const {
18671867 return CountIf(test_part_results_, TestPartFatallyFailed) > 0;
18681868 }
18691869
1870 // Returns true if the test part non-fatally failed.
1870 // Returns true iff the test part non-fatally failed.
18711871 static bool TestPartNonfatallyFailed(const TestPartResult& result) {
18721872 return result.nonfatally_failed();
18731873 }
18741874
1875 // Returns true if the test has a non-fatal failure.
1875 // Returns true iff the test has a non-fatal failure.
18761876 bool TestResult::HasNonfatalFailure() const {
18771877 return CountIf(test_part_results_, TestPartNonfatallyFailed) > 0;
18781878 }
21692169 this, &Test::TearDown, "TearDown()");
21702170 }
21712171
2172 // Returns true if the current test has a fatal failure.
2172 // Returns true iff the current test has a fatal failure.
21732173 bool Test::HasFatalFailure() {
21742174 return internal::GetUnitTestImpl()->current_test_result()->HasFatalFailure();
21752175 }
21762176
2177 // Returns true if the current test has a non-fatal failure.
2177 // Returns true iff the current test has a non-fatal failure.
21782178 bool Test::HasNonfatalFailure() {
21792179 return internal::GetUnitTestImpl()->current_test_result()->
21802180 HasNonfatalFailure();
25522552
25532553 #endif // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
25542554
2555 // Returns true if Google Test should use colors in the output.
2555 // Returns true iff Google Test should use colors in the output.
25562556 bool ShouldUseColor(bool stdout_is_tty) {
25572557 const char* const gtest_color = GTEST_FLAG(color).c_str();
25582558
36673667 return impl()->elapsed_time();
36683668 }
36693669
3670 // Returns true if the unit test passed (i.e. all test cases passed).
3670 // Returns true iff the unit test passed (i.e. all test cases passed).
36713671 bool UnitTest::Passed() const { return impl()->Passed(); }
36723672
3673 // Returns true if the unit test failed (i.e. some test case failed
3673 // Returns true iff the unit test failed (i.e. some test case failed
36743674 // or something outside of all tests failed).
36753675 bool UnitTest::Failed() const { return impl()->Failed(); }
36763676
40394039 explicit TestCaseNameIs(const String& name)
40404040 : name_(name) {}
40414041
4042 // Returns true if the name of test_case matches name_.
4042 // Returns true iff the name of test_case matches name_.
40434043 bool operator()(const TestCase* test_case) const {
40444044 return test_case != NULL && strcmp(test_case->name(), name_.c_str()) == 0;
40454045 }
41314131 // protocol.
41324132 internal::WriteToShardStatusFileIfNeeded();
41334133
4134 // True if we are in a subprocess for running a thread-safe-style
4134 // True iff we are in a subprocess for running a thread-safe-style
41354135 // death test.
41364136 bool in_subprocess_for_death_test = false;
41374137
41584158 random_seed_ = GTEST_FLAG(shuffle) ?
41594159 GetRandomSeedFromFlag(GTEST_FLAG(random_seed)) : 0;
41604160
4161 // True if at least one test has failed.
4161 // True iff at least one test has failed.
41624162 bool failed = false;
41634163
41644164 TestEventListener* repeater = listeners()->repeater();
43274327 }
43284328
43294329 // Given the total number of shards, the shard index, and the test id,
4330 // returns true if the test should be run on this shard. The test id is
4330 // returns true iff the test should be run on this shard. The test id is
43314331 // some arbitrary but unique non-negative integer assigned to each test
43324332 // method. Assumes that 0 <= shard_index < total_shards.
43334333 bool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id) {
8484 // Gets the message associated with the test part.
8585 const char* message() const { return message_.c_str(); }
8686
87 // Returns true if the test part passed.
87 // Returns true iff the test part passed.
8888 bool passed() const { return type_ == kSuccess; }
8989
90 // Returns true if the test part failed.
90 // Returns true iff the test part failed.
9191 bool failed() const { return type_ != kSuccess; }
9292
93 // Returns true if the test part non-fatally failed.
93 // Returns true iff the test part non-fatally failed.
9494 bool nonfatally_failed() const { return type_ == kNonFatalFailure; }
9595
96 // Returns true if the test part fatally failed.
96 // Returns true iff the test part fatally failed.
9797 bool fatally_failed() const { return type_ == kFatalFailure; }
9898 private:
9999 Type type_;
269269 // Used in the EXPECT_TRUE/FALSE(bool_expression).
270270 explicit AssertionResult(bool success) : success_(success) {}
271271
272 // Returns true if the assertion succeeded.
272 // Returns true iff the assertion succeeded.
273273 operator bool() const { return success_; } // NOLINT
274274
275275 // Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
380380 // class.
381381 static void TearDownTestCase() {}
382382
383 // Returns true if the current test has a fatal failure.
383 // Returns true iff the current test has a fatal failure.
384384 static bool HasFatalFailure();
385385
386 // Returns true if the current test has a non-fatal failure.
386 // Returns true iff the current test has a non-fatal failure.
387387 static bool HasNonfatalFailure();
388388
389 // Returns true if the current test has a (either fatal or
389 // Returns true iff the current test has a (either fatal or
390390 // non-fatal) failure.
391391 static bool HasFailure() { return HasFatalFailure() || HasNonfatalFailure(); }
392392
416416 virtual void TearDown();
417417
418418 private:
419 // Returns true if the current test has the same fixture class as
419 // Returns true iff the current test has the same fixture class as
420420 // the first test in the current test case.
421421 static bool HasSameFixtureClass();
422422
519519 // Returns the number of the test properties.
520520 int test_property_count() const;
521521
522 // Returns true if the test passed (i.e. no test part failed).
522 // Returns true iff the test passed (i.e. no test part failed).
523523 bool Passed() const { return !Failed(); }
524524
525 // Returns true if the test failed.
525 // Returns true iff the test failed.
526526 bool Failed() const;
527527
528 // Returns true if the test fatally failed.
528 // Returns true iff the test fatally failed.
529529 bool HasFatalFailure() const;
530530
531 // Returns true if the test has a non-fatal failure.
531 // Returns true iff the test has a non-fatal failure.
532532 bool HasNonfatalFailure() const;
533533
534534 // Returns the elapsed time, in milliseconds.
719719 // value-parameterized test.
720720 const internal::scoped_ptr value_param_;
721721 const internal::TypeId fixture_class_id_; // ID of the test fixture class
722 bool should_run_; // True if this test should run
723 bool is_disabled_; // True if this test is disabled
722 bool should_run_; // True iff this test should run
723 bool is_disabled_; // True iff this test is disabled
724724 bool matches_filter_; // True if this test matches the
725725 // user-specified filter.
726726 internal::TestFactoryBase* const factory_; // The factory that creates
786786 // Gets the number of all tests in this test case.
787787 int total_test_count() const;
788788
789 // Returns true if the test case passed.
789 // Returns true iff the test case passed.
790790 bool Passed() const { return !Failed(); }
791791
792 // Returns true if the test case failed.
792 // Returns true iff the test case failed.
793793 bool Failed() const { return failed_test_count() > 0; }
794794
795795 // Returns the elapsed time, in milliseconds.
841841 // needed for catching exceptions thrown from TearDownTestCase().
842842 void RunTearDownTestCase() { (*tear_down_tc_)(); }
843843
844 // Returns true if test passed.
844 // Returns true iff test passed.
845845 static bool TestPassed(const TestInfo* test_info) {
846846 return test_info->should_run() && test_info->result()->Passed();
847847 }
848848
849 // Returns true if test failed.
849 // Returns true iff test failed.
850850 static bool TestFailed(const TestInfo* test_info) {
851851 return test_info->should_run() && test_info->result()->Failed();
852852 }
853853
854 // Returns true if test is disabled.
854 // Returns true iff test is disabled.
855855 static bool TestDisabled(const TestInfo* test_info) {
856856 return test_info->is_disabled_;
857857 }
883883 Test::SetUpTestCaseFunc set_up_tc_;
884884 // Pointer to the function that tears down the test case.
885885 Test::TearDownTestCaseFunc tear_down_tc_;
886 // True if any test in this test case should run.
886 // True iff any test in this test case should run.
887887 bool should_run_;
888888 // Elapsed time, in milliseconds.
889889 TimeInMillis elapsed_time_;
11541154 // Gets the elapsed time, in milliseconds.
11551155 TimeInMillis elapsed_time() const;
11561156
1157 // Returns true if the unit test passed (i.e. all test cases passed).
1157 // Returns true iff the unit test passed (i.e. all test cases passed).
11581158 bool Passed() const;
11591159
1160 // Returns true if the unit test failed (i.e. some test case failed
1160 // Returns true iff the unit test failed (i.e. some test case failed
11611161 // or something outside of all tests failed).
11621162 bool Failed() const;
11631163
13381338 BiggestInt actual);
13391339
13401340 // The helper class for {ASSERT|EXPECT}_EQ. The template argument
1341 // lhs_is_null_literal is true if the first argument to ASSERT_EQ()
1341 // lhs_is_null_literal is true iff the first argument to ASSERT_EQ()
13421342 // is a null pointer literal. The following default implementation is
13431343 // for lhs_is_null_literal being false.
13441344 template
20422042 __FILE__, __LINE__, ::testing::Message() << (message))
20432043
20442044 // Compile-time assertion for type equality.
2045 // StaticAssertTypeEq() compiles if type1 and type2 are
2045 // StaticAssertTypeEq() compiles iff type1 and type2 are
20462046 // the same type. The value it returns is not interesting.
20472047 //
20482048 // Instead of making StaticAssertTypeEq a class template, we make it a
255255 // This macro is used for implementing macros such as
256256 // EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED on systems where
257257 // death tests are not supported. Those macros must compile on such systems
258 // if EXPECT_DEATH and ASSERT_DEATH compile with the same parameters on
258 // iff EXPECT_DEATH and ASSERT_DEATH compile with the same parameters on
259259 // systems that support death tests. This allows one to write such a macro
260260 // on a system that does not support death tests and be sure that it will
261261 // compile on a death-test supporting system.
265265 // for program termination. This macro has to make sure this
266266 // statement is compiled but not executed, to ensure that
267267 // EXPECT_DEATH_IF_SUPPORTED compiles with a certain
268 // parameter if EXPECT_DEATH compiles with it.
268 // parameter iff EXPECT_DEATH compiles with it.
269269 // regex - A regex that a macro such as EXPECT_DEATH would use to test
270270 // the output of statement. This parameter has to be
271271 // compiled but not evaluated by this macro, to ensure that
110110 const FilePath& base_name,
111111 const char* extension);
112112
113 // Returns true if the path is NULL or "".
113 // Returns true iff the path is NULL or "".
114114 bool IsEmpty() const { return c_str() == NULL || *c_str() == '\0'; }
115115
116116 // If input name has a trailing separator character, removes it and returns
3636 #ifndef GTEST_SRC_GTEST_INTERNAL_INL_H_
3737 #define GTEST_SRC_GTEST_INTERNAL_INL_H_
3838
39 // GTEST_IMPLEMENTATION_ is defined to 1 if the current translation unit is
39 // GTEST_IMPLEMENTATION_ is defined to 1 iff the current translation unit is
4040 // part of Google Test's implementation; otherwise it's undefined.
4141 #if !GTEST_IMPLEMENTATION_
4242 // A user is trying to include this from his code - just say no.
9898 // A valid random seed must be in [1, kMaxRandomSeed].
9999 const int kMaxRandomSeed = 99999;
100100
101 // g_help_flag is true if the --help flag or an equivalent form is
101 // g_help_flag is true iff the --help flag or an equivalent form is
102102 // specified on the command line.
103103 GTEST_API_ extern bool g_help_flag;
104104
105105 // Returns the current time in milliseconds.
106106 GTEST_API_ TimeInMillis GetTimeInMillis();
107107
108 // Returns true if Google Test should use colors in the output.
108 // Returns true iff Google Test should use colors in the output.
109109 GTEST_API_ bool ShouldUseColor(bool stdout_is_tty);
110110
111111 // Formats the given time in milliseconds as seconds.
257257 GTEST_API_ Int32 Int32FromEnvOrDie(const char* env_var, Int32 default_val);
258258
259259 // Given the total number of shards, the shard index, and the test id,
260 // returns true if the test should be run on this shard. The test id is
260 // returns true iff the test should be run on this shard. The test id is
261261 // some arbitrary but unique non-negative integer assigned to each test
262262 // method. Assumes that 0 <= shard_index < total_shards.
263263 GTEST_API_ bool ShouldRunTestOnShard(
340340 explicit TestPropertyKeyIs(const char* key)
341341 : key_(key) {}
342342
343 // Returns true if the test name of test property matches on key_.
343 // Returns true iff the test name of test property matches on key_.
344344 bool operator()(const TestProperty& test_property) const {
345345 return String(test_property.key()).Compare(key_) == 0;
346346 }
373373
374374 // Functions for processing the gtest_filter flag.
375375
376 // Returns true if the wildcard pattern matches the string. The
376 // Returns true iff the wildcard pattern matches the string. The
377377 // first ':' or '\0' character in pattern marks the end of it.
378378 //
379379 // This recursive algorithm isn't very efficient, but is clear and
380380 // works well enough for matching test names, which are short.
381381 static bool PatternMatchesString(const char *pattern, const char *str);
382382
383 // Returns true if the user-specified filter matches the test case
383 // Returns true iff the user-specified filter matches the test case
384384 // name and the test name.
385385 static bool FilterMatchesTest(const String &test_case_name,
386386 const String &test_name);
549549 // Gets the elapsed time, in milliseconds.
550550 TimeInMillis elapsed_time() const { return elapsed_time_; }
551551
552 // Returns true if the unit test passed (i.e. all test cases passed).
552 // Returns true iff the unit test passed (i.e. all test cases passed).
553553 bool Passed() const { return !Failed(); }
554554
555 // Returns true if the unit test failed (i.e. some test case failed
555 // Returns true iff the unit test failed (i.e. some test case failed
556556 // or something outside of all tests failed).
557557 bool Failed() const {
558558 return failed_test_case_count() > 0 || ad_hoc_test_result()->Failed();
869869 // desired.
870870 OsStackTraceGetterInterface* os_stack_trace_getter_;
871871
872 // True if PostFlagParsingInit() has been called.
872 // True iff PostFlagParsingInit() has been called.
873873 bool post_flag_parse_init_performed_;
874874
875875 // The random number seed used at the beginning of the test run.
286286 // expected_value: "5"
287287 // actual_value: "6"
288288 //
289 // The ignoring_case parameter is true if the assertion is a
289 // The ignoring_case parameter is true iff the assertion is a
290290 // *_STRCASEEQ*. When it's true, the string " (ignoring case)" will
291291 // be inserted into the message.
292292 GTEST_API_ AssertionResult EqFailure(const char* expected_expression,
412412 // Returns the sign bit of this number.
413413 Bits sign_bit() const { return kSignBitMask & u_.bits_; }
414414
415 // Returns true if this is NAN (not a number).
415 // Returns true iff this is NAN (not a number).
416416 bool is_nan() const {
417417 // It's a NAN if the exponent bits are all ones and the fraction
418418 // bits are not entirely zeros.
419419 return (exponent_bits() == kExponentBitMask) && (fraction_bits() != 0);
420420 }
421421
422 // Returns true if this number is at most kMaxUlps ULP's away from
422 // Returns true iff this number is at most kMaxUlps ULP's away from
423423 // rhs. In particular, this function:
424424 //
425425 // - returns false if either number is (or both are) NAN.
783783 };
784784
785785 // Defining a variable of type CompileAssertTypesEqual will cause a
786 // compiler error if T1 and T2 are different types.
786 // compiler error iff T1 and T2 are different types.
787787 template
788788 struct CompileAssertTypesEqual;
789789
859859 GTEST_ADD_REFERENCE_(const GTEST_REMOVE_REFERENCE_(T))
860860
861861 // ImplicitlyConvertible::value is a compile-time bool
862 // constant that's true if type From can be implicitly converted to
862 // constant that's true iff type From can be implicitly converted to
863863 // type To.
864864 template
865865 class ImplicitlyConvertible {
912912 const bool ImplicitlyConvertible::value;
913913
914914 // IsAProtocolMessage::value is a compile-time bool constant that's
915 // true if T is type ProtocolMessage, proto2::Message, or a subclass
915 // true iff T is type ProtocolMessage, proto2::Message, or a subclass
916916 // of those.
917917 template
918918 struct IsAProtocolMessage
265265 # include
266266 #endif
267267
268 // Defines this to true if Google Test can use POSIX regular expressions.
268 // Defines this to true iff Google Test can use POSIX regular expressions.
269269 #ifndef GTEST_HAS_POSIX_RE
270270 # define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS)
271271 #endif
306306 # endif // _HAS_EXCEPTIONS
307307 # define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS
308308 # elif defined(__GNUC__) && __EXCEPTIONS
309 // gcc defines __EXCEPTIONS to 1 if exceptions are enabled.
309 // gcc defines __EXCEPTIONS to 1 iff exceptions are enabled.
310310 # define GTEST_HAS_EXCEPTIONS 1
311311 # elif defined(__SUNPRO_CC)
312312 // Sun Pro CC supports exceptions. However, there is no compile-time way of
314314 // they are enabled unless the user tells us otherwise.
315315 # define GTEST_HAS_EXCEPTIONS 1
316316 # elif defined(__IBMCPP__) && __EXCEPTIONS
317 // xlC defines __EXCEPTIONS to 1 if exceptions are enabled.
317 // xlC defines __EXCEPTIONS to 1 iff exceptions are enabled.
318318 # define GTEST_HAS_EXCEPTIONS 1
319319 # elif defined(__HP_aCC)
320320 // Exception handling is in effect by default in HP aCC compiler. It has to
373373
374374 # ifdef _MSC_VER
375375
376 # ifdef _CPPRTTI // MSVC defines this macro if RTTI is enabled.
376 # ifdef _CPPRTTI // MSVC defines this macro iff RTTI is enabled.
377377 # define GTEST_HAS_RTTI 1
378378 # else
379379 # define GTEST_HAS_RTTI 0
380380 # endif
381381
382 // Starting with version 4.3.2, gcc defines __GXX_RTTI if RTTI is enabled.
382 // Starting with version 4.3.2, gcc defines __GXX_RTTI iff RTTI is enabled.
383383 # elif defined(__GNUC__) && (GTEST_GCC_VER_ >= 40302)
384384
385385 # ifdef __GXX_RTTI
831831 // Returns the string representation of the regex.
832832 const char* pattern() const { return pattern_; }
833833
834 // FullMatch(str, re) returns true if regular expression re matches
834 // FullMatch(str, re) returns true iff regular expression re matches
835835 // the entire str.
836 // PartialMatch(str, re) returns true if regular expression re
836 // PartialMatch(str, re) returns true iff regular expression re
837837 // matches a substring of str (including str itself).
838838 //
839839 // TODO(wan@google.com): make FullMatch() and PartialMatch() work
11801180 // When non-NULL, used to block execution until the controller thread
11811181 // notifies.
11821182 Notification* const thread_can_start_;
1183 bool finished_; // true if we know that the thread function has finished.
1183 bool finished_; // true iff we know that the thread function has finished.
11841184 pthread_t thread_; // The native thread object.
11851185
11861186 GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam);
125125 static const char* Utf16ToAnsi(LPCWSTR utf16_str);
126126 #endif
127127
128 // Compares two C strings. Returns true if they have the same content.
128 // Compares two C strings. Returns true iff they have the same content.
129129 //
130130 // Unlike strcmp(), this function can handle NULL argument(s). A
131131 // NULL C string is considered different to any non-NULL C string,
142142 // the converted string in double quotes.
143143 static String ShowWideCStringQuoted(const wchar_t* wide_c_str);
144144
145 // Compares two wide C strings. Returns true if they have the same
145 // Compares two wide C strings. Returns true iff they have the same
146146 // content.
147147 //
148148 // Unlike wcscmp(), this function can handle NULL argument(s). A
150150 // including the empty string.
151151 static bool WideCStringEquals(const wchar_t* lhs, const wchar_t* rhs);
152152
153 // Compares two C strings, ignoring case. Returns true if they
153 // Compares two C strings, ignoring case. Returns true iff they
154154 // have the same content.
155155 //
156156 // Unlike strcasecmp(), this function can handle NULL argument(s).
159159 static bool CaseInsensitiveCStringEquals(const char* lhs,
160160 const char* rhs);
161161
162 // Compares two wide C strings, ignoring case. Returns true if they
162 // Compares two wide C strings, ignoring case. Returns true iff they
163163 // have the same content.
164164 //
165165 // Unlike wcscasecmp(), this function can handle NULL argument(s).
236236 operator ::string() const { return ::string(c_str(), length()); }
237237 #endif // GTEST_HAS_GLOBAL_STRING
238238
239 // Returns true if this is an empty string (i.e. "").
239 // Returns true iff this is an empty string (i.e. "").
240240 bool empty() const { return (c_str() != NULL) && (length() == 0); }
241241
242242 // Compares this with another String.
244244 // if this is greater than rhs.
245245 int Compare(const String& rhs) const;
246246
247 // Returns true if this String equals the given C string. A NULL
247 // Returns true iff this String equals the given C string. A NULL
248248 // string and a non-NULL string are considered not equal.
249249 bool operator==(const char* a_c_str) const { return Compare(a_c_str) == 0; }
250250
251 // Returns true if this String is less than the given String. A
251 // Returns true iff this String is less than the given String. A
252252 // NULL string is considered less than "".
253253 bool operator<(const String& rhs) const { return Compare(rhs) < 0; }
254254
255 // Returns true if this String doesn't equal the given C string. A NULL
255 // Returns true iff this String doesn't equal the given C string. A NULL
256256 // string and a non-NULL string are considered not equal.
257257 bool operator!=(const char* a_c_str) const { return !(*this == a_c_str); }
258258
259 // Returns true if this String ends with the given suffix. *Any*
259 // Returns true iff this String ends with the given suffix. *Any*
260260 // String is considered to end with a NULL or empty suffix.
261261 bool EndsWith(const char* suffix) const;
262262
263 // Returns true if this String ends with the given suffix, not considering
263 // Returns true iff this String ends with the given suffix, not considering
264264 // case. Any String is considered to end with a NULL or empty suffix.
265265 bool EndsWithCaseInsensitive(const char* suffix) const;
266266
134134 template class Get;
135135
136136 // A helper for implementing tuple_element. kIndexValid is true
137 // if k < the number of fields in tuple type T.
137 // iff k < the number of fields in tuple type T.
138138 template
139139 struct TupleElement;
140140
8989
9090 #if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
9191
92 // AssertyTypeEq::type is defined if T1 and T2 are the same
92 // AssertyTypeEq::type is defined iff T1 and T2 are the same
9393 // type. This can be used as a compile-time assertion to ensure that
9494 // two types are equal.
9595