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

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

Issue 939073008: Rebased PNaCl localmods in LLVM to 223109 (Closed)
Patch Set: undo localmod Created 5 years, 10 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
« no previous file with comments | « lib/IR/Instructions.cpp ('k') | lib/IRReader/IRReader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 //=== llvm/IR/NaClAtomicIntrinsics.cpp - NaCl Atomic Intrinsics -*- 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 // This file describes atomic intrinsic functions that are specific to NaCl.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/IR/DerivedTypes.h"
15 #include "llvm/IR/NaClAtomicIntrinsics.h"
16 #include "llvm/IR/Type.h"
17
18 namespace llvm {
19
20 namespace NaCl {
21
22 AtomicIntrinsics::AtomicIntrinsics(LLVMContext &C) {
23 Type *IT[NumAtomicIntrinsicOverloadTypes] = { Type::getInt8Ty(C),
24 Type::getInt16Ty(C),
25 Type::getInt32Ty(C),
26 Type::getInt64Ty(C) };
27 size_t CurIntrin = 0;
28
29 // Initialize each of the atomic intrinsics and their overloads. They
30 // have up to 5 parameters, the following macro will take care of
31 // overloading.
32 #define INIT(P0, P1, P2, P3, P4, INTRIN) \
33 do { \
34 for (size_t CurType = 0; CurType != NumAtomicIntrinsicOverloadTypes; \
35 ++CurType) { \
36 size_t Param = 0; \
37 I[CurIntrin][CurType].OverloadedType = IT[CurType]; \
38 I[CurIntrin][CurType].ID = Intrinsic::nacl_atomic_##INTRIN; \
39 I[CurIntrin][CurType].Overloaded = \
40 P0 == Int || P0 == Ptr || P1 == Int || P1 == Ptr || P2 == Int || \
41 P2 == Ptr || P3 == Int || P3 == Ptr || P4 == Int || P4 == Ptr; \
42 I[CurIntrin][CurType].NumParams = \
43 (P0 != NoP) + (P1 != NoP) + (P2 != NoP) + (P3 != NoP) + (P4 != NoP); \
44 I[CurIntrin][CurType].ParamType[Param++] = P0; \
45 I[CurIntrin][CurType].ParamType[Param++] = P1; \
46 I[CurIntrin][CurType].ParamType[Param++] = P2; \
47 I[CurIntrin][CurType].ParamType[Param++] = P3; \
48 I[CurIntrin][CurType].ParamType[Param++] = P4; \
49 } \
50 ++CurIntrin; \
51 } while (0)
52
53 INIT(Ptr, Mem, NoP, NoP, NoP, load);
54 INIT(Ptr, Int, Mem, NoP, NoP, store);
55 INIT(RMW, Ptr, Int, Mem, NoP, rmw);
56 INIT(Ptr, Int, Int, Mem, Mem, cmpxchg);
57 INIT(Mem, NoP, NoP, NoP, NoP, fence);
58 INIT(NoP, NoP, NoP, NoP, NoP, fence_all);
59 }
60
61 AtomicIntrinsics::View AtomicIntrinsics::allIntrinsicsAndOverloads() const {
62 return View(&I[0][0], NumAtomicIntrinsics * NumAtomicIntrinsicOverloadTypes);
63 }
64
65 const AtomicIntrinsics::AtomicIntrinsic *
66 AtomicIntrinsics::find(Intrinsic::ID ID, Type *OverloadedType) const {
67 View R = allIntrinsicsAndOverloads();
68 for (const AtomicIntrinsic *AI = R.begin(), *E = R.end(); AI != E; ++AI)
69 if (AI->ID == ID && AI->OverloadedType == OverloadedType)
70 return AI;
71 return 0;
72 }
73
74 } // End NaCl namespace
75
76 } // End llvm namespace
OLDNEW
« no previous file with comments | « lib/IR/Instructions.cpp ('k') | lib/IRReader/IRReader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698