diff options
author | Leonard Chan <leonardchan@google.com> | 2018-06-20 17:19:40 +0000 |
---|---|---|
committer | Leonard Chan <leonardchan@google.com> | 2018-06-20 17:19:40 +0000 |
commit | db01c3adc6f921a27e2bd39847140c401860aa56 (patch) | |
tree | c4c7e6ec5b92b188b7224b963c196fb5fccc9c6d /clang/lib/AST/ASTDumper.cpp | |
parent | 7e067ab1afec1984e8c9d663a333d145f66c2adf (diff) | |
download | bcm5719-llvm-db01c3adc6f921a27e2bd39847140c401860aa56.tar.gz bcm5719-llvm-db01c3adc6f921a27e2bd39847140c401860aa56.zip |
[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
Diffstat (limited to 'clang/lib/AST/ASTDumper.cpp')
-rw-r--r-- | clang/lib/AST/ASTDumper.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/AST/ASTDumper.cpp b/clang/lib/AST/ASTDumper.cpp index cf512b9bd3f..6d9f24020fe 100644 --- a/clang/lib/AST/ASTDumper.cpp +++ b/clang/lib/AST/ASTDumper.cpp @@ -525,6 +525,7 @@ namespace { void VisitPredefinedExpr(const PredefinedExpr *Node); void VisitCharacterLiteral(const CharacterLiteral *Node); void VisitIntegerLiteral(const IntegerLiteral *Node); + void VisitFixedPointLiteral(const FixedPointLiteral *Node); void VisitFloatingLiteral(const FloatingLiteral *Node); void VisitStringLiteral(const StringLiteral *Str); void VisitInitListExpr(const InitListExpr *ILE); @@ -2177,6 +2178,13 @@ void ASTDumper::VisitIntegerLiteral(const IntegerLiteral *Node) { OS << " " << Node->getValue().toString(10, isSigned); } +void ASTDumper::VisitFixedPointLiteral(const FixedPointLiteral *Node) { + VisitExpr(Node); + + ColorScope Color(*this, ValueColor); + OS << " " << Node->getValueAsString(/*Radix=*/10); +} + void ASTDumper::VisitFloatingLiteral(const FloatingLiteral *Node) { VisitExpr(Node); ColorScope Color(*this, ValueColor); |