working on code
[bigint-presentation-code.git] / register_allocator / src / error.rs
index a07fb75468bdbdb3a5ebd84c97504619e8c7b185..104795e574bef51317b76603289db7ea336e7a5d 100644 (file)
@@ -1,4 +1,7 @@
-use crate::loc::{BaseTy, Ty};
+use crate::{
+    index::{BlockIdx, InstIdx},
+    loc::{BaseTy, Ty},
+};
 use thiserror::Error;
 
 #[derive(Debug, Error)]
@@ -20,6 +23,29 @@ pub enum Error {
         ty: Option<Ty>,
         expected_ty: Option<Ty>,
     },
+    #[error("function doesn't have entry block")]
+    MissingEntryBlock,
+    #[error("instruction index is too big")]
+    InstIdxTooBig,
+    #[error("block has invalid start {start}, expected {expected_start}")]
+    BlockHasInvalidStart {
+        start: InstIdx,
+        expected_start: InstIdx,
+    },
+    #[error("block {block} doesn't contain any instructions")]
+    BlockIsEmpty { block: BlockIdx },
+    #[error("entry block must not have any block parameters")]
+    EntryBlockCantHaveParams,
+    #[error("entry block must not have any predecessors")]
+    EntryBlockCantHavePreds,
+    #[error("block end is out of range: {end}")]
+    BlockEndOutOfRange { end: InstIdx },
+    #[error("block's last instruction must be a block terminator: {term_idx}")]
+    BlocksLastInstMustBeTerm { term_idx: InstIdx },
+    #[error(
+        "block terminator instructions are only allowed as a block's last instruction: {inst_idx}"
+    )]
+    TermInstOnlyAllowedAtBlockEnd { inst_idx: InstIdx },
 }
 
 pub type Result<T, E = Error> = std::result::Result<T, E>;