<meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  
  
    <div class="moz-cite-prefix">Dear Duancan Ciao,<br>
      <br>
      Your suggestion is really helpful. <br>
      Thank you very much.<br>
      <br>
      Best regards,<br>
      <br>
      On 1/18/2013 5:04 PM, Duncan Sands [via LLVM] wrote:<br>
    </div>
    <blockquote style='border-left:2px solid #CCCCCC;padding:0 1em' cite="mid:50F90FC0.3080504@free.fr" type="cite"> Hi
      Cheng,
      <br>
      <br>
      On 18/01/13 03:00, Cheng Liu wrote:
      <br>
      > I have a loop fully unrolled and got the following store
      instruction.
      <br>
      >
      <br>
      > store i32 %add.3, i32* getelementptr inbounds ([20 x [20 x
      i32]]* @c, i32 0,
      <br>
      > i32 0, i32 0), align 4
      <br>
      >
      <br>
      > I want to know exactly which element of the array that is
      going to be
      <br>
      > stored, which help me to transform the high level language to
      hardware. Take
      <br>
      > the instruction above as an example, I know the data is
      stored into c[0][0].
      <br>
      > It is just that I don't how to get c, 0, 0 from the
      instruction.
      <br>
      <br>
      this bit
      <br>
         i32* getelementptr inbounds ([20 x [20 x i32]]* @c, i32 0, i32
      0, i32 0)
      <br>
      is a constant expression (ConstantExpr class), not an instruction
      (you can
      <br>
      tell because it is printed inline).
      <br>
      <br>
      If SI is your store instruction (with type StoreInst*) then using
      <br>
         SI->getPointerOperand()
      <br>
      you get the stored to pointer.  Call the result Ptr.
      <br>
      <br>
      You can cast that to a ConstantExpr* using
      <br>
         cast<ConstantExpr>(Ptr)
      <br>
      This will assert if Ptr isn't a constant expression.  You can use
      dyn_cast
      <br>
      instead which will return null if it isn't a constant expression.
       At this
      <br>
      point you can rummage around inside the constant expression.  It
      is probably
      <br>
      simpler though to #include the Operator.h header, and cast Ptr to
      the
      <br>
      GEPOperator class instead.
      <br>
      <br>
      Ciao, Duncan.
      <br>
      <br>
      >
      <br>
      > At the moment, I use the method getNumOperands() and
      getOperand( int i) to
      <br>
      > check all the operands of the instruction. However, I can
      only get two
      <br>
      > operands. One of them is the data %add.s, and the other is
      the pointer. The
      <br>
      > pointer has no name and it is not a constant.
      <br>
      <br>
      Yes, it is a constant (Constant class).
      <br>
      <br>
        I couldn't move further into
      <div class="shrinkable-quote"><br>
        > the pointer to get the index of the element.
        <br>
        >
        <br>
        > Anyone could give me some suggestions on this?
        <br>
        >
        <br>
        >
        <br>
        >
        <br>
        > --
        <br>
        > View this message in context: <a moz-do-not-send="true"
href="http://llvm.1065342.n5.nabble.com/How-to-get-more-details-from-storeInst-tp53841.html"
          target="_top" rel="nofollow" link="external">http://llvm.1065342.n5.nabble.com/How-to-get-more-details-from-storeInst-tp53841.html</a><br>
        > Sent from the LLVM - Dev mailing list archive at
        Nabble.com.
        <br>
        > _______________________________________________
        <br>
        > LLVM Developers mailing list
        <br>
        > <a moz-do-not-send="true"
          href="/user/SendEmail.jtp?type=node&node=53853&i=0"
          target="_top" rel="nofollow" link="external">[hidden email]</a>
                <a moz-do-not-send="true"
          href="http://llvm.cs.uiuc.edu" target="_top" rel="nofollow" link="external">http://llvm.cs.uiuc.edu</a><br>
        > <a moz-do-not-send="true"
          href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev"
          target="_top" rel="nofollow" link="external">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
        >
      </div>
      <br>
      _______________________________________________
      <br>
      LLVM Developers mailing list
      <br>
      <a moz-do-not-send="true"
        href="/user/SendEmail.jtp?type=node&node=53853&i=1"
        target="_top" rel="nofollow" link="external">[hidden email]</a>
              <a moz-do-not-send="true" href="http://llvm.cs.uiuc.edu"
        target="_top" rel="nofollow" link="external">http://llvm.cs.uiuc.edu</a><br>
      <a moz-do-not-send="true"
        href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev"
        target="_top" rel="nofollow" link="external">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
      <br>
      <br>
      <hr noshade="noshade" size="1" color="#cccccc">
      <div style="color:#444; font: 12px
        tahoma,geneva,helvetica,arial,sans-serif;">
        <div style="font-weight:bold">If you reply to this email, your
          message will be added to the discussion below:</div>
        <a moz-do-not-send="true"
href="http://llvm.1065342.n5.nabble.com/How-to-get-more-details-from-storeInst-tp53841p53853.html" target="_top" rel="nofollow" link="external">http://llvm.1065342.n5.nabble.com/How-to-get-more-details-from-storeInst-tp53841p53853.html</a>
      </div>
      <div style="color:#666; font: 11px
tahoma,geneva,helvetica,arial,sans-serif;margin-top:.4em;line-height:1.5em">
        To unsubscribe from How to get more details from storeInst ?, <a
          moz-do-not-send="true"
href="" target="_top" rel="nofollow" link="external">click
          here</a>.<br>
        <a moz-do-not-send="true"
href="http://llvm.1065342.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml" rel="nofollow" style="font:9px serif" target="_top" link="external">NAML</a> </div>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Cheng Liu
PhD Candidate
Electrical and Electronic Engineering
The University of Hong Kong</pre>
  



        
        
        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://llvm.1065342.n5.nabble.com/How-to-get-more-details-from-storeInst-tp53841p54002.html">Re: How to get more details from storeInst ?</a><br/>
Sent from the <a href="http://llvm.1065342.n5.nabble.com/LLVM-Dev-f3.html">LLVM - Dev mailing list archive</a> at Nabble.com.<br/>