<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    On 3/21/11 2:00 PM, Damien Vincent wrote:
    <blockquote
      cite="mid:AANLkTi=bY9f7NYEcPupenOFFMv+qgHqZHtScP3qvFCUV@mail.gmail.com"
      type="cite">I reply to myself... I didn't go in the right
      direction in my previous email.<br>
      <br>
      There is an easy way to tell if a GlobalValue corresponds to data
      or code:<br>
      const GlobalValue *GV;<br>
      if(Function::classof(GV)) <br>
         ... // process the global value as a function<br>
      else<br>
        ... // process the global value as data<br>
      <br>
        Damien<br>
    </blockquote>
    <br>
    You should be able to use isa<Function>(GV) to determine if GV
    is a function.  You may have to put in an additional check to see if
    GV is a GlobalAlias and to determine if the GlobalAlias is an alias
    for a function:<br>
    <br>
    if (GlobalAlias * GA = dyn_cast<GlobalAlias>(GV)) {<br>
        ... Check to see if GA is an alias for a function<br>
    }<br>
    <br>
    I recommend looking at the doxygen documentation on llvm.org to
    learn the class hierarchy relationships between GlobalValue,
    GlobalVariable, GlobalAlias, and Function.  You should also read the
    Programmer's Guide to get familiar with the isa<>() and
    dyn_cast<>() functions if you are not familiar with them
    already.<br>
    <br>
    -- John T.<br>
    <br>
    <blockquote
      cite="mid:AANLkTi=bY9f7NYEcPupenOFFMv+qgHqZHtScP3qvFCUV@mail.gmail.com"
      type="cite"><br>
      <br>
      <br>
      <br>
      <div class="gmail_quote">On Fri, Mar 18, 2011 at 3:16 PM, Damien
        Vincent <span dir="ltr"><<a moz-do-not-send="true"
            href="mailto:damien.llvm@gmail.com">damien.llvm@gmail.com</a>></span>
        wrote:<br>
        <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
          0.8ex; border-left: 1px solid rgb(204, 204, 204);
          padding-left: 1ex;"><br>
          I am again calling for help from LLVM developers ;)<br>
          <br>
          For my DSP backend, at the lowering stage and also at the
          AsmPrinter stage, I need to know if a GlobalAddress is a code
          or a data address.<br>
          <br>
          So I tried at the lowering stage to use: <br>
          GlobalAddressSDNode *GSDN =
          cast<GlobalAddressSDNode>(Op);<br>
          const GlobalValue *GV = GSDN->getGlobal();<br>
          GV->hasSection()  and  GV->getSection()<br>
          But the section is not set at this stage (hasSection = false)<br>
          <br>
          And at the AsmPrinter stage: <br>
          const GlobalValue *GV = MO.getGlobal();<br>
          SectionKind sectionKind =
          Mang->getSymbol(GV)->getSection().getKind();<br>
          But again the section does not seem to be set
          (sectionKind.isInSection() = false)<br>
          <br>
          Do you know a way to tell if a global address corresponds to
          data or code ? I have to process differently text and data
          address...<br>
          <br>
            Thank you !<br>
          <font color="#888888"><br>
              Damien<br>
            <br>
          </font></blockquote>
      </div>
      <br>
    </blockquote>
    <br>
  </body>
</html>