<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/60218>60218</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [M68k] Missing memory addressing modes for codegen
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            backend:m68k
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          mshockwave
      </td>
    </tr>
</table>

<pre>
    Right now we only support a subset of all memory addressing modes. Though the current set of addressing modes will suffice to codegen most of the code, some of the missing addressing modes can lead to better codegen qualities in certain cases. More importantly, AsmParser and Disassembler depend on these operand declarations too.

Adapted from a similar table in [M68kInstrFormat.td](https://github.com/llvm/llvm-project/blob/898b5c9f5e7715f3ea4bb0ca2a8f23c301efa9c2/llvm/lib/Target/M68k/M68kInstrFormats.td#L11) originally written by Arytom, below is a table of current supporting status for all memory addressing modes. I thought it might be a good idea to track the progress of these addressing modes using this table.

| Form          | Letter |             CodeGen Support            | Shorthand / Description |
|:-----------------------:|:------:|:--------------------------------------:|:---------------------------------------------------------:|
| (An)          |    j   |                    Y                   | ARI: address register indirect              |
|          (An)+ |    o   | partial: ISel function not implemented |    ARIPI: address register indirect with postincrement    |
|          -(An) |    e   | partial: ISel function not implemented |     ARIPD: address register indirect with predecrement    |
|          (d,An)         |    p |                    Y                   |     ARID: address register indirect with displacement     |
|       (d,An,Xn.L)       |    f   | Y                   | ARII: address register indirect with index and scale == 1 |
|       (d,An,Xn.W)       |    F   | N                   | ARII: address register indirect with index and scale == 1 |
|    (d,An,Xn.L,SCALE)    |    g   |                    N |         ARII: address register indirect with index |
|    (d,An,Xn.W,SCALE)    |    G   |                    N |         ARII: address register indirect with index        |
| ([bd,An],Xn.L,SCALE,od) |    u   |                    N                   | memory indirect postindexed mode             |
| ([bd,An],Xn.W,SCALE,od) |    U   |                    N                   | memory indirect postindexed mode             |
| ([bd,An,Xn.L,SCALE],od) |    v   |                    N                   | memory indirect preindexed mode              |
| ([bd,An,Xn.W,SCALE],od) |    V   |                    N                   | memory indirect preindexed mode              |
|          abs.L |    b   |                    Y                   | AL: absolute long address                 |
|          abs.W          | B   | partial: ISel function not implemented |                 AS: absolute long address                 |
|          (d,PC)         |    q   | Y                   |           PCD: program counter with displacement          |
|       (d,PC,Xn.L)       |    k   | Y                   |       PCI: program counter with index and scale == 1      |
|       (d,PC,Xn.W)       |    K   |                    N |       PCI: program counter with index and scale == 1      |
| (d,PC,Xn.L,SCALE)    |    l   |                    N                   | PCI: program counter with index              |
| (d,PC,Xn.W,SCALE)    |    L   |                    N                   | PCI: program counter with index              |
| ([bd,PC],Xn.L,SCALE,od) |    x   |                    N                   | program counter memory indirect postindexed mode     |
| ([bd,PC],Xn.W,SCALE,od) |    X   |                    N                   | program counter memory indirect postindexed mode     |
| ([bd,PC,Xn.L,SCALE],od) |    y   |                    N                   | program counter memory indirect preindexed mode      |
| ([bd,PC,Xn.W,SCALE],od) |    Y   |                    N                   | program counter memory indirect preindexed mode      |

For explanations of these addressing modes, please refer to Section 2.2 in the [M68k Programmers' Manual](https://m680x0.github.io/ref/M68000PM_AD_Rev_1_Programmers_Reference_Manual_1992.html).

I think we can start from the low-hanging fruits like 'o', 'e', and 'B' to finish their missing functionalities first.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEmN9z2ygQx_8a_LITj4x_P_jBsc-dzCUdT9K7tE8ZJFYSDQIVUBz_9zfI8m8rdnptykNEJFg-wLJrvsxakSjEEelek-60wQqXajPKbKqj5wV7wUao-XJ0L5LUgdILWCBoJZdgizzXxgEDW4QWHegYmJSQYabNEhjnBq0VKoFMc7RN-JLqIknBpQhRYQwqB-tuB21hIaQEW8SxiBCchkhzTFBBpm3ZobShORI6AaszXL_LxMrKkcGIKZDIuDcWonNoNjZ_FEwKJ9CCUBChccw_mfXId9ogiMzPkyknl368sc3mzFg0wBSHqbDMWsxCiQY45qg4aOVh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