HomePhabricator

[Fixed Point Arithmetic] Fixed Point Precision Bits and Fixed Point Literals

Authored by leonardchan on Jun 20 2018, 10:19 AM.

Description

[Fixed Point Arithmetic] Fixed Point Precision Bits and Fixed Point Literals

This diff includes the logic for setting the precision bits for each primary fixed point type in the target info and logic for initializing a fixed point literal.

Fixed point literals are declared using the suffixes

hr: short _Fract
uhr: unsigned short _Fract
r: _Fract
ur: unsigned _Fract
lr: long _Fract
ulr: unsigned long _Fract
hk: short _Accum
uhk: unsigned short _Accum
k: _Accum
uk: unsigned _Accum

Errors are also thrown for illegal literal values

unsigned short _Accum u_short_accum = 256.0uhk;   // expected-error{{the integral part of this literal is too large for this unsigned _Accum type}}

Differential Revision: https://reviews.llvm.org/D46915

llvm-svn: 335148