r306301 - [inline asm] dot operator while using imm generates wrong ir + asm - clang part
Author: myatsina Date: Mon Jun 26 09:09:55 2017 New Revision: 306301 URL: http://llvm.org/viewvc/llvm-project?rev=306301=rev Log: [inline asm] dot operator while using imm generates wrong ir + asm - clang part Inline asm dot operator while using imm generates wrong ir and asm This is the test for the llvm changes committed in revision 306300 This also fixes bugzilla 32987: https://bugs.llvm.org//show_bug.cgi?id=32987 The llvm part of the review that contains the test can be found here: https://reviews.llvm.org/D33039 commit on behald of zizhar Differential Revision: https://reviews.llvm.org/D33040 Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=306301=306300=306301=diff == --- cfe/trunk/test/CodeGen/ms-inline-asm.c (original) +++ cfe/trunk/test/CodeGen/ms-inline-asm.c Mon Jun 26 09:09:55 2017 @@ -627,6 +627,12 @@ void t43() { // CHECK: call void asm sideeffect inteldialect "mov eax, $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) } +void dot_operator(){ +// CHECK-LABEL: define void @dot_operator + __asm { mov eax, 3[ebx]A.b} +// CHECK: call void asm sideeffect inteldialect "mov eax, $$3[ebx].4", "~{eax},~{dirflag},~{fpsr},~{flags}" +} + void call_clobber() { __asm call t41 // CHECK-LABEL: define void @call_clobber ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r306297 - [inline asm][gcc-compatiblity] "=i" output constraint support
Author: myatsina Date: Mon Jun 26 08:55:51 2017 New Revision: 306297 URL: http://llvm.org/viewvc/llvm-project?rev=306297=rev Log: [inline asm][gcc-compatiblity] "=i" output constraint support Ignore ‘i’,’n’,’E’,’F’ as output constraints in inline assembly (gcc compatibility) Differential Revision: https://reviews.llvm.org/D31383 Modified: cfe/trunk/lib/Basic/TargetInfo.cpp cfe/trunk/test/Sema/asm.c Modified: cfe/trunk/lib/Basic/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=306297=306296=306297=diff == --- cfe/trunk/lib/Basic/TargetInfo.cpp (original) +++ cfe/trunk/lib/Basic/TargetInfo.cpp Mon Jun 26 08:55:51 2017 @@ -507,6 +507,11 @@ bool TargetInfo::validateOutputConstrain case '?': // Disparage slightly code. case '!': // Disparage severely. case '*': // Ignore for choosing register preferences. +case 'i': // Ignore i,n,E,F as output constraints (match from the other + // chars) +case 'n': +case 'E': +case 'F': break; // Pass them. } Modified: cfe/trunk/test/Sema/asm.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/asm.c?rev=306297=306296=306297=diff == --- cfe/trunk/test/Sema/asm.c (original) +++ cfe/trunk/test/Sema/asm.c Mon Jun 26 08:55:51 2017 @@ -160,6 +160,41 @@ double test15() { return ret; } +void iOutputConstraint(int x){ + __asm ("nop" : "=ir" (x) : :); // no-error + __asm ("nop" : "=ri" (x) : :); // no-error + __asm ("nop" : "=ig" (x) : :); // no-error + __asm ("nop" : "=im" (x) : :); // no-error + __asm ("nop" : "=imr" (x) : :); // no-error + __asm ("nop" : "=i" (x) : :); // expected-error{{invalid output constraint '=i' in asm}} + __asm ("nop" : "+i" (x) : :); // expected-error{{invalid output constraint '+i' in asm}} + __asm ("nop" : "=ii" (x) : :); // expected-error{{invalid output constraint '=ii' in asm}} + __asm ("nop" : "=nr" (x) : :); // no-error + __asm ("nop" : "=rn" (x) : :); // no-error + __asm ("nop" : "=ng" (x) : :); // no-error + __asm ("nop" : "=nm" (x) : :); // no-error + __asm ("nop" : "=nmr" (x) : :); // no-error + __asm ("nop" : "=n" (x) : :); // expected-error{{invalid output constraint '=n' in asm}} + __asm ("nop" : "+n" (x) : :); // expected-error{{invalid output constraint '+n' in asm}} + __asm ("nop" : "=nn" (x) : :); // expected-error{{invalid output constraint '=nn' in asm}} + __asm ("nop" : "=Fr" (x) : :); // no-error + __asm ("nop" : "=rF" (x) : :); // no-error + __asm ("nop" : "=Fg" (x) : :); // no-error + __asm ("nop" : "=Fm" (x) : :); // no-error + __asm ("nop" : "=Fmr" (x) : :); // no-error + __asm ("nop" : "=F" (x) : :); // expected-error{{invalid output constraint '=F' in asm}} + __asm ("nop" : "+F" (x) : :); // expected-error{{invalid output constraint '+F' in asm}} + __asm ("nop" : "=FF" (x) : :); // expected-error{{invalid output constraint '=FF' in asm}} + __asm ("nop" : "=Er" (x) : :); // no-error + __asm ("nop" : "=rE" (x) : :); // no-error + __asm ("nop" : "=Eg" (x) : :); // no-error + __asm ("nop" : "=Em" (x) : :); // no-error + __asm ("nop" : "=Emr" (x) : :); // no-error + __asm ("nop" : "=E" (x) : :); // expected-error{{invalid output constraint '=E' in asm}} + __asm ("nop" : "+E" (x) : :); // expected-error{{invalid output constraint '+E' in asm}} + __asm ("nop" : "=EE" (x) : :); // expected-error{{invalid output constraint '=EE' in asm}} +} + // PR19837 struct foo { int a; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r290541 - Fix build error caused by r290539.
Author: myatsina Date: Mon Dec 26 07:16:40 2016 New Revision: 290541 URL: http://llvm.org/viewvc/llvm-project?rev=290541=rev Log: Fix build error caused by r290539. Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=290541=290540=290541=diff == --- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original) +++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Mon Dec 26 07:16:40 2016 @@ -164,9 +164,8 @@ getClobberConflictLocation(MultiExprArg const TargetInfo , ASTContext ) { llvm::StringSet<> InOutVars; // Collect all the input and output registers from the extended asm - // statement - // in order to check for conflicts with the clobber list - for (int i = 0; i < Exprs.size(); ++i) { + // statement in order to check for conflicts with the clobber list + for (unsigned int i = 0; i < Exprs.size(); ++i) { StringRef Constraint = Constraints[i]->getString(); StringRef InOutReg = Target.getConstraintRegister( Constraint, extractRegisterName(Exprs[i], Target)); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r290539 - [inline-asm]No error for conflict between inputs\outputs and clobber list
Author: myatsina Date: Mon Dec 26 06:23:42 2016 New Revision: 290539 URL: http://llvm.org/viewvc/llvm-project?rev=290539=rev Log: [inline-asm]No error for conflict between inputs\outputs and clobber list According to extended asm syntax, a case where the clobber list includes a variable from the inputs or outputs should be an error - conflict. for example: const long double a = 0.0; int main() { char b; double t1 = a; __asm__ ("fucompp": "=a" (b) : "u" (t1), "t" (t1) : "cc", "st", "st(1)"); return 0; } This should conflict with the output - t1 which is st, and st which is st aswell. The patch fixes it. Commit on behald of Ziv Izhar. Differential Revision: https://reviews.llvm.org/D15075 Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Basic/TargetInfo.h cfe/trunk/lib/Basic/TargetInfo.cpp cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/lib/Headers/intrin.h cfe/trunk/lib/Sema/SemaStmtAsm.cpp cfe/trunk/test/Sema/asm.c Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=290539=290538=290539=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Dec 26 06:23:42 2016 @@ -7069,6 +7069,10 @@ let CategoryName = "Inline Assembly Issu "constraint '%0' is already present here">; } + def error_inoutput_conflict_with_clobber : Error< +"asm-specifier for input or output variable conflicts with asm" +" clobber list">; + let CategoryName = "Semantic Issue" in { def err_invalid_conversion_between_vectors : Error< Modified: cfe/trunk/include/clang/Basic/TargetInfo.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=290539=290538=290539=diff == --- cfe/trunk/include/clang/Basic/TargetInfo.h (original) +++ cfe/trunk/include/clang/Basic/TargetInfo.h Mon Dec 26 06:23:42 2016 @@ -605,8 +605,16 @@ public: /// \brief Returns the "normalized" GCC register name. /// - /// For example, on x86 it will return "ax" when "eax" is passed in. - StringRef getNormalizedGCCRegisterName(StringRef Name) const; + /// ReturnCannonical true will return the register name without any additions + /// such as "{}" or "%" in it's canonical form, for example: + /// ReturnCanonical = true and Name = "rax", will return "ax". + StringRef getNormalizedGCCRegisterName(StringRef Name, + bool ReturnCanonical = false) const; + + virtual StringRef getConstraintRegister(const StringRef , + const StringRef ) const { +return ""; + } struct ConstraintInfo { enum { Modified: cfe/trunk/lib/Basic/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=290539=290538=290539=diff == --- cfe/trunk/lib/Basic/TargetInfo.cpp (original) +++ cfe/trunk/lib/Basic/TargetInfo.cpp Mon Dec 26 06:23:42 2016 @@ -410,8 +410,8 @@ bool TargetInfo::isValidGCCRegisterName( return false; } -StringRef -TargetInfo::getNormalizedGCCRegisterName(StringRef Name) const { +StringRef TargetInfo::getNormalizedGCCRegisterName(StringRef Name, + bool ReturnCanonical) const { assert(isValidGCCRegisterName(Name) && "Invalid register passed in"); // Get rid of any register prefix. @@ -436,7 +436,7 @@ TargetInfo::getNormalizedGCCRegisterName // Make sure the register that the additional name is for is within // the bounds of the register names from above. if (AN == Name && ARN.RegNum < Names.size()) -return Name; +return ReturnCanonical ? Names[ARN.RegNum] : Name; } // Now check aliases. Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=290539=290538=290539=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Mon Dec 26 06:23:42 2016 @@ -2789,6 +2789,40 @@ public: const char *getClobbers() const override { return "~{dirflag},~{fpsr},~{flags}"; } + + StringRef getConstraintRegister(const StringRef , + const StringRef ) const override { +StringRef::iterator I, E; +for (I = Constraint.begin(), E = Constraint.end(); I != E; ++I) { + if (isalpha(*I)) +break; +} +if (I == E) + return ""; +switch (*I) { +// For the register constraints, return the matching register name +case 'a': + return "ax"; +case 'b': + return "bx"; +
[PATCH] D26587: [AVX512][inline-asm] Fix AVX512 inline assembly instruction resolution when the size qualifier of a memory operand is not specified explicitly.
myatsina accepted this revision. myatsina added a comment. This revision is now accepted and ready to land. LGTM Please emphasize in you commit message that this the test case for the llvm commit (and even better if you add the commit number of the llvm commit), Repository: rL LLVM https://reviews.llvm.org/D26587 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21959: [X86] Add xgetbv xsetbv intrinsics
This revision was automatically updated to reflect the committed changes. Closed by commit rL278783: [X86] Add xgetbv/x[X86] Add xgetbv xsetbv intrinsics to non-windows platforms (authored by myatsina). Changed prior to commit: https://reviews.llvm.org/D21959?vs=65676=68146#toc Repository: rL LLVM https://reviews.llvm.org/D21959 Files: cfe/trunk/include/clang/Basic/BuiltinsX86.def cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/lib/Headers/intrin.h cfe/trunk/lib/Headers/xsaveintrin.h cfe/trunk/test/CodeGen/builtins-x86.c cfe/trunk/test/CodeGen/x86_32-xsave.c cfe/trunk/test/CodeGen/x86_64-xsave.c cfe/trunk/test/Headers/ms-intrin.cpp Index: cfe/trunk/include/clang/Basic/BuiltinsX86.def === --- cfe/trunk/include/clang/Basic/BuiltinsX86.def +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def @@ -644,6 +644,8 @@ // XSAVE TARGET_BUILTIN(__builtin_ia32_xsave, "vv*ULLi", "", "xsave") TARGET_BUILTIN(__builtin_ia32_xsave64, "vv*ULLi", "", "xsave") +TARGET_BUILTIN(__builtin_ia32_xgetbv, "ULLiUi", "", "xsave") +TARGET_BUILTIN(__builtin_ia32_xsetbv, "vUiULLi", "", "xsave") TARGET_BUILTIN(__builtin_ia32_xrstor, "vv*ULLi", "", "xsave") TARGET_BUILTIN(__builtin_ia32_xrstor64, "vv*ULLi", "", "xsave") TARGET_BUILTIN(__builtin_ia32_xsaveopt, "vv*ULLi", "", "xsaveopt") Index: cfe/trunk/test/Headers/ms-intrin.cpp === --- cfe/trunk/test/Headers/ms-intrin.cpp +++ cfe/trunk/test/Headers/ms-intrin.cpp @@ -50,7 +50,6 @@ int info[4]; __cpuid(info, 0); __cpuidex(info, 0, 0); - _xgetbv(0); __halt(); __readmsr(0); Index: cfe/trunk/test/CodeGen/x86_64-xsave.c === --- cfe/trunk/test/CodeGen/x86_64-xsave.c +++ cfe/trunk/test/CodeGen/x86_64-xsave.c @@ -1,6 +1,9 @@ // RUN: %clang_cc1 %s -DTEST_XSAVE -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSAVE // RUN: %clang_cc1 %s -DTEST_XSAVE -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSAVE +// RUN: %clang_cc1 %s -DTEST_XGETBV -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XGETBV +// RUN: %clang_cc1 %s -DTEST_XSETBV -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSETBV + // RUN: %clang_cc1 %s -DTEST_XSAVEOPT -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -target-feature +xsaveopt -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSAVEOPT // RUN: %clang_cc1 %s -DTEST_XSAVEOPT -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -target-feature +xsaveopt -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSAVEOPT @@ -10,9 +13,16 @@ // RUN: %clang_cc1 %s -DTEST_XSAVES -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -target-feature +xsaves -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSAVES // RUN: %clang_cc1 %s -DTEST_XSAVES -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -target-feature +xsaves -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSAVES +// Don't include mm_malloc.h, it's system specific. +#define __MM_MALLOC_H +#include + + void test() { - unsigned long long tmp_ULLi = 0; - void* tmp_vp = 0; + unsigned long long tmp_ULLi; + unsigned int tmp_Ui; + void* tmp_vp; + tmp_ULLi = 0; tmp_Ui = 0; tmp_vp = 0; #ifdef TEST_XSAVE // XSAVE: [[tmp_vp_1:%[0-9a-zA-z]+]] = load i8*, i8** %tmp_vp, align 8 @@ -46,6 +56,18 @@ // XSAVE: [[low32_4:%[0-9a-zA-z]+]] = trunc i64 [[tmp_ULLi_4]] to i32 // XSAVE: call void @llvm.x86.xrstor64(i8* [[tmp_vp_4]], i32 [[high32_4]], i32 [[low32_4]]) (void)__builtin_ia32_xrstor64(tmp_vp, tmp_ULLi); + +// XSAVE: call void @llvm.x86.xsave + (void)_xsave(tmp_vp, tmp_ULLi); + +// XSAVE: call void @llvm.x86.xsave64 + (void)_xsave64(tmp_vp, tmp_ULLi); + +// XSAVE: call void @llvm.x86.xrstor + (void)_xrstor(tmp_vp, tmp_ULLi); + +// XSAVE: call void @llvm.x86.xrstor64 + (void)_xrstor64(tmp_vp, tmp_ULLi); #endif #ifdef TEST_XSAVEOPT @@ -64,6 +86,12 @@ // XSAVEOPT: [[low32_2:%[0-9a-zA-z]+]] = trunc i64 [[tmp_ULLi_2]] to i32 // XSAVEOPT: call void @llvm.x86.xsaveopt64(i8* [[tmp_vp_2]], i32 [[high32_2]], i32 [[low32_2]]) (void)__builtin_ia32_xsaveopt64(tmp_vp, tmp_ULLi); + +// XSAVEOPT: call void @llvm.x86.xsaveopt + (void)_xsaveopt(tmp_vp, tmp_ULLi); + +// XSAVEOPT: call void @llvm.x86.xsaveopt64 + (void)_xsaveopt64(tmp_vp, tmp_ULLi); #endif #ifdef TEST_XSAVEC @@ -82,6 +110,12 @@ // XSAVEC: [[low32_2:%[0-9a-zA-z]+]] = trunc i64 [[tmp_ULLi_2]] to i32 // XSAVEC: call void @llvm.x86.xsavec64(i8* [[tmp_vp_2]], i32 [[high32_2]], i32
r278783 - [X86] Add xgetbv/x[X86] Add xgetbv xsetbv intrinsics to non-windows platforms
Author: myatsina Date: Tue Aug 16 03:13:36 2016 New Revision: 278783 URL: http://llvm.org/viewvc/llvm-project?rev=278783=rev Log: [X86] Add xgetbv/x[X86] Add xgetbv xsetbv intrinsics to non-windows platforms commit on behalf of guyblank Differential Revision: https://reviews.llvm.org/D21959 Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/lib/Headers/intrin.h cfe/trunk/lib/Headers/xsaveintrin.h cfe/trunk/test/CodeGen/builtins-x86.c cfe/trunk/test/CodeGen/x86_32-xsave.c cfe/trunk/test/CodeGen/x86_64-xsave.c cfe/trunk/test/Headers/ms-intrin.cpp Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=278783=278782=278783=diff == --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original) +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue Aug 16 03:13:36 2016 @@ -644,6 +644,8 @@ TARGET_BUILTIN(__builtin_ia32_fxsave64, // XSAVE TARGET_BUILTIN(__builtin_ia32_xsave, "vv*ULLi", "", "xsave") TARGET_BUILTIN(__builtin_ia32_xsave64, "vv*ULLi", "", "xsave") +TARGET_BUILTIN(__builtin_ia32_xgetbv, "ULLiUi", "", "xsave") +TARGET_BUILTIN(__builtin_ia32_xsetbv, "vUiULLi", "", "xsave") TARGET_BUILTIN(__builtin_ia32_xrstor, "vv*ULLi", "", "xsave") TARGET_BUILTIN(__builtin_ia32_xrstor64, "vv*ULLi", "", "xsave") TARGET_BUILTIN(__builtin_ia32_xsaveopt, "vv*ULLi", "", "xsaveopt") Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=278783=278782=278783=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Aug 16 03:13:36 2016 @@ -6915,7 +6915,8 @@ Value *CodeGenFunction::EmitX86BuiltinEx case X86::BI__builtin_ia32_xsavec: case X86::BI__builtin_ia32_xsavec64: case X86::BI__builtin_ia32_xsaves: - case X86::BI__builtin_ia32_xsaves64: { + case X86::BI__builtin_ia32_xsaves64: + case X86::BI__builtin_ia32_xsetbv: { Intrinsic::ID ID; #define INTRINSIC_X86_XSAVE_ID(NAME) \ case X86::BI__builtin_ia32_##NAME: \ @@ -6935,6 +6936,7 @@ Value *CodeGenFunction::EmitX86BuiltinEx INTRINSIC_X86_XSAVE_ID(xsavec64); INTRINSIC_X86_XSAVE_ID(xsaves); INTRINSIC_X86_XSAVE_ID(xsaves64); +INTRINSIC_X86_XSAVE_ID(xsetbv); } #undef INTRINSIC_X86_XSAVE_ID Value *Mhi = Builder.CreateTrunc( @@ -6944,6 +6946,8 @@ Value *CodeGenFunction::EmitX86BuiltinEx Ops.push_back(Mlo); return Builder.CreateCall(CGM.getIntrinsic(ID), Ops); } + case X86::BI__builtin_ia32_xgetbv: +return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_xgetbv), Ops); case X86::BI__builtin_ia32_storedqudi128_mask: case X86::BI__builtin_ia32_storedqusi128_mask: case X86::BI__builtin_ia32_storedquhi128_mask: Modified: cfe/trunk/lib/Headers/intrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=278783=278782=278783=diff == --- cfe/trunk/lib/Headers/intrin.h (original) +++ cfe/trunk/lib/Headers/intrin.h Tue Aug 16 03:13:36 2016 @@ -289,10 +289,6 @@ static __inline__ void _WriteBarrier(void); unsigned __int32 xbegin(void); void _xend(void); -static __inline__ -#define _XCR_XFEATURE_ENABLED_MASK 0 -unsigned __int64 __cdecl _xgetbv(unsigned int); -void __cdecl _xsetbv(unsigned int, unsigned __int64); /* These additional intrinsics are turned on in x64/amd64/x86_64 mode. */ #ifdef __x86_64__ @@ -908,12 +904,6 @@ __cpuidex(int __info[4], int __level, in __asm__ ("cpuid" : "=a"(__info[0]), "=b" (__info[1]), "=c"(__info[2]), "=d"(__info[3]) : "a"(__level), "c"(__ecx)); } -static __inline__ unsigned __int64 __cdecl __DEFAULT_FN_ATTRS -_xgetbv(unsigned int __xcr_no) { - unsigned int __eax, __edx; - __asm__ ("xgetbv" : "=a" (__eax), "=d" (__edx) : "c" (__xcr_no)); - return ((unsigned __int64)__edx << 32) | __eax; -} static __inline__ void __DEFAULT_FN_ATTRS __halt(void) { __asm__ volatile ("hlt"); Modified: cfe/trunk/lib/Headers/xsaveintrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/xsaveintrin.h?rev=278783=278782=278783=diff == --- cfe/trunk/lib/Headers/xsaveintrin.h (original) +++ cfe/trunk/lib/Headers/xsaveintrin.h Tue Aug 16 03:13:36 2016 @@ -28,6 +28,8 @@ #ifndef __XSAVEINTRIN_H #define __XSAVEINTRIN_H +#define _XCR_XFEATURE_ENABLED_MASK 0 + /* Define the default attributes for the functions in this file. */ #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("xsave"))) @@ -41,6 +43,16 @@ _xrstor(void *__p, unsigned long long __ return __builtin_ia32_xrstor(__p, __m); }
Re: [PATCH] D18123: Fix implicit copy ctor and copy assignment operator warnings when -Wdeprecated passed.
myatsina added a comment. I've committed the fix in revision 263630 http://reviews.llvm.org/D18123 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D18175: Avoid using LookupResult's implicit copy ctor and assignment operator to avoid warnings
This revision was automatically updated to reflect the committed changes. Closed by commit rL263630: Avoid using LookupResult's implicit copy ctor and assignment operator to… (authored by myatsina). Changed prior to commit: http://reviews.llvm.org/D18175?vs=50780=50811#toc Repository: rL LLVM http://reviews.llvm.org/D18175 Files: cfe/trunk/lib/Sema/SemaStmtAsm.cpp cfe/trunk/test/CodeGen/ms-inline-asm-errors.cpp Index: cfe/trunk/lib/Sema/SemaStmtAsm.cpp === --- cfe/trunk/lib/Sema/SemaStmtAsm.cpp +++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp @@ -623,16 +623,12 @@ if (!LookupName(BaseResult, getCurScope())) return true; - - LookupResult CurrBaseResult(BaseResult); - + + if(!BaseResult.isSingleResult()) +return true; + NamedDecl *FoundDecl = BaseResult.getFoundDecl(); for (StringRef NextMember : Members) { - -if (!CurrBaseResult.isSingleResult()) - return true; - const RecordType *RT = nullptr; -NamedDecl *FoundDecl = CurrBaseResult.getFoundDecl(); if (VarDecl *VD = dyn_cast(FoundDecl)) RT = VD->getType()->getAs(); else if (TypedefNameDecl *TD = dyn_cast(FoundDecl)) { @@ -655,13 +651,15 @@ if (!LookupQualifiedName(FieldResult, RT->getDecl())) return true; +if (!FieldResult.isSingleResult()) + return true; +FoundDecl = FieldResult.getFoundDecl(); + // FIXME: Handle IndirectFieldDecl? -FieldDecl *FD = dyn_cast(FieldResult.getFoundDecl()); +FieldDecl *FD = dyn_cast(FoundDecl); if (!FD) return true; -CurrBaseResult = FieldResult; - const ASTRecordLayout = Context.getASTRecordLayout(RT->getDecl()); unsigned i = FD->getFieldIndex(); CharUnits Result = Context.toCharUnitsFromBits(RL.getFieldOffset(i)); Index: cfe/trunk/test/CodeGen/ms-inline-asm-errors.cpp === --- cfe/trunk/test/CodeGen/ms-inline-asm-errors.cpp +++ cfe/trunk/test/CodeGen/ms-inline-asm-errors.cpp @@ -0,0 +1,15 @@ +// REQUIRES: x86-registered-target +// RUN: %clang_cc1 -x c++ %s -triple i386-apple-darwin10 -std=c++11 -fasm-blocks -verify + +class A { +public: + void foo(int a) {} + void foo(float a) {} +}; + + +void t_fail() { + __asm { + mov ecx, [eax]A.foo // expected-error {{Unable to lookup field reference!}} + } +} Index: cfe/trunk/lib/Sema/SemaStmtAsm.cpp === --- cfe/trunk/lib/Sema/SemaStmtAsm.cpp +++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp @@ -623,16 +623,12 @@ if (!LookupName(BaseResult, getCurScope())) return true; - - LookupResult CurrBaseResult(BaseResult); - + + if(!BaseResult.isSingleResult()) +return true; + NamedDecl *FoundDecl = BaseResult.getFoundDecl(); for (StringRef NextMember : Members) { - -if (!CurrBaseResult.isSingleResult()) - return true; - const RecordType *RT = nullptr; -NamedDecl *FoundDecl = CurrBaseResult.getFoundDecl(); if (VarDecl *VD = dyn_cast(FoundDecl)) RT = VD->getType()->getAs(); else if (TypedefNameDecl *TD = dyn_cast(FoundDecl)) { @@ -655,13 +651,15 @@ if (!LookupQualifiedName(FieldResult, RT->getDecl())) return true; +if (!FieldResult.isSingleResult()) + return true; +FoundDecl = FieldResult.getFoundDecl(); + // FIXME: Handle IndirectFieldDecl? -FieldDecl *FD = dyn_cast(FieldResult.getFoundDecl()); +FieldDecl *FD = dyn_cast(FoundDecl); if (!FD) return true; -CurrBaseResult = FieldResult; - const ASTRecordLayout = Context.getASTRecordLayout(RT->getDecl()); unsigned i = FD->getFieldIndex(); CharUnits Result = Context.toCharUnitsFromBits(RL.getFieldOffset(i)); Index: cfe/trunk/test/CodeGen/ms-inline-asm-errors.cpp === --- cfe/trunk/test/CodeGen/ms-inline-asm-errors.cpp +++ cfe/trunk/test/CodeGen/ms-inline-asm-errors.cpp @@ -0,0 +1,15 @@ +// REQUIRES: x86-registered-target +// RUN: %clang_cc1 -x c++ %s -triple i386-apple-darwin10 -std=c++11 -fasm-blocks -verify + +class A { +public: + void foo(int a) {} + void foo(float a) {} +}; + + +void t_fail() { + __asm { + mov ecx, [eax]A.foo // expected-error {{Unable to lookup field reference!}} + } +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r263630 - Avoid using LookupResult's implicit copy ctor and assignment operator to avoid warnings
Author: myatsina Date: Wed Mar 16 04:56:58 2016 New Revision: 263630 URL: http://llvm.org/viewvc/llvm-project?rev=263630=rev Log: Avoid using LookupResult's implicit copy ctor and assignment operator to avoid warnings The purpose of this patch is to keep the same functionality without using LookupResult's implicit copy ctor and assignment operator, because they cause warnings when -Wdeprecated is passed. This patch is meant to help the following review: http://reviews.llvm.org/D18123. The functionality is covered by the tests in my original commit (255890) The test case in this patch was added to test a bug caught in the review of the first version of this fix. Differential Revision: http://reviews.llvm.org/D18175 Added: cfe/trunk/test/CodeGen/ms-inline-asm-errors.cpp (with props) Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=263630=263629=263630=diff == --- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original) +++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Wed Mar 16 04:56:58 2016 @@ -623,16 +623,12 @@ bool Sema::LookupInlineAsmField(StringRe if (!LookupName(BaseResult, getCurScope())) return true; - - LookupResult CurrBaseResult(BaseResult); - + + if(!BaseResult.isSingleResult()) +return true; + NamedDecl *FoundDecl = BaseResult.getFoundDecl(); for (StringRef NextMember : Members) { - -if (!CurrBaseResult.isSingleResult()) - return true; - const RecordType *RT = nullptr; -NamedDecl *FoundDecl = CurrBaseResult.getFoundDecl(); if (VarDecl *VD = dyn_cast(FoundDecl)) RT = VD->getType()->getAs(); else if (TypedefNameDecl *TD = dyn_cast(FoundDecl)) { @@ -655,13 +651,15 @@ bool Sema::LookupInlineAsmField(StringRe if (!LookupQualifiedName(FieldResult, RT->getDecl())) return true; +if (!FieldResult.isSingleResult()) + return true; +FoundDecl = FieldResult.getFoundDecl(); + // FIXME: Handle IndirectFieldDecl? -FieldDecl *FD = dyn_cast(FieldResult.getFoundDecl()); +FieldDecl *FD = dyn_cast(FoundDecl); if (!FD) return true; -CurrBaseResult = FieldResult; - const ASTRecordLayout = Context.getASTRecordLayout(RT->getDecl()); unsigned i = FD->getFieldIndex(); CharUnits Result = Context.toCharUnitsFromBits(RL.getFieldOffset(i)); Added: cfe/trunk/test/CodeGen/ms-inline-asm-errors.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm-errors.cpp?rev=263630=auto == --- cfe/trunk/test/CodeGen/ms-inline-asm-errors.cpp (added) +++ cfe/trunk/test/CodeGen/ms-inline-asm-errors.cpp Wed Mar 16 04:56:58 2016 @@ -0,0 +1,15 @@ +// REQUIRES: x86-registered-target +// RUN: %clang_cc1 -x c++ %s -triple i386-apple-darwin10 -std=c++11 -fasm-blocks -verify + +class A { +public: + void foo(int a) {} + void foo(float a) {} +}; + + +void t_fail() { + __asm { + mov ecx, [eax]A.foo // expected-error {{Unable to lookup field reference!}} + } +} Propchange: cfe/trunk/test/CodeGen/ms-inline-asm-errors.cpp -- svn:eol-style = native Propchange: cfe/trunk/test/CodeGen/ms-inline-asm-errors.cpp -- svn:keywords = Author Date Id Rev URL Propchange: cfe/trunk/test/CodeGen/ms-inline-asm-errors.cpp -- svn:mime-type = text/plain ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D18175: Avoid using LookupResult's implicit copy ctor and assignment operator to avoid warnings
myatsina updated this revision to Diff 50780. myatsina added a comment. Adding requested test case + changing the code accordingly Repository: rL LLVM http://reviews.llvm.org/D18175 Files: lib/Sema/SemaStmtAsm.cpp test/CodeGen/ms-inline-asm-errors.cpp Index: lib/Sema/SemaStmtAsm.cpp === --- lib/Sema/SemaStmtAsm.cpp +++ lib/Sema/SemaStmtAsm.cpp @@ -623,16 +623,12 @@ if (!LookupName(BaseResult, getCurScope())) return true; - - LookupResult CurrBaseResult(BaseResult); - + + if(!BaseResult.isSingleResult()) +return true; + NamedDecl *FoundDecl = BaseResult.getFoundDecl(); for (StringRef NextMember : Members) { - -if (!CurrBaseResult.isSingleResult()) - return true; - const RecordType *RT = nullptr; -NamedDecl *FoundDecl = CurrBaseResult.getFoundDecl(); if (VarDecl *VD = dyn_cast(FoundDecl)) RT = VD->getType()->getAs(); else if (TypedefNameDecl *TD = dyn_cast(FoundDecl)) { @@ -655,13 +651,15 @@ if (!LookupQualifiedName(FieldResult, RT->getDecl())) return true; +if (!FieldResult.isSingleResult()) + return true; +FoundDecl = FieldResult.getFoundDecl(); + // FIXME: Handle IndirectFieldDecl? -FieldDecl *FD = dyn_cast(FieldResult.getFoundDecl()); +FieldDecl *FD = dyn_cast(FoundDecl); if (!FD) return true; -CurrBaseResult = FieldResult; - const ASTRecordLayout = Context.getASTRecordLayout(RT->getDecl()); unsigned i = FD->getFieldIndex(); CharUnits Result = Context.toCharUnitsFromBits(RL.getFieldOffset(i)); Index: test/CodeGen/ms-inline-asm-errors.cpp === --- test/CodeGen/ms-inline-asm-errors.cpp +++ test/CodeGen/ms-inline-asm-errors.cpp @@ -0,0 +1,15 @@ +// REQUIRES: x86-registered-target +// RUN: %clang_cc1 -x c++ %s -triple i386-apple-darwin10 -std=c++11 -fasm-blocks -verify + +class A { +public: + void foo(int a) {} + void foo(float a) {} +}; + + +void t_fail() { + __asm { + mov ecx, [eax]A.foo // expected-error {{Unable to lookup field reference!}} + } +} Index: lib/Sema/SemaStmtAsm.cpp === --- lib/Sema/SemaStmtAsm.cpp +++ lib/Sema/SemaStmtAsm.cpp @@ -623,16 +623,12 @@ if (!LookupName(BaseResult, getCurScope())) return true; - - LookupResult CurrBaseResult(BaseResult); - + + if(!BaseResult.isSingleResult()) +return true; + NamedDecl *FoundDecl = BaseResult.getFoundDecl(); for (StringRef NextMember : Members) { - -if (!CurrBaseResult.isSingleResult()) - return true; - const RecordType *RT = nullptr; -NamedDecl *FoundDecl = CurrBaseResult.getFoundDecl(); if (VarDecl *VD = dyn_cast(FoundDecl)) RT = VD->getType()->getAs(); else if (TypedefNameDecl *TD = dyn_cast(FoundDecl)) { @@ -655,13 +651,15 @@ if (!LookupQualifiedName(FieldResult, RT->getDecl())) return true; +if (!FieldResult.isSingleResult()) + return true; +FoundDecl = FieldResult.getFoundDecl(); + // FIXME: Handle IndirectFieldDecl? -FieldDecl *FD = dyn_cast(FieldResult.getFoundDecl()); +FieldDecl *FD = dyn_cast(FoundDecl); if (!FD) return true; -CurrBaseResult = FieldResult; - const ASTRecordLayout = Context.getASTRecordLayout(RT->getDecl()); unsigned i = FD->getFieldIndex(); CharUnits Result = Context.toCharUnitsFromBits(RL.getFieldOffset(i)); Index: test/CodeGen/ms-inline-asm-errors.cpp === --- test/CodeGen/ms-inline-asm-errors.cpp +++ test/CodeGen/ms-inline-asm-errors.cpp @@ -0,0 +1,15 @@ +// REQUIRES: x86-registered-target +// RUN: %clang_cc1 -x c++ %s -triple i386-apple-darwin10 -std=c++11 -fasm-blocks -verify + +class A { +public: + void foo(int a) {} + void foo(float a) {} +}; + + +void t_fail() { + __asm { + mov ecx, [eax]A.foo // expected-error {{Unable to lookup field reference!}} + } +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D18175: Avoid using LookupResult's implicit copy ctor and assignment operator to avoid warnings
myatsina added a comment. How can I create a test case where isSingleResult() returns false? I don't see existent tests in the commit that added this method's functionality. Repository: rL LLVM http://reviews.llvm.org/D18175 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D18175: Avoid using LookupResult's implicit copy ctor and assignment operator to avoid warnings
myatsina created this revision. myatsina added reviewers: rnk, hintonda, rjmccall, dblaikie. myatsina added a subscriber: cfe-commits. myatsina set the repository for this revision to rL LLVM. The purpose of this patch is to keep the same functionality without using LookupResult's implicit copy ctor and assignment operator, because they cause warnings when -Wdeprecated is passed. This patch is meant to help the following review: http://reviews.llvm.org/D18123. Repository: rL LLVM http://reviews.llvm.org/D18175 Files: lib/Sema/SemaStmtAsm.cpp Index: lib/Sema/SemaStmtAsm.cpp === --- lib/Sema/SemaStmtAsm.cpp +++ lib/Sema/SemaStmtAsm.cpp @@ -623,16 +623,15 @@ if (!LookupName(BaseResult, getCurScope())) return true; - - LookupResult CurrBaseResult(BaseResult); - + + bool IsSingleRes = BaseResult.isSingleResult(); + NamedDecl *FoundDecl = BaseResult.getFoundDecl(); for (StringRef NextMember : Members) { -if (!CurrBaseResult.isSingleResult()) +if (!IsSingleRes) return true; const RecordType *RT = nullptr; -NamedDecl *FoundDecl = CurrBaseResult.getFoundDecl(); if (VarDecl *VD = dyn_cast(FoundDecl)) RT = VD->getType()->getAs(); else if (TypedefNameDecl *TD = dyn_cast(FoundDecl)) { @@ -660,7 +659,8 @@ if (!FD) return true; -CurrBaseResult = FieldResult; +IsSingleRes = FieldResult.isSingleResult(); +FoundDecl = FieldResult.getFoundDecl(); const ASTRecordLayout = Context.getASTRecordLayout(RT->getDecl()); unsigned i = FD->getFieldIndex(); Index: lib/Sema/SemaStmtAsm.cpp === --- lib/Sema/SemaStmtAsm.cpp +++ lib/Sema/SemaStmtAsm.cpp @@ -623,16 +623,15 @@ if (!LookupName(BaseResult, getCurScope())) return true; - - LookupResult CurrBaseResult(BaseResult); - + + bool IsSingleRes = BaseResult.isSingleResult(); + NamedDecl *FoundDecl = BaseResult.getFoundDecl(); for (StringRef NextMember : Members) { -if (!CurrBaseResult.isSingleResult()) +if (!IsSingleRes) return true; const RecordType *RT = nullptr; -NamedDecl *FoundDecl = CurrBaseResult.getFoundDecl(); if (VarDecl *VD = dyn_cast(FoundDecl)) RT = VD->getType()->getAs(); else if (TypedefNameDecl *TD = dyn_cast(FoundDecl)) { @@ -660,7 +659,8 @@ if (!FD) return true; -CurrBaseResult = FieldResult; +IsSingleRes = FieldResult.isSingleResult(); +FoundDecl = FieldResult.getFoundDecl(); const ASTRecordLayout = Context.getASTRecordLayout(RT->getDecl()); unsigned i = FD->getFieldIndex(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D18123: Fix implicit copy ctor and copy assignment operator warnings when -Wdeprecated passed.
myatsina added a comment. In http://reviews.llvm.org/D18123#374170, @hintonda wrote: > LookupResult's copy ctor and assignment operator are used in > Sema::LookupInlineAsmField(). Looks like these were added back in December. > > I'll remove the defaults, from this patch, but not sure how to handle > LookupInlineAsmField(). Will add author of that change. > > OTOH, UnresolvedSetImpl requires an assignment operator since it's a base to > UnresolvedSet which has an implicit assignment operator, so I think that > change is correct. I can change my code to avoid the copy ctor and assignment operator of LookupResult - In every iteration I only need to access 2 members of the previous LookupResult (isSingleResult() and getFoundDecl()), I can keep only them instead of the whole object. Do you want me to upload a patch with this change? http://reviews.llvm.org/D18123 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17766: [ms-inline-asm][AVX512] Add ability to use k registers in MS inline asm + fix bag with curly braces
This revision was automatically updated to reflect the committed changes. Closed by commit rL262842: [ms-inline-asm][AVX512] Add ability to use k registers in MS inline asm + fix… (authored by myatsina). Changed prior to commit: http://reviews.llvm.org/D17766?vs=49945=49978#toc Repository: rL LLVM http://reviews.llvm.org/D17766 Files: cfe/trunk/lib/Parse/ParseStmtAsm.cpp cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c cfe/trunk/test/CodeGen/ms-inline-asm.c cfe/trunk/test/Parser/ms-inline-asm.c Index: cfe/trunk/test/Parser/ms-inline-asm.c === --- cfe/trunk/test/Parser/ms-inline-asm.c +++ cfe/trunk/test/Parser/ms-inline-asm.c @@ -53,6 +53,10 @@ void t12() { __asm jmp label // expected-error {{use of undeclared label 'label'}} } +void t13() { + __asm m{o}v eax, ebx // expected-error {{expected identifier}} expected-error {{use of undeclared label '{o}v eax, ebx'}} +} + int t_fail() { // expected-note {{to match this}} __asm __asm { // expected-error 3 {{expected}} expected-note {{to match this}} Index: cfe/trunk/test/CodeGen/ms-inline-asm.c === --- cfe/trunk/test/CodeGen/ms-inline-asm.c +++ cfe/trunk/test/CodeGen/ms-inline-asm.c @@ -86,7 +86,7 @@ __asm { pop ebx } } // CHECK: t9 -// 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, $$0x07\0A\09pop ebx\0A\09", "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"() } unsigned t10(void) { Index: cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c === --- cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c +++ cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c @@ -9,3 +9,13 @@ vaddpd zmm8, zmm27, zmm6 } } + + +void t2() { +// CHECK: @t2 +// CHECK: call void asm sideeffect inteldialect "vaddpd zmm8 {k1}, zmm27, zmm6", "~{zmm8},~{dirflag},~{fpsr},~{flags}"() +// CHECK: ret void + __asm { + vaddpd zmm8 {k1}, zmm27, zmm6 + } +} Index: cfe/trunk/lib/Parse/ParseStmtAsm.cpp === --- cfe/trunk/lib/Parse/ParseStmtAsm.cpp +++ cfe/trunk/lib/Parse/ParseStmtAsm.cpp @@ -390,6 +390,7 @@ if (!InAsmComment && Tok.is(tok::l_brace)) { // Consume the opening brace. SkippedStartOfLine = Tok.isAtStartOfLine(); + AsmToks.push_back(Tok); EndLoc = ConsumeBrace(); BraceNesting++; LBraceLocs.push_back(EndLoc); @@ -442,6 +443,11 @@ BraceCount == (savedBraceCount + BraceNesting)) { // Consume the closing brace. SkippedStartOfLine = Tok.isAtStartOfLine(); + // Don't want to add the closing brace of the whole asm block + if (SingleLineMode || BraceNesting > 1) { +Tok.clearFlag(Token::LeadingSpace); +AsmToks.push_back(Tok); + } EndLoc = ConsumeBrace(); BraceNesting--; // Finish if all of the opened braces in the inline asm section were Index: cfe/trunk/test/Parser/ms-inline-asm.c === --- cfe/trunk/test/Parser/ms-inline-asm.c +++ cfe/trunk/test/Parser/ms-inline-asm.c @@ -53,6 +53,10 @@ void t12() { __asm jmp label // expected-error {{use of undeclared label 'label'}} } +void t13() { + __asm m{o}v eax, ebx // expected-error {{expected identifier}} expected-error {{use of undeclared label '{o}v eax, ebx'}} +} + int t_fail() { // expected-note {{to match this}} __asm __asm { // expected-error 3 {{expected}} expected-note {{to match this}} Index: cfe/trunk/test/CodeGen/ms-inline-asm.c === --- cfe/trunk/test/CodeGen/ms-inline-asm.c +++ cfe/trunk/test/CodeGen/ms-inline-asm.c @@ -86,7 +86,7 @@ __asm { pop ebx } } // CHECK: t9 -// 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, $$0x07\0A\09pop ebx\0A\09", "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"() } unsigned t10(void) { Index: cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c === --- cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c +++ cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c @@ -9,3 +9,13 @@ vaddpd zmm8, zmm27, zmm6 } } + + +void t2() { +// CHECK: @t2 +// CHECK: call void asm sideeffect inteldialect "vaddpd zmm8 {k1}, zmm27, zmm6", "~{zmm8},~{dirflag},~{fpsr},~{flags}"() +// CHECK: ret void + __asm { + vaddpd zmm8 {k1}, zmm27, zmm6 + } +} Index: cfe/trunk/lib/Parse/ParseStmtAsm.cpp === --- cfe/trunk/lib/Parse/ParseStmtAsm.cpp +++
r262842 - [ms-inline-asm][AVX512] Add ability to use k registers in MS inline asm + fix bag with curly braces
Author: myatsina Date: Mon Mar 7 12:10:25 2016 New Revision: 262842 URL: http://llvm.org/viewvc/llvm-project?rev=262842=rev Log: [ms-inline-asm][AVX512] Add ability to use k registers in MS inline asm + fix bag with curly braces Until now curly braces could only be used in MS inline assembly to mark block start/end. All curly braces were removed completely at a very early stage. This approach caused bugs like: "m{o}v eax, ebx" turned into "mov eax, ebx" without any error. In addition, AVX-512 added special operands (e.g., k registers), which are also surrounded by curly braces that mark them as such. Now, we need to keep the curly braces and identify at a later stage if they are marking block start/end (if so, ignore them), or surrounding special AVX-512 operands (if so, parse them as such). This patch fixes the bug described above and enables the use of AVX-512 special operands. This commit is the the clang part of the patch. The clang part of the review is: http://reviews.llvm.org/D17766 The llvm part of the review is: http://reviews.llvm.org/D17767 Differential Revision: http://reviews.llvm.org/D17766 Modified: cfe/trunk/lib/Parse/ParseStmtAsm.cpp cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c cfe/trunk/test/CodeGen/ms-inline-asm.c cfe/trunk/test/Parser/ms-inline-asm.c Modified: cfe/trunk/lib/Parse/ParseStmtAsm.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmtAsm.cpp?rev=262842=262841=262842=diff == --- cfe/trunk/lib/Parse/ParseStmtAsm.cpp (original) +++ cfe/trunk/lib/Parse/ParseStmtAsm.cpp Mon Mar 7 12:10:25 2016 @@ -390,6 +390,7 @@ StmtResult Parser::ParseMicrosoftAsmStat if (!InAsmComment && Tok.is(tok::l_brace)) { // Consume the opening brace. SkippedStartOfLine = Tok.isAtStartOfLine(); + AsmToks.push_back(Tok); EndLoc = ConsumeBrace(); BraceNesting++; LBraceLocs.push_back(EndLoc); @@ -442,6 +443,11 @@ StmtResult Parser::ParseMicrosoftAsmStat BraceCount == (savedBraceCount + BraceNesting)) { // Consume the closing brace. SkippedStartOfLine = Tok.isAtStartOfLine(); + // Don't want to add the closing brace of the whole asm block + if (SingleLineMode || BraceNesting > 1) { +Tok.clearFlag(Token::LeadingSpace); +AsmToks.push_back(Tok); + } EndLoc = ConsumeBrace(); BraceNesting--; // Finish if all of the opened braces in the inline asm section were Modified: cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c?rev=262842=262841=262842=diff == --- cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c (original) +++ cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c Mon Mar 7 12:10:25 2016 @@ -9,3 +9,13 @@ void t1() { vaddpd zmm8, zmm27, zmm6 } } + + +void t2() { +// CHECK: @t2 +// CHECK: call void asm sideeffect inteldialect "vaddpd zmm8 {k1}, zmm27, zmm6", "~{zmm8},~{dirflag},~{fpsr},~{flags}"() +// CHECK: ret void + __asm { + vaddpd zmm8 {k1}, zmm27, zmm6 + } +} Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=262842=262841=262842=diff == --- cfe/trunk/test/CodeGen/ms-inline-asm.c (original) +++ cfe/trunk/test/CodeGen/ms-inline-asm.c Mon Mar 7 12:10:25 2016 @@ -86,7 +86,7 @@ void t9() { __asm { pop ebx } } // CHECK: t9 -// 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, $$0x07\0A\09pop ebx\0A\09", "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"() } unsigned t10(void) { Modified: cfe/trunk/test/Parser/ms-inline-asm.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/ms-inline-asm.c?rev=262842=262841=262842=diff == --- cfe/trunk/test/Parser/ms-inline-asm.c (original) +++ cfe/trunk/test/Parser/ms-inline-asm.c Mon Mar 7 12:10:25 2016 @@ -53,6 +53,10 @@ void t11() { void t12() { __asm jmp label // expected-error {{use of undeclared label 'label'}} } +void t13() { + __asm m{o}v eax, ebx // expected-error {{expected identifier}} expected-error {{use of undeclared label '{o}v eax, ebx'}} +} + int t_fail() { // expected-note {{to match this}} __asm __asm { // expected-error 3 {{expected}} expected-note {{to match this}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17766: [ms-inline-asm][AVX512] Add ability to use k registers in MS inline asm + fix bag with curly braces
myatsina added a subscriber: cfe-commits. myatsina updated this revision to Diff 49945. myatsina marked an inline comment as done. myatsina added a comment. Updated test to reflect changes in the llvm part of the review (http://reviews.llvm.org/D17767) Repository: rL LLVM http://reviews.llvm.org/D17766 Files: lib/Parse/ParseStmtAsm.cpp test/CodeGen/ms-inline-asm-avx512.c test/CodeGen/ms-inline-asm.c test/Parser/ms-inline-asm.c Index: lib/Parse/ParseStmtAsm.cpp === --- lib/Parse/ParseStmtAsm.cpp +++ lib/Parse/ParseStmtAsm.cpp @@ -390,6 +390,7 @@ if (!InAsmComment && Tok.is(tok::l_brace)) { // Consume the opening brace. SkippedStartOfLine = Tok.isAtStartOfLine(); + AsmToks.push_back(Tok); EndLoc = ConsumeBrace(); BraceNesting++; LBraceLocs.push_back(EndLoc); @@ -442,6 +443,11 @@ BraceCount == (savedBraceCount + BraceNesting)) { // Consume the closing brace. SkippedStartOfLine = Tok.isAtStartOfLine(); + // Don't want to add the closing brace of the whole asm block + if (SingleLineMode || BraceNesting > 1) { +Tok.clearFlag(Token::LeadingSpace); +AsmToks.push_back(Tok); + } EndLoc = ConsumeBrace(); BraceNesting--; // Finish if all of the opened braces in the inline asm section were Index: test/CodeGen/ms-inline-asm.c === --- test/CodeGen/ms-inline-asm.c +++ test/CodeGen/ms-inline-asm.c @@ -86,7 +86,7 @@ __asm { pop ebx } } // CHECK: t9 -// 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, $$0x07\0A\09pop ebx\0A\09", "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"() } unsigned t10(void) { Index: test/CodeGen/ms-inline-asm-avx512.c === --- test/CodeGen/ms-inline-asm-avx512.c +++ test/CodeGen/ms-inline-asm-avx512.c @@ -9,3 +9,13 @@ vaddpd zmm8, zmm27, zmm6 } } + + +void t2() { +// CHECK: @t2 +// CHECK: call void asm sideeffect inteldialect "vaddpd zmm8 {k1}, zmm27, zmm6", "~{zmm8},~{dirflag},~{fpsr},~{flags}"() +// CHECK: ret void + __asm { + vaddpd zmm8 {k1}, zmm27, zmm6 + } +} Index: test/Parser/ms-inline-asm.c === --- test/Parser/ms-inline-asm.c +++ test/Parser/ms-inline-asm.c @@ -53,6 +53,10 @@ void t12() { __asm jmp label // expected-error {{use of undeclared label 'label'}} } +void t13() { + __asm m{o}v eax, ebx // expected-error {{expected identifier}} expected-error {{use of undeclared label '{o}v eax, ebx'}} +} + int t_fail() { // expected-note {{to match this}} __asm __asm { // expected-error 3 {{expected}} expected-note {{to match this}} Index: lib/Parse/ParseStmtAsm.cpp === --- lib/Parse/ParseStmtAsm.cpp +++ lib/Parse/ParseStmtAsm.cpp @@ -390,6 +390,7 @@ if (!InAsmComment && Tok.is(tok::l_brace)) { // Consume the opening brace. SkippedStartOfLine = Tok.isAtStartOfLine(); + AsmToks.push_back(Tok); EndLoc = ConsumeBrace(); BraceNesting++; LBraceLocs.push_back(EndLoc); @@ -442,6 +443,11 @@ BraceCount == (savedBraceCount + BraceNesting)) { // Consume the closing brace. SkippedStartOfLine = Tok.isAtStartOfLine(); + // Don't want to add the closing brace of the whole asm block + if (SingleLineMode || BraceNesting > 1) { +Tok.clearFlag(Token::LeadingSpace); +AsmToks.push_back(Tok); + } EndLoc = ConsumeBrace(); BraceNesting--; // Finish if all of the opened braces in the inline asm section were Index: test/CodeGen/ms-inline-asm.c === --- test/CodeGen/ms-inline-asm.c +++ test/CodeGen/ms-inline-asm.c @@ -86,7 +86,7 @@ __asm { pop ebx } } // CHECK: t9 -// 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, $$0x07\0A\09pop ebx\0A\09", "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"() } unsigned t10(void) { Index: test/CodeGen/ms-inline-asm-avx512.c === --- test/CodeGen/ms-inline-asm-avx512.c +++ test/CodeGen/ms-inline-asm-avx512.c @@ -9,3 +9,13 @@ vaddpd zmm8, zmm27, zmm6 } } + + +void t2() { +// CHECK: @t2 +// CHECK: call void asm sideeffect inteldialect "vaddpd zmm8 {k1}, zmm27, zmm6", "~{zmm8},~{dirflag},~{fpsr},~{flags}"() +// CHECK: ret void + __asm { + vaddpd zmm8 {k1}, zmm27, zmm6 + } +} Index: test/Parser/ms-inline-asm.c
r261618 - [ms-inline-asm] Fixing bug in single asm statement support
Author: myatsina Date: Tue Feb 23 02:53:45 2016 New Revision: 261618 URL: http://llvm.org/viewvc/llvm-project?rev=261618=rev Log: [ms-inline-asm] Fixing bug in single asm statement support Fixing a crash caused by trying to merge a single-line asm statement with an asm block that follows it, e.g: asm int 4 asm { int 5 } Now, only adjacent single-line asm statements that are not surrounded by braces will be merged into one asm call. Differential Revision: http://reviews.llvm.org/D17496 Modified: cfe/trunk/lib/Parse/ParseStmtAsm.cpp cfe/trunk/test/CodeGen/ms-inline-asm.c cfe/trunk/test/Parser/ms-inline-asm.c Modified: cfe/trunk/lib/Parse/ParseStmtAsm.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmtAsm.cpp?rev=261618=261617=261618=diff == --- cfe/trunk/lib/Parse/ParseStmtAsm.cpp (original) +++ cfe/trunk/lib/Parse/ParseStmtAsm.cpp Tue Feb 23 02:53:45 2016 @@ -423,6 +423,10 @@ StmtResult Parser::ParseMicrosoftAsmStat // We're no longer in a comment. InAsmComment = false; if (isAsm) { + // If this is a new __asm {} block we want to process it seperately + // from the single-line __asm statements + if (PP.LookAhead(0).is(tok::l_brace)) +break; LineNo = SrcMgr.getLineNumber(ExpLoc.first, ExpLoc.second); SkippedStartOfLine = Tok.isAtStartOfLine(); } Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=261618=261617=261618=diff == --- cfe/trunk/test/CodeGen/ms-inline-asm.c (original) +++ cfe/trunk/test/CodeGen/ms-inline-asm.c Tue Feb 23 02:53:45 2016 @@ -63,10 +63,19 @@ void t7() { int t8() { __asm int 4 ; } comments for single-line asm __asm {} - __asm int 4 + __asm { int 5} + __asm int 6 + __asm int 7 + __asm { +int 8 + } return 10; // CHECK: t8 -// CHECK: call i32 asm sideeffect inteldialect "int $$4\0A\09int $$4", "={eax},~{dirflag},~{fpsr},~{flags}"() +// CHECK: call i32 asm sideeffect inteldialect "int $$4", "={eax},~{dirflag},~{fpsr},~{flags}"() +// CHECK: call i32 asm sideeffect inteldialect "", "={eax},~{dirflag},~{fpsr},~{flags}"() +// CHECK: call i32 asm sideeffect inteldialect "int $$5", "={eax},~{dirflag},~{fpsr},~{flags}"() +// CHECK: call i32 asm sideeffect inteldialect "int $$6\0A\09int $$7", "={eax},~{dirflag},~{fpsr},~{flags}"() +// CHECK: call i32 asm sideeffect inteldialect "int $$8", "={eax},~{dirflag},~{fpsr},~{flags}"() // CHECK: ret i32 10 } Modified: cfe/trunk/test/Parser/ms-inline-asm.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/ms-inline-asm.c?rev=261618=261617=261618=diff == --- cfe/trunk/test/Parser/ms-inline-asm.c (original) +++ cfe/trunk/test/Parser/ms-inline-asm.c Tue Feb 23 02:53:45 2016 @@ -55,4 +55,4 @@ void t12() { } int t_fail() { // expected-note {{to match this}} __asm - __asm { // expected-error 2 {{expected}} expected-note {{to match this}} + __asm { // expected-error 3 {{expected}} expected-note {{to match this}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r259639 - -inline-asm][X86] Add ability to use AVX512 in MS inline asm
Author: myatsina Date: Wed Feb 3 05:32:08 2016 New Revision: 259639 URL: http://llvm.org/viewvc/llvm-project?rev=259639=rev Log: -inline-asm][X86] Add ability to use AVX512 in MS inline asm Defined the new AVX512 registers in clang inline asm. Fixed a bug in the MC subtarget info creation during the parsing of MS asm statement - now it receives the actual CPU and target features information. Differential Revision: http://reviews.llvm.org/D16757 Added: cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c (with props) Modified: cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/lib/Parse/ParseStmtAsm.cpp cfe/trunk/test/Sema/asm.c Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=259639=259638=259639=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Wed Feb 3 05:32:08 2016 @@ -2047,6 +2047,14 @@ static const char* const GCCRegNames[] = "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15", "ymm0", "ymm1", "ymm2", "ymm3", "ymm4", "ymm5", "ymm6", "ymm7", "ymm8", "ymm9", "ymm10", "ymm11", "ymm12", "ymm13", "ymm14", "ymm15", + "xmm16", "xmm17", "xmm18", "xmm19", "xmm20", "xmm21", "xmm22", "xmm23", + "xmm24", "xmm25", "xmm26", "xmm27", "xmm28", "xmm29", "xmm30", "xmm31", + "ymm16", "ymm17", "ymm18", "ymm19", "ymm20", "ymm21", "ymm22", "ymm23", + "ymm24", "ymm25", "ymm26", "ymm27", "ymm28", "ymm29", "ymm30", "ymm31", + "zmm0", "zmm1", "zmm2", "zmm3", "zmm4", "zmm5", "zmm6", "zmm7", + "zmm8", "zmm9", "zmm10", "zmm11", "zmm12", "zmm13", "zmm14", "zmm15", + "zmm16", "zmm17", "zmm18", "zmm19", "zmm20", "zmm21", "zmm22", "zmm23", + "zmm24", "zmm25", "zmm26", "zmm27", "zmm28", "zmm29", "zmm30", "zmm31", }; const TargetInfo::AddlRegName AddlRegNames[] = { Modified: cfe/trunk/lib/Parse/ParseStmtAsm.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmtAsm.cpp?rev=259639=259638=259639=diff == --- cfe/trunk/lib/Parse/ParseStmtAsm.cpp (original) +++ cfe/trunk/lib/Parse/ParseStmtAsm.cpp Wed Feb 3 05:32:08 2016 @@ -17,6 +17,7 @@ #include "clang/Basic/Diagnostic.h" #include "clang/Basic/TargetInfo.h" #include "llvm/ADT/SmallString.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCInstPrinter.h" @@ -522,13 +523,17 @@ StmtResult Parser::ParseMicrosoftAsmStat if (buildMSAsmString(PP, AsmLoc, AsmToks, TokOffsets, AsmString)) return StmtError(); + TargetOptions TO = Actions.Context.getTargetInfo().getTargetOpts(); + std::string FeaturesStr = + llvm::join(TO.Features.begin(), TO.Features.end(), ","); + std::unique_ptr MRI(TheTarget->createMCRegInfo(TT)); std::unique_ptr MAI(TheTarget->createMCAsmInfo(*MRI, TT)); // Get the instruction descriptor. std::unique_ptr MII(TheTarget->createMCInstrInfo()); std::unique_ptr MOFI(new llvm::MCObjectFileInfo()); std::unique_ptr STI( - TheTarget->createMCSubtargetInfo(TT, "", "")); + TheTarget->createMCSubtargetInfo(TT, TO.CPU, FeaturesStr)); llvm::SourceMgr TempSrcMgr; llvm::MCContext Ctx(MAI.get(), MRI.get(), MOFI.get(), ); Added: cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c?rev=259639=auto == --- cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c (added) +++ cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c Wed Feb 3 05:32:08 2016 @@ -0,0 +1,11 @@ +// REQUIRES: x86-registered-target +// RUN: %clang_cc1 %s -triple x86_64-pc-windows-msvc -target-cpu knl -fasm-blocks -emit-llvm -o - | FileCheck %s + +void t1() { +// CHECK: @t1 +// CHECK: call void asm sideeffect inteldialect "vaddpd zmm8, zmm27, zmm6", "~{zmm8},~{dirflag},~{fpsr},~{flags}"() +// CHECK: ret void + __asm { + vaddpd zmm8, zmm27, zmm6 + } +} Propchange: cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c -- svn:eol-style = native Propchange: cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c -- svn:keywords = Author Date Id Rev URL Propchange: cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c -- svn:mime-type = text/plain Modified: cfe/trunk/test/Sema/asm.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/asm.c?rev=259639=259638=259639=diff == --- cfe/trunk/test/Sema/asm.c (original) +++ cfe/trunk/test/Sema/asm.c Wed Feb 3 05:32:08 2016 @@ -25,7 +25,7 @@ void clobbers() { asm ("nop" : : : "0",
r256545 - [ms inline asm] Add support for label names with '$' chars
Author: myatsina Date: Tue Dec 29 02:49:34 2015 New Revision: 256545 URL: http://llvm.org/viewvc/llvm-project?rev=256545=rev Log: [ms inline asm] Add support for label names with '$' chars In MS inline asm syntax a label with '$' char produces an error, while in AT it does not. In AT inline asm syntax Clang escapes the '$' char and replaces it with "$$". Adopted same approach for MS syntax. Differential Revision: http://reviews.llvm.org/D15795 Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp cfe/trunk/test/CodeGen/ms-inline-asm.c Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=256545=256544=256545=diff == --- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original) +++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Tue Dec 29 02:49:34 2015 @@ -750,7 +750,15 @@ LabelDecl *Sema::GetOrCreateMSAsmLabel(S // Create an internal name for the label. The name should not be a valid mangled // name, and should be unique. We use a dot to make the name an invalid mangled // name. -OS << "__MSASMLABEL_." << MSAsmLabelNameCounter++ << "__" << ExternalLabelName; +OS << "__MSASMLABEL_." << MSAsmLabelNameCounter++ << "__"; +for (auto it = ExternalLabelName.begin(); it != ExternalLabelName.end(); + ++it) { + OS << *it; + if (*it == '$') { +// We escape '$' in asm strings by replacing it with "$$" +OS << '$'; + } +} Label->setMSAsmLabel(OS.str()); } if (AlwaysCreate) { Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=256545=256544=256545=diff == --- cfe/trunk/test/CodeGen/ms-inline-asm.c (original) +++ cfe/trunk/test/CodeGen/ms-inline-asm.c Tue Dec 29 02:49:34 2015 @@ -616,6 +616,15 @@ void label4() { // CHECK: call void asm sideeffect inteldialect "{{.*}}__MSASMLABEL_.4__label:\0A\09mov eax, {{.*}}__MSASMLABEL_.4__label", "~{eax},~{dirflag},~{fpsr},~{flags}"() } +void label5() { + __asm { +jmp dollar_label$ +dollar_label$: + } + // CHECK-LABEL: define void @label5 + // CHECK: call void asm sideeffect inteldialect "jmp {{.*}}__MSASMLABEL_.5__dollar_label$$\0A\09{{.*}}__MSASMLABEL_.5__dollar_label$$:", "~{dirflag},~{fpsr},~{flags}"() +} + typedef union _LARGE_INTEGER { struct { unsigned int LowPart; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D15795: [ms inline asm] Add support for label names with '$' chars
myatsina created this revision. myatsina added reviewers: ehsan, rnk. myatsina added subscribers: llvm-commits, cfe-commits. myatsina set the repository for this revision to rL LLVM. In MS inline asm syntax a label with '$' char produces an error, while in AT it does not. In AT inline asm syntax Clang escapes the '$' char and replaces it with "$$". Adopted same approach for MS syntax. Repository: rL LLVM http://reviews.llvm.org/D15795 Files: lib/Sema/SemaStmtAsm.cpp test/CodeGen/ms-inline-asm.c Index: lib/Sema/SemaStmtAsm.cpp === --- lib/Sema/SemaStmtAsm.cpp +++ lib/Sema/SemaStmtAsm.cpp @@ -750,7 +750,15 @@ // Create an internal name for the label. The name should not be a valid mangled // name, and should be unique. We use a dot to make the name an invalid mangled // name. -OS << "__MSASMLABEL_." << MSAsmLabelNameCounter++ << "__" << ExternalLabelName; +OS << "__MSASMLABEL_." << MSAsmLabelNameCounter++ << "__"; +for (auto it = ExternalLabelName.begin(); it != ExternalLabelName.end(); + ++it) { + OS << *it; + if (*it == '$') { +// We escape '$' in asm strings by replacing it with "$$" +OS << '$'; + } +} Label->setMSAsmLabel(OS.str()); } if (AlwaysCreate) { Index: test/CodeGen/ms-inline-asm.c === --- test/CodeGen/ms-inline-asm.c +++ test/CodeGen/ms-inline-asm.c @@ -616,6 +616,15 @@ // CHECK: call void asm sideeffect inteldialect "{{.*}}__MSASMLABEL_.4__label:\0A\09mov eax, {{.*}}__MSASMLABEL_.4__label", "~{eax},~{dirflag},~{fpsr},~{flags}"() } +void label5() { + __asm { +jmp dollar_label$ +dollar_label$: + } + // CHECK-LABEL: define void @label5 + // CHECK: call void asm sideeffect inteldialect "jmp {{.*}}__MSASMLABEL_.5__dollar_label$$\0A\09{{.*}}__MSASMLABEL_.5__dollar_label$$:", "~{dirflag},~{fpsr},~{flags}"() +} + typedef union _LARGE_INTEGER { struct { unsigned int LowPart; Index: lib/Sema/SemaStmtAsm.cpp === --- lib/Sema/SemaStmtAsm.cpp +++ lib/Sema/SemaStmtAsm.cpp @@ -750,7 +750,15 @@ // Create an internal name for the label. The name should not be a valid mangled // name, and should be unique. We use a dot to make the name an invalid mangled // name. -OS << "__MSASMLABEL_." << MSAsmLabelNameCounter++ << "__" << ExternalLabelName; +OS << "__MSASMLABEL_." << MSAsmLabelNameCounter++ << "__"; +for (auto it = ExternalLabelName.begin(); it != ExternalLabelName.end(); + ++it) { + OS << *it; + if (*it == '$') { +// We escape '$' in asm strings by replacing it with "$$" +OS << '$'; + } +} Label->setMSAsmLabel(OS.str()); } if (AlwaysCreate) { Index: test/CodeGen/ms-inline-asm.c === --- test/CodeGen/ms-inline-asm.c +++ test/CodeGen/ms-inline-asm.c @@ -616,6 +616,15 @@ // CHECK: call void asm sideeffect inteldialect "{{.*}}__MSASMLABEL_.4__label:\0A\09mov eax, {{.*}}__MSASMLABEL_.4__label", "~{eax},~{dirflag},~{fpsr},~{flags}"() } +void label5() { + __asm { +jmp dollar_label$ +dollar_label$: + } + // CHECK-LABEL: define void @label5 + // CHECK: call void asm sideeffect inteldialect "jmp {{.*}}__MSASMLABEL_.5__dollar_label$$\0A\09{{.*}}__MSASMLABEL_.5__dollar_label$$:", "~{dirflag},~{fpsr},~{flags}"() +} + typedef union _LARGE_INTEGER { struct { unsigned int LowPart; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r256382 - [X86][ms-inline asm] Test case for adding support for memory operands that include structs
Author: myatsina Date: Thu Dec 24 06:11:40 2015 New Revision: 256382 URL: http://llvm.org/viewvc/llvm-project?rev=256382=rev Log: [X86][ms-inline asm] Test case for adding support for memory operands that include structs Test case for commit 256381 Differential Revision: http://reviews.llvm.org/D15749 Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=256382=256381=256382=diff == --- cfe/trunk/test/CodeGen/ms-inline-asm.c (original) +++ cfe/trunk/test/CodeGen/ms-inline-asm.c Thu Dec 24 06:11:40 2015 @@ -536,6 +536,38 @@ void t42() { // CHECK: "=*m,~{dirflag},~{fpsr},~{flags}"(i32* %flags) } +void t43() { +// CHECK-LABEL: define void @t43 + C strct; +// Work around PR20368: These should be single line blocks + __asm { mov eax, 4[strct.c1] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[strct.c3 + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$8$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 8[strct.c2.a + 4 + 32*2 - 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$72$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 12[4 + strct.c2.b] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$16$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[4 + strct.c4.b2.b + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$12$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[64 + strct.c1 + (2*32)] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$132$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[64 + strct.c2.a - 2*32] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [strct.c4.b1 + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [strct.c4.b2.a + 4 + 32*2 - 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$64$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [4 + strct.c1] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [4 + strct.c2.b + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$8$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [64 + strct.c3 + (2*32)] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$128$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [64 + strct.c4.b2.b - 2*32] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) +} + void call_clobber() { __asm call t41 // CHECK-LABEL: define void @call_clobber ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15749: [X86][ms-inline asm] Test case for adding support for memory operands that include structs
This revision was automatically updated to reflect the committed changes. Closed by commit rL256382: [X86][ms-inline asm] Test case for adding support for memory operands that… (authored by myatsina). Changed prior to commit: http://reviews.llvm.org/D15749?vs=43531=43593#toc Repository: rL LLVM http://reviews.llvm.org/D15749 Files: cfe/trunk/test/CodeGen/ms-inline-asm.c Index: cfe/trunk/test/CodeGen/ms-inline-asm.c === --- cfe/trunk/test/CodeGen/ms-inline-asm.c +++ cfe/trunk/test/CodeGen/ms-inline-asm.c @@ -536,6 +536,38 @@ // CHECK: "=*m,~{dirflag},~{fpsr},~{flags}"(i32* %flags) } +void t43() { +// CHECK-LABEL: define void @t43 + C strct; +// Work around PR20368: These should be single line blocks + __asm { mov eax, 4[strct.c1] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[strct.c3 + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$8$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 8[strct.c2.a + 4 + 32*2 - 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$72$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 12[4 + strct.c2.b] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$16$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[4 + strct.c4.b2.b + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$12$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[64 + strct.c1 + (2*32)] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$132$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[64 + strct.c2.a - 2*32] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [strct.c4.b1 + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [strct.c4.b2.a + 4 + 32*2 - 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$64$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [4 + strct.c1] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [4 + strct.c2.b + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$8$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [64 + strct.c3 + (2*32)] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$128$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [64 + strct.c4.b2.b - 2*32] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) +} + void call_clobber() { __asm call t41 // CHECK-LABEL: define void @call_clobber Index: cfe/trunk/test/CodeGen/ms-inline-asm.c === --- cfe/trunk/test/CodeGen/ms-inline-asm.c +++ cfe/trunk/test/CodeGen/ms-inline-asm.c @@ -536,6 +536,38 @@ // CHECK: "=*m,~{dirflag},~{fpsr},~{flags}"(i32* %flags) } +void t43() { +// CHECK-LABEL: define void @t43 + C strct; +// Work around PR20368: These should be single line blocks + __asm { mov eax, 4[strct.c1] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[strct.c3 + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$8$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 8[strct.c2.a + 4 + 32*2 - 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$72$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 12[4 + strct.c2.b] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$16$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[4 + strct.c4.b2.b + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$12$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[64 + strct.c1 + (2*32)] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$132$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[64 + strct.c2.a - 2*32] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [strct.c4.b1 + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov
[PATCH] D15749: [X86][ms-inline asm] Test case for adding support for memory operands that include structs
myatsina created this revision. myatsina added reviewers: rnk, mcrosier. myatsina added subscribers: llvm-commits, cfe-commits. myatsina set the repository for this revision to rL LLVM. Test case for review: http://reviews.llvm.org/D15748 Repository: rL LLVM http://reviews.llvm.org/D15749 Files: test/CodeGen/ms-inline-asm.c Index: test/CodeGen/ms-inline-asm.c === --- test/CodeGen/ms-inline-asm.c +++ test/CodeGen/ms-inline-asm.c @@ -536,6 +536,38 @@ // CHECK: "=*m,~{dirflag},~{fpsr},~{flags}"(i32* %flags) } +void t43() { +// CHECK-LABEL: define void @t43 + C strct; +// Work around PR20368: These should be single line blocks + __asm { mov eax, 4[strct.c1] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[strct.c3 + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$8$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 8[strct.c2.a + 4 + 32*2 - 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$72$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 12[4 + strct.c2.b] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$16$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[4 + strct.c4.b2.b + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$12$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[64 + strct.c1 + (2*32)] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$132$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[64 + strct.c2.a - 2*32] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [strct.c4.b1 + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [strct.c4.b2.a + 4 + 32*2 - 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$64$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [4 + strct.c1] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [4 + strct.c2.b + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$8$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [64 + strct.c3 + (2*32)] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$128$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [64 + strct.c4.b2.b - 2*32] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) +} + void call_clobber() { __asm call t41 // CHECK-LABEL: define void @call_clobber Index: test/CodeGen/ms-inline-asm.c === --- test/CodeGen/ms-inline-asm.c +++ test/CodeGen/ms-inline-asm.c @@ -536,6 +536,38 @@ // CHECK: "=*m,~{dirflag},~{fpsr},~{flags}"(i32* %flags) } +void t43() { +// CHECK-LABEL: define void @t43 + C strct; +// Work around PR20368: These should be single line blocks + __asm { mov eax, 4[strct.c1] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[strct.c3 + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$8$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 8[strct.c2.a + 4 + 32*2 - 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$72$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 12[4 + strct.c2.b] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$16$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[4 + strct.c4.b2.b + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$12$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[64 + strct.c1 + (2*32)] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$132$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[64 + strct.c2.a - 2*32] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [strct.c4.b1 + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [strct.c4.b2.a + 4 + 32*2 - 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr
r255890 - [ms-inline-asm] Add support for composite structs in MS inline asm
Author: myatsina Date: Thu Dec 17 06:51:51 2015 New Revision: 255890 URL: http://llvm.org/viewvc/llvm-project?rev=255890=rev Log: [ms-inline-asm] Add support for composite structs in MS inline asm Add MS inline asm support for structs that contain fields that are also structs. Differential Revision: http://reviews.llvm.org/D15578 Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp cfe/trunk/test/CodeGen/ms-inline-asm.c Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=255890=255889=255890=diff == --- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original) +++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Thu Dec 17 06:51:51 2015 @@ -617,45 +617,57 @@ ExprResult Sema::LookupInlineAsmIdentifi bool Sema::LookupInlineAsmField(StringRef Base, StringRef Member, unsigned , SourceLocation AsmLoc) { Offset = 0; + SmallVectorMembers; + Member.split(Members, "."); + LookupResult BaseResult(*this, (Base), SourceLocation(), LookupOrdinaryName); if (!LookupName(BaseResult, getCurScope())) return true; - if (!BaseResult.isSingleResult()) -return true; + LookupResult CurrBaseResult(BaseResult); - const RecordType *RT = nullptr; - NamedDecl *FoundDecl = BaseResult.getFoundDecl(); - if (VarDecl *VD = dyn_cast(FoundDecl)) -RT = VD->getType()->getAs(); - else if (TypedefNameDecl *TD = dyn_cast(FoundDecl)) { -MarkAnyDeclReferenced(TD->getLocation(), TD, /*OdrUse=*/false); -RT = TD->getUnderlyingType()->getAs(); - } else if (TypeDecl *TD = dyn_cast(FoundDecl)) -RT = TD->getTypeForDecl()->getAs(); - if (!RT) -return true; - - if (RequireCompleteType(AsmLoc, QualType(RT, 0), 0)) -return true; + for (StringRef NextMember : Members) { - LookupResult FieldResult(*this, (Member), SourceLocation(), - LookupMemberName); - - if (!LookupQualifiedName(FieldResult, RT->getDecl())) -return true; - - // FIXME: Handle IndirectFieldDecl? - FieldDecl *FD = dyn_cast(FieldResult.getFoundDecl()); - if (!FD) -return true; +if (!CurrBaseResult.isSingleResult()) + return true; - const ASTRecordLayout = Context.getASTRecordLayout(RT->getDecl()); - unsigned i = FD->getFieldIndex(); - CharUnits Result = Context.toCharUnitsFromBits(RL.getFieldOffset(i)); - Offset = (unsigned)Result.getQuantity(); +const RecordType *RT = nullptr; +NamedDecl *FoundDecl = CurrBaseResult.getFoundDecl(); +if (VarDecl *VD = dyn_cast(FoundDecl)) + RT = VD->getType()->getAs(); +else if (TypedefNameDecl *TD = dyn_cast(FoundDecl)) { + MarkAnyDeclReferenced(TD->getLocation(), TD, /*OdrUse=*/false); + RT = TD->getUnderlyingType()->getAs(); +} else if (TypeDecl *TD = dyn_cast(FoundDecl)) + RT = TD->getTypeForDecl()->getAs(); +else if (FieldDecl *TD = dyn_cast(FoundDecl)) + RT = TD->getType()->getAs(); +if (!RT) + return true; + +if (RequireCompleteType(AsmLoc, QualType(RT, 0), 0)) + return true; + +LookupResult FieldResult(*this, (NextMember), + SourceLocation(), LookupMemberName); + +if (!LookupQualifiedName(FieldResult, RT->getDecl())) + return true; + +// FIXME: Handle IndirectFieldDecl? +FieldDecl *FD = dyn_cast(FieldResult.getFoundDecl()); +if (!FD) + return true; + +CurrBaseResult = FieldResult; + +const ASTRecordLayout = Context.getASTRecordLayout(RT->getDecl()); +unsigned i = FD->getFieldIndex(); +CharUnits Result = Context.toCharUnitsFromBits(RL.getFieldOffset(i)); +Offset += (unsigned)Result.getQuantity(); + } return false; } Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=255890=255889=255890=diff == --- cfe/trunk/test/CodeGen/ms-inline-asm.c (original) +++ cfe/trunk/test/CodeGen/ms-inline-asm.c Thu Dec 17 06:51:51 2015 @@ -470,6 +470,18 @@ typedef struct { int b; } A; +typedef struct { + int b1; + A b2; +} B; + +typedef struct { + int c1; + A c2; + int c3; + B c4; +} C; + void t39() { // CHECK-LABEL: define void @t39 __asm mov eax, [eax].A.b @@ -478,6 +490,14 @@ void t39() { // CHECK: mov eax, [eax] .4 __asm mov eax, fs:[0] A.b // CHECK: mov eax, fs:[$$0] .4 + __asm mov eax, [eax].B.b2.a +// CHECK: mov eax, [eax].4 + __asm mov eax, [eax] B.b2.b +// CHECK: mov eax, [eax] .8 + __asm mov eax, fs:[0] C.c2.b +// CHECK: mov eax, fs:[$$0] .8 + __asm mov eax, [eax]C.c4.b2.b +// CHECK: mov eax, [eax].24 // CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"() } ___ cfe-commits mailing list cfe-commits@lists.llvm.org