[Fixed Point Arithmetic] Fixed Point Precision Bits and Fixed Point Literals
authorLeonard Chan <leonardchan@google.com>
Wed, 20 Jun 2018 17:19:40 +0000 (17:19 +0000)
committerLeonard Chan <leonardchan@google.com>
Wed, 20 Jun 2018 17:19:40 +0000 (17:19 +0000)
commitdb01c3adc6f921a27e2bd39847140c401860aa56
treec4c7e6ec5b92b188b7224b963c196fb5fccc9c6d
parent7e067ab1afec1984e8c9d663a333d145f66c2adf
[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
40 files changed:
clang/include/clang-c/Index.h
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/Expr.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/AST/Type.h
clang/include/clang/Basic/DiagnosticCommonKinds.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/StmtNodes.td
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Driver/Options.td
clang/include/clang/Lex/LiteralSupport.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTDumper.cpp
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprClassification.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/StmtPrinter.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/AST/Type.cpp
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets.cpp
clang/lib/CodeGen/CGExprAgg.cpp
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Lex/LiteralSupport.cpp
clang/lib/Sema/SemaExceptionSpec.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/test/Frontend/fixed_point.c
clang/test/Frontend/fixed_point_bit_widths.c
clang/test/Frontend/fixed_point_declarations.c [new file with mode: 0644]
clang/test/Frontend/fixed_point_errors.c
clang/test/Frontend/fixed_point_same_fbits.c [new file with mode: 0644]
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/CXCursor.cpp