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

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

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

Powered by Google App Engine
This is Rietveld 408576698