Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===--- CGStmt.cpp - Emit LLVM Code from Statements ----------------------===// | 1 //===--- CGStmt.cpp - Emit LLVM Code from Statements ----------------------===// |
| 2 // | 2 // |
| 3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 // This contains code to emit Stmt nodes as LLVM code. | 10 // This contains code to emit Stmt nodes as LLVM code. |
| 11 // | 11 // |
| 12 //===----------------------------------------------------------------------===// | 12 //===----------------------------------------------------------------------===// |
| 13 | 13 |
| 14 #include "CodeGenFunction.h" | 14 #include "CodeGenFunction.h" |
| 15 #include "CGDebugInfo.h" | 15 #include "CGDebugInfo.h" |
| 16 #include "CodeGenModule.h" | 16 #include "CodeGenModule.h" |
| 17 #include "TargetInfo.h" | 17 #include "TargetInfo.h" |
| 18 #include "clang/AST/StmtVisitor.h" | 18 #include "clang/AST/StmtVisitor.h" |
| 19 #include "clang/Basic/PrettyStackTrace.h" | 19 #include "clang/Basic/PrettyStackTrace.h" |
| 20 #include "clang/Basic/TargetInfo.h" | 20 #include "clang/Basic/TargetInfo.h" |
| 21 #include "llvm/ADT/StringExtras.h" | 21 #include "llvm/ADT/StringExtras.h" |
| 22 #include "llvm/IR/DataLayout.h" | 22 #include "llvm/IR/DataLayout.h" |
| 23 #include "llvm/IR/InlineAsm.h" | 23 #include "llvm/IR/InlineAsm.h" |
| 24 #include "llvm/IR/Intrinsics.h" | 24 #include "llvm/IR/Intrinsics.h" |
| 25 #include "llvm/IR/NaClAsm.h" // @LOCALMOD | |
|
eliben
2013/08/07 18:06:25
This is a problem for upstreaming, no?
From the o
JF
2013/08/07 19:48:12
Done.
| |
| 25 using namespace clang; | 26 using namespace clang; |
| 26 using namespace CodeGen; | 27 using namespace CodeGen; |
| 27 | 28 |
| 28 //===----------------------------------------------------------------------===// | 29 //===----------------------------------------------------------------------===// |
| 29 // Statement Emission | 30 // Statement Emission |
| 30 //===----------------------------------------------------------------------===// | 31 //===----------------------------------------------------------------------===// |
| 31 | 32 |
| 32 void CodeGenFunction::EmitStopPoint(const Stmt *S) { | 33 void CodeGenFunction::EmitStopPoint(const Stmt *S) { |
| 33 if (CGDebugInfo *DI = getDebugInfo()) { | 34 if (CGDebugInfo *DI = getDebugInfo()) { |
| 34 SourceLocation Loc; | 35 SourceLocation Loc; |
| (...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1694 bool HasSideEffect = S.isVolatile() || S.getNumOutputs() == 0; | 1695 bool HasSideEffect = S.isVolatile() || S.getNumOutputs() == 0; |
| 1695 llvm::InlineAsm::AsmDialect AsmDialect = isa<MSAsmStmt>(&S) ? | 1696 llvm::InlineAsm::AsmDialect AsmDialect = isa<MSAsmStmt>(&S) ? |
| 1696 llvm::InlineAsm::AD_Intel : llvm::InlineAsm::AD_ATT; | 1697 llvm::InlineAsm::AD_Intel : llvm::InlineAsm::AD_ATT; |
| 1697 llvm::InlineAsm *IA = | 1698 llvm::InlineAsm *IA = |
| 1698 llvm::InlineAsm::get(FTy, AsmString, Constraints, HasSideEffect, | 1699 llvm::InlineAsm::get(FTy, AsmString, Constraints, HasSideEffect, |
| 1699 /* IsAlignStack */ false, AsmDialect); | 1700 /* IsAlignStack */ false, AsmDialect); |
| 1700 llvm::CallInst *Result = Builder.CreateCall(IA, Args); | 1701 llvm::CallInst *Result = Builder.CreateCall(IA, Args); |
| 1701 Result->addAttribute(llvm::AttributeSet::FunctionIndex, | 1702 Result->addAttribute(llvm::AttributeSet::FunctionIndex, |
| 1702 llvm::Attribute::NoUnwind); | 1703 llvm::Attribute::NoUnwind); |
| 1703 | 1704 |
| 1705 // @LOCALMOD-START | |
| 1706 if (getTargetHooks().asmMemoryIsFence() && llvm::NaCl::isAsmMemory(Result)) { | |
|
eliben
2013/08/07 18:06:25
It's weird that you're going the generic way with
JF
2013/08/07 19:48:12
Done.
| |
| 1707 // Targets can ask that ``asm("":::"memory")`` be treated like | |
| 1708 // ``__sync_synchronize()``. | |
| 1709 Builder.CreateFence(llvm::SequentiallyConsistent); | |
| 1710 Builder.CreateCall( | |
| 1711 llvm::InlineAsm::get(FTy, AsmString, Constraints, HasSideEffect))-> | |
| 1712 addAttribute(llvm::AttributeSet::FunctionIndex, | |
| 1713 llvm::Attribute::NoUnwind); | |
| 1714 } | |
| 1715 // @LOCALMOD-END | |
| 1716 | |
| 1704 // Slap the source location of the inline asm into a !srcloc metadata on the | 1717 // Slap the source location of the inline asm into a !srcloc metadata on the |
| 1705 // call. FIXME: Handle metadata for MS-style inline asms. | 1718 // call. FIXME: Handle metadata for MS-style inline asms. |
| 1706 if (const GCCAsmStmt *gccAsmStmt = dyn_cast<GCCAsmStmt>(&S)) | 1719 if (const GCCAsmStmt *gccAsmStmt = dyn_cast<GCCAsmStmt>(&S)) |
| 1707 Result->setMetadata("srcloc", getAsmSrcLocInfo(gccAsmStmt->getAsmString(), | 1720 Result->setMetadata("srcloc", getAsmSrcLocInfo(gccAsmStmt->getAsmString(), |
| 1708 *this)); | 1721 *this)); |
| 1709 | 1722 |
| 1710 // Extract all of the register value results from the asm. | 1723 // Extract all of the register value results from the asm. |
| 1711 std::vector<llvm::Value*> RegResults; | 1724 std::vector<llvm::Value*> RegResults; |
| 1712 if (ResultRegTypes.size() == 1) { | 1725 if (ResultRegTypes.size() == 1) { |
| 1713 RegResults.push_back(Result); | 1726 RegResults.push_back(Result); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1747 } | 1760 } |
| 1748 } | 1761 } |
| 1749 | 1762 |
| 1750 EmitStoreThroughLValue(RValue::get(Tmp), ResultRegDests[i]); | 1763 EmitStoreThroughLValue(RValue::get(Tmp), ResultRegDests[i]); |
| 1751 } | 1764 } |
| 1752 } | 1765 } |
| 1753 | 1766 |
| 1754 void CodeGenFunction::EmitCapturedStmt(const CapturedStmt &S) { | 1767 void CodeGenFunction::EmitCapturedStmt(const CapturedStmt &S) { |
| 1755 llvm_unreachable("not implemented yet"); | 1768 llvm_unreachable("not implemented yet"); |
| 1756 } | 1769 } |
| OLD | NEW |