Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch enables the usage of constant Enum identifiers within Micr…
…osoft style inline assembly statements. Differential Revision: https://reviews.llvm.org/D33277 https://reviews.llvm.org/D33278 llvm-svn: 308965
- Loading branch information
Matan Haroush
committed
Jul 25, 2017
1 parent
cd2255e
commit b4b8d10
Showing
4 changed files
with
85 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// REQUIRES: x86-registered-target | ||
// RUN: %clang_cc1 %s -fasm-blocks -emit-llvm -o - | FileCHECK %s | ||
namespace x { | ||
enum { A = 12 }; | ||
struct y_t { | ||
enum { A = 17 }; | ||
int r; | ||
} y; | ||
} | ||
// CHECK-LABEL: x86_enum_only | ||
void x86_enum_only(){ | ||
const int a = 0; | ||
// CHECK-NOT: mov eax, [$$0] | ||
// Other constant type folding is currently unwanted. | ||
__asm mov eax, [a] | ||
} | ||
|
||
// CHECK-LABEL: x86_enum_namespaces | ||
void x86_enum_namespaces() { | ||
enum { A = 1 }; | ||
// CHECK: call void asm | ||
// CHECK-SAME: mov eax, $$12 | ||
__asm mov eax, x::A | ||
// CHECK-SAME: mov eax, $$17 | ||
__asm mov eax, x::y_t::A | ||
// CHECK-NEXT: call void asm | ||
// CHECK-SAME: mov eax, $$1 | ||
__asm {mov eax, A} | ||
} | ||
|
||
// CHECK-LABEL: x86_enum_arithmethic | ||
void x86_enum_arithmethic() { | ||
enum { A = 1, B }; | ||
// CHECK: call void asm | ||
// CHECK-SAME: mov eax, $$21 | ||
__asm mov eax, (A + 9) * 2 + A | ||
// CHECK-SAME: mov eax, $$4 | ||
__asm mov eax, A << 2 | ||
// CHECK-SAME: mov eax, $$2 | ||
__asm mov eax, B & 3 | ||
// CHECK-SAME: mov eax, $$5 | ||
__asm mov eax, 3 + (B & 3) | ||
// CHECK-SAME: mov eax, $$8 | ||
__asm mov eax, 2 << A * B | ||
} | ||
|
||
// CHECK-LABEL: x86_enum_mem | ||
void x86_enum_mem() { | ||
int arr[4]; | ||
enum { A = 4, B }; | ||
// CHECK: call void asm | ||
// CHECK-SAME: mov eax, [($$12 + $$9) + $$4 * $$5 + $$3 + $$3 + eax] | ||
__asm { mov eax, [(x::A + 9) + A * B + 3 + 3 + eax] } | ||
// CHECK-NEXT: call void asm | ||
// CHECK-SAME: mov eax, dword ptr $$4$0 | ||
__asm { mov eax, dword ptr [arr + A] } | ||
// CHECK-NEXT: call void asm | ||
// CHECK-SAME: mov eax, dword ptr $$8$0 | ||
__asm { mov eax, dword ptr A[arr + A] } | ||
} |
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