[llvm-dev] Fixed Point Support in LLVM (original) (raw)

Leonard Chan via llvm-dev llvm-dev at lists.llvm.org
Thu Sep 20 11:36:11 PDT 2018


Hi all,

We will be adding intrinsics for now to get a working version of fixed point arithmetic implemented in clang faster, but will still consider either adding a new fixed point type in LLVM or new operations that perform these fixed point operations on integers. This is a list of all the intrinsics that I plan to implement and wanted to see if anyone had any feedback on their signatures/semantics.

; Signed and unsigned saturation ; Unsigned saturation would primarily just saturate to W_MAX since you can’t really saturate towards 0 for an unsigned number declare iN @llvm.ssaturate(iN %Val, i32 %W) declare iN @llvm.usaturate(iN %Val, i32 %W)

; Saturated addition and subtraction. ; Scale is not necessary since fixed addition/subtraction does not care about the scale as long as the operands have the same scale. This will require a shift beforehand regardless. ; We cannot use the existing overflow add/sub intrinsics since they only indicate overflow but not direction to saturate in. declare iN @llvm.satsadd(iN %L, iN %R) declare iN @llvm.satuadd(iN %L, iN %R) declare iN @llvm.satssub(iN %L, iN %R) declare iN @llvm.satusub(iN %L, iN %R)

; Multiplication and division declare iN @llvm.fixsmul(iN %L, %iN R, i32 %Scale) declare iN @llvm.fixumul(iN %L, %iN R, i32 %Scale) declare iN @llvm.fixsdiv(iN %L, %iN R, i32 %Scale) declare iN @llvm.fixudiv(iN %L, %iN R, i32 %Scale) declare iN @llvm.fixsmul.sat(iN %L, %iN R, i32 %Scale) declare iN @llvm.fixumul.sat(iN %L, %iN R, i32 %Scale) declare iN @llvm.fixsdiv.sat(iN %L, %iN R, i32 %Scale) declare iN @llvm.fixudiv.sat(iN %L, %iN R, i32 %Scale)



More information about the llvm-dev mailing list