| 1133 | } |
| 1134 | |
| 1135 | void BeIRCodeGen::HandleNextCmd() |
| 1136 | { |
| 1137 | if (mFailed) |
| 1138 | { |
| 1139 | mStream->SetReadPos(mStream->GetSize()); |
| 1140 | return; |
| 1141 | } |
| 1142 | |
| 1143 | int curId = mCmdCount; |
| 1144 | |
| 1145 | BfIRCmd cmd = (BfIRCmd)mStream->Read(); |
| 1146 | mCmdCount++; |
| 1147 | |
| 1148 | #ifdef CODEGEN_TRACK |
| 1149 | gBEMemReporter.BeginSection(gIRCmdNames[cmd]); |
| 1150 | gBEMemReporter.Add(1); |
| 1151 | #endif |
| 1152 | |
| 1153 | switch (cmd) |
| 1154 | { |
| 1155 | case BfIRCmd_Module_Start: |
| 1156 | { |
| 1157 | CMD_PARAM(String, moduleName); |
| 1158 | CMD_PARAM(int, ptrSize); |
| 1159 | CMD_PARAM(bool, isOptimized); |
| 1160 | |
| 1161 | BF_ASSERT(mBeModule == NULL); |
| 1162 | mPtrSize = ptrSize; |
| 1163 | mIsOptimized = isOptimized; |
| 1164 | mBeContext = new BeContext(); |
| 1165 | mBeModule = new BeModule(moduleName, mBeContext); |
| 1166 | mBeModule->mBeIRCodeGen = this; |
| 1167 | mBeContext->mPointerSize = ptrSize; |
| 1168 | |
| 1169 | for (auto constInt : mConfigConsts) |
| 1170 | { |
| 1171 | auto constVal = mBeModule->mAlloc.Alloc<BeConstant>(); |
| 1172 | constVal->mType = mBeContext->GetPrimitiveType(BeTypeCode_Int32); |
| 1173 | constVal->mInt64 = constInt; |
| 1174 | mBeModule->mConfigConsts32.Add(constVal); |
| 1175 | |
| 1176 | constVal = mBeModule->mAlloc.Alloc<BeConstant>(); |
| 1177 | constVal->mType = mBeContext->GetPrimitiveType(BeTypeCode_Int64); |
| 1178 | constVal->mInt64 = constInt; |
| 1179 | mBeModule->mConfigConsts64.Add(constVal); |
| 1180 | } |
| 1181 | } |
| 1182 | break; |
| 1183 | case BfIRCmd_Module_SetTargetTriple: |
| 1184 | { |
| 1185 | CMD_PARAM(String, targetTriple); |
| 1186 | CMD_PARAM(String, targetCPU); |
| 1187 | mBeModule->mTargetTriple = targetTriple; |
| 1188 | mBeModule->mTargetCPU = targetCPU; |
| 1189 | } |
| 1190 | break; |
| 1191 | case BfIRCmd_Module_AddModuleFlag: |
| 1192 | { |
nothing calls this directly
no test coverage detected