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. |
(...skipping 1683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1694 bool HasSideEffect = S.isVolatile() || S.getNumOutputs() == 0; | 1694 bool HasSideEffect = S.isVolatile() || S.getNumOutputs() == 0; |
1695 llvm::InlineAsm::AsmDialect AsmDialect = isa<MSAsmStmt>(&S) ? | 1695 llvm::InlineAsm::AsmDialect AsmDialect = isa<MSAsmStmt>(&S) ? |
1696 llvm::InlineAsm::AD_Intel : llvm::InlineAsm::AD_ATT; | 1696 llvm::InlineAsm::AD_Intel : llvm::InlineAsm::AD_ATT; |
1697 llvm::InlineAsm *IA = | 1697 llvm::InlineAsm *IA = |
1698 llvm::InlineAsm::get(FTy, AsmString, Constraints, HasSideEffect, | 1698 llvm::InlineAsm::get(FTy, AsmString, Constraints, HasSideEffect, |
1699 /* IsAlignStack */ false, AsmDialect); | 1699 /* IsAlignStack */ false, AsmDialect); |
1700 llvm::CallInst *Result = Builder.CreateCall(IA, Args); | 1700 llvm::CallInst *Result = Builder.CreateCall(IA, Args); |
1701 Result->addAttribute(llvm::AttributeSet::FunctionIndex, | 1701 Result->addAttribute(llvm::AttributeSet::FunctionIndex, |
1702 llvm::Attribute::NoUnwind); | 1702 llvm::Attribute::NoUnwind); |
1703 | 1703 |
| 1704 // @LOCALMOD-START |
| 1705 // For PNaCl, emit two compiler fences containing a sequentially |
| 1706 // consistent fence (just like __sync_synchronize). This should |
| 1707 // enforce ordering of more than just atomic memory accesses, though |
| 1708 // it won't guarantee that all accesses (e.g. those to non-escaping |
| 1709 // objects) will not be reordered. |
| 1710 bool isEmptyAsm = AsmString.empty(); |
| 1711 // Different triples will encode "touch everything" differently, e.g.: |
| 1712 // - le32-unknown-nacl has "~{memory}". |
| 1713 // - x86 "~{memory},~{dirflag},~{fpsr},~{flags}". |
| 1714 // The following code therefore only searches for memory: this pass |
| 1715 // deals with portable assembly, touching anything else than memory in |
| 1716 // an empty assembly statement is meaningless. |
| 1717 bool touchesMemory = Constraints.find("~{memory}") != std::string::npos; |
| 1718 |
| 1719 if (getTarget().getTriple().getArch() == llvm::Triple::le32 && |
| 1720 ResultType->isVoidTy() && HasSideEffect && isEmptyAsm && touchesMemory) { |
| 1721 Builder.CreateFence(llvm::SequentiallyConsistent); |
| 1722 Builder.CreateCall( |
| 1723 llvm::InlineAsm::get(FTy, AsmString, Constraints, HasSideEffect))-> |
| 1724 addAttribute(llvm::AttributeSet::FunctionIndex, |
| 1725 llvm::Attribute::NoUnwind); |
| 1726 } |
| 1727 // @LOCALMOD-END |
| 1728 |
1704 // Slap the source location of the inline asm into a !srcloc metadata on the | 1729 // Slap the source location of the inline asm into a !srcloc metadata on the |
1705 // call. FIXME: Handle metadata for MS-style inline asms. | 1730 // call. FIXME: Handle metadata for MS-style inline asms. |
1706 if (const GCCAsmStmt *gccAsmStmt = dyn_cast<GCCAsmStmt>(&S)) | 1731 if (const GCCAsmStmt *gccAsmStmt = dyn_cast<GCCAsmStmt>(&S)) |
1707 Result->setMetadata("srcloc", getAsmSrcLocInfo(gccAsmStmt->getAsmString(), | 1732 Result->setMetadata("srcloc", getAsmSrcLocInfo(gccAsmStmt->getAsmString(), |
1708 *this)); | 1733 *this)); |
1709 | 1734 |
1710 // Extract all of the register value results from the asm. | 1735 // Extract all of the register value results from the asm. |
1711 std::vector<llvm::Value*> RegResults; | 1736 std::vector<llvm::Value*> RegResults; |
1712 if (ResultRegTypes.size() == 1) { | 1737 if (ResultRegTypes.size() == 1) { |
1713 RegResults.push_back(Result); | 1738 RegResults.push_back(Result); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1747 } | 1772 } |
1748 } | 1773 } |
1749 | 1774 |
1750 EmitStoreThroughLValue(RValue::get(Tmp), ResultRegDests[i]); | 1775 EmitStoreThroughLValue(RValue::get(Tmp), ResultRegDests[i]); |
1751 } | 1776 } |
1752 } | 1777 } |
1753 | 1778 |
1754 void CodeGenFunction::EmitCapturedStmt(const CapturedStmt &S) { | 1779 void CodeGenFunction::EmitCapturedStmt(const CapturedStmt &S) { |
1755 llvm_unreachable("not implemented yet"); | 1780 llvm_unreachable("not implemented yet"); |
1756 } | 1781 } |
OLD | NEW |