Create FunctionType::isValidArgumentType to go along with isValidReturnType.

Also create isValidElementType for ArrayType, PointerType, StructType and
VectorType.

Make LLParser use them. This closes up some holes like an assertion failure on:

  %x = type {label}

but largely doesn't change any semantics. The only thing we accept now which
we didn't before is vectors of opaque type such as "<4 x opaque>". The opaque
can be resolved to an int or float when linking.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73016 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nick Lewycky
2009-06-07 07:26:46 +00:00
parent 9dcc26b6a0
commit a5f54a06b0
4 changed files with 95 additions and 31 deletions

View File

@@ -159,6 +159,10 @@ public:
/// type.
static bool isValidReturnType(const Type *RetTy);
/// isValidArgumentType - Return true if the specified type is valid as an
/// argument type.
static bool isValidArgumentType(const Type *ArgTy);
inline bool isVarArg() const { return isVarArgs; }
inline const Type *getReturnType() const { return ContainedTys[0]; }
@@ -232,6 +236,10 @@ public:
/// an empty struct, pass NULL, NULL.
static StructType *get(const Type *type, ...) END_WITH_NULL;
/// isValidElementType - Return true if the specified type is valid as a
/// element type.
static bool isValidElementType(const Type *ElemTy);
// Iterator access to the elements
typedef Type::subtype_iterator element_iterator;
element_iterator element_begin() const { return ContainedTys; }
@@ -331,6 +339,10 @@ public:
///
static ArrayType *get(const Type *ElementType, uint64_t NumElements);
/// isValidElementType - Return true if the specified type is valid as a
/// element type.
static bool isValidElementType(const Type *ElemTy);
inline uint64_t getNumElements() const { return NumElements; }
// Implement the AbstractTypeUser interface.
@@ -391,6 +403,10 @@ public:
return VectorType::get(EltTy, VTy->getNumElements());
}
/// isValidElementType - Return true if the specified type is valid as a
/// element type.
static bool isValidElementType(const Type *ElemTy);
/// @brief Return the number of elements in the Vector type.
inline unsigned getNumElements() const { return NumElements; }
@@ -431,6 +447,10 @@ public:
return PointerType::get(ElementType, 0);
}
/// isValidElementType - Return true if the specified type is valid as a
/// element type.
static bool isValidElementType(const Type *ElemTy);
/// @brief Return the address space of the Pointer type.
inline unsigned getAddressSpace() const { return AddressSpace; }