blaise/vendor/qbe/test/fold1.ssa
Graeme Geldenhuys 25de8be212 Fix compilation errors; vendor QBE 1.2; end-to-end Hello World works
Fix TProgram.Uses reserved-word clash (renamed to UsedUnits), nested
brace-comment in uParser.pas, and missing uAST in Blaise.pas uses clause.

Vendor QBE 1.2 source in vendor/qbe/ (built locally with make; binary
excluded via .gitignore). End-to-end pipeline confirmed: Blaise compiles
Hello World and Calc (6*7=42) to native x86_64 Linux binaries.

71/71 FPCUnit tests passing.
2026-04-20 16:38:57 +01:00

48 lines
682 B
Plaintext

export
function w $f1() {
@start
%x =w sar 2147483648, 31
ret %x
}
export
function w $f2() {
@start
%x =w div 4294967040, 8 # -256 / 8
ret %x
}
export
function w $f3() {
@start
%x =w rem 4294967284, 7 # -12 % 7
ret %x
}
export
function w $f4() {
@start
%x =w shr 4294967296, 1 # 2^32 >> 1
ret %x
}
export
function w $f5() {
@start
%x =w udiv 1, 4294967297 # 1 / (2^32 + 1)
ret %x
}
export
function w $f6() {
@start
%x =w urem 4294967296, 7 # 2^32 % 7
ret %x
}
# >>> driver
# extern int f1(), f2(), f3(), f4(), f5(), f6();
# int main() { return !(f1() == -1 && f2() == -32 && f3() == -5 &&
# f4() == 0 && f5() == 1 && f6() == 0); }
# <<<