GCC Wikia
登録
Advertisement

このページを編集する際は,編集に関する方針に従ってください.[]

概要[]

  • gcc-4.1.0/gcc/cfgexpand.cにて定義

コメント

tree basic blockをGIMPLEからRTLへ

TREE_CODE別にrtlを生成。

rtlは、構造体をしめす構造体。

update_bb_for_insnにてbasic blockを更新

-drなどをあたえれば maybe_dump_rtl_for_tree_stmt で、rtlをテキスト形式でダンプする

引数[]

basic_block bb

FILE * dump_file


実装[]

1274: static basic_block
1275: expand_gimple_basic_block (basic_block bb, FILE * dump_file)
1276: {
1277:   block_stmt_iterator bsi = bsi_start (bb);
1278:   tree stmt = NULL;
1279:   rtx note, last;
1280:   edge e;
1281:   edge_iterator ei;
1282: 
1283:   if (dump_file)
1284:     {
1285:       fprintf (dump_file,
1286:                "\n;; Generating RTL for tree basic block %d\n",
1287:                bb->index);
1288:     }
1289: 
1290:   init_rtl_bb_info (bb);
1291:   bb->flags |= BB_RTL;
1292: 
1293:   if (!bsi_end_p (bsi))
1294:     stmt = bsi_stmt (bsi);
1295: 
1296:   if (stmt && TREE_CODE (stmt) == LABEL_EXPR)
1297:     {
1298:       last = get_last_insn ();
1299: 
1300:       expand_expr_stmt (stmt);
1301: 
1302:       /* Java emits line number notes in the top of labels.
1303:          ??? Make this go away once line number notes are obsoleted.  */
1304:       BB_HEAD (bb) = NEXT_INSN (last);
1305:       if (NOTE_P (BB_HEAD (bb)))
1306:         BB_HEAD (bb) = NEXT_INSN (BB_HEAD (bb));
1307:       bsi_next (&bsi);
1308:       note = emit_note_after (NOTE_INSN_BASIC_BLOCK, BB_HEAD (bb));
1309: 
1310:       maybe_dump_rtl_for_tree_stmt (stmt, last);
1311:     }
1312:   else
1313:     note = BB_HEAD (bb) = emit_note (NOTE_INSN_BASIC_BLOCK);
1314: 
1315:   NOTE_BASIC_BLOCK (note) = bb;
1316: 
1317:   for (ei = ei_start (bb->succs); (e = ei_safe_edge (ei)); )
1318:     {
1319:       /* Clear EDGE_EXECUTABLE.  This flag is never used in the backend.  */
1320:       e->flags &= ~EDGE_EXECUTABLE;
1321: 
1322:       /* At the moment not all abnormal edges match the RTL representation.
1323:          It is safe to remove them here as find_many_sub_basic_blocks will
1324:          rediscover them.  In the future we should get this fixed properly.  */
1325:       if (e->flags & EDGE_ABNORMAL)
1326:         remove_edge (e);
1327:       else
1328:         ei_next (&ei);
1329:     }
1330: 
1331:   for (; !bsi_end_p (bsi); bsi_next (&bsi))
1332:     {
1333:       tree stmt = bsi_stmt (bsi);
1334:       basic_block new_bb;
1335: 
1336:       if (!stmt)
1337:         continue;
1338: 
1339:       /* Expand this statement, then evaluate the resulting RTL and
1340:          fixup the CFG accordingly.  */
1341:       if (TREE_CODE (stmt) == COND_EXPR)
1342:         {
1343:           new_bb = expand_gimple_cond_expr (bb, stmt);
1344:           if (new_bb)
1345:             return new_bb;
1346:         }
1347:       else
1348:         {
1349:           tree call = get_call_expr_in (stmt);
1350:           if (call && CALL_EXPR_TAILCALL (call))
1351:             {
1352:               bool can_fallthru;
1353:               new_bb = expand_gimple_tailcall (bb, stmt, &can_fallthru);
1354:               if (new_bb)
1355:                 {
1356:                   if (can_fallthru)
1357:                     bb = new_bb;
1358:                   else
1359:                     return new_bb;
1360:                 }
1361:             }
1362:           else
1363:             {
1364:               last = get_last_insn ();
1365:               expand_expr_stmt (stmt);
1366:               maybe_dump_rtl_for_tree_stmt (stmt, last);
1367:             }
1368:         }
1369:     }
1370: 
1371:   do_pending_stack_adjust ();
1372: 
1373:   /* Find the block tail.  The last insn in the block is the insn
1374:      before a barrier and/or table jump insn.  */
1375:   last = get_last_insn ();
1376:   if (BARRIER_P (last))
1377:     last = PREV_INSN (last);
1378:   if (JUMP_TABLE_DATA_P (last))
1379:     last = PREV_INSN (PREV_INSN (last));
1380:   BB_END (bb) = last;
1381: 
1382:   update_bb_for_insn (bb);
1383: 
1384:   return bb;
1385: }



リンク元

Advertisement