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

Unified Diff: include/llvm/Analysis/NaCl/PNaClABITypeChecker.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/llvm/Analysis/NaCl/PNaClABIProps.h ('k') | include/llvm/Analysis/NaCl/PNaClABIVerifyFunctions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/llvm/Analysis/NaCl/PNaClABITypeChecker.h
diff --git a/include/llvm/Analysis/NaCl/PNaClABITypeChecker.h b/include/llvm/Analysis/NaCl/PNaClABITypeChecker.h
new file mode 100644
index 0000000000000000000000000000000000000000..257f512ef125e8afdc6bffa9d7a9413c8e71be58
--- /dev/null
+++ b/include/llvm/Analysis/NaCl/PNaClABITypeChecker.h
@@ -0,0 +1,80 @@
+//===- PNaClABITypeChecker.h - Verify PNaCl ABI rules -----------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Common type-checking code for module and function-level passes
+//
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_ANALYSIS_NACL_PNACLABITYPECHECKER_H
+#define LLVM_ANALYSIS_NACL_PNACLABITYPECHECKER_H
+
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/IR/Type.h"
+#include "llvm/Support/raw_ostream.h"
+
+namespace llvm {
+class FunctionType;
+
+class PNaClABITypeChecker {
+ PNaClABITypeChecker(const PNaClABITypeChecker&) LLVM_DELETED_FUNCTION;
+ void operator=(const PNaClABITypeChecker&) LLVM_DELETED_FUNCTION;
+public:
+ // Returns true if Ty is a valid argument or return value type for PNaCl.
+ static bool isValidParamType(const Type *Ty);
+
+ // Returns true if Ty is a valid function type for PNaCl.
+ static bool isValidFunctionType(const FunctionType *FTy);
+
+ // Returns true if Ty is a valid non-derived type for PNaCl.
+ static bool isValidScalarType(const Type *Ty);
+
+ // Returns true if Ty is a valid vector type for PNaCl.
+ static bool isValidVectorType(const Type *Ty);
+
+ // Returns true if type Ty can be used in (integer) arithmetic operations.
+ static bool isValidIntArithmeticType(const Type *Ty);
+
+ // Returns true if type Ty can be used to define the test condition of
+ // a switch instruction.
+ static bool isValidSwitchConditionType(const Type *Ty) {
+ return PNaClABITypeChecker::isValidIntArithmeticType(Ty);
+ }
+ // Returns error message showing what was expected when given the
+ // switch condition type Ty. Assumes isValidSwitchConditionType(Ty)
+ // returned false.
+ static const char *ExpectedSwitchConditionType(const Type *Ty) {
+ if (!Ty->isIntegerTy())
+ return "switch not on integer type";
+ if (Ty->isIntegerTy(1))
+ return "switch on i1 not allowed";
+ return "switch disallowed for integer type";
+ }
+
+ // There's no built-in way to get the name of a type, so use a
+ // string ostream to print it.
+ static std::string getTypeName(const Type *T) {
+ std::string TypeName;
+ raw_string_ostream N(TypeName);
+ T->print(N);
+ return N.str();
+ }
+
+ // Returns true if T1 is equivalent to T2, converting to i32 if
+ // a pointer type.
+ static bool IsPointerEquivType(Type *T1, Type *T2) {
+ if (T1->isPointerTy()) return T2->isIntegerTy(32);
+ if (T2->isPointerTy()) return T1->isIntegerTy(32);
+ return T1 == T2;
+ }
+
+};
+} // namespace llvm
+
+#endif // LLVM_ANALYSIS_NACL_PNACLABITYPECHECKER_H
« no previous file with comments | « include/llvm/Analysis/NaCl/PNaClABIProps.h ('k') | include/llvm/Analysis/NaCl/PNaClABIVerifyFunctions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698