Parse a target spec. Accept the target from the command line for pass command.
(&mut self, target_pass: Option<&str>)
| 1036 | /// Accept the target from the command line for pass command. |
| 1037 | /// |
| 1038 | fn parse_cmdline_target(&mut self, target_pass: Option<&str>) -> ParseResult<isaspec::IsaSpec> { |
| 1039 | // Were there any `target` commands specified? |
| 1040 | let mut specified_target = false; |
| 1041 | |
| 1042 | let mut targets = Vec::new(); |
| 1043 | let flag_builder = settings::builder(); |
| 1044 | |
| 1045 | if let Some(targ) = target_pass { |
| 1046 | let loc = self.loc; |
| 1047 | let triple = match Triple::from_str(targ) { |
| 1048 | Ok(triple) => triple, |
| 1049 | Err(err) => return err!(loc, err), |
| 1050 | }; |
| 1051 | let isa_builder = match isa::lookup(triple) { |
| 1052 | Err(isa::LookupError::SupportDisabled) => { |
| 1053 | return err!(loc, "support disabled target '{}'", targ); |
| 1054 | } |
| 1055 | Err(isa::LookupError::Unsupported) => { |
| 1056 | return warn!(loc, "unsupported target '{}'", targ); |
| 1057 | } |
| 1058 | Ok(b) => b, |
| 1059 | }; |
| 1060 | specified_target = true; |
| 1061 | |
| 1062 | // Construct a trait object with the aggregate settings. |
| 1063 | targets.push( |
| 1064 | isa_builder |
| 1065 | .finish(settings::Flags::new(flag_builder.clone())) |
| 1066 | .map_err(|e| ParseError { |
| 1067 | location: loc, |
| 1068 | message: format!("invalid ISA flags for '{targ}': {e:?}"), |
| 1069 | is_warning: false, |
| 1070 | })?, |
| 1071 | ); |
| 1072 | } |
| 1073 | |
| 1074 | if !specified_target { |
| 1075 | // No `target` commands. |
| 1076 | Ok(isaspec::IsaSpec::None(settings::Flags::new(flag_builder))) |
| 1077 | } else { |
| 1078 | Ok(isaspec::IsaSpec::Some(targets)) |
| 1079 | } |
| 1080 | } |
| 1081 | |
| 1082 | /// Parse a list of target specs. |
| 1083 | /// |