5 ms·
The difference between compiling and lowering is that the syntax of the output of lowering is a strict subset of the syntax of its' input, whereas the output of
by infogulch 9y ago
The difference between compiling and lowering is that the syntax of the output of lowering is a strict subset of the syntax of its' input, whereas the output of compiling produces a completely different format, e.g. an AST, an in-memory graph, assembly, machine code, etc.
This makes implementing the next layer (compiler perhaps) simpler because it has to understand fewer syntax elements. This also makes a difference is that you could manually write the output of the lowered code yourself in the original language. Another effect is that (ideally) applying the lowering function L() to any code a second time should produce no change i.e. L(code) == L(L(code)). This is not true of compiling.
- matthewwarren 9y ago> The difference between compiling and lowering is that the syntax of the output of lowering is a strict subset of the syntax of its' input, whereas the output of compiling produces a completely different format, e.g. an AST, an in-memory graph, assembly, machine code, etc. Brilliant, thanks for that explanation, I understand 'lowering' even more now!
- saurik 9y agoI am pretty sure you have added a lot of personal context to this word that is unrelated to how it is actually used: I will argue that for decades, the term "lowering" has meant a transformation to a "lower-level" representation, and that this representation often is "a completely different format". https://www.cs.utexas.edu/users/cart/Scale/lowering.html https://www.cs.utexas.edu/users/cart/Scale/lowering.html > Lowering is the transformation of higher level representations to lower level representations. For example, subscript expressions are lowered to address arithmetic operations. A compiler traditionally lowers a high level language to machine code in one or more steps. https://en.m.wikibooks.org/wiki/GNU_C_Compiler_Internals/GNU_C_Compiler_Architecture_4_1 https://en.m.wikibooks.org/wiki/GNU_C_Compiler_Internals/GNU... > As a result of lowering a function its control-flow graph is generated. http://tap2k.org/projects/WIL/ http://tap2k.org/projects/WIL/ > Generally each data value will start with an abstract representation, which will in turn go through a sequence of lowerings as representation choices are made. These lowerings will eventually transform both the representation and the operations upon it to fully concrete forms, down to the level of the actual bit layout of the value in memory, allowing for easy low-level code generation. https://pdfs.semanticscholar.org/92ea/93e93a77b80465e7aeb53df679fee2203caa.pdf https://pdfs.semanticscholar.org/92ea/93e93a77b80465e7aeb53d... > Instead of the compiler backend lowering object operations to machine operations using hard-wired runtime- specific logic, XIR allows the runtime system to implement this logic, simultaneously simplifying and separating the backend from runtime-system details. https://www.researchgate.net/profile/Michael_Burke9/publication/2649955_The_Jalapeno_Dynamic_Optimizing_Compiler_for_Java/links/00b7d518a8b2b3cb67000000/The-Jalapeno-Dynamic-Optimizing-Compiler-for-Java.pdf https://www.researchgate.net/profile/Michael_Burke9/publicat... > After high-level analyses and optimizations are performed, HIR is lowered to low-level IR (LIR). In contrast to HIR, the LIR expands instructions into operations that are specific to the Jalapeño JVM implementation, such as object layouts or parameter-passing mechanisms of the Jalapefio JVM. For example, operations in HIR to invoke methods of an object or of a class consist of a single instruction, matching the corresponding bytecode instructions invokevirtual/invokestatic. These single-instruction operations are lowered (i.e., converted) into multiple-instruction LIR operations that invoke the methods based on the virtual-function-table layout.