<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Compiler &#8211; Xojo Programming Blog</title>
	<atom:link href="https://blog.xojo.com/tag/compiler/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.xojo.com</link>
	<description>Blog about the Xojo programming language and IDE</description>
	<lastBuildDate>Wed, 19 Jun 2019 17:51:05 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Compilers 109 &#8211; Linking and Wrap-up</title>
		<link>https://blog.xojo.com/2018/04/02/compilers-109-linking-and-wrap-up/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Mon, 02 Apr 2018 09:00:47 +0000</pubDate>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Compiler]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=3679</guid>

					<description><![CDATA[This is the ninth and final post in our Compiler series. The linker is not technically part of the compiler. It is the last step to combine all the various bits and pieces of machine code created by the compiler along with the necessary information to create a runnable app for the OS.]]></description>
										<content:encoded><![CDATA[<p>The linker is not technically part of the compiler, but it is needed to make a completed app. The purpose of the linker is to combine (link) all the various bits and pieces of machine code created by the compiler along with the necessary information to create a runnable app for the OS.</p>
<p>This is the ninth and final post in our Compiler series. Previous posts:</p>
<ul>
<li><a href="https://blog.xojo.com/2017/12/04/llvm-everywhere/">LLVM Everywhere</a></li>
<li><a href="https://blog.xojo.com/2017/12/06/compilers-101-overview-and-lexer/">Compilers 101 &#8211; Overview and Lexer</a></li>
<li><a href="https://blog.xojo.com/2017/12/08/compilers-102-parser/">Compilers 102 &#8211; Parser</a></li>
<li><a href="https://blog.xojo.com/2018/01/22/compilers-103-semantic-analyzer/">Compilers 103 &#8211; Semantic Analyzer</a></li>
<li><a href="https://blog.xojo.com/2018/01/24/compilers-104-ir-generation/">Compilers 104 &#8211; IR Generation</a></li>
<li><a href="https://blog.xojo.com/2018/01/29/compilers-105-back-end-overview/">Compilers 105 &#8211; Back End Overview</a></li>
<li><a href="https://blog.xojo.com/2018/01/31/compilers-106-optimizer/">Compilers 106 &#8211; Optimizer</a></li>
<li><a href="https://blog.xojo.com/2018/03/19/compilers-107-optimizer-loop-unrolling/">Compilers 107 &#8211; Optimizer Loop Unrolling</a></li>
<li><a href="https://blog.xojo.com/2018/03/26/compilers-108-code-generation/">Compilers 108 &#8211; Code Generation</a></li>
</ul>
<p><span id="more-3679"></span></p>
<p>Each OS has a way to define an executable file so that it can run it. This typically involves some sort of header and a format that describes how the various machine code binary components are all combined. This is called an executable type, executable format or object file format.</p>
<p>This is what Xojo uses as the executable format when building 64-bit x86 and ARM apps using LLVM:</p>
<ul>
<li>For Linux, Xojo uses <a href="https://en.wikipedia.org/wiki/Executable_and_Linkable_Format">ELF</a> (Executable and Linkable Format). This is a common standard used by many Unix-like systems.</li>
<li>For macOS and iOS, Xojo uses <a href="https://en.wikipedia.org/wiki/Mach-O">Mach-O</a>. This is the format that was introduced for Cocoa apps and dates all the way back to the NeXT days.</li>
<li>For Windows, Xojo uses the <a href="https://en.wikipedia.org/wiki/Portable_Executable">PE</a> (Portable Executable) format.</li>
</ul>
<p>The <a href="https://en.wikipedia.org/wiki/Linker_(computing)">Linker</a> is responsible for combining all the machine code generated by the compiler for your project, adding libraries and generating the appropriate executable format. When the linker has finished, you have a native app that works on the operating system.</p>
<p>For 64-bit x86 and ARM apps using LLVM, Xojo uses the <a href="https://en.wikipedia.org/wiki/LLVM#Linker">lld linker</a>.</p>
<h2>Wrap-Up</h2>
<p>I hope you found the Compiler Series helpful. And when you need to easily create your own cross-platform and multi-platform apps for Windows, macOS, Linux, Raspberry Pi, iOS or the web be sure to <a href="http://www.xojo.com/download">use Xojo</a>!</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Compilers 108 &#8211; Code Generation</title>
		<link>https://blog.xojo.com/2018/03/26/compilers-108-code-generation/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Mon, 26 Mar 2018 09:00:21 +0000</pubDate>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[Machine Code]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=3676</guid>

					<description><![CDATA[This is the eighth post in our Compiler series. Code generation is one of the last steps of the compiler. This is where the compiler emits actual machine code for the IR that was previously created.]]></description>
										<content:encoded><![CDATA[<p>Code generation is one of the last steps of the compiler. This is where the compiler emits actual machine code for the IR that was previously created.</p>
<p>This is the eighth post in our Compiler series. Other posts:</p>
<ul>
<li><a href="https://blog.xojo.com/2017/12/04/llvm-everywhere/">LLVM Everywhere</a></li>
<li><a href="https://blog.xojo.com/2017/12/06/compilers-101-overview-and-lexer/">Compilers 101 &#8211; Overview and Lexer</a></li>
<li><a href="https://blog.xojo.com/2017/12/08/compilers-102-parser/">Compilers 102 &#8211; Parser</a></li>
<li><a href="https://blog.xojo.com/2018/01/22/compilers-103-semantic-analyzer/">Compilers 103 &#8211; Semantic Analyzer</a></li>
<li><a href="https://blog.xojo.com/2018/01/24/compilers-104-ir-generation/">Compilers 104 &#8211; IR Generation</a></li>
<li><a href="https://blog.xojo.com/2018/01/29/compilers-105-back-end-overview/">Compilers 105 &#8211; Back End Overview</a></li>
<li><a href="https://blog.xojo.com/2018/01/31/compilers-106-optimizer/">Compilers 106 &#8211; Optimizer</a></li>
<li><a href="https://blog.xojo.com/2018/03/19/compilers-107-optimizer-loop-unrolling/">Compilers 107 &#8211; Optimizer Loop Unrolling</a></li>
</ul>
<p><span id="more-3676"></span></p>
<p>This is the simple code we started with in the <a href="https://blog.xojo.com/2017/12/06/compilers-101-overview-and-lexer/">Compilers 101 blog post</a>:</p>
<pre>sum = 3.14 + 2 * 4 // calculation</pre>
<p>It results in a constant value of 11. After the IR is generated and optimized, it can boil down to just a single line of <a href="https://en.wikipedia.org/wiki/Machine_code">machine code</a>, which will vary by processor and architecture. Machine code is just binary and not readable, so below is what the <a href="https://en.wikipedia.org/wiki/Assembly_language">Assembly code</a> might look like.</p>
<p>This is the Assembly code for 32-bit ARM:</p>
<pre>movs r0, #11</pre>
<p>This is the Assembly code for ARM64:</p>
<pre>movz w0, #11</pre>
<p>x86 and x86-64 use this Assembly code:</p>
<pre>movl $11, %eax</pre>
<p>Obviously this is the tricky part of making a multi-platform compiler since Assembly code is different between processors and architectures.</p>
<p>Once you have machine code that the computer can run, the last step is to link all the pieces together so that you have an app that the OS can run. This is done by the <a href="https://blog.xojo.com/2018/04/02/compilers-109-linking-and-wrap-up/">Linker</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Compilers 107 &#8211; Optimizer Loop Unrolling</title>
		<link>https://blog.xojo.com/2018/03/19/compilers-107-optimizer-loop-unrolling/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Mon, 19 Mar 2018 09:00:45 +0000</pubDate>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Compiler]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=3670</guid>

					<description><![CDATA[This is the seventh post in our Compiler series. The last post covered optimization in general. In this post you'll look at a specific optimization called "loop unrolling".]]></description>
										<content:encoded><![CDATA[<p>The last post covered optimization in general. In this post you&#8217;ll look at a specific optimization called &#8220;loop unrolling&#8221;.</p>
<p>This is the seventh post in our Compiler series. Other posts:</p>
<ul>
<li><a href="https://blog.xojo.com/2017/12/04/llvm-everywhere/">LLVM Everywhere</a></li>
<li><a href="https://blog.xojo.com/2017/12/06/compilers-101-overview-and-lexer/">Compilers 101 &#8211; Overview and Lexer</a></li>
<li><a href="https://blog.xojo.com/2017/12/08/compilers-102-parser/">Compilers 102 &#8211; Parser</a></li>
<li><a href="https://blog.xojo.com/2018/01/22/compilers-103-semantic-analyzer/">Compilers 103 &#8211; Semantic Analyzer</a></li>
<li><a href="https://blog.xojo.com/2018/01/24/compilers-104-ir-generation/">Compilers 104 &#8211; IR Generation</a></li>
<li><a href="https://blog.xojo.com/2018/01/29/compilers-105-back-end-overview/">Compilers 105 &#8211; Back End Overview</a></li>
<li><a href="https://blog.xojo.com/2018/01/31/compilers-106-optimizer/">Compilers 106 &#8211; Optimizer</a></li>
</ul>
<p><span id="more-3670"></span></p>
<h2>Loop Unrolling</h2>
<p>Loops are a key optimization point. Unrolling a loop means that you repeat the code content of the loop multiple times. It is essentially exactly what you are taught not to do when writing code.</p>
<p>Loop unrolling avoids costly branches. This will not necessarily unroll the entire loop so that you get code repeated 100s of times, but it may unroll it a bit so the code repeats a few times.</p>
<p>Modern hardware hates branches because it makes other optimization more difficult, so unrolling a loop enables additional optimizations for both the compiler itself and the CPU.</p>
<p>Here is a simple loop:</p>
<pre>Dim i As Integer = 0
While i &lt; 2
  i = i + 1
Wend
Beep</pre>
<p>This gets modeled as a <a href="https://en.wikipedia.org/wiki/Control_flow_graph">control flow graph</a>:</p>
<p><img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-4071" src="https://blog.xojo.com/wp-content/uploads/2018/03/2018-03-15_09-24-11.png" alt="" width="241" height="333" /></p>
<p>A control flow graph is a <a href="https://en.wikipedia.org/wiki/Directed_graph">directed graph</a>.</p>
<p>Looking at the above, the while gets converted to an if. After the integer assignment, there is a branch back to the if. If the condition is false, then it branches to the beep. This is essentially a <a href="https://en.wikipedia.org/wiki/Goto">Goto</a>, for old-timers.</p>
<p>But the compiler may also insert stuff on your behalf. For example, Xojo adds Yield function calls to enable cooperative threading and these function calls cannot be removed by the optimization process.</p>
<p><img decoding="async" class="alignnone size-full wp-image-4072" src="https://blog.xojo.com/wp-content/uploads/2018/03/2018-03-15_09-29-59.png" alt="" width="265" height="394" /></p>
<p>So to unroll the loop, the idea is that there are only two iterations of the loop which the compiler is able to determine.</p>
<p>So unrolling results in this:</p>
<p><img decoding="async" class="alignnone size-full wp-image-4074" src="https://blog.xojo.com/wp-content/uploads/2018/03/2018-03-15_09-32-16.png" alt="" width="177" height="296" /></p>
<p>In this short and simple example, the value of the “i” variable is never used so it can be discarded, saving both iteration time and storage space.</p>
<p>With optimization complete, the compiler moves on to <a href="https://blog.xojo.com/2018/03/26/compilers-108-code-generation/">Code Generation</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Compilers 106 &#8211; Optimizer</title>
		<link>https://blog.xojo.com/2018/01/31/compilers-106-optimizer/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Wed, 31 Jan 2018 07:10:16 +0000</pubDate>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[LLVM]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=3653</guid>

					<description><![CDATA[An optimizer “improves” the IR, but that can mean a lot of different things. Improve could mean “run faster” or “use less memory”. Or perhaps&#8230;]]></description>
										<content:encoded><![CDATA[<p>An optimizer “improves” the IR, but that can mean a lot of different things. Improve could mean “run faster” or “use less memory”. Or perhaps you want to optimize for memory access time because CPUs are so fast it is sometimes more efficient to repeatedly calculate something rather than calculate it once, store it and access it later.</p>
<p>This is the sixth post in our Compiler series. Previous posts:</p>
<ul>
<li><a href="https://blog.xojo.com/2017/12/04/llvm-everywhere/">LLVM Everywhere</a></li>
<li><a href="https://blog.xojo.com/2017/12/06/compilers-101-overview-and-lexer/">Compilers 101 &#8211; Overview and Lexer</a></li>
<li><a href="https://blog.xojo.com/2017/12/08/compilers-102-parser/">Compilers 102 &#8211; Parser</a></li>
<li><a href="https://blog.xojo.com/2018/01/22/compilers-103-semantic-analyzer/">Compilers 103 &#8211; Semantic Analyzer</a></li>
<li><a href="https://blog.xojo.com/2018/01/24/compilers-104-ir-generation/">Compilers 104 &#8211; IR Generation</a></li>
<li><a href="https://blog.xojo.com/2018/01/29/compilers-105-back-end-overview/">Compilers 105 &#8211; Back End Overview</a></li>
</ul>
<p><span id="more-3653"></span></p>
<p>The Optimizer does a series of transformations to the IR code, typically in multiple passes. LLVM provides full control over these passes.</p>
<p>Not all LLVM optimizations provide benefits to Xojo code. We have distilled the many complicated optimization settings that are available with LLVM into three options that are useful for Xojo code, which you can set from the Shared Build settings: Default, Moderate and Aggressive.</p>
<p>The Default optimization does minimal optimization in order to have the quickest compile times.</p>
<p>The Moderate setting does more optimizations, primarily to reduce the time needed for mathematical calculations which results in slightly slower compile times.</p>
<p>The Aggressive setting does many more mathematical optimizations to further reduce calculation time, but also dramatically increases compile time.</p>
<p>Optimization intends to create something that is equivalent to the original code. The end result is the same, even if the means to do so might be very different. For example, the optimizer may determine that it should do a bit shift to do integer math as a single operation rather than a series of add operations. This could result in smaller, faster code but may take longer for the optimizer to process the code in order to make this determination.</p>
<p>Deciding the “best” optimization for any code is not technically a solvable problem (<a href="https://en.wikipedia.org/wiki/NP-hardness">np-hard</a>), so optimizers use a combination of “heuristics and hand-waving”. “Hand-waving” means the compiler thinks this is correct, but has no real way to prove it. And heuristics simply means that optimizations that have been known to work in prior code are used when similar code is found.</p>
<h2>Constant Folding</h2>
<p>Constant Folding is a simple example of an optimization that can be done.</p>
<p>This essentially mans the optimizer evaluates constant expressions up front to reduce execution time, and save stack and register space.</p>
<p>For example:</p>
<pre>a = 1 + 2</pre>
<p>can be replaced with:</p>
<pre>a = 3</pre>
<p>Not everything will be quite so obvious in your code, of course.</p>
<h2>Optimization Issues</h2>
<p>There are certain types of code that can make the optimizer’s job more difficult. These special Xojo features can challenge an optimizer:</p>
<ul>
<li>Exception Handling: Makes things difficult because you cannot tell where a function call may return.</li>
<li>Memory Management: Xojo has deterministic object destruction when variable goes out of scope, which forces the optimizer to have to track things more closely.</li>
<li>Introspection: The use of Introspection requires lots of metadata to remain available so it can be referenced at run-time.</li>
<li>Threading: Cooperative thread yielding affects loops and other things.</li>
<li>Xojo is a “safe” language and many of the things it does to ensure your app does not crash (and instead raise exceptions) such as Nil object checks, stack overflow checks, bounds checks, etc. all restrict what the optimizer can do.</li>
<li>Plugins: Since these are pre-compiled, they are ignored by the optimizer.</li>
</ul>
<p>Continue to learn about a specific optimization: <a href="https://blog.xojo.com/2018/03/19/compilers-107-optimizer-loop-unrolling/">Loop Unrolling</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Compilers 105 &#8211; Back End Overview</title>
		<link>https://blog.xojo.com/2018/01/29/compilers-105-back-end-overview/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Mon, 29 Jan 2018 07:10:02 +0000</pubDate>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[64-bit]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[LLVM]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=3650</guid>

					<description><![CDATA[The fifth post in our ongoing Compiler series. Once the front end has done its work its time for the back end components to take over.]]></description>
										<content:encoded><![CDATA[<p>Once the front end has done its work its time for the back end components to take over.</p>
<p>This is the fifth in our compiler series and the first on the back end. We covered the parts of the compiler that are called the front end in these posts:</p>
<ul>
<li><a href="https://blog.xojo.com/2017/12/04/llvm-everywhere/">LLVM Everywhere</a></li>
<li><a href="https://blog.xojo.com/2017/12/06/compilers-101-overview-and-lexer/">Compilers 101 &#8211; Overview and Lexer</a></li>
<li><a href="https://blog.xojo.com/2017/12/08/compilers-102-parser/">Compilers 102 &#8211; Parser</a></li>
<li><a href="https://blog.xojo.com/2018/01/22/compilers-103-semantic-analyzer/">Compilers 103 &#8211; Semantic Analyzer</a></li>
<li><a href="https://blog.xojo.com/2018/01/24/compilers-104-ir-generation/">Compilers 104 &#8211; IR Generation</a></li>
</ul>
<p><span id="more-3650"></span></p>
<h2>Back End</h2>
<p>The components of the back end take the IR that was generated by the last step of the front end and emit executable code, which is machine language in the case of Xojo.</p>
<p>To recap a bit from the LLVM post, for 32-bit x86 apps, Xojo uses its own in-house, proprietary compiler first created in 2004/2005. This powerful and fast compiler handles the front end and back end, but it does have a couple limitations: it can only target 32-bit x86 and it does not do any optimizations.</p>
<p>Today when you build an iOS app, a 64-bit app for Windows, MacOS or Linux, or an ARM app for Raspberry Pi you are using LLVM as the back end to generate your native, binary code.</p>
<p>The rest of these posts will cover the back end as it pertains to LLVM. Specifically, the components are:</p>
<ul>
<li><a href="https://blog.xojo.com/2018/01/31/compilers-106-optimizer/">Optimizer</a>, <a href="https://blog.xojo.com/2018/03/19/compilers-107-optimizer-loop-unrolling/">Loop Unrolling</a></li>
<li><a href="https://blog.xojo.com/2018/03/26/compilers-108-code-generation/">Code Generation</a></li>
<li><a href="https://blog.xojo.com/2018/04/02/compilers-109-linking-and-wrap-up/">Linker</a></li>
</ul>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Compilers 104 &#8211; IR Generation</title>
		<link>https://blog.xojo.com/2018/01/24/compilers-104-ir-generation/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Wed, 24 Jan 2018 07:10:44 +0000</pubDate>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[IR]]></category>
		<category><![CDATA[LLVM]]></category>
		<guid isPermaLink="false">http://blog.xojo.com/?p=2833</guid>

					<description><![CDATA[This is the fourth post in our Compiler series. Now that the Semantic Analyzer has verified that the code is actually correct and created syntax trees, it's time to talk about IR generation.]]></description>
										<content:encoded><![CDATA[<p>Now that the Semantic Analyzer has verified that the code is actually correct and created syntax trees, it&#8217;s time to talk about IR generation.</p>
<p>This is the fourth post in our Compiler series. Other posts:</p>
<ul>
<li><a href="https://blog.xojo.com/2017/12/04/llvm-everywhere/">LLVM Everywhere</a></li>
<li><a href="https://blog.xojo.com/2017/12/06/compilers-101-overview-and-lexer/">Compilers 101 &#8211; Overview and Lexer</a></li>
<li><a href="https://blog.xojo.com/2017/12/08/compilers-102-parser/">Compilers 102 &#8211; Parser</a></li>
<li><a href="https://blog.xojo.com/2018/01/22/compilers-103-semantic-analyzer/">Compilers 103 &#8211; Semantic Analyzer</a></li>
</ul>
<p><span id="more-2833"></span></p>
<h2>What is IR?</h2>
<p>After the Semantic Analyzer, the next step is to turn the trees that it validated and added type information to into a representation that is much closer to what the machine is actually going to generate. This representation is called an intermediate representation (IR). The Xojo compiler, when building for 64-bit or ARM, uses <a href="https://llvm.org/docs/LangRef.html">LLVM IR</a>.</p>
<p>The resulting LLVM IR describes the actual control flow of the program and every single thing that will be in the final program. In addition to the user-visible code that gets executed and the implicit conversions that are now in the trees, it also needs to contain all of the hidden, behind the scenes calls like reference counting and introspection metadata.</p>
<p>LLVM IR is actually higher level and more abstract than the actual assembly that it’ll end up generating. For example, unlike assembly language, it’s entirely strongly typed and the Xojo compiler has to be very precise in what it generates (which is a good thing!).</p>
<h2>IR Code Generation</h2>
<p>To get started, here is the abstract syntax tree that was previously created by the Semantic Analyzer:</p>
<p>￼<img loading="lazy" decoding="async" class="alignnone wp-image-2831" src="https://blog.xojo.com/wp-content/uploads/2017/05/2017-05-19_09-02-03.png" alt="" width="600" height="292" /></p>
<p>To generate IR, the compiler walks through the above tree, <a href="https://en.wikipedia.org/wiki/Depth-first_search">depth first</a>, to get to the leaf nodes. Doing this gets us to the BinaryOperator* for the multiple on the lower right side of the tree.</p>
<p>The LLVM IR to multiply those two values (<a href="https://llvm.org/docs/LangRef.html#mul-instruction">mul</a>) looks like this:</p>
<pre>%1 = <a href="https://llvm.org/docs/LangRef.html#mul-instruction">mul</a> i32 2, 4</pre>
<p>Now it works backwards through the tree. So the next item is the implicit cast, which has to cast the value that was calculated in the previous command:</p>
<pre>%2 = <a href="https://llvm.org/docs/LangRef.html#sitofp-to-instruction">sitofp</a> i32 %1 to double</pre>
<p>The <a href="https://llvm.org/docs/LangRef.html#sitofp-to-instruction">sitofp</a> IR command means &#8220;Signed Integer to Floating Point&#8221;.</p>
<p>Continuing up the tree, the binary operator is next, so it can now grab the left hand-side value to apply to the right-hand side value. This is the IR to add the values:</p>
<pre>%3 = <a href="https://llvm.org/docs/LangRef.html#fadd-instruction">fadd</a> double 3.14, %2</pre>
<p>The <a href="https://llvm.org/docs/LangRef.html#fadd-instruction">fadd</a> IR command means &#8220;floating point add&#8221;.</p>
<p>And continuing up the tree, the implicit cast is next:</p>
<pre>%4 = <a href="https://llvm.org/docs/LangRef.html#fptosi-to-instruction">fptosi</a> double %3 to i32</pre>
<p>The <a href="https://llvm.org/docs/LangRef.html#fptosi-to-instruction">fptosi</a> IR command means &#8220;floating point to signed integer&#8221;.</p>
<p>Lastly, we reach the actual assignment (<a href="https://llvm.org/docs/LangRef.html#store-instruction">store</a>) with IR that looks like this:</p>
<pre><a href="https://llvm.org/docs/LangRef.html#store-instruction">store</a> i32 %4, i32* @sum</pre>
<p>Here is the complete IR that gets generated:</p>
<pre>%1 = mul i32 2, 4
%2 = sitofp i32 %1 to double
%3 = fadd double 3.14, %2
%4 = fptosi double %3 to i32
store i32 %4, i32* @sum</pre>
<p>Reading through this you should now understand why no one wants to manually write code at such a low-level.</p>
<p>This is the last part of the compiler that is considered to be part of the front end. The rest of the compiler components belong to the <a href="https://blog.xojo.com/2018/01/29/compilers-105-back-end-overview/">back end</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Compilers 103 &#8211; Semantic Analyzer</title>
		<link>https://blog.xojo.com/2018/01/22/compilers-103-semantic-analyzer/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Mon, 22 Jan 2018 07:04:04 +0000</pubDate>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Compiler]]></category>
		<guid isPermaLink="false">http://blog.xojo.com/?p=2829</guid>

					<description><![CDATA[The Semantic Analyzer is the real heart of the compiler. Its job is to validate code and figure out what the code actually means. Essentially it validates that the code is semantically correct. This is the third post in our Compiler series.]]></description>
										<content:encoded><![CDATA[<p>The Semantic Analyzer is the real heart of the compiler. Its job is to validate code and figure out what the code actually means. Essentially it validates that the code is semantically correct.</p>
<p>This is the third post in our Compiler series. Previous posts:</p>
<ul>
<li><a href="https://blog.xojo.com/2017/12/04/llvm-everywhere/">LLVM Everywhere</a></li>
<li><a href="https://blog.xojo.com/2017/12/06/compilers-101-overview-and-lexer/">Compilers 101 &#8211; Overview and Lexer</a></li>
<li><a href="https://blog.xojo.com/2017/12/08/compilers-102-parser/">Compilers 102 &#8211; Parser</a></li>
</ul>
<p><span id="more-2829"></span></p>
<h2>Semantic Analyzer</h2>
<p>With the output from the Parser, all the compiler has is what the user actually typed, although converted to a format that is easy for the compiler to digest.</p>
<p>The Semantic Analyzer knows all the rules regarding the programming language. For example, it knows that an Integer can be multiplied with a Double. It knows a String cannot be compared with a Double. It knows how to do assignments to variables. It knows that Objects can be used with the “New” command. It knows about scope information. Everything that the compiler knows to pass the initial syntax check is in the Semantic Analyzer.</p>
<p>If we start with the syntax tree produced by the Parser, the Semantic Analyzer will go through it and add information to the syntax tree regarding types. And not just types, but adds information about things that are implicit in the language. For example, you may not think about it but there are implicit conversions that happen should you do something like assign a Double to an Integer.</p>
<p>As you can see below, the Semantic Analyzer has gone through the syntax tree and updated it to include when implicit conversions (ImplicitCast) are done.<br />
￼<img loading="lazy" decoding="async" class="alignnone wp-image-2831" src="https://blog.xojo.com/wp-content/uploads/2017/05/2017-05-19_09-02-03.png" alt="" width="600" height="292" /></p>
<p>This updated tree is then handed off to the next part of the compiler, <a href="https://blog.xojo.com/2018/01/24/compilers-104-ir-generation/">IR Generation</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Compilers 102 &#8211; Parser</title>
		<link>https://blog.xojo.com/2017/12/08/compilers-102-parser/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Fri, 08 Dec 2017 10:17:39 +0000</pubDate>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[LLVM]]></category>
		<guid isPermaLink="false">http://blog.xojo.com/?p=2800</guid>

					<description><![CDATA[At XDC 2016 there was a lot of interest in our Compiler session and LLVM. I’ve summarized a bit about LLVM in an earlier post, but to&#8230;]]></description>
										<content:encoded><![CDATA[<p>At <a href="https://xojo.com/xdc/">XDC</a> 2016 there was a lot of interest in our <a href="https://www.xojo.com/store/#conference">Compiler session</a> and <a href="https://llvm.org">LLVM</a>. I’ve summarized a bit about LLVM in an <a href="https://blog.xojo.com/2017/12/04/llvm-everywhere/">earlier post</a>, but to take things further, we put together this series of blog posts on compilers.</p>
<p>These will all be at a high-level. None of these posts are going to teach you how to write a compiler. The goal of these posts is for you to have a basic understanding of the components of a compiler and how they all work together to create a native app.</p>
<p>This is the second post in our ongoing series on compilers. I recommend that you first read <a href="https://blog.xojo.com/2017/12/06/compilers-101-overview-and-lexer/">Compilers 101 &#8211; Overview and Lexer</a> before continuing.</p>
<p><span id="more-2800"></span></p>
<p>After the Lexer has converted your source code to tokens, it sends them to the Parser. The job of the Parser is to turn these tokens into abstract syntax trees, which are representations of the source code and its meaning.</p>
<p>For reference, this is the simple source code we are “compiling”as we go through the parts of the compiler:</p>
<pre>sum = 3.14 + 2 * 4</pre>
<p>The lexer has converted this to a stream of tokens which are now sent to the Parser to process. The tokens are:</p>
<ol>
<li>Type: identifier
<ol>
<li>value: sum</li>
<li>start: 0</li>
<li>length: 3</li>
</ol>
</li>
<li>Type: equals or assigns
<ol>
<li>value: n/a</li>
<li>start: 4</li>
<li>length: 1</li>
</ol>
</li>
<li>Type: double
<ol>
<li> value: 3.14</li>
<li> start: 6</li>
<li>length: 4</li>
</ol>
</li>
<li>Type: plus
<ol>
<li>value: n/a</li>
<li>start: 11</li>
<li>length: 1</li>
</ol>
</li>
<li>Type: integer
<ol>
<li>value: 2</li>
<li>start: 15</li>
<li>length: 1</li>
</ol>
</li>
<li>Type: multiply
<ol>
<li>value: n/a</li>
<li>start: 15</li>
<li>length: 1</li>
</ol>
</li>
<li>Type: integer
<ol>
<li>value: 4</li>
<li>start: 17</li>
<li>length: 1</li>
</ol>
</li>
</ol>
<h2>Parser</h2>
<p>To see how this works, we’ll go through the tokens and create the syntax tree.</p>
<p>The first token is the identifier, which the parser knows is actually a variable. So it becomes the first node of the tree:</p>
<p>￼<img loading="lazy" decoding="async" class="alignnone wp-image-2803" src="https://blog.xojo.com/wp-content/uploads/2017/05/2017-05-17_09-42-30-1.png" alt="" width="200" height="51" /></p>
<p>The next token is equals or assigns. The parser knows things about this such as that it is an assignment and that assignment is a binary operator that has two operands, one on the left and one on the right. The variable from above is the left value, so it gets moved to the left side of the Assignment node that is now added to the tree to look like this:</p>
<p>￼<img loading="lazy" decoding="async" class="alignnone wp-image-2804" src="https://blog.xojo.com/wp-content/uploads/2017/05/2017-05-17_09-42-30.png" alt="" width="300" height="115" /></p>
<p>Continuing, the double token is next with value 3.14. This is the right value for the assignment:</p>
<p>￼<img loading="lazy" decoding="async" class="alignnone wp-image-2806" src="https://blog.xojo.com/wp-content/uploads/2017/05/2017-05-17_09-42-31.png" alt="" width="400" height="114" /></p>
<p>Moving along, the plus token is next. The parser knows this is the addition operator (BinaryOperator+) that takes two values (and is also left associative). This means that the addition is added to the tree with the double as its left value:</p>
<p>￼<img loading="lazy" decoding="async" class="alignnone wp-image-2808" src="https://blog.xojo.com/wp-content/uploads/2017/05/2017-05-17_09-42-32.png" alt="" width="400" height="177" /></p>
<p>After the plus token, an integer is next and this becomes the right value for the BinaryOperator+ node:</p>
<p>￼<img loading="lazy" decoding="async" class="alignnone wp-image-2809" src="https://blog.xojo.com/wp-content/uploads/2017/05/2017-05-17_09-42-33.png" alt="" width="500" height="178" /></p>
<p>Next is the multiply token, another binary operator that is left associative. So it gets the integer as its left value:</p>
<p>￼<img loading="lazy" decoding="async" class="alignnone wp-image-2810" src="https://blog.xojo.com/wp-content/uploads/2017/05/2017-05-17_09-42-34.png" alt="" width="500" height="241" /></p>
<p>The last token is another integer which becomes the right value for the multiplication:</p>
<p><img loading="lazy" decoding="async" class="alignnone wp-image-2811" src="https://blog.xojo.com/wp-content/uploads/2017/05/2017-05-17_14-33-23.png" alt="" width="600" height="241" /></p>
<p>And that is the final abstract syntax tree for our simple line of code. The Parser has done its work and has now created a tree that no longer represents the exact source code but is an idealized representation of what the user wrote.</p>
<p>This tree is then provided to the next component, the <a href="https://blog.xojo.com/2018/01/22/compilers-103-semantic-analyzer/">Semantic Analyzer</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Compilers 101 &#8211; Overview and Lexer</title>
		<link>https://blog.xojo.com/2017/12/06/compilers-101-overview-and-lexer/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Wed, 06 Dec 2017 09:00:46 +0000</pubDate>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[LEXER]]></category>
		<category><![CDATA[LLVM]]></category>
		<guid isPermaLink="false">http://blog.xojo.com/?p=2776</guid>

					<description><![CDATA[High-level posts with the goal giving you a basic understanding of the components of a compiler and how they all work together to create a native app.]]></description>
										<content:encoded><![CDATA[<p>At <a href="https://xojo.com/xdc/">XDC</a> 2016 there was a lot of interest in our <a href="https://www.xojo.com/store/#conference">Compiler session</a> and <a href="https://llvm.org">LLVM</a>. I’ve summarized a bit about LLVM in an <a href="https://blog.xojo.com/2017/12/04/llvm-everywhere/">earlier post</a>, but to take things further, we put together this series of blog posts on compilers.</p>
<p>These will all be at a high-level. None of these posts are going to teach you how to write a compiler. The goal of these posts is for you to have a basic understanding of the components of a compiler and how they all work together to create a native app.</p>
<p><span id="more-2776"></span></p>
<h2>Compiler Components</h2>
<p>A compiler is a complicated thing and consists of many components. In general the compiler is divided into two major parts: the front end and the back end. In turn, those two parts have their own components.</p>
<p>For the purposes of these posts, this is how we will be covering the components of the compiler:</p>
<h3>Front End</h3>
<p>The front end is responsible for taking the source code and converting it to a format that the back end can then use to generate binary code that can run on the target CPU architecture. The front end has these components:</p>
<ul>
<li>Lexer</li>
<li><a href="https://blog.xojo.com/2017/12/08/compilers-102-parser/">Parser</a></li>
<li><a href="https://blog.xojo.com/2018/01/22/compilers-103-semantic-analyzer/">Semantic Analyzer</a></li>
<li><a href="https://blog.xojo.com/2018/01/24/compilers-104-ir-generation/">IR (intermediate representation) Generator</a></li>
</ul>
<h3>Back End</h3>
<p>The back end takes the IR, optionally optimizes it and then generates a binary (machine code) file that can be run on the target CPU architecture. These are the components of the back end:</p>
<ul>
<li><a href="https://blog.xojo.com/2018/01/31/compilers-106-optimizer/">Optimizer</a></li>
<li><a href="https://blog.xojo.com/2018/03/26/compilers-108-code-generation/">Code Generation</a></li>
<li><a href="https://blog.xojo.com/2018/04/02/compilers-109-linking-and-wrap-up/">Linker</a></li>
</ul>
<p>Each of these steps processes things to get it a little further along for the next step to handle.</p>
<p>The linker is not technically part of the compiler but is often considered part of the compile process.</p>
<h2>Lexer</h2>
<p>The lexer turns source code into a stream of tokens. This term is actually a shortened version of “<a href="https://en.wikipedia.org/wiki/Lexical_analysis">lexical analysis</a>”. A token is essentially a representation of each item in the code at a simple level.</p>
<p>By way of example, here is a line of source code that does a simple calculation:</p>
<pre>sum = 3.14 + 2 * 4</pre>
<p>To see how a lexer works, let’s walk through how it would tokenize the above calculation, scanning it from left-to-right and tracking its type, value and position in the source code (which helps with more precise reporting of errors):</p>
<ol>
<li>The first token it finds is “sum”
<ol>
<li>type: identifier</li>
<li>value: sum</li>
<li>start: 0</li>
<li>length: 3</li>
</ol>
</li>
<li>Token: =
<ol>
<li>type: equals or assigns</li>
<li>value: n/a</li>
<li>start: 4</li>
<li>length: 1</li>
</ol>
</li>
<li>Token: 3.14
<ol>
<li>type: double</li>
<li> value: 3.14</li>
<li> start: 6</li>
<li>length: 4</li>
</ol>
</li>
<li>Token: +
<ol>
<li>type: plus</li>
<li>value: n/a</li>
<li>start: 11</li>
<li>length: 1</li>
</ol>
</li>
<li>Token: 2
<ol>
<li>type: integer</li>
<li>value: 2</li>
<li>start: 15</li>
<li>length: 1</li>
</ol>
</li>
<li>Token: *
<ol>
<li>type: multiply</li>
<li>value: n/a</li>
<li>start: 15</li>
<li>length: 1</li>
</ol>
</li>
<li>Token: 4
<ol>
<li>type: integer</li>
<li>value: 4</li>
<li>start: 17</li>
<li>length: 1</li>
</ol>
</li>
</ol>
<p>As you can see, white space and comments are ignored. So after processing that single line of code there are 7 tokens that are handed off to the next part of the compiler, which is the Parser. The <a href="https://blog.xojo.com/2017/12/08/compilers-102-parser/">Parser</a> is covered in the next post. Stay tuned!</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>LLVM Everywhere</title>
		<link>https://blog.xojo.com/2017/12/04/llvm-everywhere/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Mon, 04 Dec 2017 09:00:07 +0000</pubDate>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[LLVM]]></category>
		<guid isPermaLink="false">http://blog.xojo.com/?p=2757</guid>

					<description><![CDATA[Some of the most recent new features added to Xojo, including iOS, 64-bit apps, and Raspberry Pi have been made possible by LLVM. Read on to learn more about it. In effect, LLVM enables us to better support the unknown future, including new and updated architectures. One such example is 64-bit ARM Linux, which will likely become necessary at some point.]]></description>
										<content:encoded><![CDATA[<p>Some of the most recent features added to Xojo, including iOS, 64-bit apps, and Raspberry Pi have been made possible by LLVM. Read on to learn more about it.</p>
<p><span id="more-2757"></span></p>
<h2>What is LLVM?</h2>
<p>On a high-level, LLVM is a collection of libraries and tools for building compilers. The LLVM project was started in the early 2000s by Chris Lattner (who eventually went to work at Apple and has now moved on to Tesla) and remains in active development. Because LLVM is a toolkit for building compilers and because it can target most CPU architectures, its use has become much more prominent in recent years. It has widespread industry backing with support from major companies including AMD, Apple, ARM, IBM, Intel, Google, Mozilla, Nvidia, Qualcomm, Sony, Samsung.<img loading="lazy" decoding="async" class="alignright wp-image-2762" src="https://blog.xojo.com/wp-content/uploads/2017/05/LLVM_Logo.png" alt="" width="256" height="193" /></p>
<p>The first appearance of LLVM in Xojo was when we started using it to compile and run XojoScript code (2010). Later we used LLVM to build iOS apps (2014), 64-bit apps for x86 (Windows, MacOS, Linux) and 32-bit apps for Raspberry Pi (2015), and most recently we’ve hooked up the Xojo debugger so it works with apps built using LLVM (2016).</p>
<p>In addition to now being used as part of Xojo’s compiler, LLVM is also used with other languages, including: Clang, D, Rust, OpenCL, and Swift.</p>
<h2>Why is Xojo using LLVM?</h2>
<p>First, a little background. A compiler consists of many things and is typically split into parts called the “front end” and the “back end”. LLVM has components for both front ends and back ends; Xojo uses it as a back end.</p>
<p>For 32-bit x86 apps, Xojo uses its own in-house, proprietary compiler first created in 2004/2005. This powerful and fast compiler handles the front end and back end, but it does have a couple limitations: it can only target 32-bit x86 and it does not do any optimizations.</p>
<p>But technology marches on and we knew we would eventually have to add support for x86-64 (64-bit) and ARM CPU architectures. Updating a compiler is a large undertaking, but fortunately the LLVM compiler toolkit started gaining traction in the industry and became a better alternative to creating our own x86-64 and ARM compiler back ends.</p>
<p>Today when you build an iOS app, a 64-bit app for Windows, MacOS or Linux, or an ARM app for Raspberry Pi you are using LLVM as the back end to generate your native, binary code.</p>
<p>By using LLVM, we are able to respond more quickly to changes in the industry and to add features our users want. As an example, we were able to rapidly add Raspberry Pi support (32-bit ARM Linux) by leveraging much LLVM work that had already been done for x86-64 and ARM for iOS.</p>
<p>As Joe Ranieri (the Xojo compiler guru) likes to say “Every single line of code [you write] is a liability and not an asset”. With LLVM we can implement more features in less time because we don’t have to recreate the wheel, so to speak.</p>
<p>In effect, LLVM enables us to better support the unknown future, including new and updated architectures. One such example is 64-bit ARM Linux, which will likely become necessary at some point.</p>
<h2>Learn More</h2>
<p>LLVM is great. We love it and are thrilled that it has allowed us to add significant capabilities to Xojo for you. A compiler is a complicated thing and we are pleased that Xojo hides the complexity of compiler technology so that you don&#8217;t have to worry about it. You just need to focus on making the best app you can, select your OS target, click build and let Xojo take care of the rest.</p>
<p>If this post has made you curious about LLVM and you&#8217;d like to learn more, I recommend the following:</p>
<ul>
<li><a href="https://en.wikipedia.org/wiki/LLVM">Wikipedia: LLVM</a></li>
<li><a href="http://llvm.org">LLVM official site</a></li>
<li><a href="http://atp.fm/205-chris-lattner-interview-transcript/">Accidental Tech Podcast: Interview with Chris Lattner</a>, creator of LLVM</li>
<li><a href="https://www.xojo.com/store/#conference">Joe Ranieri’s Compiler Session from XDC 2016</a></li>
</ul>
<p>More on our Compiler Series: <a href="https://blog.xojo.com/2017/12/06/compilers-101-overview-and-lexer/">Compilers 101 &#8211; Overview and Lexer</a></p>
<p>Download a PDF of the full Compiler series: <a href="http://files.xojo.com/Documentation/Xojo%20LLVM%20Everywhere.pdf">LLVM Everywhere</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>What it means for your Xojo projects if Mac goes ARM</title>
		<link>https://blog.xojo.com/2017/09/29/what-it-means-for-your-xojo-projects-if-mac-goes-arm/</link>
		
		<dc:creator><![CDATA[Geoff Perlman]]></dc:creator>
		<pubDate>Fri, 29 Sep 2017 22:01:32 +0000</pubDate>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[LLVM]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=3445</guid>

					<description><![CDATA[I've speculated for some time now that Apple might decide to start putting their own ARM-based processors in Mac desktop and laptop computers. If they did, it would not be a significant amount of work for Xojo and really no work for you at all except recompiling your projects.]]></description>
										<content:encoded><![CDATA[<p>I&#8217;ve speculated for some time now that Apple might decide to start putting their own ARM-based processors in Mac desktop and laptop computers. Apparently, I&#8217;m not <a href="https://www.macrumors.com/2017/09/29/apple-interested-processors-modems/">alone</a> in thinking this. It makes a lot of sense. Apple&#8217;s big advantage is being in control of all of the important aspects of their product lines and the processor is both figuratively and physically at the center of their products.</p>
<p><span id="more-3445"></span></p>
<p>So what if they did? Say next year at WWDC Apple announced that they were planning to move to ARM-based Macs. How would that affect you as a Xojo developer? As it turns out, not much because Xojo abstracts and shields you from those sorts of platform changes. For example, since 2003 our compiler has been a modern, two-pass compiler. The first pass converts Xojo code into a sort of meta-assembly code. The second pass does a nearly straight translation from this meta-assembly code to the machine code for the processor being targeted (x86 for example or ARM for iPhone and Raspberry Pi). Had Apple made this change years ago, it would have required us to spend the time to create a new backend for ARM. However, as you may know, we have been transitioning the backend of our compiler to the open source LLVM compiler, the same one that Apple provides with Xcode. That&#8217;s how we support ARM (and 64 bit) today. Should Apple announce they are switching to their own ARM-based processors for future Macs, we could relatively easily recompile the Xojo desktop frameworks for ARM and provide that as a new build option. It would not be a significant amount of work for us and really no work for you at all except recompiling your projects.</p>
<p>This is true for other platforms as well. Incidentally, we have already been through this before. Xojo originally supported both the 68000 and PowerPC processors. When Apple switched to the x86, we switched too and Xojo users had little to do but recompile their projects.</p>
<p>This is part of the value you get from Xojo: be mostly insulated from these kinds of changes.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Where is 64-Bit Debugging for Windows?</title>
		<link>https://blog.xojo.com/2017/03/28/where-is-64-bit-debugging-for-windows/</link>
		
		<dc:creator><![CDATA[Geoff Perlman]]></dc:creator>
		<pubDate>Tue, 28 Mar 2017 19:30:22 +0000</pubDate>
				<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[LLVM]]></category>
		<category><![CDATA[Machine Code]]></category>
		<guid isPermaLink="false">http://blog.xojo.com/?p=2522</guid>

					<description><![CDATA[Xojo 2017 Release 1 includes support for running and debugging 64-bit apps right from the IDE for macOS and Linux. Windows support is noticeably absent because we have been moving Xojo from our own compiler back end to using LLVM.]]></description>
										<content:encoded><![CDATA[<p><a href="http://developer.xojo.com/2017r1-release-notes">Xojo 2017 Release 1</a> includes support for running and debugging 64-bit apps right from the IDE for macOS and Linux. Windows support is noticeably absent. Why? The answer is a bit complicated but interesting.</p>
<p><span id="more-2522"></span></p>
<p>As you may know, Xojo&#8217;s compiler takes the code you write and translates it into a sort of meta-assembly language. Think of it as assembly code that is not specific to any particular processor. This part of the compiler is called the <em>Front End</em>. The <em>Back End</em> of the compiler takes that meta-assembly code and translates it into actual machine code for a particular processor such as x86 or ARM. We have been moving Xojo from our own compiler Back End to using an open source one known as <em>LLVM</em> which is used by Apple and others as well. It&#8217;s how we are building for 64-bit and it optimizes your code for speed, something our old compiler Back End did not do.</p>
<p>We depend on LLVM to provide us with the data we need to make debugging work. LLVM version 3.7 had the necessary support for macOS and Linux. LLVM version 4 has added this for Windows but it was released only a few weeks ago, not enough time for us to get it working for today&#8217;s release of Xojo 2017 Release 1. Although you don&#8217;t directly see LLVM when you use Xojo, it&#8217;s doing significant and important work. Switching from one major release of LLVM to another affects far more than just debugging so it must be done very early in our development of a release of Xojo. It&#8217;s likely that 64-bit debugging support for Windows will be available in Xojo 2017 Release 2.</p>
<p>64-bit support in Xojo may seem like a minor feature. After all, for most of you, switching from 32 to 64-bit is a single-click operation. However, for it to be that simple has required a huge amount of effort on our part. While you can still get by with 32-bit apps in most cases today, that won&#8217;t be true in the not-too-distant future. That&#8217;s why it&#8217;s critical we make it easy for you to switch. The importance of Xojo supporting 64-bit really can&#8217;t be overstated.</p>
<p>Remember that many features in Xojo take multiple release cycles to complete. That means that when the feature list is short, there&#8217;s working going on for future releases. When it&#8217;s long, much of that work may have been done during previous release cycles. It&#8217;s a curious fact of software development that sometimes features that seem simple on the outside are actually large and complex on the inside.</p>
<p>There&#8217;s a lot more coming for Xojo in 2017 so stay tuned.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
