-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIPS] Introduce NAL instruction support for Mipsr6 and prer6 (#84429)
NAL is an assembly idiom on Pre-R6 instruction sets (which is implemented in binutils), or an actual instruction on Release 6 instruction set, and is used to read the PC, due to the nature of the MIPS architecture. Since we can't read the PC directly, on pre-R6 we use a always-not-taken Branch and Link operation to the address of the next instruction, which effectively writes the address to $31, thus PC is read with offset +8. MIPS Release 6 removed the conventional Branch and Link instructions, but kept NAL as an actual instruction for compatibility on the assembly level. The instruction has the same encoding of the pre-R6 ones, and with the same behavior: PC + 8 -> $31.
- Loading branch information
Showing
6 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# RUN: llvm-mc %s -triple=mipsel-linux-gnu -filetype=obj -o - | \ | ||
# RUN: llvm-objdump --no-print-imm-hex -d - | FileCheck %s --check-prefix=MIPS32-EL | ||
# RUN: llvm-mc %s -triple=mips-linux-gnu -filetype=obj -o - | \ | ||
# RUN: llvm-objdump --no-print-imm-hex -d - | FileCheck %s --check-prefix=MIPS32-EB | ||
|
||
# Whether it is a macro or an actual instruction, it always has a delay slot. | ||
# Ensure the delay slot is filled correctly. | ||
# MIPS32-EL: 00 00 10 04 bltzal $zero, 0x4 | ||
# MIPS32-EL-NEXT: 00 00 00 00 nop | ||
# MIPS32-EB: 04 10 00 00 bltzal $zero, 0x4 | ||
# MIPS32-EB-NEXT: 00 00 00 00 nop | ||
|
||
nal_test: | ||
nal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# RUN: llvm-mc %s -triple=mipsisa32r6el-linux-gnu -filetype=obj -o - | \ | ||
# RUN: llvm-objdump --no-print-imm-hex -d - | FileCheck %s --check-prefix=MIPS32R6-EL | ||
# RUN: llvm-mc %s -triple=mipsisa32r6-linux-gnu -filetype=obj -o - | \ | ||
# RUN: llvm-objdump --no-print-imm-hex -d - | FileCheck %s --check-prefix=MIPS32R6-EB | ||
|
||
# Whether it is a macro or an actual instruction, it always has a delay slot. | ||
# Ensure the delay slot is filled correctly. | ||
# Also ensure that NAL does not reside in a forbidden slot. | ||
# MIPS32R6-EL: 00 00 80 f8 bnezc $4, 0x4 | ||
# MIPS32R6-EL-NEXT: 00 00 00 00 nop | ||
# MIPS32R6-EL: 00 00 10 04 nal | ||
# MIPS32R6-EL-NEXT: 00 00 00 00 nop | ||
# MIPS32R6-EB: f8 80 00 00 bnezc $4, 0x4 | ||
# MIPS32R6-EB-NEXT: 00 00 00 00 nop | ||
# MIPS32R6-EB: 04 10 00 00 nal | ||
# MIPS32R6-EB-NEXT: 00 00 00 00 nop | ||
|
||
nal_test: | ||
# We generate a fobidden solt just for testing. | ||
bnezc $a0, 0 | ||
nal |