Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: lib/IR/NaClAsm.cpp

Issue 22474008: Add the new @llvm.nacl.atomic.fence.all intrinsic (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 //===-- llvm/IR/NaClAsm.h - NaCl Assembly Handling --------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "llvm/IR/InlineAsm.h"
11 #include "llvm/IR/Instruction.h"
12 #include "llvm/IR/Instructions.h"
13 #include "llvm/IR/NaClAsm.h"
14 #include <string>
15
16 namespace llvm {
17
18 namespace NaCl {
19
20 bool isAsmMemory(const Instruction *I) {
21 if (!I)
22 return false;
23 const CallInst *CI = dyn_cast<CallInst>(I);
24 if (!CI || !CI->isInlineAsm())
25 return false;
26
27 const InlineAsm *A = cast<InlineAsm>(CI->getCalledValue());
28 std::string AsmString(A->getAsmString());
29 std::string Constraints(A->getConstraintString());
30 Type *T = CI->getType();
31
32 bool isEmptyAsm = AsmString.empty();
33 // Different triples will encode "touch everything" differently, e.g.:
34 // - le32-unknown-nacl has "~{memory}".
35 // - x86 "~{memory},~{dirflag},~{fpsr},~{flags}".
36 // The following code therefore only searches for memory: this pass
37 // deals with portable assembly, touching anything else than memory in
38 // an empty assembly statement is meaningless.
39 bool touchesMemory = Constraints.find("~{memory}") != std::string::npos;
40
41 return T->isVoidTy() && A->hasSideEffects() && isEmptyAsm && touchesMemory;
42 }
43
44 } // End NaCl namespace
45
46 } // End llvm namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698