aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/NaCl/PNaClABITypeChecker.h
blob: ac3cf850e5e01db62108bb897d12368ffa471715 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//===- PNaClABITypeChecker.h - Verify PNaCl ABI rules ---------------------===//
//
//                     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 LIB_ANALYSIS_NACL_CHECKTYPES_H
#define LIB_ANALYSIS_NACL_CHECKTYPES_H

#include "llvm/ADT/DenseSet.h"
#include "llvm/IR/Type.h"
#include "llvm/Support/raw_ostream.h"

namespace llvm {
class FunctionType;

class PNaClABITypeChecker {
  // Returns true if Ty is a valid argument or return value type for PNaCl.
  static bool isValidParamType(const Type *Ty);

 public:
  // 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);

  // 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();
  }
};
} // namespace llvm

#endif // LIB_ANALYSIS_NACL_CHECKTYPES_H