From f4903a3675a9b0c66ea3a1ddc713e2465a273745 Mon Sep 17 00:00:00 2001 From: Yunzhong Gao Date: Fri, 2 Sep 2016 23:16:06 +0000 Subject: [PATCH] (clang part) Implement MASM-flavor intel syntax behavior for inline MS asm block. Clang tests for verifying the following syntaxes: 1. 0xNN and NNh are accepted as valid hexadecimal numbers, but 0xNNh is not. 0xNN and NNh may come with optional U or L suffix. 2. NNb is accepted as a valid binary (base-2) number, but 0bNN is not. NNb may come with optional U or L suffix. Differential Revision: https://reviews.llvm.org/D22112 llvm-svn: 280556 --- clang/test/CodeGen/ms-inline-asm.c | 24 ++++++++++++------------ clang/test/CodeGenCXX/ms-inline-asm-return.cpp | 10 +++++----- clang/test/Parser/ms-inline-asm.c | 8 ++++---- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/clang/test/CodeGen/ms-inline-asm.c b/clang/test/CodeGen/ms-inline-asm.c index ad9e4f3..0be89f2 100644 --- a/clang/test/CodeGen/ms-inline-asm.c +++ b/clang/test/CodeGen/ms-inline-asm.c @@ -47,7 +47,7 @@ void t6(void) { void t7() { __asm { - int 0x2c ; } asm comments are fun! }{ + int 0x2cU ; } asm comments are fun! }{ } __asm { { @@ -56,7 +56,7 @@ void t7() { } __asm {} // CHECK: t7 -// CHECK: call void asm sideeffect inteldialect "int $$0x2c", "~{dirflag},~{fpsr},~{flags}"() +// CHECK: call void asm sideeffect inteldialect "int $$0x2cU", "~{dirflag},~{fpsr},~{flags}"() // CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() } @@ -171,8 +171,8 @@ void t17() { // CHECK: t17 __asm _emit 0x4A // CHECK: .byte 0x4A - __asm _emit 0x43 -// CHECK: .byte 0x43 + __asm _emit 0x43L +// CHECK: .byte 0x43L __asm _emit 0x4B // CHECK: .byte 0x4B __asm _EMIT 0x4B @@ -219,11 +219,11 @@ void t20() { void t21() { __asm { __asm push ebx - __asm mov ebx, 0x07 + __asm mov ebx, 07H __asm pop ebx } // CHECK: t21 -// CHECK: call void asm sideeffect inteldialect "push ebx\0A\09mov ebx, $$0x07\0A\09pop ebx", "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"() +// CHECK: call void asm sideeffect inteldialect "push ebx\0A\09mov ebx, $$07H\0A\09pop ebx", "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"() } extern void t22_helper(int x); @@ -262,15 +262,15 @@ void t24() { void t25() { // CHECK: t25 __asm mov eax, 0ffffffffh -// CHECK: mov eax, $$4294967295 - __asm mov eax, 0fh +// CHECK: mov eax, $$0ffffffffh + __asm mov eax, 0fhU // CHECK: mov eax, $$15 __asm mov eax, 0a2h +// CHECK: mov eax, $$0a2h + __asm mov eax, 10100010b +// CHECK: mov eax, $$10100010b + __asm mov eax, 10100010BU // CHECK: mov eax, $$162 - __asm mov eax, 0xa2h -// CHECK: mov eax, $$0xa2h - __asm mov eax, 0xa2 -// CHECK: mov eax, $$0xa2 // CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"() } diff --git a/clang/test/CodeGenCXX/ms-inline-asm-return.cpp b/clang/test/CodeGenCXX/ms-inline-asm-return.cpp index 1219c61..51671c0 100644 --- a/clang/test/CodeGenCXX/ms-inline-asm-return.cpp +++ b/clang/test/CodeGenCXX/ms-inline-asm-return.cpp @@ -50,8 +50,8 @@ char f_i8() { bool f_i1() { __asm { - mov eax, 1 - mov edx, 1 + mov eax, 1L + mov edx, 1U } } // CHECK-LABEL: define zeroext i1 @f_i1() @@ -80,12 +80,12 @@ struct EightChars { }; EightChars f_s8() { __asm { - mov eax, 0x01010101 - mov edx, 0x01010101 + mov eax, 01010101h + mov edx, 01010101b } } // CHECK-LABEL: define i64 @f_s8() -// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$0x01010101\0A\09mov edx, $$0x01010101", "=A,~{eax},{{.*}}" +// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$01010101h\0A\09mov edx, $$01010101b", "=A,~{eax},{{.*}}" // CHECK: store i64 %[[r]], i64* %{{.*}} // CHECK: %[[r_i64:[^ ]*]] = load i64, i64* %{{.*}} // CHECK: ret i64 %[[r_i64]] diff --git a/clang/test/Parser/ms-inline-asm.c b/clang/test/Parser/ms-inline-asm.c index 7db4720..0170b2b 100644 --- a/clang/test/Parser/ms-inline-asm.c +++ b/clang/test/Parser/ms-inline-asm.c @@ -7,9 +7,9 @@ #define M2 int void t1(void) { M } -void t2(void) { __asm int 0x2c } -void t3(void) { __asm M2 0x2c } -void t4(void) { __asm mov eax, fs:[0x10] } +void t2(void) { __asm int 2ch } +void t3(void) { __asm M2 2ch } +void t4(void) { __asm mov eax, fs:[10h] } void t5() { __asm { int 0x2c ; } asm comments are fun! }{ @@ -26,7 +26,7 @@ int t6() { void t7() { __asm { push ebx - mov ebx, 0x07 + mov ebx, 07h pop ebx } } -- 2.7.4