Neg instruction removed. Cast instruction implemented.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2001-07-08 04:57:15 +00:00
parent f22696f209
commit 0908309e3c
19 changed files with 752 additions and 722 deletions

View File

@ -60,7 +60,6 @@ protected:
inline ConstRules() {} // Can only be subclassed...
public:
// Unary Operators...
virtual ConstPoolVal *neg(const ConstPoolVal *V) const = 0;
virtual ConstPoolVal *not(const ConstPoolVal *V) const = 0;
// Binary Operators...
@ -88,10 +87,6 @@ private :
};
inline ConstPoolVal *operator-(const ConstPoolVal &V) {
return ConstRules::get(V)->neg(&V);
}
inline ConstPoolVal *operator!(const ConstPoolVal &V) {
return ConstRules::get(V)->not(&V);
}
@ -154,7 +149,6 @@ inline ConstPoolVal *ConstantFoldUnaryInstruction(unsigned Opcode,
ConstPoolVal *V) {
switch (Opcode) {
case Instruction::Not: return !*V;
case Instruction::Neg: return -*V;
}
return 0;
}

View File

@ -55,10 +55,12 @@ public:
// create() - Construct a unary instruction, given the opcode
// and its operand.
//
static UnaryOperator *create(UnaryOps Op, Value *Source);
static UnaryOperator *create(UnaryOps Op, Value *Source,
const Type *DestTy = 0);
UnaryOperator(Value *S, UnaryOps iType, const string &Name = "")
: Instruction(S->getType(), iType, Name) {
UnaryOperator(Value *S, UnaryOps iType, const Type *ResultType,
const string &Name = "")
: Instruction(ResultType, iType, Name) {
Operands.reserve(1);
Operands.push_back(Use(S, this));
}

View File

@ -77,14 +77,8 @@ public:
enum UnaryOps {
FirstUnaryOp = NumTermOps,
Neg = NumTermOps, Not,
// Type conversions...
ToBoolTy ,
ToUByteTy , ToSByteTy, ToUShortTy, ToShortTy,
ToUInt , ToInt, ToULongTy , ToLongTy,
ToFloatTy , ToDoubleTy, ToArrayTy , ToPointerTy,
Not = NumTermOps, // Binary inverse
Cast, // Type cast...
NumUnaryOps // Must remain at end of enum
};

View File

@ -9,6 +9,20 @@
#include "llvm/InstrTypes.h"
//===----------------------------------------------------------------------===//
// Class to represent Unary operators
//===----------------------------------------------------------------------===//
//
class GenericUnaryInst : public UnaryOperator {
public:
GenericUnaryInst(UnaryOps Opcode, Value *S1, const Type *ResultTy = 0,
const string &Name = "")
: UnaryOperator(S1, Opcode, ResultTy, Name) {
}
virtual const char *getOpcodeName() const;
};
//===----------------------------------------------------------------------===//
// Classes to represent Binary operators
//===----------------------------------------------------------------------===//

View File

@ -308,26 +308,26 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
*yy_cp = '\0'; \
yy_c_buf_p = yy_cp;
#define YY_NUM_RULES 58
#define YY_END_OF_BUFFER 59
static yyconst short int yy_acclist[113] =
#define YY_NUM_RULES 59
#define YY_END_OF_BUFFER 60
static yyconst short int yy_acclist[114] =
{ 0,
59, 57, 58, 56, 57, 58, 56, 58, 57, 58,
57, 58, 57, 58, 8, 57, 58, 52, 57, 58,
1, 57, 58, 57, 58, 57, 58, 57, 58, 57,
58, 57, 58, 57, 58, 57, 58, 57, 58, 57,
58, 57, 58, 57, 58, 57, 58, 57, 58, 57,
58, 57, 58, 57, 58, 57, 58, 50, 49, 54,
53, 52, 1, 9, 40, 51, 49, 55, 28, 31,
3, 16, 30, 24, 25, 26, 32, 39, 29, 11,
27, 44, 45, 18, 4, 22, 17, 10, 2, 5,
20, 23, 12, 34, 38, 36, 37, 35, 33, 14,
60, 58, 59, 57, 58, 59, 57, 59, 58, 59,
58, 59, 58, 59, 8, 58, 59, 53, 58, 59,
1, 58, 59, 58, 59, 58, 59, 58, 59, 58,
59, 58, 59, 58, 59, 58, 59, 58, 59, 58,
59, 58, 59, 58, 59, 58, 59, 58, 59, 58,
59, 58, 59, 58, 59, 58, 59, 51, 50, 55,
54, 53, 1, 9, 41, 26, 52, 50, 56, 29,
32, 3, 16, 31, 24, 27, 33, 40, 30, 11,
28, 25, 45, 46, 18, 4, 22, 17, 10, 2,
5, 20, 23, 12, 35, 39, 37, 38, 36, 34,
46, 13, 19, 43, 21, 42, 41, 15, 6, 47,
48, 7
14, 47, 13, 19, 44, 21, 43, 42, 15, 6,
48, 49, 7
} ;
static yyconst short int yy_accept[199] =
static yyconst short int yy_accept[200] =
{ 0,
1, 1, 1, 2, 4, 7, 9, 11, 13, 15,
18, 21, 24, 26, 28, 30, 32, 34, 36, 38,
@ -336,20 +336,20 @@ static yyconst short int yy_accept[199] =
64, 65, 65, 65, 66, 66, 66, 66, 66, 66,
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
66, 66, 66, 66, 66, 66, 66, 66, 67, 68,
69, 70, 70, 70, 70, 70, 70, 71, 71, 72,
72, 72, 72, 72, 72, 73, 73, 73, 73, 73,
67, 67, 67, 67, 67, 67, 67, 67, 68, 69,
70, 71, 71, 71, 71, 71, 71, 71, 72, 72,
73, 73, 73, 73, 73, 73, 74, 74, 74, 74,
74, 75, 76, 77, 77, 78, 79, 79, 79, 79,
79, 80, 80, 80, 80, 80, 80, 80, 80, 80,
80, 80, 81, 82, 82, 82, 82, 82, 83, 83,
83, 83, 84, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85, 85, 86, 87, 87, 88, 88, 88,
89, 89, 90, 90, 90, 91, 92, 92, 92, 93,
93, 93, 94, 95, 96, 97, 98, 99, 100, 101,
102, 102, 103, 104, 104, 105, 105, 106, 106, 106,
107, 107, 108, 109, 110, 110, 110, 110, 111, 111,
112, 112, 112, 112, 112, 112, 113, 113
80, 80, 81, 82, 83, 83, 83, 83, 83, 84,
84, 84, 84, 85, 86, 86, 86, 86, 86, 86,
86, 86, 86, 86, 86, 87, 88, 88, 89, 89,
89, 90, 90, 91, 91, 91, 92, 93, 93, 93,
94, 94, 94, 95, 96, 97, 98, 99, 100, 101,
102, 103, 103, 104, 105, 105, 106, 106, 107, 107,
107, 108, 108, 109, 110, 111, 111, 111, 111, 112,
112, 113, 113, 113, 113, 113, 113, 114, 114
} ;
@ -393,61 +393,61 @@ static yyconst int yy_meta[33] =
4, 4
} ;
static yyconst short int yy_base[203] =
static yyconst short int yy_base[204] =
{ 0,
0, 0, 389, 390, 390, 390, 0, 379, 26, 379,
0, 0, 391, 392, 392, 392, 0, 381, 26, 381,
27, 0, 28, 40, 29, 35, 34, 42, 30, 38,
56, 60, 55, 63, 65, 84, 68, 107, 52, 382,
376, 390, 0, 376, 375, 374, 74, 0, 32, 64,
372, 78, 67, 371, 77, 92, 76, 79, 89, 98,
100, 95, 102, 105, 108, 112, 111, 119, 122, 123,
116, 126, 128, 129, 132, 134, 137, 138, 139, 140,
143, 144, 145, 149, 146, 156, 154, 390, 0, 371,
369, 157, 166, 158, 161, 167, 368, 170, 367, 174,
175, 179, 180, 182, 366, 183, 181, 188, 184, 365,
56, 60, 52, 55, 61, 81, 65, 104, 63, 384,
378, 392, 0, 378, 377, 376, 69, 0, 32, 72,
374, 78, 71, 373, 91, 89, 73, 76, 92, 95,
98, 99, 108, 110, 111, 113, 118, 117, 121, 119,
123, 124, 129, 126, 134, 136, 137, 139, 135, 372,
140, 144, 146, 152, 147, 154, 156, 392, 0, 372,
370, 157, 158, 162, 164, 155, 167, 369, 176, 368,
170, 180, 177, 184, 181, 367, 187, 185, 186, 189,
364, 363, 362, 190, 361, 360, 191, 211, 198, 199,
359, 194, 200, 201, 202, 204, 205, 212, 203, 225,
214, 358, 357, 228, 209, 231, 232, 356, 233, 234,
235, 355, 354, 236, 238, 239, 241, 247, 249, 252,
242, 254, 259, 353, 352, 256, 351, 264, 265, 350,
267, 349, 270, 271, 348, 347, 273, 274, 346, 276,
275, 345, 344, 343, 342, 341, 340, 335, 330, 325,
283, 320, 319, 278, 317, 284, 316, 285, 288, 315,
289, 313, 311, 310, 293, 291, 301, 308, 295, 244,
303, 299, 302, 307, 309, 82, 390, 331, 334, 337,
366, 365, 364, 195, 363, 362, 196, 216, 197, 201,
361, 198, 199, 203, 204, 206, 207, 212, 208, 228,
221, 360, 359, 358, 231, 219, 235, 236, 357, 237,
238, 239, 356, 355, 240, 242, 243, 245, 251, 253,
256, 246, 258, 263, 354, 353, 260, 352, 268, 269,
351, 271, 350, 274, 275, 349, 348, 277, 278, 347,
280, 279, 346, 345, 344, 339, 334, 329, 324, 323,
321, 287, 320, 319, 282, 317, 288, 315, 289, 292,
314, 293, 312, 248, 211, 297, 295, 305, 210, 299,
172, 307, 303, 306, 311, 313, 74, 392, 335, 338,
342, 53
341, 346, 53
} ;
static yyconst short int yy_def[203] =
static yyconst short int yy_def[204] =
{ 0,
197, 1, 197, 197, 197, 197, 198, 199, 200, 197,
199, 201, 199, 199, 199, 199, 199, 199, 199, 199,
199, 199, 199, 199, 199, 199, 199, 199, 199, 198,
199, 197, 202, 197, 197, 197, 199, 201, 199, 199,
199, 199, 199, 199, 199, 199, 199, 199, 199, 199,
199, 199, 199, 199, 199, 199, 199, 199, 199, 199,
199, 199, 199, 199, 199, 199, 199, 199, 199, 199,
199, 199, 199, 199, 199, 199, 199, 197, 202, 197,
199, 199, 199, 199, 199, 199, 199, 199, 199, 199,
199, 199, 199, 199, 199, 199, 199, 199, 199, 199,
198, 1, 198, 198, 198, 198, 199, 200, 201, 198,
200, 202, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 199,
200, 198, 203, 198, 198, 198, 200, 202, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 198, 203, 198,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
199, 199, 199, 199, 199, 199, 199, 199, 199, 199,
199, 199, 199, 199, 199, 199, 199, 199, 199, 199,
199, 199, 199, 199, 199, 199, 199, 199, 199, 199,
199, 199, 199, 199, 199, 199, 199, 199, 199, 199,
199, 199, 199, 199, 199, 199, 199, 199, 199, 199,
199, 199, 199, 199, 199, 199, 199, 199, 199, 199,
199, 199, 199, 199, 199, 199, 199, 199, 199, 199,
199, 199, 199, 199, 199, 199, 199, 199, 199, 199,
199, 199, 199, 199, 199, 199, 199, 199, 199, 199,
199, 199, 199, 199, 199, 199, 0, 197, 197, 197,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 0, 198, 198,
197, 197
198, 198, 198
} ;
static yyconst short int yy_nxt[423] =
static yyconst short int yy_nxt[425] =
{ 0,
4, 5, 6, 7, 8, 9, 10, 11, 4, 12,
13, 14, 15, 16, 17, 18, 19, 8, 20, 21,
@ -455,98 +455,98 @@ static yyconst short int yy_nxt[423] =
8, 8, 34, 35, 37, 32, 32, 32, 32, 45,
32, 39, 32, 32, 53, 81, 32, 40, 32, 46,
32, 41, 50, 47, 42, 49, 79, 48, 54, 55,
32, 51, 43, 32, 32, 44, 56, 52, 32, 60,
58, 32, 32, 32, 77, 32, 32, 61, 57, 64,
62, 37, 32, 82, 32, 32, 32, 32, 59, 84,
32, 63, 32, 71, 83, 65, 85, 32, 66, 72,
32, 51, 43, 32, 32, 44, 56, 52, 32, 32,
58, 32, 61, 32, 60, 63, 37, 32, 57, 32,
32, 32, 32, 62, 32, 77, 32, 70, 59, 32,
71, 82, 64, 84, 83, 65, 72, 32, 66, 32,
32, 67, 89, 32, 86, 87, 32, 88, 32, 92,
32, 68, 69, 32, 70, 32, 32, 90, 73, 32,
32, 97, 91, 96, 32, 74, 75, 32, 94, 93,
32, 32, 98, 76, 32, 95, 32, 32, 99, 101,
32, 100, 32, 102, 103, 32, 32, 32, 32, 105,
111, 32, 32, 32, 32, 104, 106, 32, 112, 109,
110, 108, 32, 107, 32, 32, 32, 114, 117, 32,
116, 113, 119, 118, 32, 32, 115, 122, 32, 120,
123, 125, 32, 32, 121, 127, 124, 32, 32, 32,
32, 32, 32, 128, 132, 129, 32, 131, 32, 32,
32, 87, 88, 32, 89, 90, 32, 32, 67, 68,
85, 69, 32, 93, 91, 73, 32, 86, 32, 32,
92, 32, 74, 75, 97, 32, 32, 32, 98, 32,
76, 32, 32, 95, 32, 94, 100, 32, 96, 99,
101, 103, 32, 32, 32, 32, 102, 32, 32, 105,
111, 104, 32, 112, 32, 32, 106, 107, 109, 110,
32, 108, 32, 32, 32, 32, 32, 114, 113, 117,
32, 118, 32, 116, 119, 32, 121, 115, 32, 120,
32, 122, 124, 123, 32, 32, 125, 126, 32, 32,
128, 129, 32, 32, 32, 32, 127, 32, 133, 130,
126, 130, 32, 134, 133, 135, 32, 32, 32, 32,
32, 32, 32, 32, 144, 145, 150, 32, 136, 32,
32, 143, 32, 141, 142, 137, 148, 138, 154, 146,
139, 147, 140, 32, 149, 152, 32, 151, 153, 32,
32, 32, 32, 32, 32, 155, 32, 32, 158, 32,
32, 157, 32, 162, 159, 32, 161, 32, 160, 156,
32, 164, 32, 166, 32, 163, 168, 32, 170, 169,
172, 171, 32, 32, 165, 32, 167, 175, 32, 32,
173, 32, 32, 32, 32, 177, 32, 178, 180, 181,
174, 32, 32, 32, 179, 176, 32, 32, 184, 32,
131, 132, 134, 32, 32, 32, 32, 32, 135, 32,
136, 32, 32, 145, 32, 32, 32, 146, 32, 32,
32, 151, 142, 137, 32, 144, 143, 32, 149, 32,
138, 147, 139, 148, 150, 140, 32, 141, 155, 32,
152, 154, 153, 32, 32, 32, 32, 32, 32, 156,
32, 32, 159, 32, 32, 158, 32, 163, 160, 32,
162, 32, 161, 157, 32, 165, 32, 167, 32, 164,
169, 32, 171, 170, 173, 172, 32, 32, 166, 32,
168, 176, 32, 32, 174, 32, 32, 32, 32, 178,
32, 179, 181, 182, 175, 32, 32, 32, 180, 177,
182, 32, 186, 32, 185, 183, 188, 32, 187, 32,
32, 32, 189, 192, 190, 32, 32, 32, 32, 32,
194, 32, 191, 32, 32, 32, 193, 32, 32, 195,
196, 30, 30, 32, 30, 30, 30, 31, 32, 31,
33, 33, 38, 32, 38, 38, 38, 38, 32, 32,
32, 32, 185, 32, 183, 32, 187, 32, 186, 184,
189, 32, 188, 32, 32, 32, 190, 193, 191, 32,
32, 32, 32, 32, 195, 32, 192, 32, 32, 32,
194, 32, 32, 196, 197, 30, 30, 32, 30, 30,
30, 31, 32, 31, 33, 33, 38, 32, 38, 38,
38, 38, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 80, 32,
32, 36, 35, 80, 32, 78, 36, 32, 197, 3,
197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
32, 32, 32, 32, 32, 32, 32, 32, 32, 80,
32, 32, 32, 36, 35, 80, 32, 78, 36, 32,
198, 3, 198, 198, 198, 198, 198, 198, 198, 198,
197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
197, 197
198, 198, 198, 198, 198, 198, 198, 198, 198, 198,
198, 198, 198, 198, 198, 198, 198, 198, 198, 198,
198, 198, 198, 198
} ;
static yyconst short int yy_chk[423] =
static yyconst short int yy_chk[425] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 9, 9, 11, 11, 13, 15, 19, 15,
39, 13, 17, 16, 19, 39, 20, 13, 14, 16,
18, 14, 18, 16, 14, 17, 202, 16, 20, 20,
29, 18, 14, 23, 21, 14, 21, 18, 22, 23,
22, 24, 40, 25, 29, 43, 27, 23, 21, 25,
24, 37, 37, 40, 47, 45, 42, 48, 22, 43,
196, 24, 26, 27, 42, 26, 45, 49, 26, 27,
18, 14, 18, 16, 14, 17, 203, 16, 20, 20,
23, 18, 14, 24, 21, 14, 21, 18, 22, 25,
22, 29, 24, 27, 23, 25, 37, 37, 21, 43,
40, 47, 197, 24, 48, 29, 42, 27, 22, 26,
27, 40, 26, 43, 42, 26, 27, 46, 26, 45,
46, 26, 49, 52, 46, 47, 50, 48, 51, 52,
53, 26, 26, 54, 26, 28, 55, 50, 28, 57,
56, 57, 51, 56, 61, 28, 28, 58, 54, 53,
59, 60, 57, 28, 62, 55, 63, 64, 58, 60,
65, 59, 66, 61, 62, 67, 68, 69, 70, 64,
69, 71, 72, 73, 75, 63, 64, 74, 70, 67,
68, 66, 77, 65, 76, 82, 84, 72, 75, 85,
74, 71, 77, 76, 83, 86, 73, 84, 88, 82,
85, 88, 90, 91, 83, 91, 86, 92, 93, 97,
94, 96, 99, 92, 97, 93, 98, 96, 104, 107,
49, 46, 47, 50, 48, 49, 51, 52, 26, 26,
45, 26, 28, 52, 50, 28, 53, 45, 54, 55,
51, 56, 28, 28, 56, 58, 57, 60, 57, 59,
28, 61, 62, 54, 64, 53, 58, 63, 55, 57,
59, 61, 65, 69, 66, 67, 60, 68, 71, 63,
68, 62, 72, 69, 73, 75, 63, 64, 66, 67,
74, 65, 76, 86, 77, 82, 83, 72, 71, 75,
84, 76, 85, 74, 77, 87, 83, 73, 91, 82,
191, 84, 86, 85, 89, 93, 87, 89, 92, 95,
92, 93, 94, 98, 99, 97, 91, 100, 98, 94,
90, 94, 112, 99, 98, 104, 109, 110, 113, 114,
115, 119, 116, 117, 113, 114, 119, 125, 107, 108,
118, 112, 121, 109, 110, 108, 117, 108, 125, 115,
108, 116, 108, 120, 118, 121, 124, 120, 124, 126,
127, 129, 130, 131, 134, 126, 135, 136, 130, 137,
141, 129, 190, 136, 131, 138, 135, 139, 134, 127,
140, 138, 142, 139, 146, 137, 140, 143, 142, 141,
146, 143, 148, 149, 138, 151, 139, 151, 153, 154,
148, 157, 158, 161, 160, 154, 174, 157, 160, 161,
149, 171, 176, 178, 158, 153, 179, 181, 176, 186,
95, 97, 99, 104, 107, 109, 112, 113, 100, 110,
104, 114, 115, 113, 116, 117, 119, 114, 189, 185,
118, 119, 109, 107, 108, 112, 110, 126, 117, 121,
108, 115, 108, 116, 118, 108, 120, 108, 126, 125,
120, 125, 121, 127, 128, 130, 131, 132, 135, 127,
136, 137, 131, 138, 142, 130, 184, 137, 132, 139,
136, 140, 135, 128, 141, 139, 143, 140, 147, 138,
141, 144, 143, 142, 147, 144, 149, 150, 139, 152,
140, 152, 154, 155, 149, 158, 159, 162, 161, 155,
175, 158, 161, 162, 150, 172, 177, 179, 159, 154,
171, 185, 179, 189, 178, 174, 185, 192, 181, 187,
193, 191, 186, 191, 187, 194, 188, 195, 184, 183,
193, 182, 189, 180, 177, 175, 192, 173, 172, 194,
195, 198, 198, 170, 198, 198, 198, 199, 169, 199,
200, 200, 201, 168, 201, 201, 201, 201, 167, 166,
165, 164, 163, 162, 159, 156, 155, 152, 150, 147,
145, 144, 133, 132, 128, 123, 122, 111, 106, 105,
103, 102, 101, 100, 95, 89, 87, 81, 80, 44,
41, 36, 35, 34, 31, 30, 10, 8, 3, 197,
197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
180, 182, 177, 187, 172, 186, 180, 190, 179, 175,
186, 193, 182, 188, 194, 192, 187, 192, 188, 195,
183, 196, 181, 178, 194, 176, 190, 174, 173, 171,
193, 170, 169, 195, 196, 199, 199, 168, 199, 199,
199, 200, 167, 200, 201, 201, 202, 166, 202, 202,
202, 202, 165, 164, 163, 160, 157, 156, 153, 151,
148, 146, 145, 134, 133, 129, 124, 123, 122, 111,
106, 105, 103, 102, 101, 96, 90, 88, 81, 80,
70, 44, 41, 36, 35, 34, 31, 30, 10, 8,
3, 198, 198, 198, 198, 198, 198, 198, 198, 198,
197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
197, 197
198, 198, 198, 198, 198, 198, 198, 198, 198, 198,
198, 198, 198, 198, 198, 198, 198, 198, 198, 198,
198, 198, 198, 198
} ;
static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr;
@ -816,14 +816,14 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 198 )
if ( yy_current_state >= 199 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
*yy_state_ptr++ = yy_current_state;
++yy_cp;
}
while ( yy_current_state != 197 );
while ( yy_current_state != 198 );
yy_find_action:
yy_current_state = *--yy_state_ptr;
@ -976,159 +976,164 @@ YY_RULE_SETUP
case 24:
YY_RULE_SETUP
#line 114 "Lexer.l"
{ RET_TOK(UnaryOpVal, Neg, NEG); }
{ RET_TOK(UnaryOpVal, Not, NOT); }
YY_BREAK
case 25:
YY_RULE_SETUP
#line 115 "Lexer.l"
{ RET_TOK(UnaryOpVal, Not, NOT); }
{ RET_TOK(UnaryOpVal, Cast, CAST); }
YY_BREAK
case 26:
YY_RULE_SETUP
#line 117 "Lexer.l"
{ return PHI; }
{ return TO; }
YY_BREAK
case 27:
YY_RULE_SETUP
#line 118 "Lexer.l"
{ return CALL; }
{ return PHI; }
YY_BREAK
case 28:
YY_RULE_SETUP
#line 119 "Lexer.l"
{ RET_TOK(BinaryOpVal, Add, ADD); }
{ return CALL; }
YY_BREAK
case 29:
YY_RULE_SETUP
#line 120 "Lexer.l"
{ RET_TOK(BinaryOpVal, Sub, SUB); }
{ RET_TOK(BinaryOpVal, Add, ADD); }
YY_BREAK
case 30:
YY_RULE_SETUP
#line 121 "Lexer.l"
{ RET_TOK(BinaryOpVal, Mul, MUL); }
{ RET_TOK(BinaryOpVal, Sub, SUB); }
YY_BREAK
case 31:
YY_RULE_SETUP
#line 122 "Lexer.l"
{ RET_TOK(BinaryOpVal, Div, DIV); }
{ RET_TOK(BinaryOpVal, Mul, MUL); }
YY_BREAK
case 32:
YY_RULE_SETUP
#line 123 "Lexer.l"
{ RET_TOK(BinaryOpVal, Rem, REM); }
{ RET_TOK(BinaryOpVal, Div, DIV); }
YY_BREAK
case 33:
YY_RULE_SETUP
#line 124 "Lexer.l"
{ RET_TOK(BinaryOpVal, SetNE, SETNE); }
{ RET_TOK(BinaryOpVal, Rem, REM); }
YY_BREAK
case 34:
YY_RULE_SETUP
#line 125 "Lexer.l"
{ RET_TOK(BinaryOpVal, SetEQ, SETEQ); }
{ RET_TOK(BinaryOpVal, SetNE, SETNE); }
YY_BREAK
case 35:
YY_RULE_SETUP
#line 126 "Lexer.l"
{ RET_TOK(BinaryOpVal, SetLT, SETLT); }
{ RET_TOK(BinaryOpVal, SetEQ, SETEQ); }
YY_BREAK
case 36:
YY_RULE_SETUP
#line 127 "Lexer.l"
{ RET_TOK(BinaryOpVal, SetGT, SETGT); }
{ RET_TOK(BinaryOpVal, SetLT, SETLT); }
YY_BREAK
case 37:
YY_RULE_SETUP
#line 128 "Lexer.l"
{ RET_TOK(BinaryOpVal, SetLE, SETLE); }
{ RET_TOK(BinaryOpVal, SetGT, SETGT); }
YY_BREAK
case 38:
YY_RULE_SETUP
#line 129 "Lexer.l"
{ RET_TOK(BinaryOpVal, SetGE, SETGE); }
{ RET_TOK(BinaryOpVal, SetLE, SETLE); }
YY_BREAK
case 39:
YY_RULE_SETUP
#line 131 "Lexer.l"
{ RET_TOK(TermOpVal, Ret, RET); }
#line 130 "Lexer.l"
{ RET_TOK(BinaryOpVal, SetGE, SETGE); }
YY_BREAK
case 40:
YY_RULE_SETUP
#line 132 "Lexer.l"
{ RET_TOK(TermOpVal, Br, BR); }
{ RET_TOK(TermOpVal, Ret, RET); }
YY_BREAK
case 41:
YY_RULE_SETUP
#line 133 "Lexer.l"
{ RET_TOK(TermOpVal, Switch, SWITCH); }
{ RET_TOK(TermOpVal, Br, BR); }
YY_BREAK
case 42:
YY_RULE_SETUP
#line 136 "Lexer.l"
{ RET_TOK(MemOpVal, Malloc, MALLOC); }
#line 134 "Lexer.l"
{ RET_TOK(TermOpVal, Switch, SWITCH); }
YY_BREAK
case 43:
YY_RULE_SETUP
#line 137 "Lexer.l"
{ RET_TOK(MemOpVal, Alloca, ALLOCA); }
{ RET_TOK(MemOpVal, Malloc, MALLOC); }
YY_BREAK
case 44:
YY_RULE_SETUP
#line 138 "Lexer.l"
{ RET_TOK(MemOpVal, Free, FREE); }
{ RET_TOK(MemOpVal, Alloca, ALLOCA); }
YY_BREAK
case 45:
YY_RULE_SETUP
#line 139 "Lexer.l"
{ RET_TOK(MemOpVal, Load, LOAD); }
{ RET_TOK(MemOpVal, Free, FREE); }
YY_BREAK
case 46:
YY_RULE_SETUP
#line 140 "Lexer.l"
{ RET_TOK(MemOpVal, Store, STORE); }
{ RET_TOK(MemOpVal, Load, LOAD); }
YY_BREAK
case 47:
YY_RULE_SETUP
#line 141 "Lexer.l"
{ RET_TOK(MemOpVal, GetField, GETFIELD); }
{ RET_TOK(MemOpVal, Store, STORE); }
YY_BREAK
case 48:
YY_RULE_SETUP
#line 142 "Lexer.l"
{ RET_TOK(MemOpVal, PutField, PUTFIELD); }
{ RET_TOK(MemOpVal, GetField, GETFIELD); }
YY_BREAK
case 49:
YY_RULE_SETUP
#line 145 "Lexer.l"
{ llvmAsmlval.StrVal = strdup(yytext+1); return VAR_ID; }
#line 143 "Lexer.l"
{ RET_TOK(MemOpVal, PutField, PUTFIELD); }
YY_BREAK
case 50:
YY_RULE_SETUP
#line 146 "Lexer.l"
{ llvmAsmlval.StrVal = strdup(yytext+1); return VAR_ID; }
YY_BREAK
case 51:
YY_RULE_SETUP
#line 147 "Lexer.l"
{
yytext[strlen(yytext)-1] = 0; // nuke colon
llvmAsmlval.StrVal = strdup(yytext);
return LABELSTR;
}
YY_BREAK
case 51:
case 52:
YY_RULE_SETUP
#line 152 "Lexer.l"
#line 153 "Lexer.l"
{
yytext[strlen(yytext)-1] = 0; // nuke end quote
llvmAsmlval.StrVal = strdup(yytext+1); // Nuke start quote
return STRINGCONSTANT;
}
YY_BREAK
case 52:
YY_RULE_SETUP
#line 159 "Lexer.l"
{ llvmAsmlval.UInt64Val = atoull(yytext); return EUINT64VAL; }
YY_BREAK
case 53:
YY_RULE_SETUP
#line 160 "Lexer.l"
{ llvmAsmlval.UInt64Val = atoull(yytext); return EUINT64VAL; }
YY_BREAK
case 54:
YY_RULE_SETUP
#line 161 "Lexer.l"
{
uint64_t Val = atoull(yytext+1);
// +1: we have bigger negative range
@ -1138,14 +1143,14 @@ YY_RULE_SETUP
return ESINT64VAL;
}
YY_BREAK
case 54:
YY_RULE_SETUP
#line 170 "Lexer.l"
{ llvmAsmlval.UIntVal = atoull(yytext+1); return UINTVAL; }
YY_BREAK
case 55:
YY_RULE_SETUP
#line 171 "Lexer.l"
{ llvmAsmlval.UIntVal = atoull(yytext+1); return UINTVAL; }
YY_BREAK
case 56:
YY_RULE_SETUP
#line 172 "Lexer.l"
{
uint64_t Val = atoull(yytext+2);
// +1: we have bigger negative range
@ -1155,22 +1160,22 @@ YY_RULE_SETUP
return SINTVAL;
}
YY_BREAK
case 56:
YY_RULE_SETUP
#line 181 "Lexer.l"
{ /* Ignore whitespace */ }
YY_BREAK
case 57:
YY_RULE_SETUP
#line 182 "Lexer.l"
{ /*printf("'%s'", yytext);*/ return yytext[0]; }
{ /* Ignore whitespace */ }
YY_BREAK
case 58:
YY_RULE_SETUP
#line 184 "Lexer.l"
#line 183 "Lexer.l"
{ /*printf("'%s'", yytext);*/ return yytext[0]; }
YY_BREAK
case 59:
YY_RULE_SETUP
#line 185 "Lexer.l"
YY_FATAL_ERROR( "flex scanner jammed" );
YY_BREAK
#line 1175 "Lexer.cpp"
#line 1180 "Lexer.cpp"
case YY_STATE_EOF(INITIAL):
yyterminate();
@ -1459,7 +1464,7 @@ static yy_state_type yy_get_previous_state()
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 198 )
if ( yy_current_state >= 199 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@ -1489,11 +1494,11 @@ yy_state_type yy_current_state;
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 198 )
if ( yy_current_state >= 199 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 197);
yy_is_jam = (yy_current_state == 198);
if ( ! yy_is_jam )
*yy_state_ptr++ = yy_current_state;
@ -2054,5 +2059,5 @@ int main()
return 0;
}
#endif
#line 184 "Lexer.l"
#line 185 "Lexer.l"

