]> granicus.if.org Git - clang/commit
clang support gnu asm goto.
authorJennifer Yu <jennifer.yu@intel.com>
Thu, 30 May 2019 01:05:46 +0000 (01:05 +0000)
committerJennifer Yu <jennifer.yu@intel.com>
Thu, 30 May 2019 01:05:46 +0000 (01:05 +0000)
commit5846cacafa3a592f1745aaa20297d744c40dc56c
treefc80c301f42eca03b5b029c2d43d44a9e2eaba70
parente7fac8a0763b4595c1e8db743697857a93d2bf7d
clang support gnu asm goto.
Syntax:
  asm [volatile] goto ( AssemblerTemplate
                      :
                      : InputOperands
                      : Clobbers
                      : GotoLabels)

https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html

New llvm IR is "callbr" for inline asm goto instead "call" for inline asm
For:
asm goto("testl %0, %0; jne %l1;" :: "r"(cond)::label_true, loop);
IR:
callbr void asm sideeffect "testl $0, $0; jne ${1:l};", "r,X,X,~{dirflag},~{fpsr},~{flags}"(i32 %0, i8* blockaddress(@foo, %label_true), i8* blockaddress(@foo, %loop)) #1
          to label %asm.fallthrough [label %label_true, label %loop], !srcloc !3

asm.fallthrough:

Compiler need to generate:
1> a dummy constarint 'X' for each label.
2> an unique fallthrough label for each asm goto stmt " asm.fallthrough%number".

Diagnostic
1> duplicate asm operand name are used in output, input and label.
2> goto out of scope.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@362045 91177308-0d34-0410-b5e6-96231b3b80d8
28 files changed:
include/clang/AST/Stmt.h
include/clang/Basic/DiagnosticParseKinds.td
include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Sema/Sema.h
lib/AST/ASTImporter.cpp
lib/AST/Stmt.cpp
lib/AST/StmtPrinter.cpp
lib/AST/StmtProfile.cpp
lib/Analysis/CFG.cpp
lib/CodeGen/CGStmt.cpp
lib/Parse/ParseStmtAsm.cpp
lib/Sema/JumpDiagnostics.cpp
lib/Sema/SemaStmtAsm.cpp
lib/Sema/TreeTransform.h
lib/Serialization/ASTReaderStmt.cpp
lib/Serialization/ASTWriterStmt.cpp
test/Analysis/asm-goto.cpp [new file with mode: 0644]
test/CodeGen/asm-goto.c [new file with mode: 0644]
test/CodeGen/asm.c
test/CodeGen/inline-asm-mixed-style.c
test/Coverage/c-language-features.inc
test/PCH/asm.h
test/Parser/asm.c
test/Parser/asm.cpp
test/Sema/asm-goto.cpp [new file with mode: 0644]
test/Sema/asm.c
test/Sema/inline-asm-validate-tmpl.cpp
test/Sema/scope-check.c