working on code
[bigint-presentation-code.git] / register_allocator / src / error.rs
1 use crate::{
2 index::{BlockIdx, InstIdx},
3 loc::{BaseTy, Ty},
4 };
5 use thiserror::Error;
6
7 #[derive(Debug, Error)]
8 pub enum Error {
9 #[error("can't create a vector of an only-scalar type: {base_ty:?}")]
10 TriedToCreateVectorOfOnlyScalarType { base_ty: BaseTy },
11 #[error("reg_len out of range")]
12 RegLenOutOfRange,
13 #[error("invalid reg_len")]
14 InvalidRegLen,
15 #[error("start not in valid range")]
16 StartNotInValidRange,
17 #[error("BaseTy mismatch")]
18 BaseTyMismatch,
19 #[error("invalid sub-Loc: offset and/or reg_len out of range")]
20 InvalidSubLocOutOfRange,
21 #[error("Ty mismatch: expected {expected_ty:?} got {ty:?}")]
22 TyMismatch {
23 ty: Option<Ty>,
24 expected_ty: Option<Ty>,
25 },
26 #[error("function doesn't have entry block")]
27 MissingEntryBlock,
28 #[error("instruction index is too big")]
29 InstIdxTooBig,
30 #[error("block has invalid start {start}, expected {expected_start}")]
31 BlockHasInvalidStart {
32 start: InstIdx,
33 expected_start: InstIdx,
34 },
35 #[error("block {block} doesn't contain any instructions")]
36 BlockIsEmpty { block: BlockIdx },
37 #[error("entry block must not have any block parameters")]
38 EntryBlockCantHaveParams,
39 #[error("entry block must not have any predecessors")]
40 EntryBlockCantHavePreds,
41 #[error("block end is out of range: {end}")]
42 BlockEndOutOfRange { end: InstIdx },
43 #[error("block's last instruction must be a block terminator: {term_idx}")]
44 BlocksLastInstMustBeTerm { term_idx: InstIdx },
45 #[error(
46 "block terminator instructions are only allowed as a block's last instruction: {inst_idx}"
47 )]
48 TermInstOnlyAllowedAtBlockEnd { inst_idx: InstIdx },
49 }
50
51 pub type Result<T, E = Error> = std::result::Result<T, E>;