View File

@ -111,9 +111,10 @@ type { llvmAsmlval.TypeVal = Type::TypeTy ; return TYPE; }
label { llvmAsmlval.TypeVal = Type::LabelTy ; return LABEL; }
neg { RET_TOK(UnaryOpVal, Neg, NEG); }
not { RET_TOK(UnaryOpVal, Not, NOT); }
cast { RET_TOK(UnaryOpVal, Cast, CAST); }
to { return TO; }
phi { return PHI; }
call { return CALL; }
add { RET_TOK(BinaryOpVal, Add, ADD); }

File diff suppressed because it is too large Load Diff

View File

@ -56,33 +56,32 @@ typedef union {
#define BEGINTOK 282
#define END 283
#define DECLARE 284
#define PHI 285
#define CALL 286
#define RET 287
#define BR 288
#define SWITCH 289
#define NEG 290
#define TO 285
#define PHI 286
#define CALL 287
#define RET 288
#define BR 289
#define SWITCH 290
#define NOT 291
#define TOINT 292
#define TOUINT 293
#define ADD 294
#define SUB 295
#define MUL 296
#define DIV 297
#define REM 298
#define SETLE 299
#define SETGE 300
#define SETLT 301
#define SETGT 302
#define SETEQ 303
#define SETNE 304
#define MALLOC 305
#define ALLOCA 306
#define FREE 307
#define LOAD 308
#define STORE 309
#define GETFIELD 310
#define PUTFIELD 311
#define CAST 292
#define ADD 293
#define SUB 294
#define MUL 295
#define DIV 296
#define REM 297
#define SETLE 298
#define SETGE 299
#define SETLT 300
#define SETGT 301
#define SETEQ 302
#define SETNE 303
#define MALLOC 304
#define ALLOCA 305
#define FREE 306
#define LOAD 307
#define STORE 308
#define GETFIELD 309
#define PUTFIELD 310
extern YYSTYPE llvmAsmlval;

View File

@ -26,8 +26,8 @@
#include <utility> // Get definition of pair class
#include <stdio.h> // This embarasment is due to our flex lexer...
int yyerror(char *ErrorMsg); // Forward declarations to prevent "implicit
int yylex(); // declaration" of xxx warnings.
int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
int yylex(); // declaration" of xxx warnings.
int yyparse();
static Module *ParserResult;
@ -403,7 +403,7 @@ Module *RunVMAsmParser(const ToolCommandLine &Opts, FILE *F) {
%type <StrVal> OptVAR_ID OptAssign
%token IMPLEMENTATION TRUE FALSE BEGINTOK END DECLARE
%token IMPLEMENTATION TRUE FALSE BEGINTOK END DECLARE TO
%token PHI CALL
// Basic Block Terminating Operators
@ -411,10 +411,7 @@ Module *RunVMAsmParser(const ToolCommandLine &Opts, FILE *F) {
// Unary Operators
%type <UnaryOpVal> UnaryOps // all the unary operators
%token <UnaryOpVal> NEG NOT
// Unary Conversion Operators
%token <UnaryOpVal> TOINT TOUINT
%token <UnaryOpVal> NOT CAST
// Binary Operators
%type <BinaryOpVal> BinaryOps // all the binary operators
@ -461,7 +458,7 @@ TypesV : Types | VOID
// Operations that are notably excluded from this list include:
// RET, BR, & SWITCH because they end basic blocks and are treated specially.
//
UnaryOps : NEG | NOT | TOINT | TOUINT
UnaryOps : NOT
BinaryOps : ADD | SUB | MUL | DIV | REM
BinaryOps : SETLE | SETGE | SETLT | SETGT | SETEQ | SETNE
@ -874,7 +871,10 @@ InstVal : BinaryOps Types ValueRef ',' ValueRef {
$$ = UnaryOperator::create($1, getVal($2, $3));
if ($$ == 0)
ThrowException("unary operator returned null!");
}
}
| CAST Types ValueRef TO Types {
$$ = UnaryOperator::create($1, getVal($2, $3), $5);
}
| PHI PHIList {
const Type *Ty = $2->front().first->getType();
$$ = new PHINode(Ty);
@ -962,7 +962,7 @@ MemoryInst : MALLOC Types {
}
%%
int yyerror(char *ErrorMsg) {
int yyerror(const char *ErrorMsg) {
ThrowException(string("Parse error: ") + ErrorMsg);
return 0;
}

View File

@ -105,6 +105,10 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
getValue(Raw.Ty, Raw.Arg1),
getValue(Raw.Ty, Raw.Arg2));
return false;
} else if (Raw.Opcode == Instruction::Cast) {
Res = UnaryOperator::create(Instruction::Cast, getValue(Raw.Ty, Raw.Arg1),
getType(Raw.Arg2));
return false;
} else if (Raw.Opcode == Instruction::PHINode) {
PHINode *PN = new PHINode(Raw.Ty);
switch (Raw.NumOperands) {

View File

@ -145,6 +145,15 @@ bool BytecodeWriter::processInstruction(const Instruction *I) {
assert(Slot != -1 && "Type not available!!?!");
Type = (unsigned)Slot;
// Handle the special case for cast...
if (I->getOpcode() == Instruction::Cast) {
// Cast has to encode the destination type as the second argument in the
// packet, or else we won't know what type to cast to!
Slots[1] = Table.getValSlot(I->getType());
assert(Slots[1] != -1 && "Cast return type unknown?");
if (Slots[1] > MaxOpSlot) MaxOpSlot = Slots[1];
NumOperands++;
}
// Decide which instruction encoding to use. This is determined primarily by
// the number of operands, and secondarily by whether or not the max operand

View File

@ -79,16 +79,6 @@ static LIVType isLinearInductionVariableH(cfg::Interval *Int, Value *V,
// loop variant computations must be instructions!
Instruction *I = V->castInstructionAsserting();
switch (I->getOpcode()) { // Handle each instruction seperately
case Instruction::Neg: {
Value *SubV = ((UnaryOperator*)I)->getOperand(0);
LIVType SubLIVType = isLinearInductionVariableH(Int, SubV, PN);
switch (SubLIVType) {
case isLIC: // Loop invariant & other computations remain the same
case isOther: return SubLIVType;
case isLIV: // Return the opposite signed LIV type
case isNLIV: return neg(isLIV);
}
}
case Instruction::Add:
case Instruction::Sub: {
Value *SubV1 = ((BinaryOperator*)I)->getOperand(0);

View File

@ -207,7 +207,9 @@ bool AssemblyWriter::processInstruction(const Instruction *I) {
Out << ",";
writeOperand(I->getOperand(0), true);
}
} else if (I->getOpcode() == Instruction::Cast) {
writeOperand(Operand, true);
Out << " to " << I->getType();
} else if (Operand) { // Print the normal way...
// PrintAllTypes - Instructions who have operands of all the same type

View File

@ -27,10 +27,6 @@ class TemplateRules : public ConstRules {
// Redirecting functions that cast to the appropriate types
//===--------------------------------------------------------------------===//
virtual ConstPoolVal *neg(const ConstPoolVal *V) const {
return SubClassName::Neg((const ArgType *)V);
}
virtual ConstPoolVal *not(const ConstPoolVal *V) const {
return SubClassName::Not((const ArgType *)V);
}
@ -55,7 +51,6 @@ class TemplateRules : public ConstRules {
// Default "noop" implementations
//===--------------------------------------------------------------------===//
inline static ConstPoolVal *Neg(const ArgType *V) { return 0; }
inline static ConstPoolVal *Not(const ArgType *V) { return 0; }
inline static ConstPoolVal *Add(const ArgType *V1, const ArgType *V2) {
@ -125,9 +120,6 @@ struct DirectRules
: public TemplateRules<ConstPoolClass,
DirectRules<ConstPoolClass, BuiltinType, Ty> > {
inline static ConstPoolVal *Neg(const ConstPoolClass *V) {
return new ConstPoolClass(*Ty, -(BuiltinType)V->getValue());;
}
inline static ConstPoolVal *Not(const ConstPoolClass *V) {
return new ConstPoolClass(*Ty, !(BuiltinType)V->getValue());;
}

View File

@ -60,7 +60,6 @@ protected:
inline ConstRules() {} // Can only be subclassed...
public:
// Unary Operators...
virtual ConstPoolVal *neg(const ConstPoolVal *V) const = 0;
virtual ConstPoolVal *not(const ConstPoolVal *V) const = 0;
// Binary Operators...
@ -88,10 +87,6 @@ private :
};
inline ConstPoolVal *operator-(const ConstPoolVal &V) {
return ConstRules::get(V)->neg(&V);
}
inline ConstPoolVal *operator!(const ConstPoolVal &V) {
return ConstRules::get(V)->not(&V);
}
@ -154,7 +149,6 @@ inline ConstPoolVal *ConstantFoldUnaryInstruction(unsigned Opcode,
ConstPoolVal *V) {
switch (Opcode) {
case Instruction::Not: return !*V;
case Instruction::Neg: return -*V;
}
return 0;
}

View File

@ -60,7 +60,6 @@ protected:
inline ConstRules() {} // Can only be subclassed...
public:
// Unary Operators...
virtual ConstPoolVal *neg(const ConstPoolVal *V) const = 0;
virtual ConstPoolVal *not(const ConstPoolVal *V) const = 0;
// Binary Operators...
@ -88,10 +87,6 @@ private :
};
inline ConstPoolVal *operator-(const ConstPoolVal &V) {
return ConstRules::get(V)->neg(&V);
}
inline ConstPoolVal *operator!(const ConstPoolVal &V) {
return ConstRules::get(V)->not(&V);
}
@ -154,7 +149,6 @@ inline ConstPoolVal *ConstantFoldUnaryInstruction(unsigned Opcode,
ConstPoolVal *V) {
switch (Opcode) {
case Instruction::Not: return !*V;
case Instruction::Neg: return -*V;
}
return 0;
}

View File

@ -11,15 +11,6 @@
#include "llvm/Type.h"
#include <algorithm> // find
// TODO: Move to getUnaryOperator iUnary.cpp when and if it exists!
UnaryOperator *UnaryOperator::create(UnaryOps Op, Value *Source) {
switch (Op) {
default:
cerr << "Don't know how to GetUnaryOperator " << Op << endl;
return 0;
}
}
//===----------------------------------------------------------------------===//
// TerminatorInst Class
//===----------------------------------------------------------------------===//

View File

@ -7,6 +7,32 @@
#include "llvm/iBinary.h"
#include "llvm/Type.h"
UnaryOperator *UnaryOperator::create(UnaryOps Op, Value *Source,
const Type *DestTy = 0) {
if (DestTy == 0) DestTy = Source->getType();
switch (Op) {
case Not: assert(DestTy == Source->getType());
case Cast: return new GenericUnaryInst(Op, Source, DestTy);
default:
cerr << "Don't know how to GetUnaryOperator " << Op << endl;
return 0;
}
}
const char *GenericUnaryInst::getOpcodeName() const {
switch (getOpcode()) {
case Not: return "not";
case Cast: return "cast";
default:
cerr << "Invalid unary operator type!" << getOpcode() << endl;
abort();
}
}
//===----------------------------------------------------------------------===//
// BinaryOperator Class
//===----------------------------------------------------------------------===//
BinaryOperator *BinaryOperator::create(BinaryOps Op, Value *S1, Value *S2,
const string &Name) {
switch (Op) {
@ -20,6 +46,10 @@ BinaryOperator *BinaryOperator::create(BinaryOps Op, Value *S1, Value *S2,
}
}
//===----------------------------------------------------------------------===//
// GenericBinaryInst Class
//===----------------------------------------------------------------------===//
const char *GenericBinaryInst::getOpcodeName() const {
switch (getOpcode()) {
// Standard binary operators...
@ -35,7 +65,7 @@ const char *GenericBinaryInst::getOpcodeName() const {
case Xor: return "xor";
default:
cerr << "Invalid binary operator type!" << getOpcode() << endl;
return 0;
abort();
}
}

11
test/Feature/casttest.ll Normal file
View File

@ -0,0 +1,11 @@
implementation
short "FunFunc"(long %x, sbyte %z)
begin
bb0: ;;<label>
%cast110 = cast sbyte %z to short ;;<short>:(signed operands)
%cast10 = cast long %x to short ;;<short>
%reg109 = add short %cast110, %cast10 ;;<short>
ret short %reg109 ;;<void>
end