reduce unnecessary casts in C output

This commit is contained in:
dzaima 2023-04-01 23:01:37 +03:00
parent 9826201343
commit 5018cf9b2e
3 changed files with 5 additions and 2 deletions

View File

@ -1,4 +1,5 @@
def v2i{x:T & w256{T}} = [32]u8 ~~ x # for compact casting for the annoying intrinsic type system
# compact casting for the annoying intrinsic type system
def v2i{x:T & w256{T}} = if(isint{eltype{T}}) x else [32]u8 ~~ x
def v2f{x:T & w256{T}} = [8]f32 ~~ x
def v2d{x:T & w256{T}} = [4]f64 ~~ x

View File

@ -6,6 +6,7 @@ oper ~~ reinterpret infix right 55
oper ** broadcast infix right 55
def Size = u64
def load{x} = *x
def reinterpret{T, x:X & T==X} = x
def exportN{f, ...ns} = each{{n} => export{n, f}, ns}
def exportT{name, fs} = { v:*type{tupsel{0,fs}} = fs; export{name, v} }

View File

@ -1,4 +1,5 @@
def v2i{x:T & w128{T}} = [16]u8 ~~ x # for compact casting for the annoying intrinsic type system
# compact casting for the annoying intrinsic type system
def v2i{x:T & w128{T}} = if(isint{eltype{T}}) x else [16]u8 ~~ x
def v2f{x:T & w128{T}} = [4]f32 ~~ x
def v2d{x:T & w128{T}} = [2]f64 ~~ x