Skip to content

Commit ca6aafa

Browse files
committed
basic use analysis
1 parent 2134f4d commit ca6aafa

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

enzyme/tools/enzyme-tblgen/enzyme-tblgen.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,9 +1166,27 @@ void handleUse(
11661166
bool usesShadow = Def->getValueAsBit("usesShadow");
11671167
bool usesCustom = Def->getValueAsBit("usesCustom");
11681168

1169-
// We don't handle any custom primal/shadow
1170-
(void)usesCustom;
1171-
assert(!usesCustom);
1169+
// This only concerns instances of StaticSelect for now
1170+
if (usesCustom) {
1171+
auto numArgs = resultTree->getNumArgs();
1172+
1173+
for (int i = numArgs == 3; i < numArgs; ++i) {
1174+
std::string foundPrimalUse2 = "";
1175+
std::string foundShadowUse2 = "";
1176+
1177+
bool foundDiffRet2 = false;
1178+
1179+
auto name = resultTree->getArgNameStr(i);
1180+
auto arg = resultTree->getArg(i);
1181+
auto arg2 = dyn_cast<DagInit>(arg);
1182+
handleUse(root, arg2, name.size() ? foundPrimalUse2 : foundPrimalUse,
1183+
name.size() ? foundShadowUse2 : foundShadowUse,
1184+
name.size() ? foundDiffRet2 : foundDiffRet,
1185+
usesPrimal ? precondition : "", tree, varNameToCondition);
1186+
}
1187+
1188+
return;
1189+
}
11721190

11731191
for (auto argEn : llvm::enumerate(resultTree->getArgs())) {
11741192
auto name = resultTree->getArgNameStr(argEn.index());

0 commit comments

Comments
 (0)