[cfe-commits] r147887 - in /cfe/trunk: include/clang/AST/Expr.h lib/AST/Expr.cpp test/CodeGen/mips64-f128-literal.c
Akira Hatanaka
ahatanaka at mips.com
Tue Jan 10 14:40:09 PST 2012
Author: ahatanak
Date: Tue Jan 10 16:40:09 2012
New Revision: 147887
URL: http://llvm.org/viewvc/llvm-project?rev=147887&view=rev
Log:
Add field IsIEEE in FloatingLiteral to distinguish between different 128-bit
floating point formats.
Added:
cfe/trunk/test/CodeGen/mips64-f128-literal.c
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/AST/Expr.cpp
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=147887&r1=147886&r2=147887&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue Jan 10 16:40:09 2012
@@ -22,6 +22,7 @@
#include "clang/AST/ASTVector.h"
#include "clang/AST/TemplateBase.h"
#include "clang/AST/UsuallyTinyPtrVector.h"
+#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/TypeTraits.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/APFloat.h"
@@ -1063,7 +1064,9 @@
class APFloatStorage : public APNumericStorage {
public:
- llvm::APFloat getValue() const { return llvm::APFloat(getIntValue()); }
+ llvm::APFloat getValue(bool IsIEEE) const {
+ return llvm::APFloat(getIntValue(), IsIEEE);
+ }
void setValue(ASTContext &C, const llvm::APFloat &Val) {
setIntValue(C, Val.bitcastToAPInt());
}
@@ -1165,6 +1168,7 @@
class FloatingLiteral : public Expr {
APFloatStorage Num;
+ bool IsIEEE : 1; // Distinguishes between PPC128 and IEEE128.
bool IsExact : 1;
SourceLocation Loc;
@@ -1172,20 +1176,25 @@
QualType Type, SourceLocation L)
: Expr(FloatingLiteralClass, Type, VK_RValue, OK_Ordinary, false, false,
false, false),
+ IsIEEE(&C.getTargetInfo().getLongDoubleFormat() ==
+ &llvm::APFloat::IEEEquad),
IsExact(isexact), Loc(L) {
setValue(C, V);
}
/// \brief Construct an empty floating-point literal.
- explicit FloatingLiteral(EmptyShell Empty)
- : Expr(FloatingLiteralClass, Empty), IsExact(false) { }
+ explicit FloatingLiteral(ASTContext &C, EmptyShell Empty)
+ : Expr(FloatingLiteralClass, Empty),
+ IsIEEE(&C.getTargetInfo().getLongDoubleFormat() ==
+ &llvm::APFloat::IEEEquad),
+ IsExact(false) { }
public:
static FloatingLiteral *Create(ASTContext &C, const llvm::APFloat &V,
bool isexact, QualType Type, SourceLocation L);
static FloatingLiteral *Create(ASTContext &C, EmptyShell Empty);
- llvm::APFloat getValue() const { return Num.getValue(); }
+ llvm::APFloat getValue() const { return Num.getValue(IsIEEE); }
void setValue(ASTContext &C, const llvm::APFloat &Val) {
Num.setValue(C, Val);
}
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=147887&r1=147886&r2=147887&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Tue Jan 10 16:40:09 2012
@@ -476,7 +476,7 @@
FloatingLiteral *
FloatingLiteral::Create(ASTContext &C, EmptyShell Empty) {
- return new (C) FloatingLiteral(Empty);
+ return new (C) FloatingLiteral(C, Empty);
}
/// getValueAsApproximateDouble - This returns the value as an inaccurate
Added: cfe/trunk/test/CodeGen/mips64-f128-literal.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mips64-f128-literal.c?rev=147887&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/mips64-f128-literal.c (added)
+++ cfe/trunk/test/CodeGen/mips64-f128-literal.c Tue Jan 10 16:40:09 2012
@@ -0,0 +1,9 @@
+// RUN: %clang -ccc-host-triple mips64el-unknown-linux -ccc-clang-archs mips64el -O3 -S -mabi=n64 -o - -emit-llvm %s | FileCheck %s
+
+typedef long double LD;
+
+// CHECK: ret fp128
+
+LD foo0() {
+ return 2.625L;
+}
More information about the cfe-commits
mailing list