llvm.org GIT mirror llvm / 01ff65f
add reader support for a bunch of new instructions git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36641 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 13 years ago
1 changed file(s) with 91 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
148148 assert((Ty == 0 || Ty == V->getType()) && "Type mismatch in value table!");
149149 return V;
150150 }
151
152 // No type specified, must be invalid reference.
153 if (Ty == 0) return 0;
151154
152155 // Create and return a placeholder, which will later be RAUW'd.
153156 Value *V = new Argument(Ty);
10781081 I = CastInst::create((Instruction::CastOps)Opc, Op, ResTy);
10791082 break;
10801083 }
1081 #if 0
1082 case bitc::FUNC_CODE_INST_GEP:
1083 // GEP: [n, n x operands]
1084 case bitc::FUNC_CODE_INST_SELECT:
1085 // SELECT: [ty, opval, opval, opval]
1086 case bitc::FUNC_CODE_INST_EXTRACTELT:
1087 // EXTRACTELT: [opty, opval, opval]
1088 case bitc::FUNC_CODE_INST_INSERTELT:
1089 // INSERTELT: [ty, opval, opval, opval]
1090 case bitc::FUNC_CODE_INST_SHUFFLEVEC:
1091 // SHUFFLEVEC: [ty, opval, opval, opval]
1092 case bitc::FUNC_CODE_INST_CMP:
1093 // CMP: [opty, opval, opval, pred]
1094 #endif
1095
1084 case bitc::FUNC_CODE_INST_GEP: { // GEP: [n, n x operands]
1085 if (Record.size() < 2 || (Record.size() & 1))
1086 return Error("Invalid GEP record");
1087 const Type *OpTy = getTypeByID(Record[0]);
1088 Value *Op = getFnValueByID(Record[1], OpTy);
1089 if (OpTy == 0 || Op == 0)
1090 return Error("Invalid GEP record");
1091
1092 SmallVector GEPIdx;
1093 for (unsigned i = 1, e = Record.size()/2; i != e; ++i) {
1094 const Type *IdxTy = getTypeByID(Record[i*2]);
1095 Value *Idx = getFnValueByID(Record[i*2+1], IdxTy);
1096 if (IdxTy == 0 || Idx == 0)
1097 return Error("Invalid GEP record");
1098 GEPIdx.push_back(Idx);
1099 }
1100
1101 I = new GetElementPtrInst(Op, &GEPIdx[0], GEPIdx.size());
1102 break;
1103 }
1104
1105 case bitc::FUNC_CODE_INST_SELECT: { // SELECT: [ty, opval, opval, opval]
1106 if (Record.size() < 4) return Error("Invalid SELECT record");
1107 const Type *Ty = getTypeByID(Record[0]);
1108 Value *Cond = getFnValueByID(Record[1], Type::Int1Ty);
1109 Value *LHS = getFnValueByID(Record[2], Ty);
1110 Value *RHS = getFnValueByID(Record[3], Ty);
1111 if (Ty == 0 || Cond == 0 || LHS == 0 || RHS == 0)
1112 return Error("Invalid SELECT record");
1113 I = new SelectInst(Cond, LHS, RHS);
1114 break;
1115 }
1116
1117 case bitc::FUNC_CODE_INST_EXTRACTELT: { // EXTRACTELT: [opty, opval, opval]
1118 if (Record.size() < 3) return Error("Invalid EXTRACTELT record");
1119 const Type *OpTy = getTypeByID(Record[0]);
1120 Value *Vec = getFnValueByID(Record[1], OpTy);
1121 Value *Idx = getFnValueByID(Record[2], Type::Int32Ty);
1122 if (OpTy == 0 || Vec == 0 || Idx == 0)
1123 return Error("Invalid EXTRACTELT record");
1124 I = new ExtractElementInst(Vec, Idx);
1125 break;
1126 }
1127
1128 case bitc::FUNC_CODE_INST_INSERTELT: { // INSERTELT: [ty, opval,opval,opval]
1129 if (Record.size() < 4) return Error("Invalid INSERTELT record");
1130 const VectorType *OpTy =
1131 dyn_cast_or_null(getTypeByID(Record[0]));
1132 if (OpTy == 0) return Error("Invalid INSERTELT record");
1133 Value *Vec = getFnValueByID(Record[1], OpTy);
1134 Value *Elt = getFnValueByID(Record[2], OpTy->getElementType());
1135 Value *Idx = getFnValueByID(Record[3], Type::Int32Ty);
1136 if (Vec == 0 || Elt == 0 || Idx == 0)
1137 return Error("Invalid INSERTELT record");
1138 I = new InsertElementInst(Vec, Elt, Idx);
1139 break;
1140 }
1141
1142 case bitc::FUNC_CODE_INST_SHUFFLEVEC: {// SHUFFLEVEC: [ty,opval,opval,opval]
1143 if (Record.size() < 4) return Error("Invalid SHUFFLEVEC record");
1144 const VectorType *OpTy =
1145 dyn_cast_or_null(getTypeByID(Record[0]));
1146 if (OpTy == 0) return Error("Invalid SHUFFLEVEC record");
1147 Value *Vec1 = getFnValueByID(Record[1], OpTy);
1148 Value *Vec2 = getFnValueByID(Record[2], OpTy);
1149 Value *Mask = getFnValueByID(Record[3],
1150 VectorType::get(Type::Int32Ty,
1151 OpTy->getNumElements()));
1152 if (Vec1 == 0 || Vec2 == 0 || Mask == 0)
1153 return Error("Invalid SHUFFLEVEC record");
1154 I = new ShuffleVectorInst(Vec1, Vec2, Mask);
1155 break;
1156 }
1157
1158 case bitc::FUNC_CODE_INST_CMP: { // CMP: [opty, opval, opval, pred]
1159 if (Record.size() < 4) return Error("Invalid CMP record");
1160 const Type *OpTy = getTypeByID(Record[0]);
1161 Value *LHS = getFnValueByID(Record[1], OpTy);
1162 Value *RHS = getFnValueByID(Record[2], OpTy);
1163 if (OpTy == 0 || LHS == 0 || RHS == 0)
1164 return Error("Invalid CMP record");
1165 if (OpTy->isFPOrFPVector())
1166 I = new FCmpInst((FCmpInst::Predicate)Record[3], LHS, RHS);
1167 else
1168 I = new ICmpInst((ICmpInst::Predicate)Record[3], LHS, RHS);
1169 break;
1170 }
1171
10961172 case bitc::FUNC_CODE_INST_RET: // RET: [opty,opval]
10971173 if (Record.size() == 0) {
10981174 I = new ReturnInst();