# Where \`add\_int\` is defined

**URL:** https://discourse.julialang.org/t/where-add-int-is-defined/67278
**Category:** Internals & Design
**Created:** [August 29, 2021, 10:16am UTC](https://discourse.julialang.org/t/where-add-int-is-defined/67278 "2021-08-29T10:16:24Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Tomas\_Pevny](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomas_pevny/32/25466_2.png) [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)
#### Post date: [August 29, 2021, 10:16am UTC](https://discourse.julialang.org/t/where-add-int-is-defined/67278/1 "2021-08-29T10:16:25Z")

</div>

I am curious how some basic operations are mapped to llvm instructions. I am looking on an addition of two integers, but I cannot find the source of julia, where `add_int` is defined. I have located in `boot.jl` that `mul_int` is imported from `.Intrinsics`, but I cannot find, where module `Intrinsics` is located. Can someone point me to this or explain to me, what I do not uderstand?

Thanks in advance.

Best wishes,  
Tomas

---

<div class="post-metadata">

### Author: ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)
#### Post date: [August 29, 2021, 10:27am UTC](https://discourse.julialang.org/t/where-add-int-is-defined/67278/2 "2021-08-29T10:27:20Z")

</div>

[https://github.com/JuliaLang/julia/blob/master/src/intrinsics.cpp](https://github.com/JuliaLang/julia/blob/master/src/intrinsics.cpp)

The macros used in that .cpp file can be found in `intrinsics.h`, which defines the enum in question.

---

<div class="post-metadata">

### Author: ![Tomas\_Pevny](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomas_pevny/32/25466_2.png) [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)
#### Post date: [August 29, 2021, 10:31am UTC](https://discourse.julialang.org/t/where-add-int-is-defined/67278/3 "2021-08-29T10:31:28Z")

</div>

Thanks a lot, I was afraid of this (in a good sense). My knowledge of C++ is from late 90s.

---

<div class="post-metadata">

### Author: ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)
#### Post date: [August 29, 2021, 10:40am UTC](https://discourse.julialang.org/t/where-add-int-is-defined/67278/4 "2021-08-29T10:40:23Z")

</div>

May I ask, what do you need the intrinsic for? How did you arrive at this question?

---

<div class="post-metadata">

### Author: ![Tomas\_Pevny](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomas_pevny/32/25466_2.png) [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)
#### Post date: [August 29, 2021, 11:31am UTC](https://discourse.julialang.org/t/where-add-int-is-defined/67278/5 "2021-08-29T11:31:53Z")

</div>

It was really a pure curiosity.  
We are introducing a Julia course and I like to know as many details as possible.

---

<div class="post-metadata">

### Author: ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)
#### Post date: [August 29, 2021, 11:43am UTC](https://discourse.julialang.org/t/where-add-int-is-defined/67278/6 "2021-08-29T11:43:00Z")

</div>

Ah, gotcha 😃 Be aware that the existence of `intrinsics.cpp` is really just an implementation detail of the compiler - it shouldn’t concern julia semantics and syntax at all.

---

<div class="post-metadata">

### Author: ![Tomas\_Pevny](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomas_pevny/32/25466_2.png) [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)
#### Post date: [August 29, 2021, 12:02pm UTC](https://discourse.julialang.org/t/where-add-int-is-defined/67278/7 "2021-08-29T12:02:27Z")

</div>

My intuition (after your answer) is that `intrinsics.cpp` defines julia function / structures that are  
mapped to specific llvm calls. Many thanks for clarification.

---

<div class="post-metadata">

### Author: ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)
#### Post date: [August 29, 2021, 12:11pm UTC](https://discourse.julialang.org/t/where-add-int-is-defined/67278/8 "2021-08-29T12:11:04Z")

</div>

Welllll… that’s the stuff the compiler itself needs, as I understand it. Since the julia compiler is not (fully) bootstrapped, a limited amount is done like this in C++. There’s other packages talking directly to LLVM, e.g. LoopVectorization has as few things it uses `llvmcall` for.

---

<div class="post-metadata">

### Author: ![Tomas\_Pevny](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomas_pevny/32/25466_2.png) [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)
#### Post date: [August 29, 2021, 2:09pm UTC](https://discourse.julialang.org/t/where-add-int-is-defined/67278/9 "2021-08-29T14:09:07Z")

</div>

That makes a lot of sense. I have thought that Julia is bootstrapped similarly as LoopVectorization, as I have peeking at some point to LoopVectorization as well and I have thought this is the way to do it. Bootstrapping of complers always seems to me like a chicken and egg problem.

Again, big thanks for swift answers.

Tomas

---

<div class="post-metadata">

### Author: ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)
#### Post date: [August 29, 2021, 2:24pm UTC](https://discourse.julialang.org/t/where-add-int-is-defined/67278/10 "2021-08-29T14:24:05Z")

</div>

LoopVectorization has the advantage of already running in a context that handles the LLVM infrastructure setup, namely julia. You’re right in that fully bootstrapping is a chicken and egg problem!

There’s also some bits in this JuliaCon talk by jeff from 2 years ago about where julia has this sort of distinction between “the compiler needs it” and “well how do we make it available in the regular language?”. It’s sort of related to the bootstrapping part, but orthogonal to the LLVM specific bits.

[![](https://global.discourse-cdn.com/julialang/original/3X/1/d/1d5c5567a3f6004a6c9852f4fb8e89eb97fe67be.jpeg "JuliaCon 2019 | What's Bad About Julia | Jeff Bezanson") ](https://www.youtube.com/watch?v=TPuJsgyu87U)

---

<div class="post-metadata">

### Author: ![Tomas\_Pevny](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomas_pevny/32/25466_2.png) [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)
#### Post date: [August 29, 2021, 4:52pm UTC](https://discourse.julialang.org/t/where-add-int-is-defined/67278/11 "2021-08-29T16:52:48Z")

</div>

I remember that talk and Jeff talking he does not like `Core` part of the language, but I did not know he is talking about this case. This talk was one of my favorite from Juliacon 2019.
