https://github.com/lucasfelixsilveira/morgana
π Comptime low than LLVM or MLIR - Morgana use community extensors for more compilation performance. Knowing exactly what it need to do since you run the build command
https://github.com/lucasfelixsilveira/morgana
better-than-llvm carla carla-lang ir ir-language language llvm mlir mlir-lang mlir-llvm mlir-llvm-morgana morgana morgana-ir morgana-ir-lang simple-syntax
Last synced: 5 months ago
JSON representation
π Comptime low than LLVM or MLIR - Morgana use community extensors for more compilation performance. Knowing exactly what it need to do since you run the build command
- Host: GitHub
- URL: https://github.com/lucasfelixsilveira/morgana
- Owner: lucasFelixSilveira
- Created: 2025-10-30T00:04:58.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2026-03-02T05:58:03.000Z (5 months ago)
- Last Synced: 2026-03-02T10:06:30.722Z (5 months ago)
- Topics: better-than-llvm, carla, carla-lang, ir, ir-language, language, llvm, mlir, mlir-lang, mlir-llvm, mlir-llvm-morgana, morgana, morgana-ir, morgana-ir-lang, simple-syntax
- Language: C++
- Homepage:
- Size: 36.6 MB
- Stars: 10
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# π Morgana IR language
Morgana is a lightweight, high-performance Intermediate Representation designed to cut through the heavy, bloated pipeline of LLVM.
It powers the Carla compiler, but is fully usable as a standalone IR for any custom language or code generation tool.
### π Why Morgana Exists
LLVM is slow.
Yes, it's insanely powerful and feature-heavy β but that complexity comes with a price: massive pipelines, heavy abstractions, and sluggish code generation.
Morgana strips away the unnecessary layers and gives you a direct, nearly-metal IR, with a tiny translation pipeline that turns instructions into machine code with minimal overhead.
If you want real speed without drowning in LLVMβs complexity,
**Morgana isnβt an upgrade β itβs the alternative.**
##
## β¨ What Is Morgana?
Morgana is a clean and compact IR language originally built to replace LLVM in the Carla compiler project.
But nothing stops you from using it in your own compiler or VM.
It was designed to be simple enough to generate, powerful enough to optimize, and low-level enough to map cleanly to native assembly.
## Morgana Extensors
What is extensors?
Extensors are extensions to Morgana codegen, which allow you to add your custom instructions, types, and optimizations to the language.
- `I need implement my own extensors?`: No, you can use the official extensors, third-party extensors or even write your own.
- `How can i write my own extensors?`: You can write your own extensors using [Runa (γ«γ)](https://github.com/lucasFelixSilveira/runa) and the pattern who is teach on the [Morgana Extensors](https://github.com/Carla-corp/extensors) repository.
- `I can write without overriding any of the existing extensors?`: Yes, you can write your own extensors without overriding any of the existing ones. Compiling with the flag `-o`
```sh-session
# x86_64 extensor for example
$ morgana build -o x86_64-optimized
```
## What official extensors are already implemented?
MCU (AVR)
MCU (xtensa)
CPU (x86_64)
CPU (i386)
CPU (ARM)
GPU (NVIDIA)
GPU (AMD)
π‘
β
π‘
β
β
β
β
# Examples
### Morgana LED Flip Flop - MCUs
[Click to watch - Morgana FLIP FLOP in AVR platform](https://youtu.be/N7LiUWXcLLY)
### Morgana reading GPIO and taking decisions - MCUs
[Click to watch - Morgana now has Branches! Arduino (MCU) use example](https://youtu.be/N7LiUWXcLLY)
## π₯ LLVM vs Morgana
- **LLVM IR**
```llvm
define i32 @main(i8 %0, ptr %1) {
entry:
%3 = alloca i8, align 1
%4 = alloca ptr, align 8
store i8 %0, ptr %3, align 1
store ptr %1, ptr %4, align 8
ret i32 0
}
```
- The same code in **Morgana IR**
```morgana
i32 main i8 [16:i8]* {
(a0, a1) @_
ret 0
}
```
Notice the difference:
**Same semantics, 5Γ less noise.**
# π Library Usage Example
```cpp
#include "morgana/builder.hpp"
#include "morgana/context.hpp"
#include "morgana.hpp"
#include
#include
int main() {
Builder builder(false);
morgana::desconstruct::values data = {};
Context context;
morgana::desconstruct d(morgana::mics::that, data);
context << d.string();
morgana::type i8 = morgana::type::integer(8);
morgana::type i32 = morgana::type::integer(32);
morgana::type pvecstr = morgana::type::integer(8).ptr().vec(16);
morgana::function f("main", i32.shared(), morgana::function::args{}, context.string());
builder << f.string();
std::cout << builder.string(); // Print the generated IR
return 0;
}
```