[llvm] 1873f3b - [demangle] Support for ISO/IEC TS 18661 binary floating point type
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 22 20:03:19 PDT 2021
Author: Pengfei Wang
Date: 2021-09-23T11:02:58+08:00
New Revision: 1873f3be78a5255df8c36c195f4c778f9f47fc5c
URL: https://github.com/llvm/llvm-project/commit/1873f3be78a5255df8c36c195f4c778f9f47fc5c
DIFF: https://github.com/llvm/llvm-project/commit/1873f3be78a5255df8c36c195f4c778f9f47fc5c.diff
LOG: [demangle] Support for ISO/IEC TS 18661 binary floating point type
Reviewed By: #libc_abi, ldionne
Differential Revision: https://reviews.llvm.org/D105278
Added:
Modified:
libcxxabi/src/demangle/ItaniumDemangle.h
libcxxabi/test/test_demangle.pass.cpp
llvm/include/llvm/Demangle/ItaniumDemangle.h
Removed:
################################################################################
diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h
index f73959868d706..c581ed7274764 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -57,6 +57,7 @@
X(LocalName) \
X(VectorType) \
X(PixelVectorType) \
+ X(BinaryFPType) \
X(SyntheticTemplateParamName) \
X(TypeTemplateParamDecl) \
X(NonTypeTemplateParamDecl) \
@@ -1074,6 +1075,21 @@ class PixelVectorType final : public Node {
}
};
+class BinaryFPType final : public Node {
+ const Node *Dimension;
+
+public:
+ BinaryFPType(const Node *Dimension_)
+ : Node(KBinaryFPType), Dimension(Dimension_) {}
+
+ template<typename Fn> void match(Fn F) const { F(Dimension); }
+
+ void printLeft(OutputStream &S) const override {
+ S += "_Float";
+ Dimension->print(S);
+ }
+};
+
enum class TemplateParamKind { Type, NonType, Template };
/// An invented name for a template parameter for which we don't have a
@@ -3904,6 +3920,16 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() {
case 'h':
First += 2;
return make<NameType>("half");
+ // ::= DF <number> _ # ISO/IEC TS 18661 binary floating point (N bits)
+ case 'F': {
+ First += 2;
+ Node *DimensionNumber = make<NameType>(parseNumber());
+ if (!DimensionNumber)
+ return nullptr;
+ if (!consumeIf('_'))
+ return nullptr;
+ return make<BinaryFPType>(DimensionNumber);
+ }
// ::= Di # char32_t
case 'i':
First += 2;
diff --git a/libcxxabi/test/test_demangle.pass.cpp b/libcxxabi/test/test_demangle.pass.cpp
index 0744172a6cbb4..903b00ee54863 100644
--- a/libcxxabi/test/test_demangle.pass.cpp
+++ b/libcxxabi/test/test_demangle.pass.cpp
@@ -23433,6 +23433,8 @@ const char* cases[][2] =
{"_ZN4llvm7APFloatC2Ef", "llvm::APFloat::APFloat(float)"},
{"_ZN4llvm7APFloatC1Ed", "llvm::APFloat::APFloat(double)"},
{"_ZN4llvm7APFloatC2Ed", "llvm::APFloat::APFloat(double)"},
+ {"_ZN4llvm7APFloatC1EDF16_", "llvm::APFloat::APFloat(_Float16)"},
+ {"_ZN4llvm7APFloatC2EDF16_", "llvm::APFloat::APFloat(_Float16)"},
{"_ZNK4llvm7APFloat8toStringERNS_15SmallVectorImplIcEEjj", "llvm::APFloat::toString(llvm::SmallVectorImpl<char>&, unsigned int, unsigned int) const"},
{"_ZNK4llvm5APIntngEv", "llvm::APInt::operator-() const"},
{"_ZN4llvm5APIntlSEj", "llvm::APInt::operator<<=(unsigned int)"},
@@ -29569,6 +29571,7 @@ const char* cases[][2] =
{"_Z2f3IJEEvDpPKT_", "void f3<>()"},
{"_Z2f3IJiEEvDpPKT_", "void f3<int>(int const*)"},
{"_Z2f3IJifEEvDpPKT_", "void f3<int, float>(int const*, float const*)"},
+ {"_Z10float16addDF16_DF16_", "float16add(_Float16, _Float16)"},
{"_Z2f4IJifdEE5tupleIJDpT_EEv", "tuple<int, float, double> f4<int, float, double>()"},
{"_Z2f5IiJifdEE8identityIFT_DpT0_EEv", "identity<int (int, float, double)> f5<int, int, float, double>()"},
{"_Z2f6IJLi1ELi2ELi3EEE9int_tupleIJXspT_EEEv", "int_tuple<1, 2, 3> f6<1, 2, 3>()"},
diff --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h
index dd824a50359d1..c921decdedae9 100644
--- a/llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -57,6 +57,7 @@
X(LocalName) \
X(VectorType) \
X(PixelVectorType) \
+ X(BinaryFPType) \
X(SyntheticTemplateParamName) \
X(TypeTemplateParamDecl) \
X(NonTypeTemplateParamDecl) \
@@ -1074,6 +1075,21 @@ class PixelVectorType final : public Node {
}
};
+class BinaryFPType final : public Node {
+ const Node *Dimension;
+
+public:
+ BinaryFPType(const Node *Dimension_)
+ : Node(KBinaryFPType), Dimension(Dimension_) {}
+
+ template<typename Fn> void match(Fn F) const { F(Dimension); }
+
+ void printLeft(OutputStream &S) const override {
+ S += "_Float";
+ Dimension->print(S);
+ }
+};
+
enum class TemplateParamKind { Type, NonType, Template };
/// An invented name for a template parameter for which we don't have a
@@ -3904,6 +3920,16 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() {
case 'h':
First += 2;
return make<NameType>("half");
+ // ::= DF <number> _ # ISO/IEC TS 18661 binary floating point (N bits)
+ case 'F': {
+ First += 2;
+ Node *DimensionNumber = make<NameType>(parseNumber());
+ if (!DimensionNumber)
+ return nullptr;
+ if (!consumeIf('_'))
+ return nullptr;
+ return make<BinaryFPType>(DimensionNumber);
+ }
// ::= Di # char32_t
case 'i':
First += 2;
More information about the llvm-commits
mailing list