| 1 | //===- PredicateExpanderDag.h - Composable predicate dag lowering ---------===// |
| 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 | // Shared walker that lowers a composable predicate dag of the form |
| 10 | // |
| 11 | // (all_of / any_of / not <leaf> ...) |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef LLVM_UTILS_TABLEGEN_BASIC_PREDICATEEXPANDERDAG_H |
| 16 | #define LLVM_UTILS_TABLEGEN_BASIC_PREDICATEEXPANDERDAG_H |
| 17 | |
| 18 | #include "llvm/ADT/STLFunctionalExtras.h" |
| 19 | |
| 20 | namespace llvm { |
| 21 | |
| 22 | class Init; |
| 23 | class Record; |
| 24 | class raw_ostream; |
| 25 | |
| 26 | /// Walk a composable predicate dag rooted at \p Val and emit the combined |
| 27 | /// boolean expression to \p OS. |
| 28 | /// |
| 29 | /// The structural operators handled are the dags `(not X)` and `(all_of ...)` / |
| 30 | /// `(any_of ...)`. Any non-dag operand (and the base leaf) is delegated to \p |
| 31 | /// EmitLeaf, which emits the leaf test and returns true on error. |
| 32 | /// |
| 33 | /// If \p ParenIfBinOp is true, a surrounding pair of parentheses is emitted |
| 34 | /// when \p Val lowers to a binary (`&&` / `||`) expression. A `(not X)` always |
| 35 | /// parenthesizes its operand. |
| 36 | bool emitPredicateDag(const Record *Owner, const Init &Val, bool ParenIfBinOp, |
| 37 | raw_ostream &OS, |
| 38 | function_ref<bool(const Init &, raw_ostream &)> EmitLeaf); |
| 39 | |
| 40 | } // namespace llvm |
| 41 | |
| 42 | #endif // LLVM_UTILS_TABLEGEN_BASIC_PREDICATEEXPANDERDAG_H |
| 43 | |