LLVM 23.0.0git
PatternMatch.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Out-of-line implementations for PatternMatch.h.
10//
11//===----------------------------------------------------------------------===//
12
16#include "llvm/IR/Constant.h"
17#include "llvm/IR/Constants.h"
18#include "llvm/IR/Value.h"
19
20using namespace llvm;
21
22bool llvm::PatternMatch::undef_match::checkAggregate(
23 const ConstantAggregate *CA) {
24 SmallPtrSet<const ConstantAggregate *, 8> Seen;
26
27 // Either UndefValue, PoisonValue, or an aggregate that only contains
28 // these is accepted by matcher.
29 // CheckValue returns false if CA cannot satisfy this constraint.
30 auto CheckValue = [&](const ConstantAggregate *CA) {
31 for (const Value *Op : CA->operand_values()) {
33 continue;
34
35 const auto *CA = dyn_cast<ConstantAggregate>(Op);
36 if (!CA)
37 return false;
38 if (Seen.insert(CA).second)
39 Worklist.emplace_back(CA);
40 }
41
42 return true;
43 };
44
45 if (!CheckValue(CA))
46 return false;
47
48 while (!Worklist.empty()) {
49 if (!CheckValue(Worklist.pop_back_val()))
50 return false;
51 }
52 return true;
53}
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
Base class for aggregate constants (with operands).
Definition Constants.h:551
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
reference emplace_back(ArgTypes &&... Args)
iterator_range< value_op_iterator > operand_values()
Definition User.h:291
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
FunctionAddr VTableAddr Value
Definition InstrProf.h:137
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
DWARFExpression::Operation Op