For PR1064:
Implement the arbitrary bit-width integer feature. The feature allows
integers of any bitwidth (up to 64) to be defined instead of just 1, 8,
16, 32, and 64 bit integers.
This change does several things:
1. Introduces a new Derived Type, IntegerType, to represent the number of
bits in an integer. The Type classes SubclassData field is used to
store the number of bits. This allows 2^23 bits in an integer type.
2. Removes the five integer Type::TypeID values for the 1, 8, 16, 32 and
64-bit integers. These are replaced with just IntegerType which is not
a primitive any more.
3. Adjust the rest of LLVM to account for this change.
Note that while this incremental change lays the foundation for arbitrary
bit-width integers, LLVM has not yet been converted to actually deal with
them in any significant way. Most optimization passes, for example, will
still only deal with the byte-width integer types. Future increments
will rectify this situation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33113 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y
index dbd6188..57ab7c5 100644
--- a/lib/AsmParser/llvmAsmParser.y
+++ b/lib/AsmParser/llvmAsmParser.y
@@ -961,7 +961,7 @@
// Built in types...
%type <TypeVal> Types ResultTypes
%type <PrimType> IntType FPType PrimType // Classifications
-%token <PrimType> VOID BOOL INT8 INT16 INT32 INT64
+%token <PrimType> VOID BOOL INTTYPE
%token <PrimType> FLOAT DOUBLE LABEL
%token TYPE
@@ -1054,7 +1054,7 @@
// These are some types that allow classification if we only want a particular
// thing... for example, only a signed, unsigned, or integral type.
-IntType : INT64 | INT32 | INT16 | INT8;
+IntType : INTTYPE;
FPType : FLOAT | DOUBLE;
// OptAssign - Value producing statements have an optional assignment component
@@ -1181,7 +1181,7 @@
// Derived types are added later...
//
-PrimType : BOOL | INT8 | INT16 | INT32 | INT64 | FLOAT | DOUBLE | LABEL ;
+PrimType : BOOL | INTTYPE | FLOAT | DOUBLE | LABEL ;
Types
: OPAQUE {
@@ -1257,8 +1257,8 @@
const llvm::Type* ElemTy = $4->get();
if ((unsigned)$2 != $2)
GEN_ERROR("Unsigned result not equal to signed result");
- if (!ElemTy->isPrimitiveType())
- GEN_ERROR("Elemental type of a PackedType must be primitive");
+ if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
+ GEN_ERROR("Element type of a PackedType must be primitive");
if (!isPowerOf2_32($2))
GEN_ERROR("Vector length should be a power of 2!");
$$ = new PATypeHolder(HandleUpRefs(PackedType::get(*$4, (unsigned)$2)));
@@ -2780,7 +2780,7 @@
delete $2;
CHECK_FOR_ERROR
}
- | MALLOC Types ',' INT32 ValueRef OptCAlign {
+ | MALLOC Types ',' INTTYPE ValueRef OptCAlign {
if (!UpRefs.empty())
GEN_ERROR("Invalid upreference in type: " + (*$2)->getDescription());
Value* tmpVal = getVal($4, $5);
@@ -2795,7 +2795,7 @@
delete $2;
CHECK_FOR_ERROR
}
- | ALLOCA Types ',' INT32 ValueRef OptCAlign {
+ | ALLOCA Types ',' INTTYPE ValueRef OptCAlign {
if (!UpRefs.empty())
GEN_ERROR("Invalid upreference in type: " + (*$2)->getDescription());
Value* tmpVal = getVal($4, $5);