@@ -698,7 +698,7 @@ static void LoadPinLoc(pugi::xml_node Locations,
698
698
for (int width = 0 ; width < type->width ; ++width) {
699
699
for (int height = 0 ; height < type->height ; ++height) {
700
700
for (e_side side : TOTAL_2D_SIDES) {
701
- for (auto token : pin_locs->assignments [sub_tile_index][width][height][layer][side]) {
701
+ for (const std::string& token : pin_locs->assignments [sub_tile_index][width][height][layer][side]) {
702
702
auto pin_range = ProcessPinString<t_sub_tile*>(Locations,
703
703
&sub_tile,
704
704
token.c_str (),
@@ -741,109 +741,97 @@ static std::pair<int, int> ProcessPinString(pugi::xml_node Locations,
741
741
T type,
742
742
const char * pin_loc_string,
743
743
const pugiutil::loc_data& loc_data) {
744
- int num_tokens;
745
- auto tokens = GetTokensFromString (pin_loc_string, &num_tokens);
744
+ Tokens tokens (pin_loc_string);
746
745
747
- int token_index = 0 ;
748
- auto token = tokens[token_index];
746
+ size_t token_index = 0 ;
749
747
750
- if (token .type != TOKEN_STRING || token .data != type->name ) {
748
+ if (tokens[token_index] .type != e_token_type::STRING || tokens[token_index] .data != type->name ) {
751
749
archfpga_throw (loc_data.filename_c_str (), loc_data.line (Locations),
752
750
" Wrong physical type name of the port: %s\n " , pin_loc_string);
753
751
}
754
752
755
753
token_index++;
756
- token = tokens[token_index];
757
754
758
- if (token .type != TOKEN_DOT ) {
755
+ if (tokens[token_index] .type != e_token_type::DOT ) {
759
756
archfpga_throw (loc_data.filename_c_str (), loc_data.line (Locations),
760
757
" No dot is present to separate type name and port name: %s\n " , pin_loc_string);
761
758
}
762
759
763
760
token_index++;
764
- token = tokens[token_index];
765
761
766
- if (token .type != TOKEN_STRING ) {
762
+ if (tokens[token_index] .type != e_token_type::STRING ) {
767
763
archfpga_throw (loc_data.filename_c_str (), loc_data.line (Locations),
768
764
" No port name is present: %s\n " , pin_loc_string);
769
765
}
770
766
771
- auto port = type->get_port (token .data );
767
+ auto port = type->get_port (tokens[token_index] .data );
772
768
if (port == nullptr ) {
773
769
archfpga_throw (loc_data.filename_c_str (), loc_data.line (Locations),
774
770
" Port %s for %s could not be found: %s\n " ,
775
- type->name .c_str (), token .data ,
771
+ type->name .c_str (), tokens[token_index] .data . c_str () ,
776
772
pin_loc_string);
777
773
}
778
774
int abs_first_pin_idx = port->absolute_first_pin_index ;
779
775
780
776
token_index++;
781
777
782
778
// All the pins of the port are taken or the port has a single pin
783
- if (token_index == num_tokens) {
784
- freeTokens (tokens, num_tokens);
779
+ if (token_index == tokens.size ()) {
785
780
return std::make_pair (abs_first_pin_idx, abs_first_pin_idx + port->num_pins );
786
781
}
787
782
788
- token = tokens[token_index];
789
-
790
- if (token.type != TOKEN_OPEN_SQUARE_BRACKET) {
783
+ if (tokens[token_index].type != e_token_type::OPEN_SQUARE_BRACKET) {
791
784
archfpga_throw (loc_data.filename_c_str (), loc_data.line (Locations),
792
785
" No open square bracket present: %s\n " , pin_loc_string);
793
786
}
794
787
795
788
token_index++;
796
- token = tokens[token_index];
797
789
798
- if (token .type != TOKEN_INT ) {
790
+ if (tokens[token_index] .type != e_token_type::INT ) {
799
791
archfpga_throw (loc_data.filename_c_str (), loc_data.line (Locations),
800
792
" No integer to indicate least significant pin index: %s\n " , pin_loc_string);
801
793
}
802
794
803
- int first_pin = vtr::atoi (token .data );
795
+ int first_pin = vtr::atoi (tokens[token_index] .data );
804
796
805
797
token_index++;
806
- token = tokens[token_index];
807
798
808
799
// Single pin is specified
809
- if (token .type != TOKEN_COLON ) {
810
- if (token .type != TOKEN_CLOSE_SQUARE_BRACKET ) {
800
+ if (tokens[token_index] .type != e_token_type::COLON ) {
801
+ if (tokens[token_index] .type != e_token_type::CLOSE_SQUARE_BRACKET ) {
811
802
archfpga_throw (loc_data.filename_c_str (), loc_data.line (Locations),
812
803
" No closing bracket: %s\n " , pin_loc_string);
813
804
}
814
805
815
806
token_index++;
816
807
817
- if (token_index != num_tokens ) {
808
+ if (token_index != tokens. size () ) {
818
809
archfpga_throw (loc_data.filename_c_str (), loc_data.line (Locations),
819
810
" pin location should be completed, but more tokens are present: %s\n " , pin_loc_string);
820
811
}
821
812
822
- freeTokens (tokens, num_tokens);
823
813
return std::make_pair (abs_first_pin_idx + first_pin, abs_first_pin_idx + first_pin + 1 );
824
814
}
825
815
826
816
token_index++;
827
- token = tokens[token_index];
828
817
829
- if (token .type != TOKEN_INT ) {
818
+ if (tokens[token_index] .type != e_token_type::INT ) {
830
819
archfpga_throw (loc_data.filename_c_str (), loc_data.line (Locations),
831
820
" No integer to indicate most significant pin index: %s\n " , pin_loc_string);
832
821
}
833
822
834
- int last_pin = vtr::atoi (token .data );
823
+ int last_pin = vtr::atoi (tokens[token_index] .data );
835
824
836
825
token_index++;
837
- token = tokens[token_index];
838
826
839
- if (token .type != TOKEN_CLOSE_SQUARE_BRACKET ) {
827
+ if (tokens[token_index] .type != e_token_type::CLOSE_SQUARE_BRACKET ) {
840
828
archfpga_throw (loc_data.filename_c_str (), loc_data.line (Locations),
841
829
" No closed square bracket: %s\n " , pin_loc_string);
842
830
}
843
831
844
832
token_index++;
845
833
846
- if (token_index != num_tokens ) {
834
+ if (token_index != tokens. size () ) {
847
835
archfpga_throw (loc_data.filename_c_str (), loc_data.line (Locations),
848
836
" pin location should be completed, but more tokens are present: %s\n " , pin_loc_string);
849
837
}
@@ -852,7 +840,6 @@ static std::pair<int, int> ProcessPinString(pugi::xml_node Locations,
852
840
std::swap (first_pin, last_pin);
853
841
}
854
842
855
- freeTokens (tokens, num_tokens);
856
843
return std::make_pair (abs_first_pin_idx + first_pin, abs_first_pin_idx + last_pin + 1 );
857
844
}
858
845
0 commit comments