<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    I finally closed the loop on the requested changes in 222707.  Sorry
    for the delay.<br>
    <br>
    Philip<br>
    <br>
    <div class="moz-cite-prefix">On 11/11/2014 04:44 PM, Sean Silva
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAHnXoakcMi2vEoRtw6HD_yNwe2sjoDUQ82m2bF837Lk9xnW-ZQ@mail.gmail.com"
      type="cite">
      <div dir="ltr"><br>
        <div class="gmail_extra"><br>
          <div class="gmail_quote">On Tue, Nov 11, 2014 at 4:42 PM,
            Philip Reames <span dir="ltr"><<a moz-do-not-send="true"
                href="mailto:listmail@philipreames.com" target="_blank">listmail@philipreames.com</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div bgcolor="#FFFFFF" text="#000000"><span class=""> <br>
                  <div>On 11/11/2014 04:33 PM, Sean Silva wrote:<br>
                  </div>
                  <blockquote type="cite">
                    <div dir="ltr">
                      <div><font face="arial, sans-serif">Can you please
                          beef up the comment to give a
                          declarative/human-readable description of the
                          mangling scheme? <br>
                        </font></div>
                    </div>
                  </blockquote>
                </span><font face="arial, sans-serif">Sure.  Will
                  address in a follow up commit.  (Without further
                  review unless you object.)</font></div>
            </blockquote>
            <div><br>
            </div>
            <div>Go for it.</div>
            <div> </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div bgcolor="#FFFFFF" text="#000000"><span class=""><br>
                  <blockquote type="cite">
                    <div dir="ltr">
                      <div><font face="arial, sans-serif"><br>
                        </font></div>
                      <div><font face="arial, sans-serif">Also, would it
                          make sense to document this mangling in
                          LangRef?</font></div>
                    </div>
                  </blockquote>
                </span><font face="arial, sans-serif">It is currently
                  not documented.   I don't have a strong opinion, but
                  would lean towards not documenting it.  It's arguably
                  an internal implementation detail.   There's enough
                  rough edges around this mechanism that I'm really
                  reluctant to encourage it's use, except through the
                  programmatic APIs.  (For example, if you get the
                  naming wrong, it's a silent codegen problem.  This is
                  not new.)<br>
                </font></div>
            </blockquote>
            <div><br>
            </div>
            <div>Makes sense.</div>
            <div><br>
            </div>
            <div>-- Sean Silva</div>
            <div> </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div bgcolor="#FFFFFF" text="#000000"><font face="arial,
                  sans-serif"> <br>
                  For context, there's discussion of removing this
                  mechanism entirely since it makes the code much harder
                  to read.  That change (which might include special
                  casing type rules around intrinsics) will definitely
                  need broader review and documentation.  </font><br>
                <span class="">
                  <blockquote type="cite">
                    <div dir="ltr"><span
                        style="font-family:arial,sans-serif;font-size:13px">
                        <div><span
                            style="font-family:arial,sans-serif;font-size:13px"><br>
                          </span></div>
                        <div><span
                            style="font-family:arial,sans-serif;font-size:13px"><br>
                          </span></div>
                        <div>One nit:<br>
                        </div>
                        <div><span
                            style="font-family:arial,sans-serif;font-size:13px"><br>
                          </span></div>
                        +    Result += "f"; //ensure distinguishable</span>
                      <div><br>
                        <div><font face="arial, sans-serif">"... use
                            proper capitalization, punctuation, etc
                            ...." </font><a moz-do-not-send="true"
                            href="http://llvm.org/docs/CodingStandards.html#commenting"
                            target="_blank">http://llvm.org/docs/CodingStandards.html#commenting</a><br>
                        </div>
                      </div>
                    </div>
                  </blockquote>
                </span> Will fix in follow up.
                <div>
                  <div class="h5"><br>
                    <blockquote type="cite">
                      <div dir="ltr">
                        <div>
                          <div><br>
                          </div>
                          <div>-- Sean Silva</div>
                        </div>
                      </div>
                      <div class="gmail_extra"><br>
                        <div class="gmail_quote">On Tue, Nov 11, 2014 at
                          4:21 PM, Philip Reames <span dir="ltr"><<a
                              moz-do-not-send="true"
                              href="mailto:listmail@philipreames.com"
                              target="_blank">listmail@philipreames.com</a>></span>
                          wrote:<br>
                          <blockquote class="gmail_quote"
                            style="margin:0 0 0 .8ex;border-left:1px
                            #ccc solid;padding-left:1ex">Author: reames<br>
                            Date: Tue Nov 11 18:21:51 2014<br>
                            New Revision: 221742<br>
                            <br>
                            URL: <a moz-do-not-send="true"
                              href="http://llvm.org/viewvc/llvm-project?rev=221742&view=rev"
                              target="_blank">http://llvm.org/viewvc/llvm-project?rev=221742&view=rev</a><br>
                            Log:<br>
                            Extend intrinsic name mangling to support
                            arrays, named structs, and function types.<br>
                            <br>
                            Currently, we have a type parameter
                            mechanism for intrinsics. Rather than having
                            to specify a separate intrinsic for each
                            combination of argument and return types, we
                            can specify a single intrinsic with one or
                            more type parameters. These type parameters
                            are passed explicitly to
                            Intrinsic::getDeclaration or can be
                            specified implicitly in the naming of the
                            intrinsic function in an LL file.<br>
                            <br>
                            Today, the types are limited to integer,
                            floating point, and pointer types. With a
                            goal of supporting symbolic targets for
                            patchpoints and statepoints, this change
                            adds support for function types.  The change
                            also includes support for first class
                            aggregate types (named structures and
                            arrays) since these appear in function types
                            we've encountered.<br>
                            <br>
                            Reviewed by: atrick, ributzka<br>
                            Differential Revision: <a
                              moz-do-not-send="true"
                              href="http://reviews.llvm.org/D4608"
                              target="_blank">http://reviews.llvm.org/D4608</a><br>
                            <br>
                            <br>
                            Modified:<br>
                                llvm/trunk/lib/IR/Function.cpp<br>
                            <br>
                            Modified: llvm/trunk/lib/IR/Function.cpp<br>
                            URL: <a moz-do-not-send="true"
