Files
c3c/test/test_suite/distinct/distinct_shift.c3t
Christoffer Lerno 5c77c9a754 - Change distinct -> typedef.
- Order of attribute declaration is changed for `alias`.
- Added `LANGUAGE_DEV_VERSION` env constant.
- Rename `anyfault` -> `fault`.
- Changed `fault` -> `faultdef`.
- Added `attrdef` instead of `alias` for attribute aliases.
2025-03-15 20:10:47 +01:00

48 lines
956 B
Plaintext

// #target: macos-x64
module test;
import std::io;
const ODD_PHI16 @local = 0x9e37;
typedef Lcg16_8 = ushort;
fn void Lcg16_8.seed(Lcg16_8* lcg, char[2] seed)
{
*lcg = bitcast(seed, Lcg16_8);
}
fn char Lcg16_8.next(Lcg16_8* lcg)
{
Lcg16_8 s = *lcg;
char result = (char)(s >> 8);
*lcg = s * 0x915d + ODD_PHI16;
return result;
}
fn void main()
{
Lcg16_8 s;
io::printfn("Point: %d", s.next());
}
/* #expect: test.ll
define zeroext i8 @test.Lcg16_8.next(ptr %0) #0 {
entry:
%s = alloca i16, align 2
%result = alloca i8, align 1
%1 = load i16, ptr %0, align 2
store i16 %1, ptr %s, align 2
%2 = load i16, ptr %s, align 2
%lshr = lshr i16 %2, 8
%3 = freeze i16 %lshr
%trunc = trunc i16 %3 to i8
store i8 %trunc, ptr %result, align 1
%4 = load i16, ptr %s, align 2
%mul = mul i16 %4, -28323
%add = add i16 %mul, -25033
store i16 %add, ptr %0, align 2
%5 = load i8, ptr %result, align 1
ret i8 %5
}