From: Chad Rosier Date: Fri, 12 Oct 2012 21:37:00 +0000 (+0000) Subject: [ms-inline asm] Remove a bunch of parsing code from the front-end, which will be X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fba3fb9a14f2d729639e0fdb834e3eeb40a8a12a;p=clang [ms-inline asm] Remove a bunch of parsing code from the front-end, which will be reimplemented in the AsmParser where it belongs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165825 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaStmtAsm.cpp b/lib/Sema/SemaStmtAsm.cpp index c29a8b17c2..ded1c3f780 100644 --- a/lib/Sema/SemaStmtAsm.cpp +++ b/lib/Sema/SemaStmtAsm.cpp @@ -320,17 +320,6 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, return Owned(NS); } -// isMSAsmKeyword - Return true if this is an MS-style inline asm keyword. These -// require special handling. -static bool isMSAsmKeyword(StringRef Name) { - bool Ret = llvm::StringSwitch(Name) - .Cases("EVEN", "ALIGN", true) // Alignment directives. - .Cases("LENGTH", "SIZE", "TYPE", true) // Type and variable sizes. - .Case("_emit", true) // _emit Pseudoinstruction. - .Default(false); - return Ret; -} - // getSpelling - Get the spelling of the AsmTok token. static StringRef getSpelling(Sema &SemaRef, Token AsmTok) { StringRef Asm; @@ -342,28 +331,9 @@ static StringRef getSpelling(Sema &SemaRef, Token AsmTok) { return Asm; } -// Determine if we should bail on this MSAsm instruction. -static bool bailOnMSAsm(std::vector Piece) { - for (unsigned i = 0, e = Piece.size(); i != e; ++i) - if (isMSAsmKeyword(Piece[i])) - return true; - return false; -} - -// Determine if we should bail on this MSAsm block. -static bool bailOnMSAsm(std::vector > Pieces) { - for (unsigned i = 0, e = Pieces.size(); i != e; ++i) - if (bailOnMSAsm(Pieces[i])) - return true; - return false; -} - // Determine if this is a simple MSAsm instruction. static bool isSimpleMSAsm(std::vector &Pieces, const TargetInfo &TI) { - if (isMSAsmKeyword(Pieces[0])) - return false; - for (unsigned i = 1, e = Pieces.size(); i != e; ++i) { if (!TI.isValidGCCRegisterName(Pieces[i])) return false; @@ -479,9 +449,6 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, bool IsSimple = isSimpleMSAsm(Pieces, Context.getTargetInfo()); - // AsmParser doesn't fully support these asm statements. - if (bailOnMSAsm(Pieces)) { DEF_SIMPLE_MSASM(EmptyAsmStr); return Owned(NS); } - // Get the target specific parser. std::string Error; const std::string &TT = Context.getTargetInfo().getTriple().getTriple(); diff --git a/test/CodeGen/ms-inline-asm.c b/test/CodeGen/ms-inline-asm.c index cfdcfc38ad..62e466bf7b 100644 --- a/test/CodeGen/ms-inline-asm.c +++ b/test/CodeGen/ms-inline-asm.c @@ -97,41 +97,12 @@ unsigned t10(void) { } void t11(void) { - __asm EVEN - __asm ALIGN -// CHECK: t11 -// CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() nounwind -// CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() nounwind -} - -void t12(void) { - __asm { - _emit 0x4A - _emit 0x43 - _emit 0x4B - } -// CHECK: t12 -// CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() nounwind -} - -void t13(void) { - unsigned arr[10]; - __asm LENGTH arr ; sizeof(arr)/sizeof(arr[0]) - __asm SIZE arr ; sizeof(arr) - __asm TYPE arr ; sizeof(arr[0]) -// CHECK: t13 -// CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() nounwind -// CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() nounwind -// CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() nounwind -} - -void t14(void) { __asm mov eax, 1 -// CHECK: t14 +// CHECK: t11 // CHECK: call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"() nounwind } -unsigned t15(void) { +unsigned t12(void) { unsigned i = 1, j, l = 1, m; __asm { mov eax, i @@ -140,6 +111,6 @@ unsigned t15(void) { mov m, eax } return j + m; -// CHECK: t15 +// CHECK: t12 // CHECK: call void asm sideeffect inteldialect "mov eax, $2\0A\09mov $0, eax\0A\09mov eax, $3\0A\09mov $1, eax", "=*m,=*m,*m,*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32* %{{.*}}, i32* %{{.*}}, i32* %{{.*}}) nounwind }