1 //===-- llvm/DerivedTypes.h - Classes for handling data types ----*- C++ -*--=//
3 // This file contains the declarations of classes that represent "derived
4 // types". These are things like "arrays of x" or "structure of x, y, z" or
5 // "method returning x taking (y,z) as parameters", etc...
7 // The implementations of these classes live in the Type.cpp file.
9 //===----------------------------------------------------------------------===//
11 #ifndef LLVM_DERIVED_TYPES_H
12 #define LLVM_DERIVED_TYPES_H
14 #include "llvm/Type.h"
17 // Future derived types: SIMD packed format
19 class MethodType : public Type {
21 typedef vector<const Type*> ParamTypes;
23 const Type *ResultType;
27 MethodType(const MethodType &); // Do not implement
28 const MethodType &operator=(const MethodType &); // Do not implement
30 // This should really be private, but it squelches a bogus warning
31 // from GCC to make them protected: warning: `class MethodType' only
32 // defines private constructors and has no friends
34 // Private ctor - Only can be created by a static member...
35 MethodType(const Type *Result, const vector<const Type*> &Params,
36 bool IsVarArgs, const string &Name);
39 inline bool isVarArg() const { return isVarArgs; }
40 inline const Type *getReturnType() const { return ResultType; }
41 inline const ParamTypes &getParamTypes() const { return ParamTys; }
43 static const MethodType *getMethodType(const Type *Result,
44 const ParamTypes &Params);
45 static const MethodType *get(const Type *Result, const ParamTypes &Params) {
46 return getMethodType(Result, Params);
51 class ArrayType : public Type {
53 const Type *ElementType;
54 int NumElements; // >= 0 for sized array, -1 for unbounded/unknown array
56 ArrayType(const ArrayType &); // Do not implement
57 const ArrayType &operator=(const ArrayType &); // Do not implement
59 // This should really be private, but it squelches a bogus warning
60 // from GCC to make them protected: warning: `class ArrayType' only
61 // defines private constructors and has no friends
64 // Private ctor - Only can be created by a static member...
65 ArrayType(const Type *ElType, int NumEl, const string &Name);
68 inline const Type *getElementType() const { return ElementType; }
69 inline int getNumElements() const { return NumElements; }
71 inline bool isSized() const { return NumElements >= 0; }
72 inline bool isUnsized() const { return NumElements == -1; }
74 static const ArrayType *getArrayType(const Type *ElementType,
75 int NumElements = -1);
76 static const ArrayType *get(const Type *ElementType, int NumElements = -1) {
77 return getArrayType(ElementType, NumElements);
82 class StructType : public Type {
84 typedef vector<const Type*> ElementTypes;
89 StructType(const StructType &); // Do not implement
90 const StructType &operator=(const StructType &); // Do not implement
93 // This should really be private, but it squelches a bogus warning
94 // from GCC to make them protected: warning: `class StructType' only
95 // defines private constructors and has no friends
97 // Private ctor - Only can be created by a static member...
98 StructType(const vector<const Type*> &Types, const string &Name);
101 inline const ElementTypes &getElementTypes() const { return ETypes; }
102 static const StructType *getStructType(const ElementTypes &Params);
103 static const StructType *get(const ElementTypes &Params) {
104 return getStructType(Params);
109 class PointerType : public Type {
111 const Type *ValueType;
113 PointerType(const PointerType &); // Do not implement
114 const PointerType &operator=(const PointerType &); // Do not implement
116 // This should really be private, but it squelches a bogus warning
117 // from GCC to make them protected: warning: `class PointerType' only
118 // defines private constructors and has no friends
121 // Private ctor - Only can be created by a static member...
122 PointerType(const Type *ElType);
125 inline const Type *getValueType() const { return ValueType; }
128 static const PointerType *getPointerType(const Type *ElementType);
129 static const PointerType *get(const Type *ElementType) {
130 return getPointerType(ElementType);