(op_dic)
| 311 | |
| 312 | |
| 313 | def WriteOpFormat(op_dic): |
| 314 | dst = open('OpFormat.cpp', 'w') |
| 315 | |
| 316 | for encoding, op_list in op_dic.items(): |
| 317 | |
| 318 | array_size = GetArraySize(op_list) |
| 319 | |
| 320 | dst.write('const std::array<GcnInstFormat, {}> g_instructionFormat{} = {{{{\n'.format(array_size, encoding.replace('GCNENC_', ''))) |
| 321 | |
| 322 | struct_array = ['\t{ },'] * array_size |
| 323 | for opcode, value, mode in op_list: |
| 324 | op_key = GetOpKey(encoding, opcode) |
| 325 | |
| 326 | if not op_key in InstDefDic: |
| 327 | #print('inst not found: {}'.format(op_key)) |
| 328 | continue |
| 329 | |
| 330 | inst_info = InstDefDic[op_key] |
| 331 | cls = inst_info[0] |
| 332 | src_count = DefaultSrcCountTable[encoding] |
| 333 | dst_type, src_type = ParseOpType(opcode) |
| 334 | src_type = GetScalarType(src_type) |
| 335 | dst_type = GetScalarType(dst_type) |
| 336 | category = GetInstCategory(cls) |
| 337 | |
| 338 | if 'GCN_SRC_NONE' in mode: |
| 339 | src_count = 0 |
| 340 | if 'GCN_SRC2_NONE' in mode: |
| 341 | src_count -= 1 |
| 342 | if 'GCN_VOP3_VOP2_DS01' in mode: |
| 343 | src_count = 2 |
| 344 | if 'GCN_VOP3_VOP1_DS0' in mode: |
| 345 | src_count = 1 |
| 346 | if 'GCN_VOP_ARG_NONE' in mode: |
| 347 | src_count = 0 |
| 348 | # VOPC in VOP3, specify 2 src operands |
| 349 | if encoding == 'GCNENC_VOP3' and (value >= 0 and value <= 247): |
| 350 | src_count = 2 |
| 351 | |
| 352 | code_line = '\t// {} = {}\n\t{{ GcnInstClass::{}, GcnInstCategory::{}, {}, {},\n\t\tGcnScalarType::{}, GcnScalarType::{} }},'.\ |
| 353 | format(value, opcode, cls, category, src_count, 1, src_type, dst_type) |
| 354 | struct_array[value] = code_line |
| 355 | |
| 356 | dst.write('\n'.join(struct_array)) |
| 357 | dst.write('\n}};\n\n\n') |
| 358 | |
| 359 | dst.close() |
| 360 | |
| 361 | def WriteOpEnum(op_dic): |
| 362 | dst = open('OpEnum.cpp', 'w') |
no test coverage detected