Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

ARM64: Switch Expansion Using Jump Table#4919

Merged
kyulee1 merged 1 commit into
dotnet:masterfrom
kyulee1:switch
May 12, 2016
Merged

ARM64: Switch Expansion Using Jump Table#4919
kyulee1 merged 1 commit into
dotnet:masterfrom
kyulee1:switch

Conversation

@kyulee1
Copy link
Copy Markdown

@kyulee1 kyulee1 commented May 11, 2016

Fixes #3332
To validate various addressing in #4896, I just enable this.
Previously, we only allow a load operation to JIT data (ldr or
IF_LARGELDC).
For switch expansion, jump table is also recorded into JIT data.
In this case, we only get the address of jump table head, and
load the right entry after computing offset. So, basically adr or
IF_LARGEADR is used to not only load label within code but also refer to
the location of JIT data.
The typical code sequence for switch expansion is like this:

  adr     x8, [@RWD00]          // load address of jump table head
  ldr     w8, [x8, x0, LSL #2]  // load jump entry from table addr + x0 * 4
  adr     x9, [G_M56320_IG02]   // load address of current baisc block
  add     x8, x8, x9            // Add them to compute the final target
  br      x8                    // Indirectly jump to the target

@kyulee1
Copy link
Copy Markdown
Author

kyulee1 commented May 11, 2016

@dotnet-bot test Windows_NT arm64 Checked
@dotnet-bot test Windows_NT arm64 Release

@kyulee1
Copy link
Copy Markdown
Author

kyulee1 commented May 11, 2016

Since #4896 is not reviewed yet, I integrate both commits here. Please review the latter part in this PR.
@dotnet/jit-contrib @dotnet/arm64-contrib PTAL

@kyulee1
Copy link
Copy Markdown
Author

kyulee1 commented May 11, 2016

@dotnet-bot test Windows_NT arm64 Release

Comment thread src/jit/emit.h
case IF_LARGELDC:
if (isVectorRegister(idReg1()))
{
// adrp + ldr + fmov
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this comment read:
// adrp + add + fmov

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is meant for ldr as it is instead of add. The change is from the previous commit. As mentioned in this PR, I'd like the latter part (3173d5b) to be reviewed in this PR. Can you please review the previous CR first -
#4896 ?

@kyulee1
Copy link
Copy Markdown
Author

kyulee1 commented May 12, 2016

The test failure seems Jenkin's issue since the actual test results are all passed in cloud storage.
@dotnet-bot test Windows_NT arm64 Checked

Comment thread src/jit/emitarm64.cpp
case INS_strb:
case INS_strh:
emitIns_R_R_R_Ext(ins, attr, reg1, reg2, reg3);
emitIns_R_R_R_Ext(ins, attr, reg1, reg2, reg3, opt);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good fix

@briansull
Copy link
Copy Markdown

Looks Good

@kyulee1
Copy link
Copy Markdown
Author

kyulee1 commented May 12, 2016

@dotnet-bot test Windows_NT arm64 Checked

Fixes #3332
To validate various addressing in dotnet#4896, I just enable this.
Previously, we only allow a load operation to JIT data (`ldr` or
`IF_LARGELDC`).
For switch expansion, jump table is also recorded into JIT data.
In this case, we only get the address of jump table head, and
load the right entry after computing offset. So, basically `adr` or
`IF_LARGEADR` is used to not only load label within code but also refer to
the location of JIT data.
The typical code sequence for switch expansion is like this:

```
  adr     x8, [@rwd00]          // load address of jump table head
  ldr     w8, [x8, x0, LSL dotnet#2]  // load jump entry from table addr + x0 * 4
  adr     x9, [G_M56320_IG02]   // load address of current baisc block
  add     x8, x8, x9            // Add them to compute the final target
  br      x8                    // Indirectly jump to the target
```
@kyulee1 kyulee1 merged commit 6d550d7 into dotnet:master May 12, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
ARM64: Switch Expansion Using Jump Table

Commit migrated from dotnet/coreclr@6d550d7
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants