Don't treat numeric (untyped) constants as a ConstInfo, just pass the

string and let ConstVal add the type.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32096 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Spencer 2006-12-01 21:52:30 +00:00
parent bd7b67fd37
commit f2d5532c66
6 changed files with 1380 additions and 1480 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -29,30 +29,30 @@
/* Put the tokens into the symbol table, so that GDB and other debuggers /* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */ know about them. */
enum yytokentype { enum yytokentype {
ESINT64VAL = 258, VOID = 258,
EUINT64VAL = 259, BOOL = 259,
SINTVAL = 260, SBYTE = 260,
UINTVAL = 261, UBYTE = 261,
FPVAL = 262, SHORT = 262,
TRUETOK = 263, USHORT = 263,
FALSETOK = 264, INT = 264,
NULL_TOK = 265, UINT = 265,
UNDEF = 266, LONG = 266,
ZEROINITIALIZER = 267, ULONG = 267,
VOID = 268, FLOAT = 268,
BOOL = 269, DOUBLE = 269,
SBYTE = 270, LABEL = 270,
UBYTE = 271, OPAQUE = 271,
SHORT = 272, ESINT64VAL = 272,
USHORT = 273, EUINT64VAL = 273,
INT = 274, SINTVAL = 274,
UINT = 275, UINTVAL = 275,
LONG = 276, FPVAL = 276,
ULONG = 277, NULL_TOK = 277,
FLOAT = 278, UNDEF = 278,
DOUBLE = 279, ZEROINITIALIZER = 279,
LABEL = 280, TRUETOK = 280,
OPAQUE = 281, FALSETOK = 281,
TYPE = 282, TYPE = 282,
VAR_ID = 283, VAR_ID = 283,
LABELSTR = 284, LABELSTR = 284,
@ -141,30 +141,30 @@
}; };
#endif #endif
/* Tokens. */ /* Tokens. */
#define ESINT64VAL 258 #define VOID 258
#define EUINT64VAL 259 #define BOOL 259
#define SINTVAL 260 #define SBYTE 260
#define UINTVAL 261 #define UBYTE 261
#define FPVAL 262 #define SHORT 262
#define TRUETOK 263 #define USHORT 263
#define FALSETOK 264 #define INT 264
#define NULL_TOK 265 #define UINT 265
#define UNDEF 266 #define LONG 266
#define ZEROINITIALIZER 267 #define ULONG 267
#define VOID 268 #define FLOAT 268
#define BOOL 269 #define DOUBLE 269
#define SBYTE 270 #define LABEL 270
#define UBYTE 271 #define OPAQUE 271
#define SHORT 272 #define ESINT64VAL 272
#define USHORT 273 #define EUINT64VAL 273
#define INT 274 #define SINTVAL 274
#define UINT 275 #define UINTVAL 275
#define LONG 276 #define FPVAL 276
#define ULONG 277 #define NULL_TOK 277
#define FLOAT 278 #define UNDEF 278
#define DOUBLE 279 #define ZEROINITIALIZER 279
#define LABEL 280 #define TRUETOK 280
#define OPAQUE 281 #define FALSETOK 281
#define TYPE 282 #define TYPE 282
#define VAR_ID 283 #define VAR_ID 283
#define LABELSTR 284 #define LABELSTR 284

View File

