| 805 | } |
| 806 | |
| 807 | fn parse_id_out<'a>( |
| 808 | &mut self, |
| 809 | id_map: &mut FxHashMap<&'a str, Word>, |
| 810 | defined_ids: &mut FxHashSet<Word>, |
| 811 | token: Token<'a, 'cx, 'tcx>, |
| 812 | ) -> Option<OutRegister<'tcx>> { |
| 813 | match token { |
| 814 | Token::Word(word) => { |
| 815 | if let Some(id) = word.strip_prefix('%') { |
| 816 | Some(OutRegister::Regular({ |
| 817 | let num = *id_map.entry(id).or_insert_with(|| self.emit().id()); |
| 818 | if !defined_ids.insert(num) { |
| 819 | self.err(&format!("%{id} is defined more than once")); |
| 820 | } |
| 821 | num |
| 822 | })) |
| 823 | } else { |
| 824 | self.err("expected ID"); |
| 825 | None |
| 826 | } |
| 827 | } |
| 828 | Token::String(_) => { |
| 829 | self.err("expected ID, not string"); |
| 830 | None |
| 831 | } |
| 832 | Token::Typeof(_, span, _) => { |
| 833 | self.tcx |
| 834 | .sess |
| 835 | .span_err(span, "cannot assign to a typeof expression"); |
| 836 | None |
| 837 | } |
| 838 | Token::Placeholder(hole, span) => match hole { |
| 839 | InlineAsmOperandRef::In { reg, value: _ } => { |
| 840 | self.check_reg(span, reg); |
| 841 | self.tcx |
| 842 | .sess |
| 843 | .span_err(span, "in register cannot be assigned to"); |
| 844 | None |
| 845 | } |
| 846 | InlineAsmOperandRef::Out { |
| 847 | reg, |
| 848 | late: _, |
| 849 | place, |
| 850 | } => { |
| 851 | self.check_reg(span, reg); |
| 852 | match place { |
| 853 | Some(place) => Some(OutRegister::Place(*place)), |
| 854 | None => { |
| 855 | self.tcx.sess.span_err(span, "missing place for register"); |
| 856 | None |
| 857 | } |
| 858 | } |
| 859 | } |
| 860 | InlineAsmOperandRef::InOut { |
| 861 | reg, |
| 862 | late: _, |
| 863 | in_value: _, |
| 864 | out_place, |