-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'junghee/alignment' into 'main'
Add alignment for instructions that require alignment Closes #544 See merge request rewriting/ddisasm!1203
- Loading branch information
Showing
7 changed files
with
166 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
all: ex_original.s | ||
gcc ex_original.s -o ex | ||
@./ex > out.txt | ||
clean: | ||
rm -f ex out.txt | ||
rm -fr ex.unstripped ex.s *.old* dl_files *.gtirb | ||
check: | ||
./ex > /tmp/res.txt | ||
@ diff out.txt /tmp/res.txt && echo TEST OK |
82 changes: 82 additions & 0 deletions
82
examples/asm_examples/ex_aligned_data_in_code/ex_original.s
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,82 @@ | ||
# This example is to demonostrate that data-in-code is properly aligned | ||
# when it is referenced by instructions that require explicitly aligned memory. | ||
# If not properly aligned, it may cause a segmentation fault due to alignment | ||
# requirement violation. | ||
# See Table 15-6 in https://cdrdv2.intel.com/v1/dl/getContent/671200. | ||
|
||
.section .text | ||
|
||
.globl main | ||
.type main, @function | ||
main: | ||
call print_message1 | ||
|
||
# Load data into XMM register using movdqa: `data128.1` needs to be aligned. | ||
movdqa data128.1(%rip), %xmm0 | ||
|
||
# A pair of instructions from an access to `data128.2`, which needs to | ||
# be aligned. | ||
lea data128.2(%rip), %rax | ||
movdqa 0(%rax), %xmm1 | ||
|
||
# Load data into YMM register using movdqa: `data256` needs to be aligned. | ||
vmovapd data256(%rip), %ymm0 | ||
|
||
# Load data into ZMM register using movdqa: `data512` needs to be aligned. | ||
vmovaps data512(%rip), %zmm0 | ||
|
||
# Load data into ZMM register using vmovups: `data512u` does not need to be aligned. | ||
vmovups data512u(%rip), %zmm1 | ||
|
||
call print_message2 | ||
|
||
xorq %rax, %rax | ||
|
||
ret | ||
|
||
.type print_message1, @function | ||
print_message1: | ||
lea message1(%rip), %rdi | ||
call printf | ||
ret | ||
|
||
.align 16 | ||
.type print_message2, @function | ||
print_message2: | ||
lea message2(%rip), %rdi | ||
call printf | ||
ret | ||
.zero 3 | ||
|
||
.align 16 | ||
data128.1: | ||
.byte 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 | ||
.align 16 | ||
data128.2: | ||
.byte 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 | ||
.align 32 | ||
data256: | ||
.byte 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 | ||
.byte 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 | ||
.align 64 | ||
data512: | ||
.byte 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 | ||
.byte 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 | ||
.byte 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 | ||
.byte 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 | ||
|
||
.zero 3 | ||
data512u: | ||
.byte 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 | ||
.byte 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 | ||
.byte 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 | ||
.byte 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 | ||
|
||
.section .data | ||
|
||
message1: | ||
.ascii "Performing SIMD operations...\n" | ||
.byte 0 | ||
message2: | ||
.ascii "SIMD operations completed.\n" | ||
.byte 0 |
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