-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[MIPS][float] Fixed SingleFloat codegen on N32/N64 targets #140575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
148 changes: 148 additions & 0 deletions
148
llvm/test/CodeGen/Mips/cconv/arguments-hard-single-float-varargs.ll
This file contains hidden or 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,148 @@ | ||
| ; RUN: llc -mtriple=mips -relocation-model=static -mattr=single-float < %s \ | ||
| ; RUN: | FileCheck --check-prefixes=ALL,SYM32,O32 %s | ||
| ; RUN: llc -mtriple=mipsel -relocation-model=static -mattr=single-float < %s \ | ||
| ; RUN: | FileCheck --check-prefixes=ALL,SYM32,O32 %s | ||
|
|
||
| ; RUN: llc -mtriple=mips64 -relocation-model=static -target-abi n32 -mattr=single-float < %s \ | ||
| ; RUN: | FileCheck --check-prefixes=ALL,SYM32,N32,NEW,NEWBE %s | ||
| ; RUN: llc -mtriple=mips64el -relocation-model=static -target-abi n32 -mattr=single-float < %s \ | ||
| ; RUN: | FileCheck --check-prefixes=ALL,SYM32,N32,NEW,NEWLE %s | ||
|
|
||
| ; RUN: llc -mtriple=mips64 -relocation-model=static -target-abi n64 -mattr=single-float < %s \ | ||
| ; RUN: | FileCheck --check-prefixes=ALL,SYM64,N64,NEW,NEWBE %s | ||
| ; RUN: llc -mtriple=mips64el -relocation-model=static -target-abi n64 -mattr=single-float < %s \ | ||
| ; RUN: | FileCheck --check-prefixes=ALL,SYM64,N64,NEW,NEWLE %s | ||
|
|
||
| @floats = global [11 x float] zeroinitializer | ||
| @doubles = global [11 x double] zeroinitializer | ||
|
|
||
| define void @double_args(double %a, ...) | ||
| nounwind { | ||
| entry: | ||
| %0 = getelementptr [11 x double], ptr @doubles, i32 0, i32 1 | ||
| store volatile double %a, ptr %0 | ||
|
|
||
| %ap = alloca ptr | ||
| call void @llvm.va_start(ptr %ap) | ||
| %b = va_arg ptr %ap, double | ||
| %1 = getelementptr [11 x double], ptr @doubles, i32 0, i32 2 | ||
| store volatile double %b, ptr %1 | ||
| call void @llvm.va_end(ptr %ap) | ||
| ret void | ||
| } | ||
|
|
||
| ; ALL-LABEL: double_args: | ||
| ; We won't test the way the global address is calculated in this test. This is | ||
| ; just to get the register number for the other checks. | ||
| ; SYM32-DAG: addiu [[R2:\$[0-9]+]], ${{[0-9]+}}, %lo(doubles) | ||
| ; SYM64-DAG: daddiu [[R2:\$[0-9]+]], ${{[0-9]+}}, %lo(doubles) | ||
|
|
||
| ; O32 forbids using floating point registers for the non-variable portion. | ||
| ; N32/N64 allow it. | ||
| ; O32-DAG: sw $4, 8([[R2]]) | ||
| ; O32-DAG: sw $5, 12([[R2]]) | ||
| ; NEW-DAG: sd $4, 8([[R2]]) | ||
|
|
||
| ; The varargs portion is dumped to stack | ||
| ; O32-DAG: sw $6, 16($sp) | ||
| ; O32-DAG: sw $7, 20($sp) | ||
| ; NEW-DAG: sd $5, 8($sp) | ||
| ; NEW-DAG: sd $6, 16($sp) | ||
| ; NEW-DAG: sd $7, 24($sp) | ||
| ; NEW-DAG: sd $8, 32($sp) | ||
| ; NEW-DAG: sd $9, 40($sp) | ||
| ; NEW-DAG: sd $10, 48($sp) | ||
| ; NEW-DAG: sd $11, 56($sp) | ||
|
|
||
| ; Get the varargs pointer | ||
| ; O32 has 4 bytes padding, 4 bytes for the varargs pointer, and 8 bytes reserved | ||
| ; for arguments 1 and 2. | ||
| ; N32/N64 has 8 bytes for the varargs pointer, and no reserved area. | ||
| ; O32-DAG: addiu [[VAPTR:\$[0-9]+]], $sp, 16 | ||
| ; O32-DAG: sw [[VAPTR]], 4($sp) | ||
| ; N32-DAG: addiu [[VAPTR:\$[0-9]+]], $sp, 8 | ||
| ; N32-DAG: sw [[VAPTR]], 4($sp) | ||
| ; N64-DAG: daddiu [[VAPTR:\$[0-9]+]], $sp, 8 | ||
| ; N64-DAG: sd [[VAPTR]], 0($sp) | ||
|
|
||
| ; Increment the pointer then get the varargs arg | ||
| ; LLVM will rebind the load to the stack pointer instead of the varargs pointer | ||
| ; during lowering. This is fine and doesn't change the behaviour. | ||
| ; O32-DAG: addiu [[VAPTR]], [[VAPTR]], 8 | ||
| ; N32-DAG: addiu [[VAPTR]], [[VAPTR]], 8 | ||
| ; N64-DAG: daddiu [[VAPTR]], [[VAPTR]], 8 | ||
| ; O32-DAG: lw [[R3:\$[0-9]+]], 16($sp) | ||
| ; O32-DAG: lw [[R4:\$[0-9]+]], 20($sp) | ||
| ; O32-DAG: sw [[R3]], 16([[R2]]) | ||
| ; O32-DAG: sw [[R4]], 20([[R2]]) | ||
| ; NEW-DAG: ld [[R3:\$[0-9]+]], 8($sp) | ||
| ; NEW-DAG: sd [[R3]], 16([[R2]]) | ||
|
|
||
| define void @float_args(float %a, ...) nounwind { | ||
| entry: | ||
| %0 = getelementptr [11 x float], ptr @floats, i32 0, i32 1 | ||
| store volatile float %a, ptr %0 | ||
|
|
||
| %ap = alloca ptr | ||
| call void @llvm.va_start(ptr %ap) | ||
| %b = va_arg ptr %ap, float | ||
| %1 = getelementptr [11 x float], ptr @floats, i32 0, i32 2 | ||
| store volatile float %b, ptr %1 | ||
| call void @llvm.va_end(ptr %ap) | ||
| ret void | ||
| } | ||
|
|
||
| ; ALL-LABEL: float_args: | ||
| ; We won't test the way the global address is calculated in this test. This is | ||
| ; just to get the register number for the other checks. | ||
| ; SYM32-DAG: addiu [[R2:\$[0-9]+]], ${{[0-9]+}}, %lo(floats) | ||
| ; SYM64-DAG: daddiu [[R2:\$[0-9]+]], ${{[0-9]+}}, %lo(floats) | ||
|
|
||
| ; The first four arguments are the same in O32/N32/N64. | ||
| ; The non-variable portion should be unaffected. | ||
| ; O32-DAG: mtc1 $4, $f0 | ||
| ; O32-DAG: swc1 $f0, 4([[R2]]) | ||
| ; NEW-DAG: swc1 $f12, 4([[R2]]) | ||
|
|
||
| ; The varargs portion is dumped to stack | ||
| ; O32-DAG: sw $5, 12($sp) | ||
| ; O32-DAG: sw $6, 16($sp) | ||
| ; O32-DAG: sw $7, 20($sp) | ||
| ; NEW-DAG: sd $5, 8($sp) | ||
| ; NEW-DAG: sd $6, 16($sp) | ||
| ; NEW-DAG: sd $7, 24($sp) | ||
| ; NEW-DAG: sd $8, 32($sp) | ||
| ; NEW-DAG: sd $9, 40($sp) | ||
| ; NEW-DAG: sd $10, 48($sp) | ||
| ; NEW-DAG: sd $11, 56($sp) | ||
|
|
||
| ; Get the varargs pointer | ||
| ; O32 has 4 bytes padding, 4 bytes for the varargs pointer, and should have 8 | ||
| ; bytes reserved for arguments 1 and 2 (the first float arg) but as discussed in | ||
| ; arguments-float.ll, GCC doesn't agree with MD00305 and treats floats as 4 | ||
| ; bytes so we only have 12 bytes total. | ||
| ; N32/N64 has 8 bytes for the varargs pointer, and no reserved area. | ||
| ; O32-DAG: addiu [[VAPTR:\$[0-9]+]], $sp, 12 | ||
| ; O32-DAG: sw [[VAPTR]], 4($sp) | ||
| ; N32-DAG: addiu [[VAPTR:\$[0-9]+]], $sp, 8 | ||
| ; N32-DAG: sw [[VAPTR]], 4($sp) | ||
| ; N64-DAG: daddiu [[VAPTR:\$[0-9]+]], $sp, 8 | ||
| ; N64-DAG: sd [[VAPTR]], 0($sp) | ||
|
|
||
| ; Increment the pointer then get the varargs arg | ||
| ; LLVM will rebind the load to the stack pointer instead of the varargs pointer | ||
| ; during lowering. This is fine and doesn't change the behaviour. | ||
| ; Also, in big-endian mode the offset must be increased by 4 to retrieve the | ||
| ; correct half of the argument slot. | ||
| ; | ||
| ; O32-DAG: addiu [[VAPTR]], [[VAPTR]], 4 | ||
| ; N32-DAG: addiu [[VAPTR]], [[VAPTR]], 8 | ||
| ; N64-DAG: daddiu [[VAPTR]], [[VAPTR]], 8 | ||
| ; O32-DAG: lwc1 [[FTMP1:\$f[0-9]+]], 12($sp) | ||
| ; NEWLE-DAG: lwc1 [[FTMP1:\$f[0-9]+]], 8($sp) | ||
| ; NEWBE-DAG: lwc1 [[FTMP1:\$f[0-9]+]], 12($sp) | ||
| ; ALL-DAG: swc1 [[FTMP1]], 8([[R2]]) | ||
|
|
||
| declare void @llvm.va_start(ptr) | ||
| declare void @llvm.va_copy(ptr, ptr) | ||
| declare void @llvm.va_end(ptr) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.