Commit f875817b by Chris Mihelich Committed by Copybara-Service

Demangle fixed-width floating-point types, DF....

PiperOrigin-RevId: 641400156
Change-Id: Ib9f6e4f6c4bbd6d3234dfd322d1d14a59b08d88a
parent 3941dc41
...@@ -1455,9 +1455,14 @@ static bool ParseExtendedQualifier(State *state) { ...@@ -1455,9 +1455,14 @@ static bool ParseExtendedQualifier(State *state) {
// ::= Dd, etc. # two-character builtin types // ::= Dd, etc. # two-character builtin types
// ::= DB (<number> | <expression>) _ # _BitInt(N) // ::= DB (<number> | <expression>) _ # _BitInt(N)
// ::= DU (<number> | <expression>) _ # unsigned _BitInt(N) // ::= DU (<number> | <expression>) _ # unsigned _BitInt(N)
// ::= DF <number> _ # _FloatN (N bits)
// ::= DF <number> x # _FloatNx
// ::= DF16b # std::bfloat16_t
// //
// Not supported: // Not supported:
// ::= DF <number> _ # _FloatN (N bits) // ::= [DS] DA <fixed-point-size>
// ::= [DS] DR <fixed-point-size>
// because real implementations of N1169 fixed-point are scant.
static bool ParseBuiltinType(State *state) { static bool ParseBuiltinType(State *state) {
ComplexityGuard guard(state); ComplexityGuard guard(state);
if (guard.IsTooComplex()) return false; if (guard.IsTooComplex()) return false;
...@@ -1491,6 +1496,30 @@ static bool ParseBuiltinType(State *state) { ...@@ -1491,6 +1496,30 @@ static bool ParseBuiltinType(State *state) {
return true; return true;
} }
// DF <number> _ # _FloatN
// DF <number> x # _FloatNx
// DF16b # std::bfloat16_t
if (ParseTwoCharToken(state, "DF")) {
if (ParseThreeCharToken(state, "16b")) {
MaybeAppend(state, "std::bfloat16_t");
return true;
}
int number = 0;
if (!ParseNumber(state, &number)) {
state->parse_state = copy;
return false;
}
MaybeAppend(state, "_Float");
MaybeAppendDecimal(state, number);
if (ParseOneCharToken(state, 'x')) {
MaybeAppend(state, "x");
return true;
}
if (ParseOneCharToken(state, '_')) return true;
state->parse_state = copy;
return false;
}
for (const AbbrevPair *p = kBuiltinTypeList; p->abbrev != nullptr; ++p) { for (const AbbrevPair *p = kBuiltinTypeList; p->abbrev != nullptr; ++p) {
// Guaranteed only 1- or 2-character strings in kBuiltinTypeList. // Guaranteed only 1- or 2-character strings in kBuiltinTypeList.
if (p->abbrev[1] == '\0') { if (p->abbrev[1] == '\0') {
......
...@@ -660,6 +660,30 @@ TEST(Demangle, ComplexFloatingPointLiterals) { ...@@ -660,6 +660,30 @@ TEST(Demangle, ComplexFloatingPointLiterals) {
EXPECT_STREQ("f<>()", tmp); EXPECT_STREQ("f<>()", tmp);
} }
TEST(Demangle, Float128) {
char tmp[80];
// S::operator _Float128() const
EXPECT_TRUE(Demangle("_ZNK1ScvDF128_Ev", tmp, sizeof(tmp)));
EXPECT_STREQ("S::operator _Float128()", tmp);
}
TEST(Demangle, Float128x) {
char tmp[80];
// S::operator _Float128x() const
EXPECT_TRUE(Demangle("_ZNK1ScvDF128xEv", tmp, sizeof(tmp)));
EXPECT_STREQ("S::operator _Float128x()", tmp);
}
TEST(Demangle, Bfloat16) {
char tmp[80];
// S::operator std::bfloat16_t() const
EXPECT_TRUE(Demangle("_ZNK1ScvDF16bEv", tmp, sizeof(tmp)));
EXPECT_STREQ("S::operator std::bfloat16_t()", tmp);
}
TEST(Demangle, SimpleSignedBitInt) { TEST(Demangle, SimpleSignedBitInt) {
char tmp[80]; char tmp[80];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment