mirror of
https://github.com/intel/llvm.git
synced 2026-02-08 00:50:03 +08:00
EDSC: support conditional branch instructions
Leverage the recently introduced support for multiple argument groups and multiple destination blocks in EDSC Expressions to implement conditional branches in EDSC. Conditional branches have two successors and three argument groups. The first group contains a single expression of i1 type that corresponds to the condition of the branch. The two following groups contain arguments of the two successors of the conditional branch instruction, in the same order as the successors. Expose this instruction to the C API and Python bindings. PiperOrigin-RevId: 235542768
This commit is contained in:
@@ -472,6 +472,24 @@ PYBIND11_MODULE(pybind, m) {
|
||||
return PythonStmt(::Branch(destination, makeCExprs(owning, operands)));
|
||||
},
|
||||
py::arg("destination"), py::arg("operands") = py::list());
|
||||
m.def("CondBranch",
|
||||
[](PythonExpr condition, PythonBlock trueDestination,
|
||||
const py::list &trueOperands, PythonBlock falseDestination,
|
||||
const py::list &falseOperands) {
|
||||
SmallVector<edsc_expr_t, 8> owningTrue;
|
||||
SmallVector<edsc_expr_t, 8> owningFalse;
|
||||
return PythonStmt(::CondBranch(
|
||||
condition, trueDestination, makeCExprs(owningTrue, trueOperands),
|
||||
falseDestination, makeCExprs(owningFalse, falseOperands)));
|
||||
});
|
||||
m.def("CondBranch", [](PythonExpr condition, PythonBlock trueDestination,
|
||||
PythonBlock falseDestination) {
|
||||
edsc_expr_list_t emptyList;
|
||||
emptyList.exprs = nullptr;
|
||||
emptyList.n = 0;
|
||||
return PythonStmt(::CondBranch(condition, trueDestination, emptyList,
|
||||
falseDestination, emptyList));
|
||||
});
|
||||
m.def("For", [](const py::list &ivs, const py::list &lbs, const py::list &ubs,
|
||||
const py::list &steps, const py::list &stmts) {
|
||||
SmallVector<edsc_expr_t, 8> owningIVs;
|
||||
|
||||
Reference in New Issue
Block a user