Skip to content

Commit 4c36a96

Browse files
KMJ-007ZuseZ4
authored andcommitted
Add TypeTree insert FFI to C API for hierarchical type construction (#2439)
1 parent f290645 commit 4c36a96

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

enzyme/Enzyme/CApi.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,14 @@ void EnzymeTypeTreeShiftIndiciesEq(CTypeTreeRef CTT, const char *datalayout,
875875
*(TypeTree *)CTT =
876876
((TypeTree *)CTT)->ShiftIndices(DL, offset, maxSize, addOffset);
877877
}
878+
void EnzymeTypeTreeInsertEq(CTypeTreeRef CTT, const int64_t *indices,
879+
size_t len, CConcreteType ct, LLVMContextRef ctx) {
880+
std::vector<int> seq;
881+
for (size_t i = 0; i < len; i++) {
882+
seq.push_back(indices[i]);
883+
}
884+
((TypeTree *)CTT)->insert(seq, eunwrap(ct, *unwrap(ctx)));
885+
}
878886
const char *EnzymeTypeTreeToString(CTypeTreeRef src) {
879887
std::string tmp = ((TypeTree *)src)->str();
880888
char *cstr = new char[tmp.length() + 1];

enzyme/Enzyme/CApi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ void EnzymeTypeTreeData0Eq(CTypeTreeRef dst);
9696
void EnzymeTypeTreeShiftIndiciesEq(CTypeTreeRef dst, const char *datalayout,
9797
int64_t offset, int64_t maxSize,
9898
uint64_t addOffset);
99+
void EnzymeTypeTreeInsertEq(CTypeTreeRef dst, const int64_t *indices,
100+
size_t len, CConcreteType ct, LLVMContextRef ctx);
99101
const char *EnzymeTypeTreeToString(CTypeTreeRef src);
100102
void EnzymeTypeTreeToStringFree(const char *cstr);
101103

0 commit comments

Comments
 (0)