<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 6/15/2017 4:06 AM, 陳韋任 via llvm-dev
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAFSLk9dL8LVbc7mACcSb9TsSciCd9GtPXVh1VHWb+tskSqMHVg@mail.gmail.com">
      <div dir="ltr">
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif">Hi Mats,</div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif"><br>
        </div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif">  It's private
          backend. I will try describing what I am dealing with.</div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif"><br>
        </div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif">    struct S {</div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif">      unsigned
          int a : 8;</div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif">      unsigned
          int b : 8;</div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif">      unsigned
          int c : 8;</div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif">      unsigned
          int d : 8;</div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif"><br>
        </div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif">      unsigned
          int e;</div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif">    }</div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif"><br>
        </div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif">We want to read
          S->b for example. The size of struct S is 64 bits, and
          seems LLVM treats it as i64.</div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif">Below is the IR
          corresponding to S->b, IIRC. </div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif"><br>
        </div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif">    %0 = load
          i64, *i64 ptr, align 4;</div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif">    %1 = %0
          lshr 8;</div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif">    %2 = %1 and
          255;</div>
      </div>
    </blockquote>
    <br>
    This looks fine.<br>
    <br>
    <blockquote type="cite"
cite="mid:CAFSLk9dL8LVbc7mACcSb9TsSciCd9GtPXVh1VHWb+tskSqMHVg@mail.gmail.com">
      <div dir="ltr">
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif"><br>
        </div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif">Our target
          doesn't support load i64, so we have following code
          in XXXISelLowering.cpp</div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif"><br>
        </div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif"> 
            setOperationAction(ISD::LOAD, MVT::i64, Custom);</div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif">  </div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif">Transform load
          i64 to load v2i32 during type legalization.</div>
      </div>
    </blockquote>
    <br>
    If misaligned load v2i32 isn't legal, don't generate it.  If it is
    legal, you might need to mess with your implementation of
    allowsMisalignedMemoryAccesses.<br>
    <br>
    <blockquote type="cite"
cite="mid:CAFSLk9dL8LVbc7mACcSb9TsSciCd9GtPXVh1VHWb+tskSqMHVg@mail.gmail.com">
      <div dir="ltr">
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif">Besides of
          that, our target has bitset/bitextract instructions, we want
          to use them on bitfield</div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif">access, too.
          But don't know how to do that.</div>
      </div>
    </blockquote>
    <br>
    This is generally implemented by pattern-matching the shift and mask
    operations.  ARM has instructions like this if you're looking for
    inspiration; look for UBFX, SBFX and BFI.<br>
    <br>
    -Eli<br>
    <pre class="moz-signature" cols="72">-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project</pre>
  </body>
</html>