Update clang to r339409b.
Change-Id: Ied8a188bb072c40035320acedc86164b66d920af
diff --git a/linux-x64/clang/include/llvm/IR/PatternMatch.h b/linux-x64/clang/include/llvm/IR/PatternMatch.h
index af0616c..7c05834 100644
--- a/linux-x64/clang/include/llvm/IR/PatternMatch.h
+++ b/linux-x64/clang/include/llvm/IR/PatternMatch.h
@@ -666,6 +666,13 @@
return m_FSub(m_NegZeroFP(), X);
}
+/// Match 'fneg X' as 'fsub +-0.0, X'.
+template <typename RHS>
+inline BinaryOp_match<cstfp_pred_ty<is_any_zero_fp>, RHS, Instruction::FSub>
+m_FNegNSZ(const RHS &X) {
+ return m_FSub(m_AnyZeroFP(), X);
+}
+
template <typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, Instruction::Mul> m_Mul(const LHS &L,
const RHS &R) {
@@ -991,116 +998,111 @@
}
//===----------------------------------------------------------------------===//
-// Matchers for SelectInst classes
+// Matchers for instructions with a given opcode and number of operands.
//
-template <typename Cond_t, typename LHS_t, typename RHS_t>
-struct SelectClass_match {
- Cond_t C;
- LHS_t L;
- RHS_t R;
+/// Matches instructions with Opcode and three operands.
+template <typename T0, unsigned Opcode> struct OneOps_match {
+ T0 Op1;
- SelectClass_match(const Cond_t &Cond, const LHS_t &LHS, const RHS_t &RHS)
- : C(Cond), L(LHS), R(RHS) {}
+ OneOps_match(const T0 &Op1) : Op1(Op1) {}
template <typename OpTy> bool match(OpTy *V) {
- if (auto *I = dyn_cast<SelectInst>(V))
- return C.match(I->getOperand(0)) && L.match(I->getOperand(1)) &&
- R.match(I->getOperand(2));
+ if (V->getValueID() == Value::InstructionVal + Opcode) {
+ auto *I = cast<Instruction>(V);
+ return Op1.match(I->getOperand(0));
+ }
return false;
}
};
+/// Matches instructions with Opcode and three operands.
+template <typename T0, typename T1, unsigned Opcode> struct TwoOps_match {
+ T0 Op1;
+ T1 Op2;
+
+ TwoOps_match(const T0 &Op1, const T1 &Op2) : Op1(Op1), Op2(Op2) {}
+
+ template <typename OpTy> bool match(OpTy *V) {
+ if (V->getValueID() == Value::InstructionVal + Opcode) {
+ auto *I = cast<Instruction>(V);
+ return Op1.match(I->getOperand(0)) && Op2.match(I->getOperand(1));
+ }
+ return false;
+ }
+};
+
+/// Matches instructions with Opcode and three operands.
+template <typename T0, typename T1, typename T2, unsigned Opcode>
+struct ThreeOps_match {
+ T0 Op1;
+ T1 Op2;
+ T2 Op3;
+
+ ThreeOps_match(const T0 &Op1, const T1 &Op2, const T2 &Op3)
+ : Op1(Op1), Op2(Op2), Op3(Op3) {}
+
+ template <typename OpTy> bool match(OpTy *V) {
+ if (V->getValueID() == Value::InstructionVal + Opcode) {
+ auto *I = cast<Instruction>(V);
+ return Op1.match(I->getOperand(0)) && Op2.match(I->getOperand(1)) &&
+ Op3.match(I->getOperand(2));
+ }
+ return false;
+ }
+};
+
+/// Matches SelectInst.
template <typename Cond, typename LHS, typename RHS>
-inline SelectClass_match<Cond, LHS, RHS> m_Select(const Cond &C, const LHS &L,
- const RHS &R) {
- return SelectClass_match<Cond, LHS, RHS>(C, L, R);
+inline ThreeOps_match<Cond, LHS, RHS, Instruction::Select>
+m_Select(const Cond &C, const LHS &L, const RHS &R) {
+ return ThreeOps_match<Cond, LHS, RHS, Instruction::Select>(C, L, R);
}
/// This matches a select of two constants, e.g.:
/// m_SelectCst<-1, 0>(m_Value(V))
template <int64_t L, int64_t R, typename Cond>
-inline SelectClass_match<Cond, constantint_match<L>, constantint_match<R>>
+inline ThreeOps_match<Cond, constantint_match<L>, constantint_match<R>,
+ Instruction::Select>
m_SelectCst(const Cond &C) {
return m_Select(C, m_ConstantInt<L>(), m_ConstantInt<R>());
}
-//===----------------------------------------------------------------------===//
-// Matchers for InsertElementInst classes
-//
-
+/// Matches InsertElementInst.
template <typename Val_t, typename Elt_t, typename Idx_t>
-struct InsertElementClass_match {
- Val_t V;
- Elt_t E;
- Idx_t I;
-
- InsertElementClass_match(const Val_t &Val, const Elt_t &Elt, const Idx_t &Idx)
- : V(Val), E(Elt), I(Idx) {}
-
- template <typename OpTy> bool match(OpTy *VV) {
- if (auto *II = dyn_cast<InsertElementInst>(VV))
- return V.match(II->getOperand(0)) && E.match(II->getOperand(1)) &&
- I.match(II->getOperand(2));
- return false;
- }
-};
-
-template <typename Val_t, typename Elt_t, typename Idx_t>
-inline InsertElementClass_match<Val_t, Elt_t, Idx_t>
+inline ThreeOps_match<Val_t, Elt_t, Idx_t, Instruction::InsertElement>
m_InsertElement(const Val_t &Val, const Elt_t &Elt, const Idx_t &Idx) {
- return InsertElementClass_match<Val_t, Elt_t, Idx_t>(Val, Elt, Idx);
+ return ThreeOps_match<Val_t, Elt_t, Idx_t, Instruction::InsertElement>(
+ Val, Elt, Idx);
}
-//===----------------------------------------------------------------------===//
-// Matchers for ExtractElementInst classes
-//
-
-template <typename Val_t, typename Idx_t> struct ExtractElementClass_match {
- Val_t V;
- Idx_t I;
-
- ExtractElementClass_match(const Val_t &Val, const Idx_t &Idx)
- : V(Val), I(Idx) {}
-
- template <typename OpTy> bool match(OpTy *VV) {
- if (auto *II = dyn_cast<ExtractElementInst>(VV))
- return V.match(II->getOperand(0)) && I.match(II->getOperand(1));
- return false;
- }
-};
-
+/// Matches ExtractElementInst.
template <typename Val_t, typename Idx_t>
-inline ExtractElementClass_match<Val_t, Idx_t>
+inline TwoOps_match<Val_t, Idx_t, Instruction::ExtractElement>
m_ExtractElement(const Val_t &Val, const Idx_t &Idx) {
- return ExtractElementClass_match<Val_t, Idx_t>(Val, Idx);
+ return TwoOps_match<Val_t, Idx_t, Instruction::ExtractElement>(Val, Idx);
}
-//===----------------------------------------------------------------------===//
-// Matchers for ShuffleVectorInst classes
-//
-
+/// Matches ShuffleVectorInst.
template <typename V1_t, typename V2_t, typename Mask_t>
-struct ShuffleVectorClass_match {
- V1_t V1;
- V2_t V2;
- Mask_t M;
-
- ShuffleVectorClass_match(const V1_t &v1, const V2_t &v2, const Mask_t &m)
- : V1(v1), V2(v2), M(m) {}
-
- template <typename OpTy> bool match(OpTy *V) {
- if (auto *SI = dyn_cast<ShuffleVectorInst>(V))
- return V1.match(SI->getOperand(0)) && V2.match(SI->getOperand(1)) &&
- M.match(SI->getOperand(2));
- return false;
- }
-};
-
-template <typename V1_t, typename V2_t, typename Mask_t>
-inline ShuffleVectorClass_match<V1_t, V2_t, Mask_t>
+inline ThreeOps_match<V1_t, V2_t, Mask_t, Instruction::ShuffleVector>
m_ShuffleVector(const V1_t &v1, const V2_t &v2, const Mask_t &m) {
- return ShuffleVectorClass_match<V1_t, V2_t, Mask_t>(v1, v2, m);
+ return ThreeOps_match<V1_t, V2_t, Mask_t, Instruction::ShuffleVector>(v1, v2,
+ m);
+}
+
+/// Matches LoadInst.
+template <typename OpTy>
+inline OneOps_match<OpTy, Instruction::Load> m_Load(const OpTy &Op) {
+ return OneOps_match<OpTy, Instruction::Load>(Op);
+}
+
+/// Matches StoreInst.
+template <typename ValueOpTy, typename PointerOpTy>
+inline TwoOps_match<ValueOpTy, PointerOpTy, Instruction::Store>
+m_Store(const ValueOpTy &ValueOp, const PointerOpTy &PointerOp) {
+ return TwoOps_match<ValueOpTy, PointerOpTy, Instruction::Store>(ValueOp,
+ PointerOp);
}
//===----------------------------------------------------------------------===//
@@ -1181,54 +1183,6 @@
}
//===----------------------------------------------------------------------===//
-// Matcher for LoadInst classes
-//
-
-template <typename Op_t> struct LoadClass_match {
- Op_t Op;
-
- LoadClass_match(const Op_t &OpMatch) : Op(OpMatch) {}
-
- template <typename OpTy> bool match(OpTy *V) {
- if (auto *LI = dyn_cast<LoadInst>(V))
- return Op.match(LI->getPointerOperand());
- return false;
- }
-};
-
-/// Matches LoadInst.
-template <typename OpTy> inline LoadClass_match<OpTy> m_Load(const OpTy &Op) {
- return LoadClass_match<OpTy>(Op);
-}
-
-//===----------------------------------------------------------------------===//
-// Matcher for StoreInst classes
-//
-
-template <typename ValueOp_t, typename PointerOp_t> struct StoreClass_match {
- ValueOp_t ValueOp;
- PointerOp_t PointerOp;
-
- StoreClass_match(const ValueOp_t &ValueOpMatch,
- const PointerOp_t &PointerOpMatch) :
- ValueOp(ValueOpMatch), PointerOp(PointerOpMatch) {}
-
- template <typename OpTy> bool match(OpTy *V) {
- if (auto *LI = dyn_cast<StoreInst>(V))
- return ValueOp.match(LI->getValueOperand()) &&
- PointerOp.match(LI->getPointerOperand());
- return false;
- }
-};
-
-/// Matches StoreInst.
-template <typename ValueOpTy, typename PointerOpTy>
-inline StoreClass_match<ValueOpTy, PointerOpTy>
-m_Store(const ValueOpTy &ValueOp, const PointerOpTy &PointerOp) {
- return StoreClass_match<ValueOpTy, PointerOpTy>(ValueOp, PointerOp);
-}
-
-//===----------------------------------------------------------------------===//
// Matchers for control flow.
//