This video demonstrates the implementation of binary operations (binop) in a compiler, covering how to handle left and right operands, manage types, and generate appropriate instructions for different operation types including assignment operators. The speaker also discusses control flow implementation including basic blocks, branches, and loops, explaining how to map expressions to intermediate representation and handle various edge cases in compiler design.
深掘り
前提条件
- データがありません。
次のステップ
- データがありません。
深掘り
studying compilers every day until i land a compiler role (day 203)追加:
And we're live. Cool. Um, hello all.
Hello world. It's been it's been a really tiring day. It's been a really long day, but I am here. Um, this is day 203 of studying compilers every day until I land a compiler role. Um, last last stream we were going to finish all the experts and then we ran out of time to finish um, binary expert or binop expert, binary op, whatever whatever combination of words you want to throw at it. Um, but we did finish uh, what's it called? We finished Oh man, I'm I'm really cooked today. Uh, we finished Uniop. So that was good. Um, yeah, this time we will we will get binary op done and life will hopefully be good. So, yeah, let's let's just keep chugging along. I guess that's kind of that's kind of how business is for now.
Um, okay. I think we could yank some of this first.
Uh, instead of get value, get left.
Uh, and then we do left.
And then instead of left here, we do right.
And this will be interesting because we actually have to um we got to implement some new behavior. So that will be that will be fun. Uh, what's up, James?
Um, I think we kind of got to do these like buffers again, which is really funny.
Um, yeah, that's that's really funny, actually.
Uh, what's up, Isra?
I see I see I'm not the only one that's fried today.
Um, okay. So, we have binary op Uh yeah, we can do this, I guess.
Uh let's see. What else do we want to do in here?
Yeah, I mean it it happens all good.
Uh let's see where where is the pile? Or I guess we actually don't handle a lot of stuff interesting here. Uh, what's up, Panda? Good to see you.
Um, okay. So, we want binary op and we have a lot of different things here now. So, we got to we got to handle things a little bit more interestingly here.
So, yeah, I mean, you're you're here. That's that's all that matters.
Um, oh wait, we can't actually do it like this anymore. Um, so right necessarily is a use, but left we got to we got to be careful with.
Um, yeah.
So, let's we could do a another switch block on this, but I don't know. It gets it gets really ugly really quickly. Uh, what type is this? This is value star. So we also want we also want a buffer for this. So left and then that or left is also putter.
Um yeah, janky code. It happens. I'm I'm about to write some really scuffed code as well, so it will be fine. Um how'd you get your domain name for the GitHub page? Yeah. Um I bought it off pork button.
So, oh man, this is bright compared to my room. It actually just lights up my screen. That's so funny.
Um, yeah, you can you can search up domains.
Uh, yeah, we love Pokemon.
Yeah, I am just like full blind.
Yeah. Um, some of these are a lot cheaper than others. Um, AI is always really expensive for some reason. Mom exists. There's some really interesting ones that exist, but yeah, I bought it off here and then I um I think I registered it with Cloudflare. I don't remember exactly what I did, but this is where I bought it at least.
Um, okay.
Let's see. We want to We want to yank this in some capacity.
Let's yank that.
Uh, okay. So, let's just norm We can do that.
Okay, so now we can work off of this.
Yeah, I actually just got Yuru flashed.
Um well, I didn't get Yuru flashed cuz nobody plays Yuru anymore, but man, I'm now I'm sad.
That that really sucks.
Um okay, anyways, all jokes aside, let's see.
Um, these are all simple and then assignment makes a mess. I believe that's kind of that's kind of how we're that's kind of how we're handling this.
I think um yeah, so these are all straightforward enough.
So then these we can kind of just uh we can kind of copy the code from above pretty much.
Um, actually we don't need this like literal buffer anymore, which is really funny.
So, we want to make unique of um uh Oh, we need to make a we need to make a No, we don't need to make anything yet.
Uh, we got to store something eventually, but we'll worry about that in a bit.
Um, oh, we got to get right as or we got to get left.
Yes. So, we got to do this.
I guess we have to do this anyways, right? So, it's just a question of if we use prep expert, I think, right?
Yeah, we got to do this, I think.
Wait actually. Yeah. How do we want to do that?
So we the thing is we need to handle the case where it's an address operator I believe.
Yeah. Yeah, I don't remember what my plan was for this, but we'll figure that out in a second. I'm fairly sure use prep expert. Okay, so we can do that.
Okay, so we can instruction binary op.
So give it what does this take again?
Okay, well that doesn't help me at all.
Um, actually, did it help me?
Uh, wow, that actually did not help me.
That's pretty funny.
Okay, so let's look here.
Yeah.
Or is it was it actually just the topmost? It was actually the topmost.
God damn it. Okay, so we have type up left and right.
Um, so we have type uh actually we could yank type from like uh how do we get type up here again?
Or I guess we just like assigned it differently.
We'll worry. We should probably worry about this right now. Let's Let's try something different.
Let's Let's just do this first.
So, we have E get OP.
So we want uh to MIR and we give it the OP and then left and then right like that.
And then we need to handle some other stuff in a second.
Uh a little late. Yeah. I mean I I keep pushing the stream back. I'm just it's just been a really tiring day. So, it is it is what it is.
Uh do you ever use Jupyter Notebook? Um not really actually. I've never really like Jupiter. It's just been like I don't know. It It feels clunky to use.
It feels really silly to just permanently store state in a notebook.
So, I don't really like that. Um yeah, I don't know. It's just and also like I don't really write a lot of Python nowadays anyway. So it's like I don't the one advantage it has I don't really take advantage of I guess.
Um if I were to like take notes digitally in some organized format I'd probably just use markdown. Um either markdown like on its own or like Markdown is like a part of Obsidian.
Yeah, it's all it's all stylistic at the end of the day. You can do C++. I see.
Wait, can you actually Yeah, it's like kind of awkward, but like even still, it's like when am I like writing code in my notes, right? I guess more fundamentally, the big problem is like I don't really like take notes of a lot of stuff. So like when I do take notes, it's just plain English.
And if I'm just using markdown exclusively markdown, then it's like what's the point of using Jupiter, right?
Yeah. I don't know. That's it's all it's all preference at the end of the day.
But my preference is not aligned with Jupiter for better or for worse.
Um, let's see. What do we change here?
Wait, why did I cast this like that?
Unop is a Oh, I see. Okay.
Um, did you look at the QBE compiler? I did not, unfortunately.
Yeah, I got I got code the right unfortunately right now.
Okay, we can do that.
Um, yeah. Okay, so that's good.
We want to do this and then we want to yink the type.
Actually, this is this is very awkward.
Can we just do left get type?
Uh oh, we can't do that.
Um okay let's do expert types at e get leftft I believe h yeah how are we doing type let's just let's just yank the type from left seems wrong.
Uh, so we want expert types at that.
Yeah, we can do this, I guess. This is so ugly. I really don't like how this looks, but this is fine. We'll we'll worry about this in a second.
What's wrong with this clone, I think. Or do you just want to get I think I think we should just do that.
Oh, what's up, Panchchu?
Um, how the hell did I do type here? We just did it by hand. Okay, great. Um but here we needed to do something interesting.
Um why why are we see right? So we wanted to get we wanted to get the base. We can we don't really need to worry about that. We don't need to worry about that at all here.
um to MIR.
That's what we wanted.
Uh I'm getting pinged somewhere.
Okay.
Uh, let's not be on that one so I don't leak esports stuff. Uh, college is about to start in a few weeks and my course is CSSE before starting CSSE. Um, you're you're new to school, right? I'm I'm assuming that's why you're asking.
Uh, but if you're not, like if you're not, please correct me cuz I imagine the feedback will look very different.
Uh, is this correct?
Yes. Okay, that's what we want. Then we have type.
Oh man, this is this is getting really unwieldy actually. Holy hell.
Yeah. So, I guess we need the children first.
I'm new. Okay, cool. Um, advice-wise, I think the big thing is just like the big thing is just to like pay attention. Um, it's really easy to like get sidetracked. And like whenever I go to classes, I am also like kind of guilty of this, but like a solid like 30% of the class is just doing whatever.
whether it's like like scrolling your phone or like playing like Plants vs. Zombies on their laptop for some reason or just like texting people instead of paying attention. Um I do think it actually is helpful to like like you know like all your like study skills so I won't like prescribe anything on that.
But I will say that like it is very easy to get distracted because with like how large class sizes are, professors genuinely just do not have time to like care. Um, and the upshot of that is um you'll it's very easy to like erode your own learning just by like being careless. So I think it's pretty important to at least like um make an active effort to stay focused whether that's like taking handwritten notes for a bit or like um making sure like you have Discord closed on your laptop for instance just like anything you can do to just like more actively pay attention. Um there's a lot of like intro classes I really wished that like um yeah I really wish I guess I really wish I paid more attention like if I in our like 111 class or like our first intro sequence class we learned about like lambda functions and I was like I don't I don't care about this so I just didn't pay attention and then it turns out I ended up getting into something that's kind of programming languages related and all of a sudden I really need to know about lambdas. Um you might like it everything might seem insignificant at first but like it's just nice to know stuff so pay attention. Um yeah all of this is just to say pay attention pretty much but be very deliberate with it.
Um yes also it is true that you you'll very frequently be left to your own devices in terms of like studying. Um, yeah, that's that's kind of just inevitable and you'll you'll get through it, though. I believe you will.
Okay. Um, let's see. Let's let's continue.
So, this is all good.
Um, what does our two MIR look like for for this case?
What's our two MR for assignment?
Actually, I I think we unreachable that, right? Is that what we did?
Yeah. Okay. We just we just I think we just unreachable assignment. Yeah. Okay.
So, this might this might cause some problems. Um Okay. So, how do we want to do this?
Uh, if you're confused about anything, don't wait to ask for help. Yes. Um, remember that your professors are getting well, they're getting paid to be here at least. Um, whether um whether they enjoy talking to students or not is a completely different question, but like they are obligated to like help you if you ask for help. Um, hopefully your professor like enjoys teaching, but if if your professor doesn't, then like it's it's still all good. Like you can still probably ask for help as long as you like show an active effort to learn.
It's really hard to like it's really hard to like turn down a student that struggling at least.
Um, yeah, like the even just like anecdotally like Um, the way I got to where I am now, a lot of it stems from the fact that I just like cold reached out to my compiler's professor after taking the class and I was like, "Yo, I want to do research."
And he was like, "Bet, let's let's schedule a meeting." Um, it is like really scary to cold reach out because like I mean like duh, but um, it will it will be fine.
Want to start a startup, but it'll interrupt my academics. Uh, not necessarily. It's about It's all about just like how much time you want to put into it, right? So, um, okay, let's see. What do we want to do here?
Yeah, time management. I imagine you probably already know why that's important and what you need to do for that.
Um, wait. How did I do plus equals actually?
Oh, we need to generate a different store. I see. Okay, that's that's what I needed to do.
Uh, where you from? I'm from the US. I guess that doesn't really say a lot, but yeah.
Um, oh man. Let's see. How do we want to do this? This is This is rough.
Yeah. So, we want to reuse an allocate.
So, we want to use this, I believe.
Right. Um, or we have a help. We had the helper there, but we want to yank the body without making a load pretty much.
Where did this go? Where'd I put it? Did I blind?
Uh.
Ah, here we are.
Um, let's see how how the hell do we even do this from India? Nice.
How How do I do this? Actually, this is very awkward.
I guess we can just take the expert, right? That's just that is the value or the putter.
Yeah. Okay. This necessarily is something assignable. Either like a pointer or like a stack variable.
I guess we do need to load it anyway, huh?
Best of luck. Nice to talk to you. Thank you. And uh best of luck to you as well.
Um, college has definitely been like the highlight of my life. So, um, hopefully you will have as good experience as mine, if not better.
Um, okay. So, we want to generate the load without the allocate, I guess.
Um, actually, let's let's actually just make a helper that lets us like clean this up a little bit.
Um yeah. So under our operator pile, let's do this is all fine and all. Let's do or not even there. Just like here bool is assignment.
Yeah. So, this will let us avoid a little bit of this mess.
Um, yeah.
So, let's let's yank that.
I think this kind of just goes at the top, actually.
Okay. Um, yeah, this is going to look really funny. So, we're gonna We're going to yank all of that.
Oh, I deleted the yink. Okay. Okay.
Let's inflict that instead.
Um, we're just going to do a little bit of this. These are not assignment.
Return true or false actually.
Or actually, let's invert it.
Um, default. All right. Yeah, let's default.
Jesus.
Okay. Um, the reason I'm putting unreachable here is because the llinter gets mad. So, yeah, that's Yeah, that's that's a little bit rough.
Okay. Um, all right, we have that now.
Add is assignment.
Cool.
So, let's go back down here.
Yeah. So, this lets us actually skip this giant switch block.
So, we do that.
Yeah. So then we can we don't even need these buffers anymore actually because this is just an if statement which is really nice.
Um or we still need some of these buffers because we reuse value or we re reuse computation.
Oh my god. Wait, I forgot we can just like make pointers for things. Actually, we can make autoputters.
Oh, I got to wait. Now I got to I got to look over my code again. Well, god damn it. Let's Let's see.
Um, I guess C++ auto putter or auto star explicitly forces it. Okay.
I should probably do this more.
I don't know. That's fine. We'll worry about that at some other time. And by some other time, I mean I'm adding it to this stack.
What the hell? I should I should do it now.
Star putter.
Yeah. Okay. Let's Let's do a quick pass over everything actually. Oh, what's up, Jac?
What type is this?
That's an iterator.
This doesn't work right. Okay. Yeah.
Um, what does replace file name do anyway?
It makes it Wait. Oh, I see.
What am I doing here?
What is current file?
Oh, I see. We don't we don't care.
That's fine.
Okay, we don't need to worry about that one.
I don't think we need to worry about it in these for the most part.
Okay, this necessarily is a copy.
So, that's good. That's also good.
Yeah. Okay. This is I mean this is fine I guess.
Yeah. I mean I can't fault any of this.
This all looks fine.
Okay. This is all very boring actually.
Okay, that's a unique pointer. Okay, I guess none of this should change.
Wait. Okay, that's a move. So that's fine. That's also move.
That's fine.
Let's actually work the other way instead.
Yeah. Okay, this is all good. I'm fairly sure. Pop expert is a unique pointer.
These are all unique pointers cuz we're making things Um, okay, cool. So, the parser is fine.
Why am I doing this? This is like such a waste of time.
Yeah. So, like we mark refs properly at least.
Ah, here we are. This actually matters.
Okay. Okay. And then we went back to the beginning. Okay.
Yeah, that's something I want to get in the habit of doing. So, I guess it's probably better to do it than not, I guess.
Okay. And this is the file we're working on right now.
Um, yeah. So, like here for instance, this should be a putter.
A putter.
What is that? That is just a type which is an enum.
Yeah. Okay. We can do that.
All right. We can't do that.
What is this? Actually, this is an iterator. So that's fine.
Okay, that's also a vector.
Yeah, I want to I want to get in the habit of doing this at least.
pram. Okay, that's fine. That's fine.
This should be a star.
Um, that's good. That's good.
Yeah. Okay.
That's also good. That's also good.
That's good. That's good.
Okay. Do that.
Oh, wait. I'm I'm tripping.
Okay. And we run back. Okay. So, this is all good now.
Um, okay. So, add puddters.
Nice.
Okay. Now that we've wasted like we've wasted like 5 minutes, uh, let's get back to actually implementing this thing.
Um, okay. So, this time we're just skipping the giant switch block, which is very nice.
Um, and then the rest of this I think we just got to we got to figure this out.
Um, yeah. Okay. So, we want left putter in some capacity.
Uh, we can delete the rest of this.
We don't need this.
Um, new to your channel. Could you please tell me how you started learning from scratch? Um, if you're talking about compilers specifically, I took a class from uh the school I go to and then I've been doing like academic research. Um, and then I've been like supplementing that with a couple books here and there. It's nothing like particularly like laid out or anything.
I've just kind of been like slowly building up a mass of knowledge at least. Um, that's probably not the answer you wanted to hear, but I think that's the least inaccurate way to go about it.
Did I delete too much here? Oh, wow.
Okay. Yeah, we deleted way too much.
Okay. Um, let's see.
So, that's a value. That's good.
Um, yeah. Yeah. So, we want to load from this at least, I think. Yeah, we don't have a load. So, this is fine.
Uh, let's yank the load from up here, I believe, that we made before.
Yes, we can do that.
Yeah. So, we're going to do prev expert here.
Um, why did I need this again? Oh, cuz that's the value. Duh. Okay.
So, this is I guess left now.
Okay.
So then or I guess actually if e get op if that's binary op specifically just assign then we want to do something different or if it's not assign actually maybe right actually yeah how do we want to do this so if it's just assignment then we just store the value in there otherwise we need to like do an op I guess that's how we want to frame this I think um let's just figure out what we would need to do for a sign anyways So we have private exper which is I guess we should probably make that a putter.
Yeah we h yeah actually no this makes sense. Um, test equals.
Yeah, we're going to need to we're going to need to fudge with the terminology a little bit. So, we want prev expert.
Yeah. So, we can do this again, I think.
Or may as well just do dust just for correctness.
Okay. So then we load from that and then we do left and right and then um oh we need to we need to track types still. Uh but that's fine. We'll worry about that in a second.
I guess we can kind of just keep that college, bro. Yeah, that's that's a very succinct way to very succinct way to go about it.
Um, I need to read something.
Need to throw a tomato at someone.
anyways.
Oh, let's test. It's Yeah, it has been a second. Hopefully, we've been doing all right.
Let's see.
Yeah, this is this is very ugly.
I guess this type will always be that. I guess maybe we'll figure that out later.
Yeah, that Let's just dduplicate a little bit. Um, yeah, this this type thing is like really annoying.
We might we might want a helper or we might just want we might just want to like make macros for this. I can't believe I'm saying it, but it would make things cleaner.
Um, okay. So, we make a load. So, this performs the computation.
Yeah, we don't need these buffers anymore for the most part, right?
H wait no wait no we need to handle these differently now um so what if we do that let's just generate the code and then if we can dduplicate it then like that would be great but if not then like that's fine as well and we'll we'll worry about that in a second um Okay.
Do we even care about this? Okay. So, we need to do that and then we need to generate a store.
I guess here we It's like really awkward because we don't necessarily generate a store.
I know. What am I saying? We always generate just let's let's just keep that. That's headache.
We'll see what we use. We'll see what we don't use.
Um okay. So we have that and then the difference is if we make a new pointer I believe.
Yeah. Okay. So we can handle that separately though which is fine.
We could even else if this even I think um yeah because assignment we literally just we take unobs and we just store the we just generate a store. It's very boring.
Um yeah so we could just else if this Oh man, I can't type.
Yeah. So, we can do that.
Yeah. So, we can do that.
I guess we don't even need dust, right?
Yeah, we can we can figure this out in a second.
Um, yeah. So we want to load from that and here we need to generate a computation I guess.
Yeah. Okay. We don't actually Yeah, we don't need binop anymore.
Yeah. As in we can auto that now at least.
Um but we still need res at least. So that's the resulting computation.
Uh then we can handle assign differently later on because that will just be very boring.
Unless we could we could just else here even Okay. Then we have op assign standard assign or standard binary op.
Okay. Uh what you working on today? I'm finishing the stuff that I didn't get to finish last time cuz I ran out of time last time.
So that's kind of that's kind of how it is. Uh what's up bling? Good to see you.
Um yeah, dark stream cuz well it's night time.
Um okay so this will be very boring.
Binopz is just uh it's just right.
Yeah. Okay.
So that's fine. Um okay. So now we need to generate the store which shouldn't be that bad.
Um yeah, let's let's just yank all that.
Um so if this is e get op equals binary op assign if it's an assign then we just do prev expert which we haven't overwritten yet. Otherwise we just make an allocate and that's the result of this and then we do that which is fine.
Okay. And then store instead of this it's binary opres and we push that back.
And then the type of this expression is I guess the type of the left that we've done. Yeah, I guess that's how we're inferring the type.
Yeah. Okay.
So that should be all the expressions at least.
Um Okay. So this is binop rewrite I guess. Okay.
Oh man. All right. Now we just got the rest of the stuff to do.
Yeah, we have time. Let's Let's throw some more stuff at it. I want today I wanted today to be like a little bit short cuz I'm just really tired. But slash it's been a long day. But you know, we we keep going.
Um yeah, how do we do this?
Yeah. Okay. Um, expert is fine.
Declaration is fine.
Or not quite fine actually.
We got to we got to do some mapping.
So we want first of all we want scope bindings.
So we want to what does this map again?
This is very important.
So we want the back. So we want the current scope.
Um, so we want at i get variable and then get value.
So we want that and then I think we assigned it to the alloc I think.
Yes. So, we want the value because it's it could be a putter the way that we've written it.
Wait.
Oh, yeah. It could actually. Yeah. Okay.
Um, god damn it.
Could it be a putter? I don't think it can actually. These are necessarily variable bindings, so it has to be an allocator the way that I've implemented it.
Okay, we can do that, I guess.
Is there anything I missed here?
No. Okay. Uh, did your instructor have to use a certain book? No, we just worked off the slides pretty much. Um, the slides were very, very rich. Um, they were more than enough for the homework.
Okay, so we make the binding and we also need to make the type, I guess, right?
Yeah. What what other things do we need to track here?
We have scope bindings. We need to track the type.
So types.
Oh, we need to we need to make the thing.
What type is this vector of unordered map?
What's wrong with this?
Oh, wait. There's no S there. Okay, this is very silly.
Yeah. So, we just we just make a stack.
We'll optimize this in a bit. And by a bit, I mean in a year, probably.
Um, we we won't worry about that too much, you know.
Um.
Huh?
Why did we need this again?
Ah, right. Because we might need to get the type, but it's like the other the awful type.
Get type get orget.
Wait, what?
Oh, that is already puddter. Nice.
Okay, so that works.
My room smells like like blueberry bagels for some reason. I did buy some today, but I don't know.
That's a little odd.
Um, okay. So, we do all that. What else do we need to keep track of?
Scope, we don't need to worry about.
We've done those two. Prev expert, we don't care about expert types, we don't care about function types, we don't care about, I think. Yeah, not in here. And function calls, we don't care about here. Okay, so I think that's all the state we need to map.
Um, yeah. Okay, this all looks good.
Uh the return we don't care about, I think.
Yeah, we don't we don't care about this.
Um and then we where do we get variable again?
Oh yeah, we have get use. Okay. Yeah, that's the thing.
Um, okay. So, we have to I think we have to map this somewhere. I don't think we have the infrastructure to map this yet.
So, let's let's set that up real quick.
Um, I don't know how I want to do this.
Uh, set branch up for connecting basic blocks.
Oh man, I don't even remember what I did for this the first time around. Um, the store looks fine though, so we can keep that.
Yeah, this is really annoying.
We'll worry about that at some point.
Um, yeah. And then I think, what did I mean by map branch again? I genuinely do not remember this.
Um, this is the fun of doing these rewrites.
What am I mapping?
We'll worry about that later. I think I think this is one and the same though.
Yeah.
Yeah. Let's do it that way actually.
Um Maybe we also need to close the basic block.
Yeah, we're going to need to figure that out. Actually, we we literally do this here. What am I saying? Um yeah, this this is fine.
Yeah. Okay, we'll we'll worry about that later.
Yeah, this should probably go there, I guess, then. Okay. Um, and now all we have left is just control flow, which I really don't want to do right now, but I mean, we didn't we don't quit things because we don't want to do them. So, we will we will chug along. Let's let's get this done.
Um, okay.
Listen, if so, maybe we should make like a start basic block and end basic block helper. I think that might make things easier.
Um, yeah, that that might be smart.
Um maybe every time we close a basic block we can do like resolution.
Yeah, that's that's like n squ.
That that would not be very smart. Okay.
Um I know we definitely figure out like what the shape looks like up here. So we can kind of yank that in a way. I'm fairly sure.
Yeah. Um, we definitely want that, I think.
So, that's probably a good start.
So, we want a true block, a false block, and a or continuation slash continue block.
Um, okay. So ah that's annoying.
I guess let's yank the con stuff first.
So we can do that. Autocon star equals get or use prep expert.
Okay, so that generates the condition and then we need to generate the branch.
That's not going to be fun.
Um con branch.
So that takes what? Cond null putter. Null putter. Right.
Okay.
Yeah. So on that um let's see when associate the branch with uh let's see true and false basic blocks.
Okay. So now we want to handle the true block.
The true block will always exist. So we don't need to worry about it a lot.
Um well we can just do this actually.
Yeah. So then true block goes here.
Um, we should close the basic block.
Ah, yeah. Okay. So, Oh, man.
So, we want that Instead of that, I guess condur.
Yeah. So, we do that. We push that.
Oh, I understand what I was saying now.
Um to do uh associate or associate the basic block.
Yeah.
or I guess tag or I guess like or add basic block to mapping I guess more verbosely.
Yes, we can do that.
Uh yeah, maybe we should make like a close block, open block helper, I guess. Start block, end block.
That would be helpful.
Uh this lives here.
Yeah.
See, get type. We have all that stuff.
Make params.
Um, void start basic block and then end basic block.
Is that how I set it up in this thing?
Oh, I see.
What do I need start a basic block for?
Oh, wait. We actually did need it for something.
Oh, to close the last block. Was this what this was?
What? What was I doing? I don't know.
That's That's very annoying.
Yeah, I think we do actually need to like copy this structure a little bit.
Yeah, we could we could just do that.
This should be more clean to read.
Um then this we actually need the unique pointer I think.
Yeah, we can do that, I guess.
Do we even need to do we even need start basic block? That feels a little bit ridiculous.
Yeah, we can do that. I guess make basic block that also goes up with like we'll figure out how to organize this eventually.
But that actually is an extreme problem.
I think right now I just want all this to get done. So, um I guess we could figure out make pram.
That shouldn't be that bad actually.
Yeah, but that will that will happen later.
Okay. Anyways, so we can do this.
Yeah. So, we can kind of we can kind of yink that. I think that goes in here.
Okay. And then, yeah, that looks reasonable to me.
So, we just clear the buffer, I guess.
Um, all of that just to say make basic block branch or stood move branch.
Okay.
Um, yeah. So then we can do this as well.
Okay. So now we need to handle the true block.
So uh yeah, how do we do this? We should look here.
So we just get the body, I guess.
Um, oh yeah, we need to handle this differently because we're making blocks.
So, true branch and then false branch.
Okay. So then here we just want I get T branch and then we revisit that and then let's see.
Yeah. And then we want to make a basic block.
once again. Or we kind of want to kind of want to do this.
Uh actually yeah. So we can do that.
So T to [ __ ] I guess.
Um, yeah, this is going to be really annoying to map actually now that I think about it.
Okay, let's let's just deal with the false branch real quick. This should be very straightforward as well.
Uh instead of con, this is actually just terminator branch.
Yeah, so we can do that.
10 billion operator overloads for visit.
Yes, we love we actually hate the visitor pattern, but we hate uh we hate object-oriented programming more. So we will we will visit until the day until the sun goes down.
Yeah. Okay.
Um yeah. Okay. And then the way we map this is we just do the next block. I think we want to map it to the next block.
I believe I guess can't block.
And we also want to do this as well.
Okay. And then we can just move on here.
I believe that's kind of I think that's what's happening here.
Um so false or can't basic block.
We could also just like generate an empty.
That might be interesting, but this is probably fine.
Okay. And now we get to we get to do wall loop which I don't remember what I did for that. Seems pretty straightforward though. So I mean surely it'll be fine.
Um so we need to yank this as well and just do that.
uh body. Let's go on the body block. And we want the I guess latch block, I guess, or cont.
Okay. Um let's make the let's make the body So, you can kind of just do this as well, I think.
Yeah. Let's We don't need the comment actually.
Yeah. So, we can get the body.
Yeah. So, we can do that.
Yeah. So, we can do that.
So, that jumps up to the cond.
Oh, wait. We need a new block actually.
Yeah, this this matters here.
Um Uh what do we even call this?
Trav to cond I guess.
So we just have a branch np putter.
Yeah. So then we give it.
Yeah, this all makes sense now. So we can close that up. And then here we have the new block. We check the condition and then we load.
Um, let's see what else do we do.
So, we do this.
Uh, this should be cond basic block.
Okay. And then from here, the rest is just the next block pretty much.
Yeah, I think this should be correct.
Um, yeah. So, the only things left is like figuring out how we want to link these basic blocks up and then generating like parameters, which is like fine.
Um, yeah, actually, we could do this map thing real quick.
That should be pretty easy.
Uh, we have a we have a map made for it already, I think. Yeah, we have function types, which should not be bad.
And then resolve functions should not be that bad as well.
Yeah. So, we can just loop through function types and that should be f that should let us resolve functions pretty easily.
Let's actually do that real quick. So, function types at Oh man. Uh, we probably need to do this.
Oh, actually no. We have the get name get value.
So that we can assign to what type are we using? Looks like we're using the original type. What the wait.
Oh yeah, we had a reason for that. Okay.
Um, f get type.
Yeah, we can do that.
Yes, that's fine.
Uh, we could even put this here.
Yeah. And then we can do this here as well. That's fine.
Um, and that allows for recursion when we handle a body, I guess.
Yeah. Okay. So, now we can just do this real quick. This should be pretty easy.
Um, also this needs to be a putter, I think. or no.
Oh, never mind. We don't need to worry.
Okay, so we have ID and uh type H. Actually, do we need this?
Oh, wait. We forgot to actually map the damn functions. Whoops.
Uh yeah.
Uh let's see. And then where did we Oh, we just put it in resz.
Oh, yeah. Okay, that makes sense.
I'm not sure why we don't just make a I'm not sure why we don't just make one giant buffer for it, but that's fine.
Um, yeah, I guess I guess there is a reason behind the madness. So surely this is fine.
Uh instead of that that should just be function function star.
It's ID function in functions.
Um, yeah, maybe we should just like keep a ve a buffer of functions instead.
Uh, but we need this mapping anyway, so it's like fine, actually.
Yeah, it doesn't change a thing.
Okay, let's map this real quick as well at actually function ids. Let's let's name it that instead.
There we go.
So at f get name get value.
Um oh we need to worry about like overloading.
That's really annoying.
Yeah, I just thought I just thought about that. That's really annoying.
So we can do that and then that will be fine.
Okay.
Function ids.
So then otherwise we have uh auto star call in function calls at id call. We want to set ki to fun.
Yeah, that's a very silly function. But I mean, I guess we need it, so that's probably fair.
Um, yeah. Okay. So, that was that was easy enough.
So, all we need to do now is figure out basic block edges.
And we only have 19 to-dos in this file.
including please bleach this.
That's great.
Okay. Well, I'll save the rest of this for next time, though. I'm I'm tired.
Today's Today's been a really long day.
Um, what did we add here again?
Okay, so we added finish instructions map functions.
Okay.
Yeah, I think I think that's good enough for today. Um, thank you all so much for showing up today. Um, if you haven't already, like the stream, sub to the channel. Um, it really does help out a lot with the algorithm. Um, while you're down there, check out the Discord. Join it. It's the best place to get pinged when I go live and stay connected with everyone else in the community. Um, what else? Uh, GitHub in the description, LinkedIn in the description, GitHub sponsors in the description. Um, and yeah, I think I think that's about it. Um, yeah. Um, take care y'all. Take it easy.
Um, I'm going to go get food now. Um, I will see you all tomorrow hopefully.
関連おすすめ
Re: 🗣️📍theprophedu📍2026 GST 103 CLASS (E-EXAM REVISION)
theprophedu
636 views•2026-06-04
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanation💯✅
LearnwithSahera
1K views•2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 views•2026-05-29
Search Algorithms Explained in 60 Seconds! 🤖💨
samarthtuliofficial
218 views•2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 views•2026-05-30
Instagram accounts got PWNed
EricParker
13K views•2026-06-03
Introduction to Problem Solving Part - 1 | Lecture 1 | Intermediate DSA
ascensionix
107 views•2026-05-29
So What's Odin Lang Even Good For
TechOverTea
131 views•2026-06-01











