[demangle] Support for ISO/IEC TS 18661 binary floating point type

Reviewed By: #libc_abi, ldionne

Differential Revision: https://reviews.llvm.org/D105278
This commit is contained in:
Pengfei Wang 2021-09-23 11:02:25 +08:00 committed by Wang, Pengfei
parent ebec077e07
commit 1873f3be78
3 changed files with 55 additions and 0 deletions

View file

@ -57,6 +57,7 @@
X(LocalName) \
X(VectorType) \
X(PixelVectorType) \
X(BinaryFPType) \
X(SyntheticTemplateParamName) \
X(TypeTemplateParamDecl) \
X(NonTypeTemplateParamDecl) \
@ -1074,6 +1075,21 @@ public:
}
};
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;

View file

@ -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>()"},

View file

@ -57,6 +57,7 @@
X(LocalName) \
X(VectorType) \
X(PixelVectorType) \
X(BinaryFPType) \
X(SyntheticTemplateParamName) \
X(TypeTemplateParamDecl) \
X(NonTypeTemplateParamDecl) \
@ -1074,6 +1075,21 @@ public:
}
};
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;