href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Function.cpp?rev=221742&r1=221741&r2=221742&view=diff"
                              target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Function.cpp?rev=221742&r1=221741&r2=221742&view=diff</a><br>
==============================================================================<br>
                            --- llvm/trunk/lib/IR/Function.cpp
                            (original)<br>
                            +++ llvm/trunk/lib/IR/Function.cpp Tue Nov
                            11 18:21:51 2014<br>
                            @@ -455,6 +455,33 @@ unsigned
                            Function::lookupIntrinsicID() c<br>
                               return 0;<br>
                             }<br>
                            <br>
                            +/// Returns a stable mangling for the type
                            specified for use in the name<br>
                            +/// mangling scheme used by 'any' types in
                            intrinsic signatures.<br>
                            +static std::string getMangledTypeStr(Type*
                            Ty) {<br>
                            +  std::string Result;<br>
                            +  if (PointerType* PTyp =
                            dyn_cast<PointerType>(Ty)) {<br>
                            +    Result += "p" +
                            llvm::utostr(PTyp->getAddressSpace()) +<br>
                            +     
                            getMangledTypeStr(PTyp->getElementType());<br>
                            +  } else if (ArrayType* ATyp =
                            dyn_cast<ArrayType>(Ty)) {<br>
                            +    Result += "a" +
                            llvm::utostr(ATyp->getNumElements()) +<br>
                            +     
                            getMangledTypeStr(ATyp->getElementType());<br>
                            +  } else if (StructType* STyp =
                            dyn_cast<StructType>(Ty)) {<br>
                            +    if (!STyp->isLiteral())<br>
                            +      Result += STyp->getName();<br>
                            +    else<br>
                            +      llvm_unreachable("TODO: implement
                            literal types");<br>
                            +  } else if (FunctionType* FT =
                            dyn_cast<FunctionType>(Ty)) {<br>
                            +    Result += "f_" +
                            getMangledTypeStr(FT->getReturnType());<br>
                            +    for (size_t i = 0; i <
                            FT->getNumParams(); i++)<br>
                            +      Result +=
                            getMangledTypeStr(FT->getParamType(i));<br>
                            +    if (FT->isVarArg())<br>
                            +      Result += "vararg";<br>
                            +    Result += "f"; //ensure distinguishable<br>
                            +  } else if (Ty)<br>
                            +    Result +=
                            EVT::getEVT(Ty).getEVTString();<br>
                            +  return Result;<br>
                            +}<br>
                            +<br>
                             std::string Intrinsic::getName(ID id,
                            ArrayRef<Type*> Tys) {<br>
                               assert(id < num_intrinsics &&
                            "Invalid intrinsic ID!");<br>
                               static const char * const Table[] = {<br>
                            @@ -467,12 +494,7 @@ std::string
                            Intrinsic::getName(ID id, Ar<br>
                                 return Table[id];<br>
                               std::string Result(Table[id]);<br>
                               for (unsigned i = 0; i < Tys.size();
                            ++i) {<br>
                            -    if (PointerType* PTyp =
                            dyn_cast<PointerType>(Tys[i])) {<br>
                            -      Result += ".p" +
                            llvm::utostr(PTyp->getAddressSpace()) +<br>
                            -               
                            EVT::getEVT(PTyp->getElementType()).getEVTString();<br>
                            -    }<br>
                            -    else if (Tys[i])<br>
                            -      Result += "." +
                            EVT::getEVT(Tys[i]).getEVTString();<br>
                            +    Result += "." +
                            getMangledTypeStr(Tys[i]);<br>
                               }<br>
                               return Result;<br>
                             }<br>
                            <br>
                            <br>
_______________________________________________<br>
                            llvm-commits mailing list<br>
                            <a moz-do-not-send="true"
                              href="mailto:llvm-commits@cs.uiuc.edu"
                              target="_blank">llvm-commits@cs.uiuc.edu</a><br>
                            <a moz-do-not-send="true"
                              href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits"
                              target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
                          </blockquote>
                        </div>
                        <br>
                      </div>
                    </blockquote>
                    <br>
                  </div>
                </div>
              </div>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>