Get the controlling type variable, or `INVALID` if `inst` isn't polymorphic.
(&self, inst: Inst)
| 1212 | |
| 1213 | /// Get the controlling type variable, or `INVALID` if `inst` isn't polymorphic. |
| 1214 | pub fn ctrl_typevar(&self, inst: Inst) -> Type { |
| 1215 | let constraints = self.insts[inst].opcode().constraints(); |
| 1216 | |
| 1217 | if !constraints.is_polymorphic() { |
| 1218 | types::INVALID |
| 1219 | } else if constraints.requires_typevar_operand() { |
| 1220 | // Not all instruction formats have a designated operand, but in that case |
| 1221 | // `requires_typevar_operand()` should never be true. |
| 1222 | self.value_type( |
| 1223 | self.insts[inst] |
| 1224 | .typevar_operand(&self.value_lists) |
| 1225 | .unwrap_or_else(|| { |
| 1226 | panic!( |
| 1227 | "Instruction format for {:?} doesn't have a designated operand", |
| 1228 | self.insts[inst] |
| 1229 | ) |
| 1230 | }), |
| 1231 | ) |
| 1232 | } else { |
| 1233 | self.value_type(self.first_result(inst)) |
| 1234 | } |
| 1235 | } |
| 1236 | } |
| 1237 | |
| 1238 | /// basic blocks. |
no test coverage detected