Ecosyste.ms: Packages

An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

Top 9.5% dependent packages on proxy.golang.org

proxy.golang.org : modernc.org/libqbe

Package libqbe is a ccgo/v4 version of the QBE command in a library form. QBE compiles SSA source code to assembler source code. See the QBE Intermediate Language manual for the full specification. (Copied verbatim from QBE vs LLVM.) Both QBE and LLVM are compiler backends using an SSA representation. This document will explain why LLVM does not make QBE a redundant project. Obviously, everything following is biased, because written by me. QBE is a much smaller scale project with different goals than LLVM. QBE is for amateur language designers. It does not address all the problems faced when conceiving an industry-grade language. If you are toying with some language ideas, using LLVM will be like hauling your backpack with a truck, but using QBE will feel more like riding a bicycle. QBE is about the first 70%, not the last 30%. It attempts to pinpoint, in the extremely vast compilation literature, the optimizations that get you 70% of the performance in 10% of the code of full blown compilers. For example, copy propagation on SSA form is implemented in 160 lines of code in QBE! QBE is extremely hackable. First, it is, and will remain, a small project (less than 8 kloc). Second, it is programmed in non-fancy C99 without any dependencies. Third, it is able to dump the IL and debug information in a uniform format after each pass. On my Core 2 Duo machine, QBE compiles in half a second (without optimizations). LLVM is definitely more packed with features, but there are a few things provided in QBE to consider. LLVM does NOT provide full C compatibility for you. In more technical terms, any language that provides good C compatibility and uses LLVM as a backend needs to reimplement large chunks of the ABI in its frontend! This well known issue in the LLVM community causes a great deal of duplication and bugs. Implementing a complete C ABI (with struct arguments and returns) is incredibly tricky, and not really a lot of fun. QBE provides you with IL operations to call in (and be called by) C with no pain. Moreover the ABI implementation in QBE has been thoroughly tested by fuzzing and manual tests. LLVM IL is more cluttered with memory operations. Implementing SSA construction is hard. To save its users from having to implement it, LLVM provides stack slots. This means that one increment of a variable v will be composed of three LLVM instructions: one load, one add, and one store. QBE provides simple non-SSA temporaries, so incrementing v is simply done with one instruction This could seem cosmetic, but dividing the size of the IL by three makes it easier for the frontend writers to spot bugs in the generated code. LLVM IL is more cluttered with type annotations and casts. For the sake of advanced optimizations and correctness, LLVM has complex IL types. However, only a few types are really first class and many operations of source languages require casts to be compiled. Because QBE makes a much lighter use of types, the IL is more readable and shorter. It can of course be argued back that the correctness of QBE is jeopardized, but remember that, in practice, the large amount of casts necessary in LLVM IL is undermining the overall effectiveness of the type system. (End of the verbatim copy from QBE vs LLVM.) (Copied verbatim from Phi.) First and foremost, phi instructions are NOT necessary when writing a frontend to QBE. One solution to avoid having to deal with SSA form is to use stack allocated variables for all source program variables and perform assignments and lookups using Memory operations. This is what LLVM users typically do. Another solution is to simply emit code that is not in SSA form! Contrary to LLVM, QBE is able to fixup programs not in SSA form without requiring the boilerplate of loading and storing in memory. For example, the following program will be correctly compiled by QBE. Now, if you want to know what phi instructions are and how to use them in QBE, you can read the following. Phi instructions are specific to SSA form. In SSA form values can only be assigned once, without phi instructions, this requirement is too strong to represent many programs. For example consider the following C program. The variable y is assigned twice, the solution to translate it in SSA form is to insert a phi instruction. Phi instructions return one of their arguments depending on where the control came from. In the example, %y is set to 1 if the @ift branch is taken, or it is set to 2 otherwise. An important remark about phi instructions is that QBE assumes that if a variable is defined by a phi it respects all the SSA invariants. So it is critical to not use phi instructions unless you know exactly what you are doing. (End of the verbatim copy from Phi.) All supported hosts can cross compile for any of the supported targets.

Registry - Source - Documentation - JSON
purl: pkg:golang/modernc.org/libqbe
Keywords: QBE, backend, compiler
License: BSD-3-Clause
Latest release: 5 months ago
First release: 7 months ago
Namespace: modernc.org
Dependent packages: 1
Stars: 1 on GitLab.com
Forks: 0 on GitLab.com
See more repository details: repos.ecosyste.ms
Last synced: 23 days ago

    Loading...
    Readme
    Loading...