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

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

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 | « include/llvm/Analysis/NaCl.h ('k') | include/llvm/Analysis/NaCl/PNaClABITypeChecker.h » ('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 //===- PNaClABIProps.h - Verify PNaCl ABI Properties ----------------------===//
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 // Verify PNaCl ABI properties.
11 //
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_ANALYSIS_NACL_PNACLABIPROPS_H
16 #define LLVM_ANALYSIS_NACL_PNACLABIPROPS_H
17
18 #include "llvm/ADT/APInt.h"
19 #include "llvm/IR/CallingConv.h"
20 #include "llvm/IR/GlobalValue.h"
21 #include "llvm/IR/Type.h"
22
23 namespace llvm {
24
25 class NamedMDNode;
26 class DataLayout;
27
28 // Checks properties needed to verify IR constructs. Unlike
29 // PNaClABIVerifyFunctions and PNaClABIVerifyModule, this class is
30 // pass-free, and checks individual elements within IR.
31 class PNaClABIProps {
32 PNaClABIProps(const PNaClABIProps&) LLVM_DELETED_FUNCTION;
33 void operator=(const PNaClABIProps&) LLVM_DELETED_FUNCTION;
34 public:
35 // Returns true if metadata kind MDKind is allowed.
36 static bool isWhitelistedMetadata(unsigned MDKind);
37 // Returns true if metadata is allowed.
38 static bool isWhitelistedMetadata(const NamedMDNode *MD);
39 // Returns true if integer constant Idx is in [0..NumElements).
40 static bool isVectorIndexSafe(const APInt &Idx,
41 unsigned NumElements) {
42 return Idx.ult(NumElements);
43 }
44 // Returns true if Alignment is allowed for type Ty, assuming DL.
45 static bool isAllowedAlignment(const DataLayout *DL, uint64_t Alignment,
46 const Type *Ty);
47
48 // Returns true if alloca type Ty is correct.
49 static bool isAllocaAllocatedType(const Type *Ty) {
50 return Ty->isIntegerTy(8);
51 }
52 // Returns true if the type associated with the size field in an alloca
53 // instruction is valid.
54 static bool isAllocaSizeType(const Type *Ty) {
55 return Ty->isIntegerTy(32);
56 }
57 // Returns string describing expected type for the size field in an
58 // alloca instruction.
59 static const char *ExpectedAllocaSizeType() {
60 return "alloca array size is not i32";
61 }
62 // Returns the name for the given calling convention.
63 static const char *CallingConvName(CallingConv::ID CallingConv);
64 // Returns true if CallingConv is valid.
65 static bool isValidCallingConv(CallingConv::ID CallingConv) {
66 return CallingConv == CallingConv::C;
67 }
68 // Returns the name for linkage type LT.
69 static const char *LinkageName(GlobalValue::LinkageTypes LT);
70 // Returns true if Linkage is valid.
71 static bool isValidGlobalLinkage(GlobalValue::LinkageTypes Linkage);
72 // Returns kind of global value name, based on IsFunction.
73 static const char *GVTypeName(bool IsFunction) {
74 return IsFunction ? "Function" : "Variable";
75 }
76 };
77
78 }
79
80 #endif // LLVM_ANALYSIS_NACL_PNACLABIPROPS_H
OLDNEW
« no previous file with comments | « include/llvm/Analysis/NaCl.h ('k') | include/llvm/Analysis/NaCl/PNaClABITypeChecker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698