| 895 | } |
| 896 | |
| 897 | fn parse_id_in<'a>( |
| 898 | &mut self, |
| 899 | id_map: &mut FxHashMap<&'a str, Word>, |
| 900 | token: Token<'a, 'cx, 'tcx>, |
| 901 | ) -> Option<Word> { |
| 902 | match token { |
| 903 | Token::Word(word) => { |
| 904 | if let Some(id) = word.strip_prefix('%') { |
| 905 | Some(*id_map.entry(id).or_insert_with(|| self.emit().id())) |
| 906 | } else { |
| 907 | self.err("expected ID"); |
| 908 | None |
| 909 | } |
| 910 | } |
| 911 | Token::String(_) => { |
| 912 | self.err("expected ID, not string"); |
| 913 | None |
| 914 | } |
| 915 | Token::Typeof(hole, span, kind) => match hole { |
| 916 | InlineAsmOperandRef::In { reg, value } => { |
| 917 | self.check_reg(span, reg); |
| 918 | let ty = value.immediate().ty; |
| 919 | Some(match kind { |
| 920 | TypeofKind::Plain => ty, |
| 921 | TypeofKind::Dereference => match self.lookup_type(ty) { |
| 922 | SpirvType::Pointer { pointee } => pointee, |
| 923 | other => { |
| 924 | self.tcx.sess.span_err( |
| 925 | span, |
| 926 | format!( |
| 927 | "cannot use typeof* on non-pointer type: {}", |
| 928 | other.debug(ty, self) |
| 929 | ), |
| 930 | ); |
| 931 | ty |
| 932 | } |
| 933 | }, |
| 934 | }) |
| 935 | } |
| 936 | InlineAsmOperandRef::Out { |
| 937 | reg, |
| 938 | late: _, |
| 939 | place, |
| 940 | } => { |
| 941 | self.check_reg(span, reg); |
| 942 | match place { |
| 943 | Some(place) => match self.lookup_type(place.llval.ty) { |
| 944 | SpirvType::Pointer { pointee } => Some(pointee), |
| 945 | other => { |
| 946 | self.tcx.sess.span_err( |
| 947 | span, |
| 948 | format!( |
| 949 | "out register type not pointer: {}", |
| 950 | other.debug(place.llval.ty, self) |
| 951 | ), |
| 952 | ); |
| 953 | None |
| 954 | } |