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

Side by Side Diff: include/llvm/Analysis/NaCl/PNaClAllowedIntrinsics.h

Issue 939073008: Rebased PNaCl localmods in LLVM to 223109 (Closed)
Patch Set: undo localmod Created 5 years, 9 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 //===- PNaClAllowedIntrinsics.h - Set of allowed 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 // Declares class that holds set of allowed PNaCl intrinsics.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_ANALYSIS_NACL_PNACLALLOWEDINTRINSICS_H
15 #define LLVM_ANALYSIS_NACL_PNACLALLOWEDINTRINSICS_H
16
17 #include "llvm/ADT/StringMap.h"
18 #include "llvm/IR/Intrinsics.h"
19
20 namespace llvm {
21
22 class LLVMContext;
23 class Function;
24 class FunctionType;
25
26 // Holds the set of allowed instrinsics.
27 class PNaClAllowedIntrinsics {
28 PNaClAllowedIntrinsics(const PNaClAllowedIntrinsics&) LLVM_DELETED_FUNCTION;
29 void operator=(const PNaClAllowedIntrinsics&) LLVM_DELETED_FUNCTION;
30 public:
31 PNaClAllowedIntrinsics(LLVMContext *Context);
32
33 // Checks if there is an allowable PNaCl intrinsic function with the
34 // given name and type signature.
35 bool isAllowed(const std::string &FcnName, const FunctionType *FcnType) {
36 return isIntrinsicName(FcnName) && FcnType == getIntrinsicType(FcnName);
37 }
38 // Checks if Func is an allowed PNaCl intrinsic function. Note:
39 // This function also allows debugging intrinsics if
40 // PNaClABIAllowDebugMetadata is true.
41 bool isAllowed(const Function *Func);
42
43 // Returns the type signature for the Name'd intrinsic, if entered
44 // via a call to AddIntrinsic. Returns 0 otherwise (implying we
45 // don't know the expected type signature).
46 FunctionType *getIntrinsicType(const std::string &Name) {
47 return isIntrinsicName(Name) ? TypeMap[Name] : 0;
48 }
49
50 private:
51 LLVMContext *Context;
52 // Maps from an allowed intrinsic's name to its type.
53 StringMap<FunctionType *> TypeMap;
54
55 // Tys is an array of type parameters for the intrinsic. This
56 // defaults to an empty array.
57 void addIntrinsic(Intrinsic::ID ID,
58 ArrayRef<Type *> Tys = ArrayRef<Type*>());
59
60 // Returns true if a valid PNaCl intrinsic name.
61 bool isIntrinsicName(const std::string &Name) {
62 return TypeMap.count(Name) == 1;
63 }
64
65 // Returns true if intrinsic ID is allowed as a PNaCl intrinsic.
66 bool isAllowedIntrinsicID(unsigned ID);
67 };
68
69 }
70
71 #endif // LLVM_ANALYSIS_NACL_PNACLALLOWEDINTRINSICS_H
OLDNEW
« no previous file with comments | « include/llvm/Analysis/NaCl/PNaClABIVerifyModule.h ('k') | include/llvm/Bitcode/NaCl/AbbrevTrieNode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698