Mangling of floating-point literals
Mark Mitchell
mark at codesourcery.com
Thu Oct 17 01:00:28 UTC 2002
It was pointed out to me that the ABI spec made it sound like mangling
floating-poit literals is optional -- but it's not:
f<int(3.14159)>
is legal even in ISO C++, and the spec is very clear that no folding
or simplification is supposed to take place.
I cleaned this up with the following patch.
--
Mark Mitchell mark at codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
Index: abi.html
===================================================================
RCS file: /usr/local/Repository/cxx-abi/abi.html,v
retrieving revision 1.35
diff -c -5 -p -r1.35 abi.html
*** abi.html 11 Oct 2002 19:00:33 -0000 1.35
--- abi.html 17 Oct 2002 01:01:32 -0000
*************** This is used in names for specialization
*** 4322,4335 ****
but also in types and scope identification.
<pre><font color=blue><code>
<template-args> ::= I <template-arg>+ E
<template-arg> ::= <type> # type or template
- ::= L <type> <<i>value</i> number> E # literal
- ::= L_Z <encoding> E # external name
::= X <expression> E # expression
! </pre></font></code>
<p>
Type arguments appear using their regular encoding.
For example, the template class "A<char, float>" is encoded as "1AIcfE".
A slightly more involved example is
--- 4320,4346 ----
but also in types and scope identification.
<pre><font color=blue><code>
<template-args> ::= I <template-arg>+ E
<template-arg> ::= <type> # type or template
::= X <expression> E # expression
! ::= <expr-primary> # simple expressions
!
! <expression> ::= <<i>unary</i> operator-name> <expression>
! ::= <<i>binary</i> operator-name> <expression> <expression>
! ::= <<i>trinary</i> operator-name> <expression> <expression> <expression>
! ::= st <type>
! ::= <template-param>
! ::= sr <type> <unqualified-name> # dependent name
! ::= sr <type> <unqualified-name> <template-args> # dependent template-id
! ::= <expr-primary>
!
! <expr-primary> ::= L <type> <<i>value</i> number> E # integer literal
! ::= L <type <<i>value</i> float> E # floating literal
! ::= L <mangled-name> E # external name
!
! </pre></code></font>
<p>
Type arguments appear using their regular encoding.
For example, the template class "A<char, float>" is encoded as "1AIcfE".
A slightly more involved example is
*************** where the "N...E" construct is used to d
*** 4342,4356 ****
Literal arguments, e.g. "A<42L>",
are encoded with their type and value.
Negative integer values are preceded with "n";
for example, "A<-42L>" becomes "1AILln42EE".
The bool value false is encoded as 0, true as 1.
! If floating-point arguments are accepted as an extension,
! their values should be encoded using a fixed-length lowercase hexadecimal
! string corresponding to the internal representation (IEEE on Itanium),
! high-order bytes first, without leading zeroes.
! For example: "Lf bf800000 E" is -1.0f on Itanium.
<p>
A reference to an entity with external linkage is encoded with
"L<mangled name>E".
For example:
--- 4353,4374 ----
Literal arguments, e.g. "A<42L>",
are encoded with their type and value.
Negative integer values are preceded with "n";
for example, "A<-42L>" becomes "1AILln42EE".
The bool value false is encoded as 0, true as 1.
!
! <p>
! Floating-point literals are encoded using a fixed-length lowercase
! hexadecimal string corresponding to the internal representation (IEEE
! on Itanium), high-order bytes first, without leading zeroes. For
! example: "Lf bf800000 E" is -1.0f on Itanium.
!
! <p>
! The encoding for a literal of an enumerated type is the encoding of the
! type name followed by the encoding of the numeric value of the literal
! in its base integral type
! (which deals with values that don't have names declared in the type).
<p>
A reference to an entity with external linkage is encoded with
"L<mangled name>E".
For example:
*************** simplification,
*** 4386,4423 ****
and without parentheses, which are implicit in the prefix representation.
Except for the parentheses, therefore,
it represents the source token stream.
(C++ Standard reference 14.5.5.1 p. 5.)
- <pre><font color=blue><code>
- <expression> ::= <<i>unary</i> operator-name> <expression>
- ::= <<i>binary</i> operator-name> <expression> <expression>
- ::= <<i>trinary</i> operator-name> <expression> <expression> <expression>
- ::= st <type>
- ::= <expr-primary>
- <expr-primary> ::= <template-param>
- ::= L <type> <<i>value</i> number> E # literal
- ::= L <mangled-name> E # external name
-
- </pre></font></code>
-
<p>
! Template arguments that could be pointer-to-member constants are
! difficult because it is often not possible to distinguish them from
! pointers to static member functions or data members without doing the
! substitution.
! Therefore, the <i>scope resolution</i> (sr) mangling operator is used
! if the LHS operand of :: involves a template parameter.
! Ignoring substitutions, <code>&T::j</code> as a template argument
! would be encoded <code>Xadsr1T1jE</code>.
!
! <p>
! The encoding for a literal of an enumerated type is the encoding of the
! type name followed by the encoding of the numeric value of the literal
! in its base integral type
! (which deals with values that don't have names declared in the type).
!
<p>
<a name=mangling-scope>
<h4> 5.1.6 Scope Encoding </h4>
--- 4404,4420 ----
and without parentheses, which are implicit in the prefix representation.
Except for the parentheses, therefore,
it represents the source token stream.
(C++ Standard reference 14.5.5.1 p. 5.)
<p>
! If an expression is a qualified-name, and the qualifying scope is a
! dependent type, one of the <code>sr</code> productions is used, rather
! than the <code><mangled-name></code> production. If the qualified
! name refers to an operator for which both unary and binary manglings
! are available, the mangling chosen is the mangling for the binary
! version.
<p>
<a name=mangling-scope>
<h4> 5.1.6 Scope Encoding </h4>
*************** unwind table location.
*** 4871,4880 ****
--- 4868,4885 ----
<p> <hr> <p>
<a name=revisions>
<h2> Appendix R: Revision History </h2>
<p> <hr> <p>
+
+ <p>
+ <font color=blue>[021016]</font>
+ Clarify mangling of floating-point literals.
<p>
<font color=blue>[021011]</font>
Add mangling for unary plus.
More information about the cxx-abi-dev
mailing list