Changeset 3999 for icGREP/icgrep-devel/icgrep/llvm_gen.cpp
- Timestamp:
- Aug 13, 2014, 10:00:28 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
icGREP/icgrep-devel/icgrep/llvm_gen.cpp
r3991 r3999 1030 1030 { 1031 1031 IRBuilder<> b(mBasicBlock); 1032 1032 #if 0 1033 1033 //CarryQ - carry in. 1034 1034 Value* carryq_idx = b.getInt64(mCarryQueueIdx); … … 1071 1071 1072 1072 retVal = result_value; 1073 #endif 1074 //Get the input stream. 1075 Value* strm_value = Generate_PabloE(mstar->getExpr1()); 1076 //Get the scanthru bit stream. 1077 Value* cc_value = Generate_PabloE(mstar->getExpr2()); 1078 retVal = genMatchStar(strm_value, cc_value); 1073 1079 } 1074 1080 else if (ScanThru* sthru = dynamic_cast<ScanThru*>(expr)) 1075 1081 { 1076 1082 IRBuilder<> b(mBasicBlock); 1077 1083 #if 0 1078 1084 //CarryQ - carry in. 1079 1085 Value* carryq_idx = b.getInt64(mCarryQueueIdx); … … 1109 1115 1110 1116 retVal = result_value; 1117 #endif 1118 //Get the input stream. 1119 Value* strm_value = Generate_PabloE(sthru->getScanFrom()); 1120 //Get the scanthru bit stream. 1121 Value* scanthru_value = Generate_PabloE(sthru->getScanThru()); 1122 retVal = genScanThru(strm_value, scanthru_value); 1111 1123 } 1112 1124 … … 1114 1126 } 1115 1127 1128 1129 Value* LLVM_Generator::genMatchStar(Value* marker_expr, Value* cc_expr) { 1130 IRBuilder<> b(mBasicBlock); 1131 Value* marker_and_cc = b.CreateAnd(marker_expr, cc_expr); 1132 return b.CreateOr(b.CreateXor(genAddWithCarry(marker_and_cc, cc_expr), cc_expr), marker_expr, "matchstar_rslt"); 1133 } 1134 1135 Value* LLVM_Generator::genScanThru(Value* marker_expr, Value* cc_expr) { 1136 IRBuilder<> b(mBasicBlock); 1137 return b.CreateAnd(genAddWithCarry(marker_expr, cc_expr), genNot(cc_expr), "scanthru_rslt"); 1138 } 1139 1140 Value* LLVM_Generator::genAddWithCarry(Value* e1, Value* e2) { 1141 IRBuilder<> b(mBasicBlock); 1142 1143 //CarryQ - carry in. 1144 Value* carryq_idx = b.getInt64(mCarryQueueIdx); 1145 Value* carryq_GEP = b.CreateGEP(mptr_carry_q, carryq_idx); 1146 Value* carryq_value = b.CreateLoad(carryq_GEP); 1147 1148 Value* carrygen = b.CreateAnd(e1, e2, "carrygen"); 1149 Value* carryprop = b.CreateOr(e1, e2, "carryprop"); 1150 Value* digitsum = b.CreateAdd(e1, e2, "digitsum"); 1151 Value* partial = b.CreateAdd(digitsum, carryq_value, "partial"); 1152 Value* digitcarry = b.CreateOr(carrygen, b.CreateAnd(carryprop, genNot(partial))); 1153 Value* mid_carry_in = genShiftLeft64(b.CreateLShr(digitcarry, 63), "mid_carry_in"); 1154 1155 Value* sum = b.CreateAdd(partial, mid_carry_in, "sum"); 1156 Value* carry_out = genShiftRight127(b.CreateOr(carrygen, b.CreateAnd(carryprop, genNot(sum))), "carry_out"); 1157 1158 //CarryQ - carry out: 1159 Value* void_1 = b.CreateStore(carry_out, carryq_GEP); 1160 1161 mCarryQueueIdx++; 1162 return sum; 1163 } 1164 1165 #define bitBlockExprType m64x2Vect 1166 1167 Value* LLVM_Generator::genShiftRight127(Value* e, const Twine &namehint) { 1168 IRBuilder<> b(mBasicBlock); 1169 Value* i128_val = b.CreateBitCast(e, IntegerType::get(mMod->getContext(), 128)); 1170 return b.CreateBitCast(b.CreateLShr(i128_val, 127, namehint), bitBlockExprType); 1171 } 1172 1173 Value* LLVM_Generator::genShiftLeft64(Value* e, const Twine &namehint) { 1174 IRBuilder<> b(mBasicBlock); 1175 Value* i128_val = b.CreateBitCast(e, IntegerType::get(mMod->getContext(), 128)); 1176 return b.CreateBitCast(b.CreateShl(i128_val, 64, namehint), bitBlockExprType); 1177 } 1178 1179 Value* LLVM_Generator::genNot(Value* e, const Twine &namehint) { 1180 IRBuilder<> b(mBasicBlock); 1181 return b.CreateXor(e, mConst_Aggregate_64x2_neg1, namehint); 1182 } 1183 1184 1185 1186
Note: See TracChangeset
for help on using the changeset viewer.