- Timestamp:
- Jul 3, 2020, 7:19:17 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core/generate.rb
r321 r429 4 4 # Generator for TOPPERS Embedded Component System 5 5 # 6 # Copyright (C) 2008-201 6by TOPPERS Project6 # Copyright (C) 2008-2019 by TOPPERS Project 7 7 #-- 8 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ … … 122 122 123 123 class Namespace 124 @@domain_gen_factory_list = nil 124 125 def generate 125 126 … … 135 136 return 136 137 end 138 if instance_of? Region then 139 @@domain_gen_factory_list = {} # create hash 140 end 137 141 end 138 142 … … 141 145 gen_global_header 142 146 147 if ( instance_of? Region ) && get_domain_type != nil then 148 # p "******************* domain_type: #{get_domain_type.get_name} ****************" 149 domain_type = get_domain_type 150 if @@domain_gen_factory_list[ domain_type ] == nil then 151 @@domain_gen_factory_list[ domain_type ] = self 152 domain_type.gen_factory 153 end 154 end 155 143 156 # signature のコードを生成 144 157 @signature_list.each { |s| … … 262 275 263 276 f.print( "/* Descriptor for dynamic join */\n" ) 264 f.print( "#define Descriptor( signature_global_name ) DynDesc__ ## signature_global_name\n\n" ) 277 f.print( "#define Descriptor( signature_global_name ) DynDesc__ ## signature_global_name\n" ) 278 f.print( "#define is_descriptor_unjoined( desc ) ((desc).vdes==NULL)\n\n" ) 265 279 endif_macro_only f 266 280 end … … 454 468 } 455 469 end 456 f.print " rm -f $(CELLTYPE_COBJS) $(TECSGEN_COBJS) $(PLUGIN_COBJS) $(OTHER_OBJS) $(TARGET) #{timestamp}\n"470 f.print " rm -f $(CELLTYPE_COBJS) $(TECSGEN_COBJS) $(PLUGIN_COBJS) $(OTHER_OBJS) $(TARGET) #{timestamp}\n" 457 471 if $generating_region == @@root_namespace then 458 472 f.print " rm -rf $(GEN_DIR)\n" … … 464 478 f.print "tecs : $(PRE_TECSGEN_TARGET) $(TIMESTAMP) $(POST_TECSGEN_TARGET)\n\n" 465 479 f.print "$(TIMESTAMP) : $(TECS_IMPORTS)\n" 466 f.print " $(TECSGEN) #{TECSGEN.subst_tecspath( $arguments, true )}\n "480 f.print " $(TECSGEN) #{TECSGEN.subst_tecspath( $arguments, true )}\n\n" 467 481 # f.print " touch $(TIMESTAMP)\n\n" 468 469 482 else 470 483 f.print "tecs:\n" … … 472 485 end 473 486 487 # tecsflow:, tcflow ターゲット 488 if $generating_region.get_n_cells != 0 || $generating_region == @@root_namespace then 489 f.print "##### TECSFlow targets #####\n" 490 end 491 492 if Region.get_link_roots.length > 1 && $generating_region == @@root_namespace then 493 tecsflow_target = "tecsflow_sub" 494 if $generating_region.get_n_cells > 0 then 495 f.print "tecsflow: tecs tecsflow_sub\n" 496 else 497 f.print "tecsflow:\n" 498 end 499 Region.get_link_roots.each {|region| 500 if region.get_n_cells > 0 then 501 f.print "\tcd #{region.get_global_name}; make tecsflow\n" 502 end 503 } 504 f.print "\n" 505 else 506 tecsflow_target = "tecsflow" 507 end 508 509 if $generating_region.get_n_cells != 0 then 510 f.print "#{tecsflow_target} : $(GEN_DIR)/tecsgen.rbdmp tcflow\n" 511 f.print "\ttecsflow -g $(GEN_DIR)\n\n" 512 f.print "tecsflow_u : $(GEN_DIR)/tecsgen.rbdmp tcflow\n" 513 f.print "\ttecsflow -g $(GEN_DIR) -U\n\n" 514 f.print "$(GEN_DIR)/tecsgen.rbdmp : tecs\n\n" 515 f.print "tcflow : tecs\n" 516 f.print "\tmake tcflow_exec\n\n" 517 f.print "tcflow_exec : $(GEN_DIR)/tcflow.rbdmp\n" 518 f.print "$(GEN_DIR)/tcflow.rbdmp : $(CELLTYPE_SRCS) $(PLUGIN_CELLTYPE_SRCS)\n" 519 f.print "\ttcflow -g $(GEN_DIR) -c '$(CC) -E -DTECSFLOW -DTECSGEN $(CFLAGS) -I ./' $^\n" 520 end 521 522 if $generating_region.get_n_cells != 0 || $generating_region == @@root_namespace then 523 f.print "##### end TECSFlow targets #####\n\n" 524 end 525 526 # generic %.o : %.c 474 527 f.print "# generic target for objs\n" 475 528 f.print "$(_TECS_OBJ_DIR)%.o : %.#{$c_suffix}\n" … … 491 544 ### Makefile.tecsgen の生成 492 545 f = AppFile.open( "#{$gen}/Makefile.tecsgen" ) 546 547 f.print <<EOT 548 # generated automatically by tecsgen. 549 # This file is not intended to modify. 550 # 551 # Makefile variables below are defined. 552 # TECS_IMPORT_CDLS .cdl files improted by import statement 553 # SIGNATURE_HEADERS .h files of signature 554 # CELLTYPE_TECSGEN_HEADERS .h files of celltype 555 # CELLTYPE_FACTORY_HEADERS .h files of celltype's factory 556 # TECS_HEADERS summary of .h files above 557 # TECS_INLINE_HEADERS .h files of celltype inline header 558 # PLUGIN_INLINE_HEADERS .h files of plugin generated inline header 559 # 560 # TECS_COBJS .o files of TECS 561 # = $(TECSGEN_COBJS)+$(PLUGIN_COBJS)+$(CELLTYPE_COBJS) 562 # = $(TECS_KERNEL_COBJS)+$(TECS_KERNEL_COBJS)+$(TECS_OUTOFDOMAIN_COBJS) 563 # = $(TECSGEN_domain_COBJS)+$(PLUGIN_domain_COBJS)+$(CELLTYPE_domain_COBJS) for each domain 564 # 565 # TECSGEN_COBJS .o files of celltype_tecsgen.c 566 # CELLTYPE_COBJS .o files of celltype.c (celltype code) 567 # PLUGIN_COBJS .o files of plugin generated .c files 568 # 569 # TECSGEN_SRCS .c files of celltype_tecsgen.c 570 # CELLTYPE_SRCS .c files of celltype.c (celltype code) 571 # PLUGIN_SRCS .c files of plugin generated 572 # PLUGIN_CELLTYPE_SRCS .c files of plugin generated celltype.c (celltype code) 573 # PLUGIN_TECSGEN_SRCS .c files of plugin generated celltype_tecsgen.c 574 # 575 # Variables for domain 576 # TECS_DOMAINS domain names 577 # TECS_KERNEL_COBJS .o files of kernel domain (tecsgen, celltype, plugin) 578 # TECS_USER_COBJS .o files of user domain (tecsgen, celltype, plugin) 579 # TECS_OUTOFDOMAIN_COBJS .o files of OutOfDomain (tecsgen, celltype, plugin) 580 # TECSGEN_domain_COBJS .o files of celltype_tecsgen.c files for each domain 581 # PLUGIN_domain_COBJS .o files of plugin generated .c files for each domain 582 # CELLTYPE_domain_COBJS .o files of celltype.c files for each domain 583 # TECSGEN_domain_SRCS .c files of celltype_domain_tecsgen.c 584 # PLUGIN_domain_SRCS .c files of plugin generated .c files for each domain 585 # CELLTYPE_domain_SRCS .c files of celltype.c files for each domain 586 587 EOT 493 588 494 589 f.print( "TECS_IMPORT_CDLS =" ) … … 545 640 DomainType.get_domain_regions.each{ |dt, regions| 546 641 # domain_type は一つのノードには、一つしかないので、このループは、必ず一回しか回らない 642 ### mikan 複数のノードがあり、異なる domain_type が指定される可能性はある 547 643 domain_regions = regions 548 644 domain_type = dt … … 587 683 f.print( "\n\n" ) 588 684 589 f.print( "# TECS_COBJS: objects from sources which are automatically generated by tecsgen\n" ) 685 f.print( "# TECS_KERNEL_COBJS: objects belong to kernel domain\n" ) 686 f.print( "TECS_KERNEL_COBJS = \\\n" ) 687 domain_regions.each{ |r| 688 if r.get_domain_type.get_kind == :kernel then 689 f.print( " $(TECSGEN#{decideDomainNameProc.call r}_COBJS) \\\n" ) 690 f.print( " $(PLUGIN#{decideDomainNameProc.call r}_COBJS) \\\n" ) 691 f.print( " $(CELLTYPE#{decideDomainNameProc.call r}_COBJS) \\\n" ) 692 end 693 } 694 f.print( "# TECS_KERNEL_COBJS terminator\n\n" ) 695 696 f.print( "# TECS_USER_COBJS: objects belong to user domain\n" ) 697 f.print( "TECS_USER_COBJS = \\\n" ) 698 domain_regions.each{ |r| 699 if r.get_domain_type.get_kind == :user then 700 f.print( " $(TECSGEN#{decideDomainNameProc.call r}_COBJS) \\\n" ) 701 f.print( " $(PLUGIN#{decideDomainNameProc.call r}_COBJS) \\\n" ) 702 f.print( " $(CELLTYPE#{decideDomainNameProc.call r}_COBJS) \\\n" ) 703 end 704 } 705 f.print( "# TECS_USER_COBJS terminator\n\n" ) 706 707 f.print( "# TECS_OUTOFDOMAIN_COBJS: objects belong to OutOfDomain\n" ) 708 f.print( "TECS_OUTOFDOMAIN_COBJS = \\\n" ) 709 domain_regions.each{ |r| 710 if r.get_domain_type.get_kind == :OutOfDomain then 711 f.print( " $(TECSGEN#{decideDomainNameProc.call r}_COBJS) \\\n" ) 712 f.print( " $(PLUGIN#{decideDomainNameProc.call r}_COBJS) \\\n" ) 713 f.print( " $(CELLTYPE#{decideDomainNameProc.call r}_COBJS) \\\n" ) 714 end 715 } 716 f.print( "# TECS_OUTOFDOMAIN_COBJS terminator\n\n" ) 717 718 f.print( "# TECSGEN_COBJS: objects from sources which are automatically generated by tecsgen\n" ) 590 719 f.print( "TECSGEN_COBJS = \\\n" ) 591 720 domain_regions.each{ |r| … … 621 750 622 751 ### 623 f.print( "# TECS _COBJS: objects from sources which are automatically generated by tecsgen\n" )752 f.print( "# TECSGEN_COBJS: objects from sources which are automatically generated by tecsgen\n" ) 624 753 domain_regions.each{ |r| 625 754 nsp = decideDomainNameProc.call( r ) … … 655 784 656 785 f.print( "# PLUGIN_SRCS: sources automatically generated by plugin\n" ) 786 f.print( "PLUGIN_CELLTYPE_SRCS = \\\n" ) 657 787 domain_regions.each{ |r| 658 788 nsp = decideDomainNameProc.call( r ) 659 f.print( "PLUGIN#{nsp}_SRCS = \\\n" ) 660 gen_celltype_names_domain( f, " $(GEN_DIR)/", "_tecsgen.#{$c_suffix} \\\n", domain_type, r, true ) 661 gen_celltype_names_domain2( f, " $(GEN_DIR)/", ".#{$c_suffix} \\\n", domain_type, r, true, false ) 662 f.print( "# PLUGIN#{nsp}_SRCS terminator\n\n" ) 663 } 664 789 f.print( " $(PLUGIN#{nsp}_CELLTYPE_SRCS)\\\n" ) 790 } 791 f.print( "# PLUGIN_CELLTYPE_SRCS terminator\n\n" ) 792 f.print( "PLUGIN_TECSGEN_SRCS = \\\n" ) 793 domain_regions.each{ |r| 794 nsp = decideDomainNameProc.call( r ) 795 f.print( " $(PLUGIN#{nsp}_TECSGEN_SRCS)\\\n" ) 796 } 797 f.print( "# PLUGIN_TECSGEN_SRCS terminator\n\n" ) 798 domain_regions.each{ |r| 799 nsp = decideDomainNameProc.call( r ) 800 f.print( "PLUGIN#{nsp}_SRCS = $(PLUGIN#{nsp}_CELLTYPE_SRCS) $(PLUGIN#{nsp}_TECSGEN_SRCS)\n\n" ) 801 f.print( "PLUGIN#{nsp}_CELLTYPE_SRCS = \\\n" ) 802 gen_celltype_names_domain2( f, "", ".#{$c_suffix} \\\n", domain_type, r, true, false ) 803 f.print( "# PLUGIN#{nsp}_CELLTYPE_SRCS terminator\n\n" ) 804 nsp = decideDomainNameProc.call( r ) 805 f.print( "PLUGIN#{nsp}_TECSGEN_SRCS = \\\n" ) 806 gen_celltype_names_domain( f, "", "_tecsgen.#{$c_suffix} \\\n", domain_type, r, true ) 807 f.print( "# PLUGIN#{nsp}_TECSGEN_SRCS terminator\n\n" ) 808 } 809 810 f.print( "# CELLTYPE_SRCS: sources of celltype code written by user\n" ) 811 f.print( "CELLTYPE_SRCS = \\\n" ) 812 gen_celltype_names( f, " ", ".#{$c_suffix} \\\n", false, false ) 813 f.print( "# CELLTYPE_SRCS terminator\n\n" ) 665 814 f.close 666 815 … … 762 911 end 763 912 913 #=== Namespace#すべてのシグニチャをたどる 914 def travers_all_signature # ブロック引数 { |signature| } 915 proc = Proc.new # このメソッドのブロック引数 916 @signature_list.each{ |sig| 917 proc.call sig 918 } 919 @namespace_list.each{ |ns| 920 ns.travers_all_signature_proc proc 921 } 922 end 923 def travers_all_signature_proc proc 924 @signature_list.each{ |sig| 925 proc.call sig 926 } 927 @namespace_list.each{ |ns| 928 ns.travers_all_signature_proc proc 929 } 930 end 931 932 #=== Namespace#すべてのセルタイプをたどる 933 def travers_all_celltype # ブロック引数 { |celltype| } 934 proc = Proc.new # このメソッドのブロック引数 935 @celltype_list.each{ |ct| 936 proc.call ct 937 } 938 @namespace_list.each{ |ns| 939 ns.travers_all_celltype_proc proc 940 } 941 end 942 def travers_all_celltype_proc proc 943 @celltype_list.each{ |ct| 944 proc.call ct 945 } 946 @namespace_list.each{ |ns| 947 ns.travers_all_celltype_proc proc 948 } 949 end 764 950 end 765 951 … … 854 1040 f.printf TECSMsg.get(:SDI_comment), "#_SDI_#" 855 1041 dl.each{ |dt,param| 856 f.print "#include \"#{dt.get_signature.get_global_name}_tecsgen.#{$h_suffix}\"\n" 1042 f.print <<EOT 1043 /* pre-typedef incomplete-type to avoid error in case of mutual or cyclic reference */ 1044 #ifndef Descriptor_of_#{dt.get_global_name}_Defined 1045 #define Descriptor_of_#{dt.get_global_name}_Defined 1046 typedef struct { struct tag_#{dt.get_global_name}_VDES *vdes; } Descriptor( #{dt.get_global_name} ); 1047 #endif 1048 EOT 1049 # f.print "#include \"#{dt.get_global_name}_tecsgen.#{$h_suffix}\"\n" 857 1050 } 858 1051 f.print "\n" … … 904 1097 end 905 1098 906 f.print "};\n" 907 f.printf "\n" 1099 f.print "};\n\n" 908 1100 f.printf TECSMsg.get(:SDES_comment), "#_SDES_#" 909 f.print( "typedef struct { struct tag_#{@global_name}_VDES *vdes; } Descriptor( #{@global_name} );\n" ) 1101 f.print <<EOT 1102 #ifndef Descriptor_of_#{@global_name}_Defined 1103 #define Descriptor_of_#{@global_name}_Defined 1104 typedef struct { struct tag_#{@global_name}_VDES *vdes; } Descriptor( #{@global_name} ); 1105 #endif 1106 EOT 910 1107 end 911 1108 … … 993 1190 gen_ph_get_cellcb f 994 1191 gen_ph_attr_access f if @n_attribute_rw > 0 || @n_attribute_ro > 0 || @n_var > 0 995 gen_ph_cp_fun_macro f if @n_call_port > 0 1192 f.print "#ifndef TECSFLOW\n" 1193 gen_ph_cp_fun_macro f, false if @n_call_port > 0 1194 f.print "#else /* TECSFLOW */\n" 1195 gen_ph_cp_fun_macro f, true if @n_call_port > 0 1196 f.print "#endif /* TECSFLOW */\n" 996 1197 # gen_ph_abstract_ep_des_type f 997 1198 … … 1008 1209 # gen_ph_ep_fun_prototype f 1009 1210 gen_ph_ep_skel_prototype f 1211 1212 #--- CB_TYPE_ONLY の場合、ref_desc, set_desc 関数は含めない (マクロ参照するため) 1213 if @n_entry_port_inline == 0 then 1214 ifndef_cb_type_only f 1215 end 1216 gen_ph_ref_desc_func f 1217 gen_ph_set_desc_func f 1218 if @n_entry_port_inline == 0 then 1219 endif_cb_type_only f 1220 end 1010 1221 end_extern_C f 1011 1222 endif_macro_only f … … 1019 1230 gen_ph_attr_access_abbrev f if @n_attribute_rw > 0 || @n_attribute_ro > 0 || @n_var > 0 1020 1231 gen_ph_cp_fun_macro_abbrev f if @n_call_port > 0 1232 gen_ph_ref_desc_macro_abbrev f 1233 gen_ph_set_desc_macro_abbrev f 1021 1234 gen_ph_test_optional_call_port_abbrev f 1022 1235 gen_ph_ep_fun_macro f if @n_entry_port > 0 … … 1084 1297 end 1085 1298 } 1299 if p.is_dynamic? then 1300 f.print( "#undef #{p.get_name}_set_descriptor\n" ) 1301 if p.is_optional? then 1302 f.print( "#undef #{p.get_name}_unjoin\n" ) 1303 end 1304 elsif p.is_ref_desc? then 1305 f.print( "#undef #{p.get_name}_refer_to_descriptor\n" ) 1306 f.print( "#undef #{p.get_name}_ref_desc\n" ) 1307 end 1086 1308 } 1087 1309 @port.each { |p| … … 1196 1418 def gen_ph_info f 1197 1419 1420 yn_multi_domain = "no" 1421 yn_multi_domain = "yes" if multi_domain? 1198 1422 yn_idx_is_id = "no" 1199 1423 yn_idx_is_id = "yes" if @idx_is_id … … 1204 1428 yn_rom = "no" 1205 1429 yn_rom = "yes" if $rom 1430 yn_has_CB = "no" 1431 yn_has_CB = "yes" if has_CB? 1432 yn_has_INIB = "no" 1433 yn_has_INIB = "yes" if has_INIB? 1206 1434 yn_cb_init = "no" 1207 1435 yn_cb_init = "yes" if need_CB_initializer? … … 1212 1440 * celltype : #{@name} 1213 1441 * global name : #{@global_name} 1442 * multi-domain : #{yn_multi_domain} 1214 1443 * idx_is_id(actual) : #{yn_idx_is_id}(#{yn_idx_is_id_act}) 1215 1444 * singleton : #{yn_singleton} 1216 * has_CB : #{ has_CB?}1217 * has_INIB : #{ has_INIB?}1445 * has_CB : #{yn_has_CB} 1446 * has_INIB : #{yn_has_INIB} 1218 1447 * rom : #{yn_rom} 1219 1448 * CB initializer : #{yn_cb_init} … … 1438 1667 end 1439 1668 1440 if p.get_array_size == nil then 1441 f.print( "#define #{@global_name}_is_#{p.get_name}_joined(p_that) \\\n" ) 1442 else 1443 f.print( "#define #{@global_name}_is_#{p.get_name}_joined(p_that,subscript) \\\n" ) 1444 end 1669 if @singleton then 1670 param = "" 1671 delim = "" 1672 else 1673 param = "p_that" 1674 delim = "," 1675 end 1676 if p.get_array_size != nil then 1677 param = param + delim + "subscript" 1678 end 1679 f.print( "#define #{@global_name}_is_#{p.get_name}_joined(#{param}) \\\n" ) 1445 1680 1446 1681 if p.is_omit? then … … 1452 1687 # mikan 全部つながっているかどうかで (1) を判定する 1453 1688 if ! p.is_VMT_useless? then 1689 if p.is_dynamic? then 1690 if @singleton then 1691 inib_tmp = "CB" 1692 else 1693 inib_tmp = "" 1694 end 1695 else 1696 inib_tmp = inib 1697 end 1698 1454 1699 # 標準コード 1455 1700 if p.get_array_size == nil then 1456 1701 if @singleton then 1457 f.print( "\t (#{@global_name}_SINGLE_CELL_#{inib }.#{p.get_name}!=0)\n" )1702 f.print( "\t (#{@global_name}_SINGLE_CELL_#{inib_tmp}.#{p.get_name}!=0)\n" ) 1458 1703 else 1459 f.print( "\t ((p_that)#{inib }->#{p.get_name}!=0)\n" )1704 f.print( "\t ((p_that)#{inib_tmp}->#{p.get_name}!=0)\n" ) 1460 1705 end 1461 1706 else 1462 1707 # 配列の場合 1463 1708 if @singleton then 1464 f.print( "\t ((#{@global_name}_SINGLE_CELL_#{inib }.#{p.get_name}!=0) \\\n" )1465 f.print( "\t &&(#{@global_name}_SINGLE_CELL_#{inib }.#{p.get_name}[subscript]!=0))\n" )1709 f.print( "\t ((#{@global_name}_SINGLE_CELL_#{inib_tmp}.#{p.get_name}!=0) \\\n" ) 1710 f.print( "\t &&(#{@global_name}_SINGLE_CELL_#{inib_tmp}.#{p.get_name}[subscript]!=0))\n" ) 1466 1711 else 1467 f.print( "\t (((p_that)#{inib }->#{p.get_name}!=0)\\\n" )1468 f.print( "\t &&((p_that)#{inib }->#{p.get_name}[subscript]!=0))\n" )1712 f.print( "\t (((p_that)#{inib_tmp}->#{p.get_name}!=0)\\\n" ) 1713 f.print( "\t &&((p_that)#{inib_tmp}->#{p.get_name}[subscript]!=0))\n" ) 1469 1714 end 1470 1715 end … … 1503 1748 end 1504 1749 1750 if @singleton then 1751 param = "" 1752 delim = "" 1753 else 1754 param = "p_cellcb" 1755 delim = "," 1756 end 1757 1505 1758 if p.get_array_size == nil then 1506 f.print( "#define is_#{p.get_name}_joined()\\\n\t\t#{@global_name}_is_#{p.get_name}_joined(p_cellcb)\n" ) 1507 else 1508 f.print( "#define is_#{p.get_name}_joined(subscript)\\\n" ) 1509 f.print( "\t\t#{@global_name}_is_#{p.get_name}_joined(p_cellcb,subscript)\n" ) 1510 end 1759 subscript = "" 1760 else 1761 subscript = "subscript" 1762 param = param + delim + subscript 1763 end 1764 f.print( "#define is_#{p.get_name}_joined(#{subscript})\\\n\t\t#{@global_name}_is_#{p.get_name}_joined(#{param})\n" ) 1511 1765 } 1512 1766 end … … 1519 1773 f.print( "#define #{@global_name}_GET_CELLCB(idx) ((void *)0)\n" ) 1520 1774 elsif @idx_is_id_act then # mikan 単一のセルの場合の最適化, idx_is_id でない場合 1521 f.print( "#define #{@global_name}_GET_CELLCB(idx) (#{@global_name}_CB_ tab[(idx) - #{@global_name}_ID_BASE])\n" )1775 f.print( "#define #{@global_name}_GET_CELLCB(idx) (#{@global_name}_CB_ptab[(idx) - #{@global_name}_ID_BASE])\n" ) 1522 1776 else 1523 1777 f.print( "#define #{@global_name}_GET_CELLCB(idx) (idx)\n" ) … … 1723 1977 end 1724 1978 1725 def gen_ph_cp_fun_macro f 1726 if @n_call_port >0 then1979 def gen_ph_cp_fun_macro f, b_flow 1980 if @n_call_port >0 && b_flow == false then 1727 1981 f.printf( TECSMsg.get( :CPM_comment ) , "#_CPM_#" ) 1728 end1729 1730 if @singleton then1731 if has_INIB? then1732 inib = "INIB"1733 else1734 inib = "CB"1735 end1736 else1737 if has_CB? && has_INIB? then1738 inib = "->_inib"1739 else1740 inib = ""1741 end1742 1982 end 1743 1983 … … 1747 1987 1748 1988 p.get_signature.get_function_head_array.each{ |fun| 1989 if @singleton then 1990 if has_INIB? then 1991 inib = "INIB" 1992 else 1993 inib = "CB" 1994 end 1995 if p.is_dynamic? && p.get_array_size == nil then 1996 # dynamic call port (not array) 1997 inib = "CB" 1998 end 1999 else 2000 if has_CB? && has_INIB? then 2001 inib = "->_inib" 2002 else 2003 inib = "" 2004 end 2005 if p.is_dynamic? && p.get_array_size == nil then 2006 # dynamic call port (not array) 2007 inib = "" 2008 end 2009 end 2010 1749 2011 f.print( "#define #{@global_name}_#{p.get_name}_#{fun.get_name}(" ) 1750 2012 ft = fun.get_declarator.get_type … … 1772 2034 1773 2035 # 関数名の出力(標準:受け口ディスクリプタから VMT の関数名、最適化:受け口関数 or 受け口ディスクリプタ) 1774 if ! p.is_VMT_useless? then 2036 if b_flow then 2037 f.print( "\t (p_that)->#{p.get_name}#{subsc}.#{fun.get_name}__T( \\\n" ) 2038 elsif ! p.is_VMT_useless? then 1775 2039 # 標準コード 1776 2040 if @singleton then … … 1807 2071 1808 2072 # 受け口情報の出力(標準:受け口ディスクリプタ、最適化:IDX など) 1809 if ! p.is_skelton_useless? && ! p.is_cell_unique? then 2073 if b_flow then 2074 elsif ! p.is_skelton_useless? && ! p.is_cell_unique? then 1810 2075 # 標準コード 1811 2076 if @singleton then … … 1857 2122 end 1858 2123 2124 #=== ref_desc 指定された呼び口に対するディスクリプタ参照関数の生成 2125 def gen_ph_ref_desc_func f 2126 if @n_call_port_ref_desc >0 then 2127 f.printf( TECSMsg.get( :CRD_comment ), "#_CRD_#" ) 2128 end 2129 2130 if has_CB? && has_INIB? then 2131 inib = "->_inib" 2132 else 2133 inib = "" 2134 end 2135 @port.each { |p| 2136 next if p.get_port_type != :CALL 2137 next if ! p.is_ref_desc? 2138 2139 if @singleton then 2140 p_that = "" 2141 p_cellcb = "" 2142 delim = "" 2143 if has_INIB? then 2144 cb = "#{@global_name}_SINGLE_CELL_INIB." 2145 else 2146 cb = "#{@global_name}_SINGLE_CELL_CB." 2147 end 2148 else 2149 p_that = "#{@global_name}_CB *p_that" 2150 p_cellcb = " #{@global_name}_CB *p_cellcb = p_that;\n" 2151 delim = ", " 2152 cb = "p_cellcb#{inib}->" 2153 end 2154 2155 if p.get_array_size 2156 array = "#{delim}int_t i " 2157 array2 = "[ i ]" 2158 assert = " assert( 0 <= i && i < NCP_#{p.get_name} );\n" 2159 else 2160 array = "" 2161 array2 = "" 2162 assert = "" 2163 end 2164 f.print <<EOT 2165 /* [ref_desc] #{p.get_name} */ 2166 Inline Descriptor( #{p.get_signature.get_global_name} ) 2167 #{@global_name}_#{p.get_name}_refer_to_descriptor( #{p_that}#{array} ) 2168 { 2169 Descriptor( #{p.get_signature.get_global_name} ) des; 2170 #{p_cellcb} /* cast is ncecessary for removing 'const' */ 2171 #{assert} des.vdes = (struct tag_#{p.get_signature.get_global_name}_VDES *)#{cb}#{p.get_name}#{array2}; 2172 return des; 2173 } 2174 2175 EOT 2176 } 2177 end 2178 2179 #=== dynamic 指定された呼び口に対するディスクリプタ設定関数の生成 2180 def gen_ph_set_desc_func f 2181 if @n_call_port_dynamic >0 then 2182 f.printf( TECSMsg.get( :SDF_comment ), "#_SDF_#" ) 2183 end 2184 2185 @port.each { |p| 2186 next if p.get_port_type != :CALL 2187 next if ! p.is_dynamic? 2188 if has_CB? && has_INIB? && p.get_array_size then 2189 inib = "->_inib" 2190 else 2191 inib = "" 2192 end 2193 if @singleton then 2194 # p "main== #{@global_name} #{p.get_name} #{p.get_array_size}" 2195 p_that = "" 2196 p_that2 = "" 2197 p_cellcb = "" 2198 if p.get_array_size && $rom then 2199 cb = "#{@global_name}_SINGLE_CELL_INIB." 2200 else 2201 cb = "#{@global_name}_SINGLE_CELL_CB." 2202 end 2203 else 2204 p_that = "#{@global_name}_CB *p_that, " 2205 p_that2 = "#{@global_name}_CB *p_that " 2206 p_cellcb = " #{@global_name}_CB *p_cellcb = p_that;\n" 2207 cb = "(p_cellcb)->#{inib}" 2208 end 2209 2210 if p.get_array_size then 2211 array = "int_t i, " 2212 array2 = "[ i ]" 2213 array3 = " int_t i " 2214 assert2 = " assert( 0 <= i && i < NCP_#{p.get_name} );\n" 2215 else 2216 array = "" 2217 array2 = "" 2218 array3 = "" 2219 assert2 = "" 2220 end 2221 f.print <<EOT 2222 /* [dynamic] #{p.get_name} */ 2223 Inline void 2224 #{@global_name}_#{p.get_name}_set_descriptor( #{p_that}#{array}Descriptor( #{p.get_signature.get_global_name} ) des ) 2225 { 2226 #{p_cellcb} assert( des.vdes != NULL ); 2227 #{assert2} #{cb}#{p.get_name}#{array2} = des.vdes; 2228 } 2229 2230 EOT 2231 2232 if p.is_optional? then 2233 if p_that2 != "" && array3 != "" then 2234 delim = ", " 2235 else 2236 delim = "" 2237 end 2238 f.print <<EOT 2239 /* [dynamic,optional] #{p.get_name} */ 2240 Inline void 2241 #{@global_name}_#{p.get_name}_unjoin( #{p_that2}#{delim}#{array3} ) 2242 { 2243 #{p_cellcb} #{cb}#{p.get_name}#{array2} = NULL; 2244 } 2245 2246 EOT 2247 end 2248 } 2249 end 2250 1859 2251 #=== send/receive で受け取ったメモリ領域を dealloc するマクロコード 1860 2252 #f:: File … … 1958 2350 1959 2351 if p.is_omit? then 1960 f.print( " 1961 else 1962 f.print( " 2352 f.print( " #{dummy_p_cell_access_pre}omitted #{p.get_name}_#{fun.get_name}(" ) 2353 else 2354 f.print( " #{dummy_p_cell_access_pre}#{@global_name}_#{p.get_name}_#{fun.get_name}(" ) 1963 2355 end 1964 2356 ft = fun.get_declarator.get_type … … 1981 2373 f.print( " )#{dummy_p_cell_access_post}\n" ) 1982 2374 } 2375 } 2376 f.print( "\n" ) 2377 end 2378 2379 def gen_ph_ref_desc_macro_abbrev f 2380 if @n_call_port_ref_desc >0 then 2381 f.printf( TECSMsg.get( :CRDA_comment ), "#_CRDA_#" ) 2382 end 2383 2384 @port.each { |p| 2385 next if p.get_port_type != :CALL 2386 next if ! p.is_ref_desc? 2387 2388 if @singleton then 2389 p_cellcb = "" 2390 delim = "" 2391 else 2392 p_cellcb = "p_cellcb" 2393 delim = ", " 2394 end 2395 2396 if p.get_array_size then 2397 array = " i " 2398 array2 = "#{delim}i" 2399 else 2400 array = "" 2401 array2 = "" 2402 end 2403 2404 f.printf( "#define %s_refer_to_descriptor(#{array})\\\n %s_refer_to_descriptor( #{p_cellcb}#{array2} )\n", 2405 "#{p.get_name}", 2406 "#{@global_name}_#{p.get_name}" ) 2407 f.printf( "#define %s_ref_desc(#{array})\\\n %s_refer_to_descriptor(#{array})\n", 2408 "#{p.get_name}", 2409 "#{p.get_name}" ) 2410 } 2411 f.print( "\n" ) 2412 end 2413 2414 def gen_ph_set_desc_macro_abbrev f 2415 if @n_call_port_dynamic >0 then 2416 f.printf( TECSMsg.get( :SDMA_comment ), "#_SDMA_#" ) 2417 end 2418 2419 if @singleton then 2420 p_cellcb = "" 2421 delim = "" 2422 else 2423 p_cellcb = "p_cellcb" 2424 delim = ", " 2425 end 2426 @port.each { |p| 2427 next if p.get_port_type != :CALL 2428 next if ! p.is_dynamic? 2429 2430 if p.get_array_size then 2431 subsc = "i, " 2432 subsc2 = "i" 2433 subsc3 = delim + subsc2 2434 else 2435 subsc = "" 2436 subsc2 = "" 2437 subsc3 = "" 2438 end 2439 f.printf( "#define %s_set_descriptor( #{subsc}desc )\\\n %s_set_descriptor( #{p_cellcb}#{delim}#{subsc}desc )\n", 2440 "#{p.get_name}", 2441 "#{@global_name}_#{p.get_name}" ) 2442 f.printf( "#define %s_unjoin( #{subsc2} )\\\n %s_unjoin( #{p_cellcb}#{subsc3} )\n", 2443 "#{p.get_name}", 2444 "#{@global_name}_#{p.get_name}" ) 1983 2445 } 1984 2446 f.print( "\n" ) … … 2149 2611 f.print( "typedef const struct tag_#{@global_name}_INIB {\n" ) 2150 2612 2151 gen_cell_cb_type_port f2613 gen_cell_cb_type_port( f, :INIB ) 2152 2614 gen_cell_cb_type_attribute( f, :INIB ) 2153 2615 … … 2162 2624 f.print " #{@global_name}_INIB *_inib;\n" 2163 2625 end 2626 gen_cell_cb_type_port( f, :CB_DYNAMIC ) 2164 2627 gen_cell_cb_type_attribute( f, :CB ) 2165 2628 gen_cell_cb_type_var f … … 2180 2643 f.print( "typedef struct tag_#{@global_name}_CB {\n" ) 2181 2644 2182 gen_cell_cb_type_port f2645 gen_cell_cb_type_port( f, :CB ) 2183 2646 gen_cell_cb_type_attribute( f, :CB ) 2184 2647 gen_cell_cb_type_var f … … 2248 2711 end 2249 2712 2250 def gen_cell_cb_type_port f2251 gen_cell_cb_type_call_port f2252 gen_cell_cb_type_entry_port f2253 end 2254 2255 def gen_cell_cb_type_call_port f2713 def gen_cell_cb_type_port( f, inib_cb ) 2714 gen_cell_cb_type_call_port( f, inib_cb ) 2715 gen_cell_cb_type_entry_port( f, inib_cb ) 2716 end 2717 2718 def gen_cell_cb_type_call_port( f, inib_cb ) 2256 2719 # 呼び口 2257 2720 if @n_call_port >0 then 2258 f.print " /* call port #_TCP_# */ 2721 f.print " /* call port #_TCP_# */\n" 2259 2722 end 2260 2723 … … 2262 2725 next if p.get_port_type != :CALL 2263 2726 next if p.is_omit? 2264 ptr = '' 2265 ptr = '*' if p.get_array_size 2727 next if inib_cb == :INIB && p.is_dynamic? && p.get_array_size == nil && ! $ram_initializer 2728 next if inib_cb == :CB_DYNAMIC && ( ! p.is_dynamic? || p.get_array_size != nil ) 2729 # bprint "cb_type #{inib_cb} #{p.get_name} dynamic=#{p.is_dynamic?}\n" 2730 2731 ptr = p.get_array_size ? '*' : '' 2266 2732 2267 2733 if ! p.is_cell_unique? then 2734 const = p.is_dynamic? ? '' : 'const' 2735 if inib_cb == :INIB && p.is_dynamic? && p.get_array_size == nil && $ram_initializer then 2736 init = '_init_' 2737 const2 = 'const' 2738 else 2739 init = '' 2740 const2 = 'const' 2741 end 2742 2268 2743 if ! p.is_skelton_useless? then 2269 2744 # 標準形 2270 f.print( " struct tag_#{p.get_signature.get_global_name}_VDES #{ptr}const*#{p.get_name;};\n" ) 2745 if inib_cb == :INIB && p.is_dynamic? && p.get_array_size != nil && $ram_initializer then 2746 f.print( " struct tag_#{p.get_signature.get_global_name}_VDES #{ptr}#{const2}*#{p.get_name;}_init_;\n" ) 2747 end 2748 f.print( " struct tag_#{p.get_signature.get_global_name}_VDES #{ptr}#{const}*#{p.get_name;}#{init};\n" ) 2749 # f.print( " struct tag_#{p.get_signature.get_global_name}_VDES #{ptr}*#{p.get_name;};\n" ) 2271 2750 if p.get_array_size == "[]" then 2272 2751 f.print( " int_t n_#{p.get_name};\n" ) … … 2295 2774 2296 2775 #=== Celltype#受け口配列添数を記憶する変数の定義 2297 def gen_cell_cb_type_entry_port f2776 def gen_cell_cb_type_entry_port( f, inib_cb ) 2298 2777 # 呼び口 2299 2778 if @n_entry_port >0 then … … 2318 2797 f.print "extern #{@global_name}_INIB #{@global_name}_SINGLE_CELL_INIB;\n" 2319 2798 end 2320 2321 # @ordered_cell_list.each{ |c|2322 # f.print "extern #{@global_name}_CB #{@global_name}_#{c.get_name}_CB;\n"2323 # }2324 2325 2799 f.print "\n" 2326 elsif @idx_is_id_act then 2327 f.print "extern #{@global_name}_CB *#{@global_name}_CB_tab[];\n" 2800 elsif @b_need_ptab then 2801 f.printf( TECSMsg.get( :SCP_comment ), "#_MCPP_#" ) 2802 if has_CB? then 2803 f.print "extern #{@global_name}_CB *const #{@global_name}_CB_ptab[];\n" 2804 @ordered_cell_list.each{ |c| 2805 if c.is_generate? then # 生成対象か? 2806 name_array = get_name_array c 2807 f.print "extern #{@global_name}_CB #{name_array[4]};\n" 2808 end 2809 } 2810 elsif has_INIB? 2811 f.print "extern #{@global_name}_INIB *const #{@global_name}_INIB_ptab[];\n" 2812 @ordered_cell_list.each{ |c| 2813 if c.is_generate? then # 生成対象か? 2814 name_array = get_name_array c 2815 f.print "extern #{@global_name}_INIB #{name_array[11]};\n" 2816 end 2817 } 2818 end 2328 2819 else 2329 f.print "extern #{@global_name}_CB #{@global_name}_CB_tab[];\n" 2820 f.printf( TECSMsg.get( :SCP_comment ), "#_MCPB_#" ) 2821 if has_CB? then 2822 f.print "extern #{@global_name}_CB #{@global_name}_CB_tab[];\n" 2823 elsif has_INIB? 2824 f.print "extern #{@global_name}_INIB #{@global_name}_INIB_tab[];\n" 2825 end 2330 2826 end 2331 2827 end 2332 2828 2333 2829 def gen_ph_INIB_as_CB f 2334 2830 # ここは、手抜きである。本来なら INIB を出力すべき 2335 2831 if ! has_CB? && has_INIB? then 2336 2832 f.printf( TECSMsg.get( :DCI_comment ), "#_DCI_#" ) 2337 f.print "#define #{@global_name}_CB_tab #{@global_name}_INIB_tab\n" 2338 f.print "#define #{@global_name}_SINGLE_CELL_CB #{@global_name}_SINGLE_CELL_INIB\n" 2833 if @singleton then 2834 f.print "#define #{@global_name}_SINGLE_CELL_CB #{@global_name}_SINGLE_CELL_INIB\n" 2835 elsif @b_need_ptab then 2836 f.print "#define #{@global_name}_CB_ptab #{@global_name}_INIB_ptab\n" 2837 else 2838 f.print "#define #{@global_name}_CB_tab #{@global_name}_INIB_tab\n" 2839 end 2339 2840 f.print "#define #{@global_name}_CB #{@global_name}_INIB\n" 2340 2841 f.print "#define tag_#{@global_name}_CB tag_#{@global_name}_INIB\n" … … 2360 2861 f.printf( TECSMsg.get( :FEC_comment ), "#_FEC_#" ) 2361 2862 2362 if @ idx_is_id_actthen2863 if @b_need_ptab then 2363 2864 amp = '' 2865 tab = 'ptab' 2364 2866 else 2365 2867 amp = '&' 2868 tab = 'tab' 2366 2869 end 2367 2870 f.print <<EOT 2368 2871 #define FOREACH_CELL(i,p_cb) \\ 2369 2872 for( (i) = 0; (i) < #{@global_name}_N_CELL; (i)++ ){ \\ 2370 #{necessity}(p_cb) = #{amp}#{@global_name}_CB_ tab[i];2873 #{necessity}(p_cb) = #{amp}#{@global_name}_CB_#{tab}[i]; 2371 2874 2372 2875 #define END_FOREACH_CELL } … … 2418 2921 2419 2922 if @n_cell_gen > 0 && need_CB_initializer? then 2923 b_var_init = false 2420 2924 f.print "#define INITIALIZE_CB#{arg}" 2421 2925 @var.each { |v| … … 2423 2927 next if init == nil 2424 2928 2929 b_var_init = true 2425 2930 type = v.get_type.get_original_type 2426 2931 f.print "\\\n" … … 2438 2943 # post = "" 2439 2944 end 2440 f.print "\tmemcpy((void*)#{pre}#{@global_name}_VAR_#{v.get_name}#{p_that}#{post}, (void*)#{pre}#{@global_name}_#{v.get_name}_VAR_INIT#{post}, sizeof(#{@global_name}_#{v.get_name}_VAR_INIT));" 2945 f.print "\tmemcpy((void*)#{pre}#{@global_name}_VAR_#{v.get_name}#{p_that}#{post}, " 2946 f.print "(void*)#{pre}#{@global_name}_#{v.get_name}_VAR_INIT#{post}, sizeof(#{@global_name}_#{v.get_name}_VAR_INIT));" 2441 2947 elsif init.instance_of? C_EXP then 2442 2948 f.print "\t#{that}#{v.get_name} = #{init.get_c_exp_string};" … … 2451 2957 end 2452 2958 } 2959 2960 # dynamic call port の初期化コード 2961 b_dyn_port = false 2962 @port.each{ |p| 2963 next if p.get_port_type != :CALL 2964 if p.is_dynamic? && $ram_initializer then 2965 if p.get_array_size == nil then 2966 f.print "\\\n\t#{that}#{p.get_name} = #{that}_inib->#{p.get_name}_init_;" 2967 else 2968 if @singleton || p.get_array_size != "[]" then 2969 p_that = "" 2970 else 2971 p_that = "(p_that)" 2972 end 2973 if @singleton then 2974 that = "#{@global_name}_SINGLE_CELL_INIB." 2975 else 2976 that = "(p_that)->" 2977 end 2978 if has_CB? then 2979 init = '_init->' 2980 else 2981 init = '' 2982 end 2983 f.printf( "\\\n%-80s\\\n", ' {' ) 2984 f.printf( "%-80s\\\n", ' int_t j;' ) 2985 f.printf( "%-80s\\\n", " for( j = 0; j < N_CP_#{p.get_name}#{p_that}; j++ ){" ) 2986 f.printf( "%-80s\\\n", " #{that}#{p.get_name}[j] = #{that}#{init}#{p.get_name}_init_[j];" ) 2987 f.printf( "%-80s\\\n", ' }' ) 2988 f.printf( "%-80s", ' }' ) 2989 end 2990 b_dyn_port = true 2991 end 2992 } 2993 if b_dyn_port then 2994 f.print( "\n" ) 2995 end 2996 2997 if b_var_init == false && b_dyn_port == false && ! @singleton then 2998 f.print "\t(void)(p_that);" 2999 end 2453 3000 f.print "\n" 2454 3001 … … 2457 3004 if @singleton then 2458 3005 f.print "\t#{that}_inib = &#{@global_name}_SINGLE_CELL_INIB;\n\n" 2459 elsif @ idx_is_id_act2460 f.print "\t#{that}_inib = #{@global_name}_INIB_ tab[(i)];\n\n"3006 elsif @b_need_ptab then 3007 f.print "\t#{that}_inib = #{@global_name}_INIB_ptab[(i)];\n\n" 2461 3008 else 2462 3009 f.print "\t#{that}_inib = &#{@global_name}_INIB_tab[(i)];\n\n" … … 2697 3244 j = am[i] 2698 3245 if j then 2699 if am[i].get_ cell.get_celltype == self then3246 if am[i].get_rhs_cell.get_celltype == self then 2700 3247 # 同じセルタイプへ結合している場合(VDES では type conflict になる) 2701 3248 p = am[i].get_rhs_port … … 2726 3273 end 2727 3274 else 2728 if j.get_cell.get_celltype == self then 3275 dbgPrint "me=#{@name} callee=#{j.get_rhs_cell.get_celltype.get_name} #{j.get_cell.get_celltype.get_name} \n" 3276 if j.get_rhs_cell.get_celltype == self then 2729 3277 # 同じセルタイプへ結合している場合(VDES では type conflict になる) 2730 3278 p = j.get_rhs_port … … 2765 3313 2766 3314 jl = c.get_join_list 2767 jl.get_items.each{ |j| 2768 definition = j.get_definition 2769 next unless definition.instance_of? Port 3315 # ループを回す変数を jl から @port に変更 3316 # dynamic, optional 3317 # jl.get_items.each{ |j| 3318 @port.each { |port| 3319 next if port.get_port_type != :CALL 3320 dbgPrint( "gen_cell_ep_vdes_array: #{c.get_name}.#{port.get_name}\n" ) 3321 3322 # definition = j.get_definition 3323 # next unless definition.instance_of? Port 3324 j = jl.get_item( port.get_name ) 3325 2770 3326 # port = definition # definition は composite の Port が得られることがある 2771 port = find j.get_name # celltype の Port (こちらに最適化情報がある)3327 # port = find j.get_name # celltype の Port (こちらに最適化情報がある) 2772 3328 next if port.is_cell_unique? 2773 3329 next if port.is_omit? 2774 3330 2775 am = j.get_array_member2 2776 if am then 3331 b_array = false 3332 am = nil 3333 if j then 3334 am = j.get_array_member2 3335 if am then 3336 b_array = true 3337 end 3338 else 3339 if port.get_array_size == "[]" then 3340 # this case is dynamic optional and nothing joined 3341 next 3342 elsif port.get_array_size then 3343 b_array = true 3344 end 3345 end 3346 if b_array then 3347 # if am then 2777 3348 # 左辺は配列 3349 const = ( port.is_dynamic? && ! $ram_initializer ) ? '' : 'const ' 3350 init = ( port.is_dynamic? && $ram_initializer ) ? '_init_' : '' 2778 3351 2779 3352 if ! port.is_skelton_useless? then 2780 f.printf( "struct %s * const%s_%s[] = {\n",3353 f.printf( "struct %s * #{const}%s_%s[] = {\n", 2781 3354 "tag_#{port.get_signature.get_global_name}_VDES", 2782 3355 "#{c.get_global_name}", 2783 "#{ j.get_name}")3356 "#{port.get_name}" + init ) 2784 3357 else 2785 3358 2786 3359 # スケルトン関数不要最適化の場合、この配列は参照されない 2787 3360 # mikan このケースがテストされていない 2788 f.printf( " const%s_IDX %s_%s[] = {\n",3361 f.printf( "#{const}%s_IDX %s_%s[] = {\n", 2789 3362 # "#{j.get_celltype.get_global_name}", # 右辺 composite に対応できない 2790 3363 "#{j.get_rhs_cell.get_celltype.get_global_name}", … … 2800 3373 i = 0 2801 3374 while i < length 3375 if am == nil then 3376 f.print( " 0,\n" ) 3377 i += 1 3378 next 3379 end 2802 3380 j = am[i] 2803 3381 i += 1 … … 2841 3419 # mikan cell の namespace 未対応、Join で Cell オブジェクトを引当ておく必要あり 2842 3420 f.print "};\n" 3421 # dynamic の呼び口配列 3422 if port.is_dynamic? && $ram_initializer then 3423 f.printf( "struct %s * %s_%s[ #{length} ];\n", 3424 "tag_#{port.get_signature.get_global_name}_VDES", 3425 "#{c.get_global_name}", 3426 "#{port.get_name}" ) 3427 end 2843 3428 end 2844 3429 } … … 2967 3552 init = v.get_initializer 2968 3553 if init && init.instance_of?( Array ) then 2969 type = v.get_type.get_original_type 2970 2971 if( type.kind_of? PtrType )then 3554 type = v.get_type 3555 org_type = v.get_type.get_original_type 3556 3557 if( org_type.kind_of? PtrType )then 2972 3558 # PtrType は ArrayType にすり替える 2973 3559 … … 2976 3562 t2.set_type( type.get_type ) 2977 3563 type = t2 3564 org_type = t2 2978 3565 end 2979 3566 … … 2982 3569 # f.print "const #{type0.get_type_str}\t#{@global_name}_#{v.get_name}_VAR_INIT#{type0.get_type_str_post} = " 2983 3570 f.print "const #{type.get_type_str}\t#{@global_name}_#{v.get_name}_VAR_INIT#{type.get_type_str_post} = " 2984 if type.kind_of? StructType then3571 if org_type.kind_of? StructType then 2985 3572 # celltype の default の初期値あり 2986 3573 str = gen_cell_cb_init( f, c, name_array, type, init, v.get_identifier, 1, true ) 2987 elsif( type.kind_of?( PtrType ) ||type.kind_of?( ArrayType ) ) then3574 elsif( org_type.kind_of?( PtrType ) || org_type.kind_of?( ArrayType ) ) then 2988 3575 str = "{ " 2989 type = type.get_type3576 type = org_type.get_type 2990 3577 # mikan ポインタではなく、配列型としないと、ポインタ変数の領域の分、損する 2991 3578 init.each { |i| … … 3015 3602 fs.each{ |r, f| f.print "#{@global_name}_INIB #{@global_name}_SINGLE_CELL_INIB = \n" } 3016 3603 indent = 0 3017 elsif ! @ idx_is_id_actthen3604 elsif ! @b_need_ptab then 3018 3605 fs.each{ |r, f| f.print "#{@global_name}_INIB #{@global_name}_INIB_tab[] = {\n" } 3019 3606 indent = 1 … … 3036 3623 3037 3624 print_indent( f, indent ) 3038 if @ idx_is_id_actthen3625 if @b_need_ptab then 3039 3626 f.print "const #{@global_name}_INIB #{name_array[5]} = " 3040 3627 end 3041 3628 f.print "{\n" 3042 3629 3043 gen_cell_cb_port( c, indent, f, name_array )3630 gen_cell_cb_port( c, indent, f, name_array, :INIB ) 3044 3631 gen_cell_cb_attribute( c, indent, f, name_array, :INIB ) 3045 3632 3046 3633 unless @singleton then 3047 3634 # 1 つの cell INIB の終わり 3048 if @ idx_is_id_actthen3635 if @b_need_ptab then 3049 3636 f.print( "};\n\n" ) 3050 3637 else … … 3053 3640 end 3054 3641 } 3055 if ! @ idx_is_id_actthen3642 if ! @b_need_ptab then 3056 3643 fs.each{ |r, f| f.print( "};\n\n" ) } 3057 3644 end … … 3068 3655 fs.each{ |r, f| f.print "struct tag_#{@global_name}_CB #{@global_name}_SINGLE_CELL_CB = \n" } 3069 3656 indent = 0 3070 elsif ! @ idx_is_id_actthen3657 elsif ! @b_need_ptab then 3071 3658 fs.each{ |r, f| f.print "struct tag_#{@global_name}_CB #{@global_name}_CB_tab[] = {\n" } 3072 3659 indent = 1 3660 else 3661 indent = 0 3073 3662 end 3074 3663 … … 3087 3676 3088 3677 print_indent( f, indent ) 3089 if @ idx_is_id_actthen3678 if @b_need_ptab then 3090 3679 f.print "#{@global_name}_CB #{name_array[2]} = " 3091 3680 end … … 3097 3686 end 3098 3687 3099 if ! has_INIB? then 3100 gen_cell_cb_port( c, indent, f, name_array ) 3688 #if ! has_INIB? then 3689 if $rom == false then 3690 gen_cell_cb_port( c, indent, f, name_array, :CB_ALL ) 3691 else 3692 gen_cell_cb_port( c, indent, f, name_array, :CB_DYNAMIC ) 3101 3693 end 3102 3694 … … 3106 3698 unless @singleton then 3107 3699 # 1 つの cell CB の終わり 3108 if @ idx_is_id_actthen3700 if @b_need_ptab then 3109 3701 f.print( "};\n\n" ) 3110 3702 else … … 3113 3705 end 3114 3706 } 3115 if ! @ idx_is_id_actthen3707 if ! @b_need_ptab then 3116 3708 fs.each{ |r, f| f.print( "};\n\n" ) } 3117 3709 end … … 3120 3712 fs.each{ |r, f| f.print "struct tag_#{@global_name}_CB #{@global_name}_SINGLE_CELL_CB;\n" } 3121 3713 indent = 0 3122 elsif @ idx_is_id_actthen3714 elsif @b_need_ptab then 3123 3715 @ordered_cell_list.each{ |c| 3124 3716 next if ! c.is_generate? … … 3139 3731 def gen_cell_cb_tab f 3140 3732 indent = 0 3141 if @ idx_is_id_actthen3733 if @b_need_ptab then 3142 3734 if has_INIB? && ( $ram_initializer || ! has_CB? ) then 3143 3735 f.print "/* ID to INIB table #_INTAB_# */\n" … … 3150 3742 } 3151 3743 3152 f.print "#{@global_name}_INIB * #{@global_name}_INIB_tab[] ={\n"3744 f.print "#{@global_name}_INIB *const #{@global_name}_INIB_ptab[] ={\n" 3153 3745 @ordered_cell_list.each{ |c| 3154 3746 if c.is_generate? then # 生成対象か? … … 3170 3762 } 3171 3763 3172 f.print "#{@global_name}_CB * #{@global_name}_CB_tab[] ={\n"3764 f.print "#{@global_name}_CB *const #{@global_name}_CB_ptab[] ={\n" 3173 3765 @ordered_cell_list.each{ |c| 3174 3766 if c.is_generate? then # 生成対象か? … … 3199 3791 # name_array[9] = @global_name # celltype global name 3200 3792 # name_array[10] = cell.get_global_name # cell global name 3793 # name_array[11] = cell_INIB_proto #INIB name for proto type 3201 3794 3202 3795 def get_name_array( cell ) … … 3207 3800 cell_CB_proto = "#{@global_name}_SINGLE_CELL_CB" 3208 3801 cell_INIB_name = "#{@global_name}_SINGLE_CELL_INIB" 3802 cell_INIB_proto = cell_INIB_name 3209 3803 cell_ID = 0 3210 3804 else 3211 if ! @ idx_is_id_actthen3805 if ! @b_need_ptab then 3212 3806 index = cell.get_id - cell.get_celltype.get_id_base 3213 3807 cell_CB_name = "#{@global_name}_CB_tab[#{index}]" … … 3215 3809 cell_CB_proto = "#{@global_name}_CB_tab[]" 3216 3810 cell_INIB_name = "#{@global_name}_INIB_tab[#{index}]" 3811 cell_INIB_proto = "#{@global_name}_INIB_tab[]" 3217 3812 else 3218 3813 cell_CB_name = "#{cell.get_global_name}_CB" … … 3220 3815 cell_CB_proto = cell_CB_name 3221 3816 cell_INIB_name = "#{cell.get_global_name}_INIB" 3817 cell_INIB_proto = cell_INIB_name 3222 3818 end 3223 3819 cell_ID = cell.get_id 3224 3820 end 3821 3822 if has_CB? then 3823 cell_CBP = "&#{cell_CB_name}" 3824 elsif has_INIB? then 3825 cell_CBP = "&#{cell_INIB_name}" 3826 else 3827 cell_CBP = "NULL" # CB も INIB もなければ NULL に置換 3828 end 3829 3225 3830 if @idx_is_id_act then 3226 3831 cell_IDX = cell_ID 3227 3832 else 3228 cell_IDX = "&#{cell_CB_name}" 3229 end 3230 3231 if ! has_CB? && ! has_INIB? then 3232 cell_CBP = "NULL" # CB も INIB もなければ NULL に置換 3233 else 3234 cell_CBP = "&#{cell_CB_name}" 3833 cell_IDX = cell_CBP 3235 3834 end 3236 3835 … … 3247 3846 name_array[9] = @global_name # celltype global name 3248 3847 name_array[10] = cell.get_global_name # cell global name 3848 name_array[11] = cell_INIB_proto # INIB name for prototype 3249 3849 3250 3850 return name_array … … 3331 3931 end 3332 3932 3333 def gen_cell_cb_port( cell, indent, f, name_array ) 3334 gen_cell_cb_call_port( cell, indent, f, name_array ) 3933 #inib_cb::Symbol: :INIB, :CB_ALL, :CB_DYNAMIC 3934 def gen_cell_cb_port( cell, indent, f, name_array, inib_cb = :INIB ) 3935 gen_cell_cb_call_port( cell, indent, f, name_array, inib_cb ) 3335 3936 gen_cell_cb_entry_port( cell, indent, f, name_array ) 3336 3937 end 3337 3938 3338 3939 #=== 呼び口の初期化コードの生成 3339 def gen_cell_cb_call_port( cell, indent, f, name_array )3940 def gen_cell_cb_call_port( cell, indent, f, name_array, inib_cb ) 3340 3941 jl = cell.get_join_list 3341 3942 3342 3943 port = get_port_list 3343 if @n_call_port != 0 then 3944 if inib_cb == :INIB && ( @n_call_port - @n_call_port_omitted_in_CB - 3945 ( $ram_initializer ? 0 : (@n_call_port_dynamic-@n_call_port_array_dynamic) ) > 0 ) || 3946 inib_cb == :CB_ALL && @n_call_port > 0 || 3947 inib_cb == :CB_DYNAMIC && (@n_call_port_dynamic - @n_call_port_array_dynamic) > 0 then 3344 3948 print_indent( f, indent + 1 ) 3345 f.print "/* call port #_CP_# */ \n"3949 f.print "/* call port (#{inib_cb}) #_CP_# */ \n" 3346 3950 port.each{ |p| 3347 3951 next if p.get_port_type != :CALL 3348 3952 next if p.is_omit? 3349 3953 next if p.is_cell_unique? # 最適化(単一セルで呼び口マクロに埋め込まれる) 3954 next if inib_cb == :INIB && p.is_dynamic? && p.get_array_size == nil && ! $ram_initializer 3955 next if inib_cb == :CB_DYNAMIC && ( ! p.is_dynamic? || p.get_array_size != nil ) 3350 3956 3351 3957 j = jl.get_item( p.get_name ) … … 3354 3960 # debug 3355 3961 if j == nil then 3962 dbgPrint "cell_cb_call_port: #{p.get_name} array size=#{p.get_array_size}\n" 3356 3963 # optional 呼び口 3357 3964 # cdl_error( "H1003 internal error: cell \'$1\' port \'$2\': initializer not found\n" , cell.get_name, p.get_name ) 3358 3965 # exit( 1 ) 3359 f.printf( "%-40s /* #_CCP5_# */\n", "0," ) 3360 if p.get_array_size == "[]" then 3361 # 添数省略の呼び口配列 3362 print_indent( f, indent + 1 ) 3363 f.printf( "%-40s /* %s #_CCP6_# */\n", "0,", "length of #{p.get_name} (n_#{p.get_name})" ) 3966 if p.get_array_size then 3967 if p.is_dynamic? then 3968 if inib_cb == :INIB then 3969 if $ram_initializer then 3970 f.printf( "%-40s /* #_CCP7_# _init_ */\n", "#{cell.get_global_name}_#{p.get_name}_init_," ) 3971 print_indent( f, indent + 1 ) 3972 end 3973 f.printf( "%-40s /* #_CCP7B_# */\n", "#{cell.get_global_name}_#{p.get_name}," ) 3974 elsif $rom == false then 3975 f.printf( "%-40s /* #_CCP8_# */\n", "#{cell.get_global_name}_#{p.get_name}," ) 3976 end 3977 else 3978 f.printf( "%-40s /* #_CCP9_# */\n", "0," ) 3979 end 3980 if p.get_array_size == "[]" then 3981 # 添数省略の呼び口配列 3982 print_indent( f, indent + 1 ) 3983 f.printf( "%-40s /* %s #_CCP6_# */\n", "0,", "length of #{p.get_name} (n_#{p.get_name})" ) 3984 end 3985 else 3986 f.printf( "%-40s /* #_CCP5_# */\n", "0," ) 3364 3987 end 3365 3988 next … … 3369 3992 if am then 3370 3993 # 呼び口配列の場合 3371 f.printf( "%-40s /* #_CCP3_# */\n", "#{cell.get_global_name}_#{j.get_name}," ) 3994 if inib_cb == :INIB && p.is_dynamic? && p.get_array_size != nil && $ram_initializer then 3995 f.printf( "%-40s /* #_CCP3_# _init_ */\n", "#{cell.get_global_name}_#{j.get_name}_init_," ) 3996 print_indent( f, indent + 1 ) 3997 end 3998 f.printf( "%-40s /* #_CCP3B_# */\n", "#{cell.get_global_name}_#{j.get_name}," ) 3372 3999 if p.get_array_size == "[]" then 3373 4000 # 添数省略の呼び口配列 … … 3385 4012 end 3386 4013 4014 init = ( p.is_dynamic? && inib_cb == :INIB ) ? "_init_" : "" 4015 3387 4016 if j.get_rhs_subscript then 3388 4017 # 受け口配列の場合 … … 3391 4020 # "&#{j.get_cell_global_name}_#{j.get_port_name}_des#{subscript},", 3392 4021 "#{des_type_cast}&#{j.get_port_global_name}_des#{subscript},", 3393 p.get_name )4022 p.get_name.to_s + init ) 3394 4023 else 3395 4024 # 呼び口配列でも、受け口配列でもない … … 3397 4026 f.printf( "%-40s /* %s #_CCP1_# */\n", 3398 4027 "#{des_type_cast}&#{j.get_port_global_name}_des,", 3399 p.get_name )4028 p.get_name.to_s + init ) 3400 4029 else 3401 4030 # スケルトン不要最適化(CB (INIB) へのポインタを埋め込む) 3402 4031 c = j.get_rhs_cell # 呼び先セル 3403 4032 ct = c.get_celltype # 呼び先セルタイプ 4033 name_array = ct.get_name_array( c ) # 呼び先セルタイプで name_array を得る 3404 4034 if ct.has_INIB? || ct.has_CB? then 3405 name_array = ct.get_name_array( c ) # 呼び先セルタイプで name_array を得る3406 4035 f.printf( "%-40s /* %s #_CCP2_# */\n", "#{name_array[7]},", p.get_name ) 3407 4036 else 3408 4037 # 呼び先は CB も INIB も持たない(NULL に初期化) 3409 f.printf( "%-40s /* %s #_CCP2 _# */\n", "0,", p.get_name )4038 f.printf( "%-40s /* %s #_CCP2B_# */\n", "0,", p.get_name ) 3410 4039 end 3411 4040 end … … 3689 4318 f = fs[ c.get_region.get_domain_root ] 3690 4319 3691 ct = c.get_celltype 4320 ct = c.get_celltype # ct = self でも同じ 3692 4321 jl = c.get_join_list 4322 name_array = get_name_array( c ) 3693 4323 3694 4324 port = ct.get_port_list … … 3725 4355 else 3726 4356 if has_CB? then 3727 if @singleton then 3728 f.print " &#{@global_name}_SINGLE_CELL_CB, /* CB */\n" 3729 else 3730 # f.print " &#{@global_name}_#{c.get_name}_CB,\n" 3731 f.print " &#{@global_name}_CB_tab[#{index}], /* CB */\n" 3732 end 4357 # if @singleton then 4358 # f.print " &#{@global_name}_SINGLE_CELL_CB, /* CB 1 */\n" 4359 # else 4360 # # f.print " &#{@global_name}_#{c.get_name}_CB,\n" 4361 # f.print " &#{@global_name}_CB_tab[#{index}], /* CB 2 */\n" 4362 # end 4363 f.print " #{name_array[8]}, /* CB 1 */\n" 3733 4364 elsif has_INIB? then 3734 if @singleton then 3735 f.print " &#{@global_name}_SINGLE_CELL_INIB, /* INIB */\n" 3736 else 3737 f.print " &#{@global_name}_INIB_tab[#{index}], /* INIB */\n" 3738 end 4365 # if @singleton then 4366 # f.print " &#{@global_name}_SINGLE_CELL_INIB, /* INIB 1 */\n" 4367 # else 4368 # f.print " &#{@global_name}_INIB_tab[#{index}], /* INIB 2 */\n" 4369 # end 4370 f.print " &#{name_array[5]}, /* INIB 1 */\n" 3739 4371 else 3740 4372 f.print " 0,\n" … … 3760 4392 else 3761 4393 if has_CB? then 3762 if @singleton then 3763 f.print " &#{@global_name}_SINGLE_CELL_CB, /* CB */\n" 3764 else 3765 f.print " &#{@global_name}_CB_tab[#{index}], /* CB */\n" 3766 # f.print " &#{@global_name}_#{c.get_name}_CB,\n" 3767 end 4394 # if @singleton then 4395 # f.print " &#{@global_name}_SINGLE_CELL_CB, /* CB 3 */\n" 4396 # else 4397 # f.print " &#{@global_name}_CB_tab[#{index}], /* CB 4 */\n" 4398 # # f.print " &#{@global_name}_#{c.get_name}_CB,\n" 4399 # end 4400 f.print " #{name_array[8]}, /* CB 3 */\n" 3768 4401 elsif has_INIB? then 3769 if @singleton then 3770 f.print " &#{@global_name}_SINGLE_CELL_INIB, /* INIB */\n" 3771 else 3772 f.print " &#{@global_name}_INIB_tab[#{index}], /* INIB */\n" 3773 end 4402 # if @singleton then 4403 # f.print " &#{@global_name}_SINGLE_CELL_INIB, /* INIB 3 */\n" 4404 # else 4405 # # f.print " &#{@global_name}_INIB_tab[#{index}], /* INIB 4 */\n" 4406 # end 4407 f.print " &#{name_array[5]}, /* INIB 3 */\n" 3774 4408 else 3775 4409 f.print " 0,\n" … … 3940 4574 3941 4575 ft.get_paramlist.get_items.each{ |param| 4576 # p "type_str: #{param.get_type.get_type_str}" 3942 4577 f.print( "#{delim} #{param.get_type.get_type_str}" ) 3943 4578 f.print( " #{param.get_name}#{param.get_type.get_type_str_post}" ) … … 3967 4602 end 3968 4603 4604 if p.is_ref_desc? then 4605 subsc = p.get_array_size ? ' int_t subscript ' : '' 4606 f.print " * [ref_desc]\n" 4607 f.printf( " * %-14s %s;\n", 4608 "Descriptor( #{p.get_signature.get_global_name} )", 4609 "#{p.get_name}_refer_to_descriptor(#{subsc})" ) 4610 f.printf( " * %-14s %s;\n", 4611 "Descriptor( #{p.get_signature.get_global_name} )", 4612 "#{p.get_name}_ref_desc(#{subsc}) (same as above; abbreviated version)" ) 4613 end 4614 if p.is_dynamic? then 4615 subsc = p.get_array_size ? 'int_t subscript, ' : '' 4616 subsc2 = p.get_array_size ? ' int_t subscript' : '' 4617 if p.is_optional? then 4618 f.print " * [dynamic, optional]\n" 4619 else 4620 f.print " * [dynamic]\n" 4621 end 4622 f.printf( " * %-14s %s;\n", 4623 "void", 4624 "#{p.get_name}_set_descriptor( #{subsc}Descriptor( #{p.get_signature.get_global_name} ) desc )" ) 4625 if p.is_optional? then 4626 f.printf( " * %-14s %s;\n", 4627 "void", 4628 "#{p.get_name}_unjoin( #{subsc2} )" ) 4629 end 4630 end 3969 4631 } 3970 4632 … … 4048 4710 delim = ", " 4049 4711 f.print param.get_type.get_type_str 4712 # p "type_str2: #{param.get_type.get_type_str}" 4050 4713 f.print " " 4051 4714 f.print param.get_name … … 4103 4766 def generate_inline_template_code 4104 4767 return if @n_entry_port_inline == 0 4768 return if @b_reuse && ! $generate_all_template 4105 4769 if ! ( @plugin && @plugin.gen_ep_func? ) then 4106 4770 return if @b_reuse && ! $generate_all_template … … 4480 5144 # str に以下の置換を行う 4481 5145 #- $ct$ ⇒ セルタイプ名(ct) 4482 #- $cell$ ⇒ セル名(cell) cell が nil ならば 3つの置換は行われない5146 #- $cell$ ⇒ セル名(cell) cell が nil ならば以下の置換は行われない 4483 5147 #- $cb$ ⇒ CB の C 言語名(cb) 4484 5148 #- $cbp$ ⇒ CB へのポインタ(cbp) 4485 5149 #- $cb_proto$ ⇒ CB の C 言語名プロトタイプ宣言用(cb_proto) 4486 #- $id$ ⇒ ct_cell5150 #- $id$ ⇒ $ct$_$cell_global$ # ct_cell before or same V1.5.2 4487 5151 #- $idx$ ⇒ idx 4488 5152 #- $ID$ ⇒ id (整数の番号) 4489 5153 #- $ct_global$ ⇒ セルタイプ名(ct) 4490 #- $cell_global$ ⇒ セル名(cell) cell が nil ならば3つの置換は行われない5154 #- $cell_global$ ⇒ セル名(cell) 4491 5155 #- $$ ⇒ $ 4492 5156 def subst_name( str, name_array ) … … 4503 5167 4504 5168 str = str.gsub( /(^|[^\$])\$ct\$/, "\\1#{ct}" ) 5169 str = str.gsub( /(^|[^\$])\$ct_global\$/, "\\1#{ct_global}" ) 4505 5170 if cell then 4506 5171 str = str.gsub( /(^|[^\$])\$cell\$/, "\\1#{cell}" ) 4507 5172 str = str.gsub( /(^|[^\$])\$cb\$/, "\\1#{cb}" ) 4508 str = str.gsub( /(^|[^\$])\$id\$/, "\\1#{ct}_#{cell}" ) 5173 # str = str.gsub( /(^|[^\$])\$id\$/, "\\1#{ct}_#{cell}" ) 5174 str = str.gsub( /(^|[^\$])\$id\$/, "\\1#{ct}_#{cell_global}" ) 4509 5175 str = str.gsub( /(^|[^\$])\$cb_proto\$/, "\\1#{cb_proto}" ) 4510 5176 str = str.gsub( /(^|[^\$])\$ID\$/, "\\1#{id}" ) 4511 5177 str = str.gsub( /(^|[^\$])\$idx\$/, "\\1#{idx}" ) 4512 5178 str = str.gsub( /(^|[^\$])\$cbp\$/, "\\1#{cbp}" ) 4513 str = str.gsub( /(^|[^\$])\$ct_global\$/, "\\1#{ct_global}" )4514 5179 str = str.gsub( /(^|[^\$])\$cell_global\$/, "\\1#{cell_global}" ) 4515 5180 end … … 4631 5296 end 4632 5297 end 5298 5299 class DomainType < Node 5300 def gen_factory 5301 # p "DomainType: gen_factory" 5302 @plugin.gen_factory 5303 end 5304 end
Note:
See TracChangeset
for help on using the changeset viewer.