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

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

Issue 17777004: Concurrency support for PNaCl ABI (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Address eliben's comments (4). Created 7 years, 5 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/NaClIntrinsics.cpp - NaCl 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 intrinsic functions that are specific to NaCl.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/IR/DerivedTypes.h"
15 #include "llvm/IR/NaClIntrinsics.h"
16 #include "llvm/IR/Type.h"
17
18 namespace llvm {
19
20 namespace NaCl {
21
22 AtomicIntrinsics::AtomicIntrinsics(LLVMContext &C) {
23 Type *IT[NumAtomicIntrinsicTypes] = { Type::getInt8Ty(C), Type::getInt16Ty(C),
24 Type::getInt32Ty(C),
25 Type::getInt64Ty(C) };
26 size_t CurIntrin = 0;
27
28 // Initialize each of the atomic intrinsics and their overloads. They
29 // have up to 5 parameters, the following macro will take care of
30 // overloading.
31 #define INIT(P0, P1, P2, P3, P4, INTRIN) \
32 do { \
33 for (size_t CurType = 0; CurType != NumAtomicIntrinsicTypes; ++CurType) { \
34 size_t Param = 0; \
35 I[CurIntrin][CurType].OverloadedType = IT[CurType]; \
36 I[CurIntrin][CurType].ID = Intrinsic::nacl_atomic_##INTRIN; \
37 I[CurIntrin][CurType].Overloaded = \
38 P0 == Int || P0 == Ptr || P1 == Int || P1 == Ptr || P2 == Int || \
39 P2 == Ptr || P3 == Int || P3 == Ptr || P4 == Int || P4 == Ptr; \
40 I[CurIntrin][CurType].NumParams = \
41 (P0 != NoP) + (P1 != NoP) + (P2 != NoP) + (P3 != NoP) + (P4 != NoP); \
42 I[CurIntrin][CurType].ParamType[Param++] = P0; \
43 I[CurIntrin][CurType].ParamType[Param++] = P1; \
44 I[CurIntrin][CurType].ParamType[Param++] = P2; \
45 I[CurIntrin][CurType].ParamType[Param++] = P3; \
46 I[CurIntrin][CurType].ParamType[Param++] = P4; \
47 } \
48 ++CurIntrin; \
49 } while (0)
50
51 INIT(Ptr, Mem, NoP, NoP, NoP, load);
52 INIT(Ptr, Int, Mem, NoP, NoP, store);
53 INIT(RMW, Ptr, Int, Mem, NoP, rmw);
54 INIT(Ptr, Int, Int, Mem, Mem, cmpxchg);
55 INIT(Mem, NoP, NoP, NoP, NoP, fence);
56 }
57
58 AtomicIntrinsics::View AtomicIntrinsics::allIntrinsicsAndOverloads() const {
59 return View(&I[0][0], NumAtomicIntrinsics * NumAtomicIntrinsicTypes);
60 }
61
62 AtomicIntrinsics::View AtomicIntrinsics::overloadsFor(Intrinsic::ID ID) const {
63 // Overloads are stored consecutively.
64 View R = allIntrinsicsAndOverloads();
65 for (const AtomicIntrinsic *AI = R.begin(), *E = R.end(); AI != E; ++AI)
66 if (AI->ID == ID)
67 return View(AI, NumAtomicIntrinsicTypes);
68 llvm_unreachable("unhandled atomic intrinsic");
69 }
70
71 const AtomicIntrinsics::AtomicIntrinsic *
72 AtomicIntrinsics::find(Intrinsic::ID ID, Type *OverloadedType) const {
73 View R = allIntrinsicsAndOverloads();
74 for (const AtomicIntrinsic *AI = R.begin(), *E = R.end(); AI != E; ++AI)
75 if (AI->ID == ID && AI->OverloadedType == OverloadedType)
76 return AI;
77 llvm_unreachable("unhandled atomic intrinsic");
78 }
79
80 } // End NaCl namespace
81
82 } // End llvm namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698