@ -29,30 +29,30 @@
/* Put the tokens into the symbol table, so that GDB and other debuggers /* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */ know about them. */
enum yytokentype { enum yytokentype {
ESINT64VAL = 258, VOID = 258,
EUINT64VAL = 259, BOOL = 259,
SINTVAL = 260, SBYTE = 260,
UINTVAL = 261, UBYTE = 261,
FPVAL = 262, SHORT = 262,
TRUETOK = 263, USHORT = 263,
FALSETOK = 264, INT = 264,
NULL_TOK = 265, UINT = 265,
UNDEF = 266, LONG = 266,
ZEROINITIALIZER = 267, ULONG = 267,
VOID = 268, FLOAT = 268,
BOOL = 269, DOUBLE = 269,
SBYTE = 270, LABEL = 270,
UBYTE = 271, OPAQUE = 271,
SHORT = 272, ESINT64VAL = 272,
USHORT = 273, EUINT64VAL = 273,
INT = 274, SINTVAL = 274,
UINT = 275, UINTVAL = 275,
LONG = 276, FPVAL = 276,
ULONG = 277, NULL_TOK = 277,
FLOAT = 278, UNDEF = 278,
DOUBLE = 279, ZEROINITIALIZER = 279,
LABEL = 280, TRUETOK = 280,
OPAQUE = 281, FALSETOK = 281,
TYPE = 282, TYPE = 282,
VAR_ID = 283, VAR_ID = 283,
LABELSTR = 284, LABELSTR = 284,
@ -141,30 +141,30 @@
}; };
#endif #endif
/* Tokens. */ /* Tokens. */
#define ESINT64VAL 258 #define VOID 258
#define EUINT64VAL 259 #define BOOL 259
#define SINTVAL 260 #define SBYTE 260
#define UINTVAL 261 #define UBYTE 261
#define FPVAL 262 #define SHORT 262
#define TRUETOK 263 #define USHORT 263
#define FALSETOK 264 #define INT 264
#define NULL_TOK 265 #define UINT 265
#define UNDEF 266 #define LONG 266
#define ZEROINITIALIZER 267 #define ULONG 267
#define VOID 268 #define FLOAT 268
#define BOOL 269 #define DOUBLE 269
#define SBYTE 270 #define LABEL 270
#define UBYTE 271 #define OPAQUE 271
#define SHORT 272 #define ESINT64VAL 272
#define USHORT 273 #define EUINT64VAL 273
#define INT 274 #define SINTVAL 274
#define UINT 275 #define UINTVAL 275
#define LONG 276 #define FPVAL 276
#define ULONG 277 #define NULL_TOK 277
#define FLOAT 278 #define UNDEF 278
#define DOUBLE 279 #define ZEROINITIALIZER 279
#define LABEL 280 #define TRUETOK 280
#define OPAQUE 281 #define FALSETOK 281
#define TYPE 282 #define TYPE 282
#define VAR_ID 283 #define VAR_ID 283
#define LABELSTR 284 #define LABELSTR 284

View File

