xref: /llvm-project/llvm/test/MC/X86/displacement-overflow.s (revision 8a71284cb9463a90fab0d9e8edbeb5d879531e32)
1# RUN: not llvm-mc -triple=x86_64 %s 2>&1 | FileCheck %s --check-prefixes=CHECK,X64 --implicit-check-not=error: --implicit-check-not=warning:
2# RUN: llvm-mc -triple=i686 --defsym A16=1 %s 2>&1 | FileCheck %s --check-prefixes=CHECK,X86 --implicit-check-not=error: --implicit-check-not=warning:
3
4.ifndef A16
5movq 0x80000000-1(%rip), %rax
6leaq -0x80000000(%rip), %rax
7
8# X64: [[#@LINE+1]]:17: error: displacement 2147483648 is not within [-2147483648, 2147483647]
9movq 0x80000000(%rip), %rax
10
11# X64: [[#@LINE+1]]:18: error: displacement -2147483649 is not within [-2147483648, 2147483647]
12leaq -0x80000001(%rip), %rax
13.endif
14
15movl 0xffffffff(%eax), %eax
16leal -0xffffffff(%eax), %eax
17
18# CHECK: [[#@LINE+1]]:19: warning: displacement 4294967296 shortened to 32-bit signed 0
19movl 0xffffffff+1(%eax), %eax
20
21# CHECK: [[#@LINE+1]]:20: warning: displacement -4294967296 shortened to 32-bit signed 0
22leal -0xffffffff-1(%eax), %eax
23# CHECK: [[#@LINE+1]]:20: warning: displacement -4294967297 shortened to 32-bit signed -1
24leal -0xffffffff-2(%eax), %eax
25
26{disp8} leal 0x100(%ebx), %eax
27{disp8} leal -0x100(%ebx), %eax
28
29.ifdef A16
30.code16
31movw $0, 0xffff(%bp)
32movw $0, -0xffff(%si)
33
34# X86: [[#@LINE+1]]:19: warning: displacement 65536 shortened to 16-bit signed 0
35movw $0, 0xffff+1(%bp)
36# X86: [[#@LINE+1]]:20: warning: displacement -65536 shortened to 16-bit signed 0
37movw $0, -0xffff-1(%si)
38.endif
39