-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement ListInsert
in the LLVM Backend
#932
Conversation
@czgdp1807 int main() {
int a[] = {1, 3, 4, 0};
for (int i = 3; i > 1; i--) {
a[i] = a[i-1];
}
a[1] = 2;
for (int i = 0; i <=3; i ++) {
std::cout << a[i] << " ";
}
return 0;
} |
Can you please provide some explanation:
llvm::Value* arg_size = builder->CreateMul(llvm::ConstantInt::get(context, llvm::APInt(32, type_size)), src_capacity); Does this work as intended?
|
Well, it needs the following steps IMO,
That should be it. |
Yup, I had the same thought! |
It points to the index of the next incoming element. Say you have 4 elements in the list then its value will be 4 (0, 1, 2, 3 will be the indices of the already existing elements and 4 will be the index of the next incoming list).
If you are planning to use |
Thank you, I got it! |
Well doing the second step in #932 (comment) from tmp1 = l[pos]
for i in range(pos, n):
tmp2 = l[i + 1]
l[i + 1] = tmp1
tmp1 = tmp2 I tested the above approach but not so sure. You can see the code here and try it out for yourself before implementing the same logic in LPython (https://ideone.com/JSDhuh, -100 acts like a garbage value). |
b4b50f3
to
4a496a2
Compare
I have implemented it as mentioned, but I got stuck in handling the loop, Can you please review and help debug the issue here? The while loop goes to an infinite loop! |
4a496a2
to
2b18a01
Compare
2b18a01
to
19150c1
Compare
@czgdp1807, this PR is ready, Can you please review it? |
Will review tomorrow. |
Thank you very much for your guidance and review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine to merge.
We can create some nicer API to create loops in LLVM in some easier way.
Thank you! |
How do I implement API for loops, or if possible, |
You implement some nice C++ utility classes or functions, that make using loops/if statements in LLVM easier. Perhaps something with C++ lambda functions: I created a new issue #938 to discuss further. |
No description provided.