@ -134,12 +134,10 @@ const char* getCastOpcode(TypeInfo& SrcTy, TypeInfo&DstTy) {
ConstInfo Const; ConstInfo Const;
} }
%token <Const> ESINT64VAL EUINT64VAL SINTVAL UINTVAL FPVAL TRUETOK FALSETOK
%token <Const> NULL_TOK UNDEF ZEROINITIALIZER
%token <Type> VOID BOOL SBYTE UBYTE SHORT USHORT INT UINT LONG ULONG %token <Type> VOID BOOL SBYTE UBYTE SHORT USHORT INT UINT LONG ULONG
%token <Type> FLOAT DOUBLE LABEL OPAQUE %token <Type> FLOAT DOUBLE LABEL OPAQUE
%token <String> ESINT64VAL EUINT64VAL SINTVAL UINTVAL FPVAL
%token <String> NULL_TOK UNDEF ZEROINITIALIZER TRUETOK FALSETOK
%token <String> TYPE VAR_ID LABELSTR STRINGCONSTANT %token <String> TYPE VAR_ID LABELSTR STRINGCONSTANT
%token <String> IMPLEMENTATION BEGINTOK ENDTOK %token <String> IMPLEMENTATION BEGINTOK ENDTOK
%token <String> DECLARE GLOBAL CONSTANT SECTION VOLATILE %token <String> DECLARE GLOBAL CONSTANT SECTION VOLATILE
@ -177,7 +175,8 @@ const char* getCastOpcode(TypeInfo& SrcTy, TypeInfo&DstTy) {
%type <Type> IntType SIntType UIntType FPType TypesV Types %type <Type> IntType SIntType UIntType FPType TypesV Types
%type <Type> PrimType UpRTypesV UpRTypes %type <Type> PrimType UpRTypesV UpRTypes
%type <Const> IntVal EInt64Val ConstVal %type <String> IntVal EInt64Val
%type <Const> ConstVal
%type <Value> ResolvedVal %type <Value> ResolvedVal
@ -186,7 +185,7 @@ const char* getCastOpcode(TypeInfo& SrcTy, TypeInfo&DstTy) {
%% %%
// Handle constant integer size restriction and conversion... // Handle constant integer size restriction and conversion...
IntVal : SINTVAL | UINTVAL IntVal : SINTVAL | UINTVAL ;
EInt64Val : ESINT64VAL | EUINT64VAL; EInt64Val : ESINT64VAL | EUINT64VAL;
// Operations that are notably excluded from this list include: // Operations that are notably excluded from this list include:
@ -221,8 +220,8 @@ OptCallingConv
: CCC_TOK | CSRETCC_TOK | FASTCC_TOK | COLDCC_TOK | X86_STDCALLCC_TOK : CCC_TOK | CSRETCC_TOK | FASTCC_TOK | COLDCC_TOK | X86_STDCALLCC_TOK
| X86_FASTCALLCC_TOK | X86_FASTCALLCC_TOK
| CC_TOK EUINT64VAL { | CC_TOK EUINT64VAL {
*$1 += *$2.cnst; *$1 += *$2;
$2.destroy(); delete $2;
$$ = $1; $$ = $1;
} }
| /*empty*/ { $$ = new std::string(""); } ; | /*empty*/ { $$ = new std::string(""); } ;
@ -231,14 +230,14 @@ OptCallingConv
// a comma before it. // a comma before it.
OptAlign OptAlign
: /*empty*/ { $$ = new std::string(); } : /*empty*/ { $$ = new std::string(); }
| ALIGN EUINT64VAL { *$1 += " " + *$2.cnst; delete $2.cnst; $$ = $1; }; | ALIGN EUINT64VAL { *$1 += " " + *$2; delete $2; $$ = $1; };
; ;
OptCAlign OptCAlign
: /*empty*/ { $$ = new std::string(); } : /*empty*/ { $$ = new std::string(); }
| ',' ALIGN EUINT64VAL { | ',' ALIGN EUINT64VAL {
$2->insert(0, ", "); $2->insert(0, ", ");
*$2 += " " + *$3.cnst; *$2 += " " + *$3;
delete $3.cnst; delete $3;
$$ = $2; $$ = $2;
}; };
@ -265,8 +264,8 @@ GlobalVarAttributes
GlobalVarAttribute GlobalVarAttribute
: SectionString : SectionString
| ALIGN EUINT64VAL { | ALIGN EUINT64VAL {
*$1 += " " + *$2.cnst; *$1 += " " + *$2;
delete $2.cnst; delete $2;
$$ = $1; $$ = $1;
}; };
@ -293,8 +292,8 @@ UpRTypes : OPAQUE | PrimType
// Include derived types in the Types production. // Include derived types in the Types production.
// //
UpRTypes : '\\' EUINT64VAL { // Type UpReference UpRTypes : '\\' EUINT64VAL { // Type UpReference
$2.cnst->insert(0, "\\"); $2->insert(0, "\\");
$$.newTy = $2.cnst; $$.newTy = $2;
$$.oldTy = OpaqueTy; $$.oldTy = OpaqueTy;
} }
| UpRTypesV '(' ArgTypeListI ')' { // Function derived type? | UpRTypesV '(' ArgTypeListI ')' { // Function derived type?
@ -304,17 +303,17 @@ UpRTypes : '\\' EUINT64VAL { // Type UpReference
$$.oldTy = FunctionTy; $$.oldTy = FunctionTy;
} }
| '[' EUINT64VAL 'x' UpRTypes ']' { // Sized array type? | '[' EUINT64VAL 'x' UpRTypes ']' { // Sized array type?
$2.cnst->insert(0,"[ "); $2->insert(0,"[ ");
*$2.cnst += " x " + *$4.newTy + " ]"; *$2 += " x " + *$4.newTy + " ]";
delete $4.newTy; delete $4.newTy;
$$.newTy = $2.cnst; $$.newTy = $2;
$$.oldTy = ArrayTy; $$.oldTy = ArrayTy;
} }
| '<' EUINT64VAL 'x' UpRTypes '>' { // Packed array type? | '<' EUINT64VAL 'x' UpRTypes '>' { // Packed array type?
$2.cnst->insert(0,"< "); $2->insert(0,"< ");
*$2.cnst += " x " + *$4.newTy + " >"; *$2 += " x " + *$4.newTy + " >";
delete $4.newTy; delete $4.newTy;
$$.newTy = $2.cnst; $$.newTy = $2;
$$.oldTy = PackedTy; $$.oldTy = PackedTy;
} }
| '{' TypeListI '}' { // Structure type? | '{' TypeListI '}' { // Structure type?
@ -404,14 +403,14 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
| Types NULL_TOK { | Types NULL_TOK {
$$.type = $1; $$.type = $1;
$$.cnst = new std::string(*$1.newTy); $$.cnst = new std::string(*$1.newTy);
*$$.cnst += " " + *$2.cnst; *$$.cnst += " " + *$2;
$2.destroy(); delete $2;
} }
| Types UNDEF { | Types UNDEF {
$$.type = $1; $$.type = $1;
$$.cnst = new std::string(*$1.newTy); $$.cnst = new std::string(*$1.newTy);
*$$.cnst += " " + *$2.cnst; *$$.cnst += " " + *$2;
$2.destroy(); delete $2;
} }
| Types SymbolicValueRef { | Types SymbolicValueRef {
$$.type = $1; $$.type = $1;
@ -428,38 +427,38 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
| Types ZEROINITIALIZER { | Types ZEROINITIALIZER {
$$.type = $1; $$.type = $1;
$$.cnst = new std::string(*$1.newTy); $$.cnst = new std::string(*$1.newTy);
*$$.cnst += " " + *$2.cnst; *$$.cnst += " " + *$2;
$2.destroy(); delete $2;
} }
| SIntType EInt64Val { // integral constants | SIntType EInt64Val { // integral constants
$$.type = $1; $$.type = $1;
$$.cnst = new std::string(*$1.newTy); $$.cnst = new std::string(*$1.newTy);
*$$.cnst += " " + *$2.cnst; *$$.cnst += " " + *$2;
$2.destroy(); delete $2;
} }
| UIntType EUINT64VAL { // integral constants | UIntType EUINT64VAL { // integral constants
$$.type = $1; $$.type = $1;
$$.cnst = new std::string(*$1.newTy); $$.cnst = new std::string(*$1.newTy);
*$$.cnst += " " + *$2.cnst; *$$.cnst += " " + *$2;
$2.destroy(); delete $2;
} }
| BOOL TRUETOK { // Boolean constants | BOOL TRUETOK { // Boolean constants
$$.type = $1; $$.type = $1;
$$.cnst = new std::string(*$1.newTy); $$.cnst = new std::string(*$1.newTy);
*$$.cnst += " " + *$2.cnst; *$$.cnst += " " + *$2;
$2.destroy(); delete $2;
} }
| BOOL FALSETOK { // Boolean constants | BOOL FALSETOK { // Boolean constants
$$.type = $1; $$.type = $1;
$$.cnst = new std::string(*$1.newTy); $$.cnst = new std::string(*$1.newTy);
*$$.cnst += " " + *$2.cnst; *$$.cnst += " " + *$2;
$2.destroy(); delete $2;
} }
| FPType FPVAL { // Float & Double constants | FPType FPVAL { // Float & Double constants
$$.type = $1; $$.type = $1;
$$.cnst = new std::string(*$1.newTy); $$.cnst = new std::string(*$1.newTy);
*$$.cnst += " " + *$2.cnst; *$$.cnst += " " + *$2;
$2.destroy(); delete $2;
}; };
@ -630,10 +629,10 @@ TargetDefinition
$$ = $1; $$ = $1;
} }
| POINTERSIZE '=' EUINT64VAL { | POINTERSIZE '=' EUINT64VAL {
*$1 += " = " + *$3.cnst; *$1 += " = " + *$3;
if (*$3.cnst == "64") if (*$3 == "64")
SizeOfPointer = 64; SizeOfPointer = 64;
$3.destroy(); delete $3;
$$ = $1; $$ = $1;
} }
| TRIPLE '=' STRINGCONSTANT { | TRIPLE '=' STRINGCONSTANT {
@ -770,14 +769,8 @@ OptSideEffect : /* empty */ { $$ = new std::string(); }
| SIDEEFFECT; | SIDEEFFECT;
ConstValueRef ConstValueRef
: ESINT64VAL { $$ = $1.cnst; } : ESINT64VAL | EUINT64VAL | FPVAL | TRUETOK | FALSETOK | NULL_TOK | UNDEF
| EUINT64VAL { $$ = $1.cnst; } | ZEROINITIALIZER
| FPVAL { $$ = $1.cnst; }
| TRUETOK { $$ = $1.cnst; }
| FALSETOK { $$ = $1.cnst; }
| NULL_TOK { $$ = $1.cnst; }
| UNDEF { $$ = $1.cnst; }
| ZEROINITIALIZER { $$ = $1.cnst; }
| '<' ConstVector '>' { | '<' ConstVector '>' {
$2->insert(0, "<"); $2->insert(0, "<");
*$2 += ">"; *$2 += ">";
@ -793,7 +786,7 @@ ConstValueRef
$$ = $1; $$ = $1;
}; };
SymbolicValueRef : IntVal { $$ = $1.cnst; } | Name ; SymbolicValueRef : IntVal | Name ;
// ValueRef - A reference to a definition... either constant or symbolic // ValueRef - A reference to a definition... either constant or symbolic
ValueRef : SymbolicValueRef | ConstValueRef; ValueRef : SymbolicValueRef | ConstValueRef;
@ -810,8 +803,10 @@ ResolvedVal : Types ValueRef {
}; };
BasicBlockList : BasicBlockList BasicBlock { BasicBlockList : BasicBlockList BasicBlock {
$$ = 0;
} }
| BasicBlock { // Do not allow functions with 0 basic blocks | BasicBlock { // Do not allow functions with 0 basic blocks
$$ = 0;
}; };
@ -819,7 +814,7 @@ BasicBlockList : BasicBlockList BasicBlock {
// br, br/cc, switch, ret // br, br/cc, switch, ret
// //
BasicBlock : InstructionList BBTerminatorInst { BasicBlock : InstructionList BBTerminatorInst {
*O << *$2 ; $$ = 0;
}; };
InstructionList : InstructionList Inst { InstructionList : InstructionList Inst {

View File

@ -134,12 +134,10 @@ const char* getCastOpcode(TypeInfo& SrcTy, TypeInfo&DstTy) {
ConstInfo Const; ConstInfo Const;
} }
%token <Const> ESINT64VAL EUINT64VAL SINTVAL UINTVAL FPVAL TRUETOK FALSETOK
%token <Const> NULL_TOK UNDEF ZEROINITIALIZER
%token <Type> VOID BOOL SBYTE UBYTE SHORT USHORT INT UINT LONG ULONG %token <Type> VOID BOOL SBYTE UBYTE SHORT USHORT INT UINT LONG ULONG
%token <Type> FLOAT DOUBLE LABEL OPAQUE %token <Type> FLOAT DOUBLE LABEL OPAQUE
%token <String> ESINT64VAL EUINT64VAL SINTVAL UINTVAL FPVAL
%token <String> NULL_TOK UNDEF ZEROINITIALIZER TRUETOK FALSETOK
%token <String> TYPE VAR_ID LABELSTR STRINGCONSTANT %token <String> TYPE VAR_ID LABELSTR STRINGCONSTANT
%token <String> IMPLEMENTATION BEGINTOK ENDTOK %token <String> IMPLEMENTATION BEGINTOK ENDTOK
%token <String> DECLARE GLOBAL CONSTANT SECTION VOLATILE %token <String> DECLARE GLOBAL CONSTANT SECTION VOLATILE
@ -177,7 +175,8 @@ const char* getCastOpcode(TypeInfo& SrcTy, TypeInfo&DstTy) {
%type <Type> IntType SIntType UIntType FPType TypesV Types %type <Type> IntType SIntType UIntType FPType TypesV Types
%type <Type> PrimType UpRTypesV UpRTypes %type <Type> PrimType UpRTypesV UpRTypes
%type <Const> IntVal EInt64Val ConstVal %type <String> IntVal EInt64Val
%type <Const> ConstVal
%type <Value> ResolvedVal %type <Value> ResolvedVal
@ -186,7 +185,7 @@ const char* getCastOpcode(TypeInfo& SrcTy, TypeInfo&DstTy) {
%% %%
// Handle constant integer size restriction and conversion... // Handle constant integer size restriction and conversion...
IntVal : SINTVAL | UINTVAL IntVal : SINTVAL | UINTVAL ;
EInt64Val : ESINT64VAL | EUINT64VAL; EInt64Val : ESINT64VAL | EUINT64VAL;
// Operations that are notably excluded from this list include: // Operations that are notably excluded from this list include:
@ -221,8 +220,8 @@ OptCallingConv
: CCC_TOK | CSRETCC_TOK | FASTCC_TOK | COLDCC_TOK | X86_STDCALLCC_TOK : CCC_TOK | CSRETCC_TOK | FASTCC_TOK | COLDCC_TOK | X86_STDCALLCC_TOK
| X86_FASTCALLCC_TOK | X86_FASTCALLCC_TOK
| CC_TOK EUINT64VAL { | CC_TOK EUINT64VAL {
*$1 += *$2.cnst; *$1 += *$2;
$2.destroy(); delete $2;
$$ = $1; $$ = $1;
} }
| /*empty*/ { $$ = new std::string(""); } ; | /*empty*/ { $$ = new std::string(""); } ;
@ -231,14 +230,14 @@ OptCallingConv
// a comma before it. // a comma before it.
OptAlign OptAlign
: /*empty*/ { $$ = new std::string(); } : /*empty*/ { $$ = new std::string(); }
| ALIGN EUINT64VAL { *$1 += " " + *$2.cnst; delete $2.cnst; $$ = $1; }; | ALIGN EUINT64VAL { *$1 += " " + *$2; delete $2; $$ = $1; };
; ;
OptCAlign OptCAlign
: /*empty*/ { $$ = new std::string(); } : /*empty*/ { $$ = new std::string(); }
| ',' ALIGN EUINT64VAL { | ',' ALIGN EUINT64VAL {
$2->insert(0, ", "); $2->insert(0, ", ");
*$2 += " " + *$3.cnst; *$2 += " " + *$3;
delete $3.cnst; delete $3;
$$ = $2; $$ = $2;
}; };
@ -265,8 +264,8 @@ GlobalVarAttributes
GlobalVarAttribute GlobalVarAttribute
: SectionString : SectionString
| ALIGN EUINT64VAL { | ALIGN EUINT64VAL {
*$1 += " " + *$2.cnst; *$1 += " " + *$2;
delete $2.cnst; delete $2;
$$ = $1; $$ = $1;
}; };
@ -293,8 +292,8 @@ UpRTypes : OPAQUE | PrimType
// Include derived types in the Types production. // Include derived types in the Types production.
// //
UpRTypes : '\\' EUINT64VAL { // Type UpReference UpRTypes : '\\' EUINT64VAL { // Type UpReference
$2.cnst->insert(0, "\\"); $2->insert(0, "\\");
$$.newTy = $2.cnst; $$.newTy = $2;
$$.oldTy = OpaqueTy; $$.oldTy = OpaqueTy;
} }
| UpRTypesV '(' ArgTypeListI ')' { // Function derived type? | UpRTypesV '(' ArgTypeListI ')' { // Function derived type?
@ -304,17 +303,17 @@ UpRTypes : '\\' EUINT64VAL { // Type UpReference
$$.oldTy = FunctionTy; $$.oldTy = FunctionTy;
} }
| '[' EUINT64VAL 'x' UpRTypes ']' { // Sized array type? | '[' EUINT64VAL 'x' UpRTypes ']' { // Sized array type?
$2.cnst->insert(0,"[ "); $2->insert(0,"[ ");
*$2.cnst += " x " + *$4.newTy + " ]"; *$2 += " x " + *$4.newTy + " ]";
delete $4.newTy; delete $4.newTy;
$$.newTy = $2.cnst; $$.newTy = $2;
$$.oldTy = ArrayTy; $$.oldTy = ArrayTy;
} }
| '<' EUINT64VAL 'x' UpRTypes '>' { // Packed array type? | '<' EUINT64VAL 'x' UpRTypes '>' { // Packed array type?
$2.cnst->insert(0,"< "); $2->insert(0,"< ");
*$2.cnst += " x " + *$4.newTy + " >"; *$2 += " x " + *$4.newTy + " >";
delete $4.newTy; delete $4.newTy;
$$.newTy = $2.cnst; $$.newTy = $2;
$$.oldTy = PackedTy; $$.oldTy = PackedTy;
} }
| '{' TypeListI '}' { // Structure type? | '{' TypeListI '}' { // Structure type?
@ -404,14 +403,14 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
| Types NULL_TOK { | Types NULL_TOK {
$$.type = $1; $$.type = $1;
$$.cnst = new std::string(*$1.newTy); $$.cnst = new std::string(*$1.newTy);
*$$.cnst += " " + *$2.cnst; *$$.cnst += " " + *$2;
$2.destroy(); delete $2;
} }
| Types UNDEF { | Types UNDEF {
$$.type = $1; $$.type = $1;
$$.cnst = new std::string(*$1.newTy); $$.cnst = new std::string(*$1.newTy);
*$$.cnst += " " + *$2.cnst; *$$.cnst += " " + *$2;
$2.destroy(); delete $2;
} }
| Types SymbolicValueRef { | Types SymbolicValueRef {
$$.type = $1; $$.type = $1;
@ -428,38 +427,38 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
| Types ZEROINITIALIZER { | Types ZEROINITIALIZER {
$$.type = $1; $$.type = $1;
$$.cnst = new std::string(*$1.newTy); $$.cnst = new std::string(*$1.newTy);
*$$.cnst += " " + *$2.cnst; *$$.cnst += " " + *$2;
$2.destroy(); delete $2;
} }
| SIntType EInt64Val { // integral constants | SIntType EInt64Val { // integral constants
$$.type = $1; $$.type = $1;
$$.cnst = new std::string(*$1.newTy); $$.cnst = new std::string(*$1.newTy);
*$$.cnst += " " + *$2.cnst; *$$.cnst += " " + *$2;
$2.destroy(); delete $2;
} }
| UIntType EUINT64VAL { // integral constants | UIntType EUINT64VAL { // integral constants
$$.type = $1; $$.type = $1;
$$.cnst = new std::string(*$1.newTy); $$.cnst = new std::string(*$1.newTy);
*$$.cnst += " " + *$2.cnst; *$$.cnst += " " + *$2;
$2.destroy(); delete $2;
} }
| BOOL TRUETOK { // Boolean constants | BOOL TRUETOK { // Boolean constants
$$.type = $1; $$.type = $1;
$$.cnst = new std::string(*$1.newTy); $$.cnst = new std::string(*$1.newTy);
*$$.cnst += " " + *$2.cnst; *$$.cnst += " " + *$2;
$2.destroy(); delete $2;
} }
| BOOL FALSETOK { // Boolean constants | BOOL FALSETOK { // Boolean constants
$$.type = $1; $$.type = $1;
$$.cnst = new std::string(*$1.newTy); $$.cnst = new std::string(*$1.newTy);
*$$.cnst += " " + *$2.cnst; *$$.cnst += " " + *$2;
$2.destroy(); delete $2;
} }
| FPType FPVAL { // Float & Double constants | FPType FPVAL { // Float & Double constants
$$.type = $1; $$.type = $1;
$$.cnst = new std::string(*$1.newTy); $$.cnst = new std::string(*$1.newTy);
*$$.cnst += " " + *$2.cnst; *$$.cnst += " " + *$2;
$2.destroy(); delete $2;
}; };
@ -630,10 +629,10 @@ TargetDefinition
$$ = $1; $$ = $1;
} }
| POINTERSIZE '=' EUINT64VAL { | POINTERSIZE '=' EUINT64VAL {
*$1 += " = " + *$3.cnst; *$1 += " = " + *$3;
if (*$3.cnst == "64") if (*$3 == "64")
SizeOfPointer = 64; SizeOfPointer = 64;
$3.destroy(); delete $3;
$$ = $1; $$ = $1;
} }
| TRIPLE '=' STRINGCONSTANT { | TRIPLE '=' STRINGCONSTANT {
@ -770,14 +769,8 @@ OptSideEffect : /* empty */ { $$ = new std::string(); }
| SIDEEFFECT; | SIDEEFFECT;
ConstValueRef ConstValueRef
: ESINT64VAL { $$ = $1.cnst; } : ESINT64VAL | EUINT64VAL | FPVAL | TRUETOK | FALSETOK | NULL_TOK | UNDEF
| EUINT64VAL { $$ = $1.cnst; } | ZEROINITIALIZER
| FPVAL { $$ = $1.cnst; }
| TRUETOK { $$ = $1.cnst; }
| FALSETOK { $$ = $1.cnst; }
| NULL_TOK { $$ = $1.cnst; }
| UNDEF { $$ = $1.cnst; }
| ZEROINITIALIZER { $$ = $1.cnst; }
| '<' ConstVector '>' { | '<' ConstVector '>' {
$2->insert(0, "<"); $2->insert(0, "<");
*$2 += ">"; *$2 += ">";
@ -793,7 +786,7 @@ ConstValueRef
$$ = $1; $$ = $1;
}; };
SymbolicValueRef : IntVal { $$ = $1.cnst; } | Name ; SymbolicValueRef : IntVal | Name ;
// ValueRef - A reference to a definition... either constant or symbolic // ValueRef - A reference to a definition... either constant or symbolic
ValueRef : SymbolicValueRef | ConstValueRef; ValueRef : SymbolicValueRef | ConstValueRef;
@ -810,8 +803,10 @@ ResolvedVal : Types ValueRef {
}; };
BasicBlockList : BasicBlockList BasicBlock { BasicBlockList : BasicBlockList BasicBlock {
$$ = 0;
} }
| BasicBlock { // Do not allow functions with 0 basic blocks | BasicBlock { // Do not allow functions with 0 basic blocks
$$ = 0;
}; };
@ -819,7 +814,7 @@ BasicBlockList : BasicBlockList BasicBlock {
// br, br/cc, switch, ret // br, br/cc, switch, ret
// //
BasicBlock : InstructionList BBTerminatorInst { BasicBlock : InstructionList BBTerminatorInst {
*O << *$2 ; $$ = 0;
}; };
InstructionList : InstructionList Inst { InstructionList : InstructionList Inst {