Moved Cast from being a Unary instruction to being an "Other" instruction
authorChris Lattner <sabre@nondot.org>
Sun, 8 Jul 2001 19:03:27 +0000 (19:03 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 8 Jul 2001 19:03:27 +0000 (19:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/InstrTypes.h
include/llvm/Instruction.h
include/llvm/iOperators.h
include/llvm/iOther.h
lib/AsmParser/Lexer.cpp
lib/AsmParser/Lexer.l
lib/AsmParser/llvmAsmParser.cpp
lib/AsmParser/llvmAsmParser.h
lib/AsmParser/llvmAsmParser.y
lib/Bytecode/Reader/InstructionReader.cpp
lib/VMCore/iOperators.cpp

index 8bfaca4a8a44f769daf8d8e2eac2a870885b439c..fa0ce87c9ca78104f6f4c2a1ddd4e82b61a149f4 100644 (file)
@@ -55,12 +55,10 @@ public:
   // create() - Construct a unary instruction, given the opcode
   // and its operand.
   //
-  static UnaryOperator *create(UnaryOps Op, Value *Source,
-                              const Type *DestTy = 0);
+  static UnaryOperator *create(UnaryOps Op, Value *Source);
 
-  UnaryOperator(Value *S, UnaryOps iType, const Type *ResultType,
-               const string &Name = "")
-      : Instruction(ResultType, iType, Name) {
+  UnaryOperator(Value *S, UnaryOps iType, const string &Name = "")
+      : Instruction(S->getType(), iType, Name) {
     Operands.reserve(1);
     Operands.push_back(Use(S, this));
   }
index 16adbb2982cf5f8e9ff747f76e53c1abe6f51c7a..cce9662122de771a286752a275bba9a61a4bf327 100644 (file)
@@ -78,7 +78,6 @@ public:
   enum UnaryOps {
     FirstUnaryOp = NumTermOps,
     Not          = NumTermOps,      // Binary inverse
-    Cast,                           // Type cast...
 
     NumUnaryOps        // Must remain at end of enum
   };
@@ -112,6 +111,7 @@ public:
   enum OtherOps {
     FirstOtherOp = NumMemoryOps,
     PHINode      = NumMemoryOps,     // PHI node instruction
+    Cast,                            // Type cast...
     Call,                            // Call a function
 
     Shl, Shr,                        // Shift operations...
index 5d02a40477260f105763cb7a78d725002c2aa6d3..7cbaecf64a02ee72dc2abae03040a49da22c228a 100644 (file)
@@ -15,9 +15,8 @@
 //
 class GenericUnaryInst : public UnaryOperator {
 public:
-  GenericUnaryInst(UnaryOps Opcode, Value *S1, const Type *ResultTy = 0,
-                  const string &Name = "")
-    : UnaryOperator(S1, Opcode, ResultTy, Name) {
+  GenericUnaryInst(UnaryOps Opcode, Value *S1, const string &Name = "")
+    : UnaryOperator(S1, Opcode, Name) {
   }
 
   virtual const char *getOpcodeName() const;
index ebd6475a96f5e7704f56cef8e24c7561b85fea8d..cf9fe9689397098f4bf8701f065a1214d8e20588 100644 (file)
 #include "llvm/Method.h"
 #include <vector>
 
+//===----------------------------------------------------------------------===//
+//                                 CastInst Class
+//===----------------------------------------------------------------------===//
+
+// CastInst - This function represents a cast from Operand[0] to the type of
+// the instruction (i->getType()).
+//
+class CastInst : public Instruction {
+  CastInst(const CastInst &CI) : Instruction(CI.getType(), Cast) {
+    Operands.reserve(1);
+    Operands.push_back(Use((Value*)CI.getOperand(0), this));
+  }
+public:
+  CastInst(Value *S, const Type *Ty, const string &Name = "")
+    : Instruction(Ty, Cast, Name) {
+    Operands.reserve(1);
+    Operands.push_back(Use(S, this));
+  }
+
+  virtual Instruction *clone() const { return new CastInst(*this); }
+  virtual const char *getOpcodeName() const { return "cast"; }
+};
+
+
 //===----------------------------------------------------------------------===//
 //                               PHINode Class
 //===----------------------------------------------------------------------===//
index 7e2191b692f2140d8e5963a037bb864b84c7f671..cf37530b2b00349aeb30a0df8b6c297c937bd251 100644 (file)
@@ -318,9 +318,9 @@ static yyconst short int yy_acclist[114] =
        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,
+       54,   53,    1,    9,   41,   28,   52,   50,   56,   29,
+       32,    3,   16,   31,   24,   25,   33,   40,   30,   11,
+       26,   27,   45,   46,   18,    4,   22,   17,   10,    2,
         5,   20,   23,   12,   35,   39,   37,   38,   36,   34,
 
        14,   47,   13,   19,   44,   21,   43,   42,   15,    6,
@@ -980,23 +980,23 @@ YY_RULE_SETUP
        YY_BREAK
 case 25:
 YY_RULE_SETUP
-#line 115 "Lexer.l"
-{ RET_TOK(UnaryOpVal, Cast, CAST); }
+#line 116 "Lexer.l"
+{ return PHI; }
        YY_BREAK
 case 26:
 YY_RULE_SETUP
 #line 117 "Lexer.l"
-{ return TO; }
+{ return CALL; }
        YY_BREAK
 case 27:
 YY_RULE_SETUP
 #line 118 "Lexer.l"
-{ return PHI; }
+{ return CAST; }
        YY_BREAK
 case 28:
 YY_RULE_SETUP
 #line 119 "Lexer.l"
-{ return CALL; }
+{ return TO; }
        YY_BREAK
 case 29:
 YY_RULE_SETUP
index 2d7ee22f327f6c2b68837643ca55c07277c771dc..28a3c1dfb40967767266d85ed2e64b29b3bdd9ad 100644 (file)
@@ -112,11 +112,11 @@ type            { llvmAsmlval.TypeVal = Type::TypeTy  ; return TYPE;   }
 label           { llvmAsmlval.TypeVal = Type::LabelTy ; return LABEL;  }
 
 not             { RET_TOK(UnaryOpVal, Not, NOT); }
-cast            { RET_TOK(UnaryOpVal, Cast, CAST); }
 
-to              { return TO; }
 phi             { return PHI; }
 call            { return CALL; }
+cast            { return CAST; }
+to              { return TO; }
 add             { RET_TOK(BinaryOpVal, Add, ADD); }
 sub             { RET_TOK(BinaryOpVal, Sub, SUB); }
 mul             { RET_TOK(BinaryOpVal, Mul, MUL); }
index d9cf7d7e88a60229687ec0860cbd8a736e835da2..f3138b21756997dfa384ca325290820c7618a62c 100644 (file)
 #define        TO      285
 #define        PHI     286
 #define        CALL    287
-#define        RET     288
-#define        BR      289
-#define        SWITCH  290
-#define        NOT     291
-#define        CAST    292
+#define        CAST    288
+#define        RET     289
+#define        BR      290
+#define        SWITCH  291
+#define        NOT     292
 #define        ADD     293
 #define        SUB     294
 #define        MUL     295
@@ -492,7 +492,7 @@ static const short yyrhs[] = {     5,
      0,     6,     0,     3,     0,     4,     0,     8,     0,     9,
      0,    10,     0,    11,     0,    12,     0,    13,     0,    14,
      0,    15,     0,    16,     0,    17,     0,    18,     0,    19,
-     0,    20,     0,    21,     0,    69,     0,     7,     0,    37,
+     0,    20,     0,    21,     0,    69,     0,     7,     0,    38,
      0,    39,     0,    40,     0,    41,     0,    42,     0,    43,
      0,    44,     0,    45,     0,    46,     0,    47,     0,    48,
      0,    49,     0,    15,     0,    13,     0,    11,     0,     9,
@@ -515,15 +515,15 @@ static const short yyrhs[] = {     5,
      0,    61,    91,    62,     0,    61,    62,     0,    69,    66,
      0,    69,     0,    91,    63,    69,     0,    92,    93,     0,
     87,    93,     0,    94,    95,     0,    23,    94,    95,     0,
-    94,    97,     0,     0,    34,    69,    90,     0,    34,     7,
-     0,    35,    21,    90,     0,    35,     8,    90,    63,    21,
-    90,    63,    21,    90,     0,    36,    75,    90,    63,    21,
+    94,    97,     0,     0,    35,    69,    90,     0,    35,     7,
+     0,    36,    21,    90,     0,    36,     8,    90,    63,    21,
+    90,    63,    21,    90,     0,    37,    75,    90,    63,    21,
     90,    58,    96,    59,     0,    96,    75,    89,    63,    21,
     90,     0,    75,    89,    63,    21,    90,     0,    76,   101,
      0,    69,    58,    90,    63,    90,    59,     0,    98,    63,
     58,    90,    63,    90,    59,     0,    69,    90,     0,    99,
     63,    90,     0,    99,     0,     0,    72,    69,    90,    63,
-    90,     0,    71,    69,    90,     0,    38,    69,    90,    31,
+    90,     0,    71,    69,    90,     0,    34,    69,    90,    31,
     69,     0,    32,    98,     0,    33,    69,    90,    64,   100,
     65,     0,   102,     0,    50,    69,     0,    50,    69,    63,
     14,    90,     0,    51,    69,     0,    51,    69,    63,    14,
@@ -557,7 +557,7 @@ static const char * const yytname[] = {   "$","error","$undefined.","ESINT64VAL"
 "EUINT64VAL","SINTVAL","UINTVAL","VOID","BOOL","SBYTE","UBYTE","SHORT","USHORT",
 "INT","UINT","LONG","ULONG","FLOAT","DOUBLE","STRING","TYPE","LABEL","VAR_ID",
 "LABELSTR","STRINGCONSTANT","IMPLEMENTATION","TRUE","FALSE","BEGINTOK","END",
-"DECLARE","TO","PHI","CALL","RET","BR","SWITCH","NOT","CAST","ADD","SUB","MUL",
+"DECLARE","TO","PHI","CALL","CAST","RET","BR","SWITCH","NOT","ADD","SUB","MUL",
 "DIV","REM","SETLE","SETGE","SETLT","SETGT","SETEQ","SETNE","MALLOC","ALLOCA",
 "FREE","LOAD","STORE","GETFIELD","PUTFIELD","'='","'['","']'","'x'","'{'","'}'",
 "','","'('","')'","'*'","INTVAL","EINT64VAL","Types","TypesV","UnaryOps","BinaryOps",
@@ -613,8 +613,8 @@ static const short yydefact[] = {    60,
      4,    45,    46,     0,    85,    87,     0,    70,    84,     0,
     72,    44,     0,     0,     0,     0,    94,    96,     0,     0,
      0,     0,    19,    91,    65,    68,    69,     0,    83,    95,
-    99,    19,     0,     0,    41,    42,     0,     0,     0,    21,
-     0,    22,    23,    24,    25,    26,    27,    28,    29,    30,
+    99,    19,     0,     0,    41,    42,     0,     0,     0,     0,
+    21,    22,    23,    24,    25,    26,    27,    28,    29,    30,
     31,    32,     0,     0,     0,     0,     0,   105,   117,    19,
      0,    56,     0,    86,    64,    66,     0,    71,    98,     0,
    100,     0,    19,   115,    19,    19,   118,   120,    19,    19,
@@ -636,36 +636,36 @@ static const short yydefgoto[] = {    31,
 };
 
 static const short yypact[] = {-32768,
-   131,   319,   -53,-32768,    26,-32768,-32768,-32768,-32768,-32768,
+     7,   319,    12,-32768,    26,-32768,-32768,-32768,-32768,-32768,
 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   378,   234,
--32768,   -13,   -21,-32768,    46,-32768,-32768,-32768,    85,-32768,
-    53,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,    65,
-   319,   403,   294,   126,   108,-32768,    60,   -11,    83,-32768,
-    93,    76,-32768,    84,   209,   100,-32768,-32768,    32,-32768,
--32768,-32768,-32768,-32768,    93,    98,    -8,   121,    92,-32768,
--32768,-32768,-32768,   319,-32768,-32768,   319,   319,-32768,   103,
--32768,    32,   462,    36,   189,   239,-32768,-32768,   319,   111,
-   125,   127,    22,    93,    -1,   129,-32768,   124,-32768,-32768,
-   142,     4,   157,   157,-32768,-32768,   157,   319,   319,-32768,
-   319,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
--32768,-32768,   319,   319,   319,   319,   319,-32768,-32768,    24,
-     3,-32768,    26,-32768,-32768,-32768,   319,-32768,-32768,   144,
--32768,   146,   -34,   147,     4,     4,    61,    80,     4,     4,
-     4,   132,-32768,-32768,    33,   113,-32768,   211,   213,   157,
+-32768,    13,   -21,-32768,    86,-32768,-32768,-32768,    85,-32768,
+   -22,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,    88,
+   319,   403,   294,    64,   121,-32768,    66,    24,    74,-32768,
+   -12,    81,-32768,    83,   209,   102,-32768,-32768,    22,-32768,
+-32768,-32768,-32768,-32768,   -12,    68,    54,    87,    96,-32768,
+-32768,-32768,-32768,   319,-32768,-32768,   319,   319,-32768,    92,
+-32768,    22,   462,    45,   189,   239,-32768,-32768,   319,   108,
+   113,   115,    63,   -12,    -1,   119,-32768,   127,-32768,-32768,
+   125,     4,   157,   157,-32768,-32768,   157,   319,   319,   319,
+-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
+-32768,-32768,   319,   319,   319,   319,   319,-32768,-32768,    80,
+     3,-32768,    26,-32768,-32768,-32768,   319,-32768,-32768,   143,
+-32768,   144,   -33,   146,     4,     4,    90,   124,     4,     4,
+     4,   152,-32768,-32768,    -8,   106,-32768,   211,   213,   157,
    199,   195,   231,   249,   250,-32768,-32768,   202,    91,-32768,
     26,-32768,   157,   157,   203,   157,   319,   319,   157,   157,
-   157,-32768,    50,-32768,   205,   215,   157,   206,     4,   212,
-   228,    93,-32768,-32768,-32768,-32768,   273,   189,   258,   157,
+   157,-32768,    33,-32768,   205,   217,   157,   206,     4,   230,
+   229,   -12,-32768,-32768,-32768,-32768,   255,   189,   258,   157,
 -32768,   157,-32768,   157,   170,    62,-32768,   260,-32768,-32768,
    279,-32768,   170,-32768,   323,   284,   157,   327,-32768,   157,
 -32768,   349,   350,-32768
 };
 
 static const short yypgoto[] = {-32768,
--32768,    -2,   351,-32768,-32768,   -93,   -90,  -183,   -63,    -4,
+-32768,    -2,   351,-32768,-32768,   -93,   -89,  -128,   -45,    -4,
   -123,   317,-32768,-32768,-32768,-32768,   207,-32768,-32768,-32768,
--32768,  -163,   -19,    -6,-32768,   318,   291,   267,-32768,-32768,
+-32768,  -134,   -19,    -5,-32768,   318,   291,   267,-32768,-32768,
 -32768,-32768,-32768,-32768,-32768
 };
 
@@ -674,36 +674,36 @@ static const short yypgoto[] = {-32768,
 
 
 static const short yytable[] = {    32,
-    56,   115,    64,    40,   116,    96,     6,     7,     8,     9,
+    56,   115,    64,    72,    73,   116,     6,     7,     8,     9,
     41,    42,    43,    44,    45,    46,    47,    48,    49,   166,
-   145,    50,    51,   170,   215,    25,    58,    26,    96,    27,
-    28,    63,   223,    41,    42,    43,    44,    45,    46,    47,
-    48,    49,    65,   113,    50,    51,    79,    85,    75,    77,
-   100,   221,    63,     3,    63,   193,   114,    63,    90,   226,
-    52,   163,   -19,    53,    63,    93,    94,    95,    67,    63,
-    42,    43,    44,    45,    46,    47,    48,    49,    72,    73,
-   144,   103,   162,    52,   104,   105,    53,    63,    74,    63,
-   112,   180,   149,   150,   151,   181,   140,   152,    41,    42,
-    43,    44,    45,    46,    47,    48,    49,    67,   206,    50,
-    51,    83,   181,    70,   115,   153,   155,   116,   156,    84,
-   222,     3,   115,   174,   -19,   116,    63,    91,    80,    81,
-   157,   158,   159,   160,   161,   172,   173,    86,    87,   176,
-   177,   178,   175,   -19,   105,    63,    65,    88,    52,   192,
-   185,    53,     3,   102,    87,     4,   -19,    99,    63,     6,
-     7,     8,     9,   195,   196,    87,   198,   109,   141,   203,
-   204,   205,     6,     7,   182,   181,   194,   209,    25,   211,
-    26,   101,    27,    28,   199,   202,   142,   143,   148,   179,
-   218,   147,   219,    26,   220,    27,    28,    42,    43,    44,
-    45,    46,    47,    48,    49,   -20,   168,   229,   169,   171,
+   145,    50,    51,    96,   170,    25,    58,    26,     3,    27,
+    28,     4,    63,    41,    42,    43,    44,    45,    46,    47,
+    48,    49,    65,     3,    50,    51,    96,    79,    75,    77,
+   180,   -19,   113,    63,   181,   193,    93,    94,    95,    90,
+    52,   163,   -19,    53,    63,   114,    80,    81,    40,    63,
+    42,    43,    44,    45,    46,    47,    48,    49,    63,   215,
+   221,   103,    85,    52,   104,   105,    53,   223,   226,    63,
+   112,   206,   149,   150,   151,   181,   140,   152,    41,    42,
+    43,    44,    45,    46,    47,    48,    49,    67,    67,    50,
+    51,    74,   100,    70,   115,   153,   155,   156,   116,    63,
+   222,   144,   115,     3,    83,    84,   116,    99,    63,    91,
+   157,   158,   159,   160,   161,   172,   173,    65,   162,   176,
+   177,   178,    86,    87,   105,    63,    88,   101,    52,   192,
+   185,    53,   174,   -19,    87,    63,   109,   102,    87,     6,
+     7,     8,     9,   195,   196,   141,   198,   182,   181,   203,
+   204,   205,     6,     7,   142,   143,   194,   209,    25,   211,
+    26,   147,    27,    28,   199,   202,   175,   -19,   -20,    63,
+   218,   148,   219,    26,   220,    27,    28,    42,    43,    44,
+    45,    46,    47,    48,    49,   168,   169,   229,   171,   179,
    231,     6,     7,     8,     9,    10,    11,    12,    13,    14,
     15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
     25,   183,    26,   184,    27,    28,     6,     7,     8,     9,
     10,    11,    12,    13,    14,    15,    16,    17,    18,    19,
     20,    21,    22,    23,    24,    25,   186,    26,   187,    27,
     28,   188,   189,   190,   191,   197,    29,   207,   210,    30,
-   118,   119,   208,    89,   212,   120,   121,   122,   123,   124,
+   118,   119,   120,    89,   208,   214,   121,   122,   123,   124,
    125,   126,   127,   128,   129,   130,   131,   132,   133,   134,
-   135,    29,   213,   214,    30,    60,     6,     7,     8,     9,
+   135,    29,   212,   213,    30,    60,     6,     7,     8,     9,
     10,    11,    12,    13,    14,    15,    16,    17,    18,    19,
     20,    21,    22,    23,    24,    25,   217,    26,   224,    27,
     28,     6,     7,     8,     9,    10,    11,    12,    13,    14,
@@ -730,36 +730,36 @@ static const short yytable[] = {    32,
 };
 
 static const short yycheck[] = {     2,
-     5,    95,    24,    57,    95,    69,     3,     4,     5,     6,
+     5,    95,    24,    26,    27,    95,     3,     4,     5,     6,
      8,     9,    10,    11,    12,    13,    14,    15,    16,   143,
-    22,    19,    20,    58,   208,    22,    29,    24,    92,    26,
-    27,    66,   216,     8,     9,    10,    11,    12,    13,    14,
-    15,    16,    64,     8,    19,    20,    53,    59,    51,    52,
-    59,   215,    66,    22,    66,   179,    21,    66,    65,   223,
-    58,    59,    64,    61,    66,    34,    35,    36,    23,    66,
-     9,    10,    11,    12,    13,    14,    15,    16,    26,    27,
-    59,    84,    59,    58,    87,    88,    61,    66,    24,    66,
+    22,    19,    20,    69,    58,    22,    29,    24,    22,    26,
+    27,    25,    66,     8,     9,    10,    11,    12,    13,    14,
+    15,    16,    64,    22,    19,    20,    92,    53,    51,    52,
+    59,    64,     8,    66,    63,   179,    35,    36,    37,    65,
+    58,    59,    64,    61,    66,    21,     3,     4,    57,    66,
+     9,    10,    11,    12,    13,    14,    15,    16,    66,   208,
+   215,    84,    59,    58,    87,    88,    61,   216,   223,    66,
     93,    59,   112,   113,   114,    63,    99,   117,     8,     9,
-    10,    11,    12,    13,    14,    15,    16,    23,    59,    19,
-    20,     4,    63,    29,   208,   118,   119,   208,   121,    60,
-    59,    22,   216,    63,    64,   216,    66,    28,     3,     4,
-   133,   134,   135,   136,   137,   155,   156,    62,    63,   159,
-   160,   161,    63,    64,   147,    66,    64,    64,    58,    59,
-   170,    61,    22,    62,    63,    25,    64,    60,    66,     3,
-     4,     5,     6,   183,   184,    63,   186,    65,    58,   189,
-   190,   191,     3,     4,    62,    63,   181,   197,    22,   199,
-    24,    61,    26,    27,   187,   188,    62,    61,    65,    58,
-   210,    63,   212,    24,   214,    26,    27,     9,    10,    11,
-    12,    13,    14,    15,    16,    64,    63,   227,    63,    63,
+    10,    11,    12,    13,    14,    15,    16,    23,    23,    19,
+    20,    24,    59,    29,   208,   118,   119,   120,   208,    66,
+    59,    59,   216,    22,     4,    60,   216,    60,    66,    28,
+   133,   134,   135,   136,   137,   155,   156,    64,    59,   159,
+   160,   161,    62,    63,   147,    66,    64,    61,    58,    59,
+   170,    61,    63,    64,    63,    66,    65,    62,    63,     3,
+     4,     5,     6,   183,   184,    58,   186,    62,    63,   189,
+   190,   191,     3,     4,    62,    61,   181,   197,    22,   199,
+    24,    63,    26,    27,   187,   188,    63,    64,    64,    66,
+   210,    65,   212,    24,   214,    26,    27,     9,    10,    11,
+    12,    13,    14,    15,    16,    63,    63,   227,    63,    58,
    230,     3,     4,     5,     6,     7,     8,     9,    10,    11,
     12,    13,    14,    15,    16,    17,    18,    19,    20,    21,
     22,    21,    24,    21,    26,    27,     3,     4,     5,     6,
      7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
     17,    18,    19,    20,    21,    22,    58,    24,    64,    26,
     27,    31,    14,    14,    63,    63,    58,    63,    63,    61,
-    32,    33,    58,    65,    63,    37,    38,    39,    40,    41,
+    32,    33,    34,    65,    58,    21,    38,    39,    40,    41,
     42,    43,    44,    45,    46,    47,    48,    49,    50,    51,
-    52,    58,    65,    21,    61,    62,     3,     4,     5,     6,
+    52,    58,    63,    65,    61,    62,     3,     4,     5,     6,
      7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
     17,    18,    19,    20,    21,    22,    59,    24,    59,    26,
     27,     3,     4,     5,     6,     7,     8,     9,    10,    11,
@@ -1893,7 +1893,7 @@ case 113:
 case 114:
 #line 875 "llvmAsmParser.y"
 {
-    yyval.InstVal = UnaryOperator::create(yyvsp[-4].UnaryOpVal, getVal(yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), yyvsp[0].TypeVal);
+    yyval.InstVal = new CastInst(getVal(yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), yyvsp[0].TypeVal);
   ;
     break;}
 case 115:
index 01c6c8bf5ddf78fead73e9478c88442f62f24e1c..a639953b8833b33531b4adb9570a3504da8af125 100644 (file)
@@ -59,11 +59,11 @@ typedef union {
 #define        TO      285
 #define        PHI     286
 #define        CALL    287
-#define        RET     288
-#define        BR      289
-#define        SWITCH  290
-#define        NOT     291
-#define        CAST    292
+#define        CAST    288
+#define        RET     289
+#define        BR      290
+#define        SWITCH  291
+#define        NOT     292
 #define        ADD     293
 #define        SUB     294
 #define        MUL     295
index b3d521b4820eb9829badfbb0f15178abf9852a30..5e3d27378e18a9ace3a5238523ac7583618c03f3 100644 (file)
@@ -404,14 +404,14 @@ Module *RunVMAsmParser(const ToolCommandLine &Opts, FILE *F) {
 
 
 %token IMPLEMENTATION TRUE FALSE BEGINTOK END DECLARE TO
-%token PHI CALL
+%token PHI CALL CAST
 
 // Basic Block Terminating Operators 
 %token <TermOpVal> RET BR SWITCH
 
 // Unary Operators 
 %type  <UnaryOpVal> UnaryOps  // all the unary operators
-%token <UnaryOpVal> NOT CAST
+%token <UnaryOpVal> NOT
 
 // Binary Operators 
 %type  <BinaryOpVal> BinaryOps  // all the binary operators
@@ -873,7 +873,7 @@ InstVal : BinaryOps Types ValueRef ',' ValueRef {
       ThrowException("unary operator returned null!");
   }
   | CAST Types ValueRef TO Types {
-    $$ = UnaryOperator::create($1, getVal($2, $3), $5);
+    $$ = new CastInst(getVal($2, $3), $5);
   }
   | PHI PHIList {
     const Type *Ty = $2->front().first->getType();
index 80127cef8cc093d68c69f2b9b43ba59035e18cda..d08d19b6bd3e092a7cd3520a3a3151c26d653099 100644 (file)
@@ -106,8 +106,7 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
                                 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));
+    Res = new CastInst(getValue(Raw.Ty, Raw.Arg1), getType(Raw.Arg2));
     return false;
   } else if (Raw.Opcode == Instruction::PHINode) {
     PHINode *PN = new PHINode(Raw.Ty);
index 6f7c2f158ebb71c1d694dfec48fe64dc77ae599e..22b6052d4692dd5f484e22795387e0011bf5767b 100644 (file)
@@ -1,24 +1,30 @@
-//===-- iBinaryOperators.cpp - Implement the BinaryOperators -----*- C++ -*--=//
+//===-- iOperators.cpp - Implement the Binary & Unary Operators --*- C++ -*--=//
 //
-// This file implements the nontrivial binary operator instructions.
+// This file implements the nontrivial binary & unary operator instructions.
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/iBinary.h"
+#include "llvm/iOperators.h"
 #include "llvm/Type.h"
 
-UnaryOperator *UnaryOperator::create(UnaryOps Op, Value *Source,
-                                    const Type *DestTy = 0) {
-  if (DestTy == 0) DestTy = Source->getType();
+//===----------------------------------------------------------------------===//
+//                              UnaryOperator Class
+//===----------------------------------------------------------------------===//
+
+UnaryOperator *UnaryOperator::create(UnaryOps Op, Value *Source) {
   switch (Op) {
-  case Not:  assert(DestTy == Source->getType());
-  case Cast: return new GenericUnaryInst(Op, Source, DestTy);
+  case Not:  return new GenericUnaryInst(Op, Source);
   default:
-    cerr << "Don't know how to GetUnaryOperator " << Op << endl;
+    cerr << "Don't know how to Create UnaryOperator " << Op << endl;
     return 0;
   }
 }
 
+
+//===----------------------------------------------------------------------===//
+//                           GenericUnaryOperator Class
+//===----------------------------------------------------------------------===//
+
 const char *GenericUnaryInst::getOpcodeName() const {
   switch (getOpcode()) {
   case Not: return "not";
@@ -29,6 +35,7 @@ const char *GenericUnaryInst::getOpcodeName() const {
   }
 }
 
+
 //===----------------------------------------------------------------------===//
 //                             BinaryOperator Class
 //===----------------------------------------------------------------------===//
@@ -46,6 +53,7 @@ BinaryOperator *BinaryOperator::create(BinaryOps Op, Value *S1, Value *S2,
   }
 }
 
+
 //===----------------------------------------------------------------------===//
 //                            GenericBinaryInst Class
 //===----------------------------------------------------------------------===//
@@ -69,6 +77,7 @@ const char *GenericBinaryInst::getOpcodeName() const {
   }
 }
 
+
 //===----------------------------------------------------------------------===//
 //                             SetCondInst Class
 //===----------------------------------------------------------------------===//