summaryrefslogtreecommitdiffstats
path: root/third_party/rust/cranelift-codegen/src/result.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /third_party/rust/cranelift-codegen/src/result.rs
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/cranelift-codegen/src/result.rs')
-rw-r--r--third_party/rust/cranelift-codegen/src/result.rs48
1 files changed, 48 insertions, 0 deletions
diff --git a/third_party/rust/cranelift-codegen/src/result.rs b/third_party/rust/cranelift-codegen/src/result.rs
new file mode 100644
index 0000000000..493545c151
--- /dev/null
+++ b/third_party/rust/cranelift-codegen/src/result.rs
@@ -0,0 +1,48 @@
+//! Result and error types representing the outcome of compiling a function.
+
+use crate::verifier::VerifierErrors;
+use std::string::String;
+use thiserror::Error;
+
+/// A compilation error.
+///
+/// When Cranelift fails to compile a function, it will return one of these error codes.
+#[derive(Error, Debug, PartialEq, Eq)]
+pub enum CodegenError {
+ /// A list of IR verifier errors.
+ ///
+ /// This always represents a bug, either in the code that generated IR for Cranelift, or a bug
+ /// in Cranelift itself.
+ #[error("Verifier errors")]
+ Verifier(#[from] VerifierErrors),
+
+ /// An implementation limit was exceeded.
+ ///
+ /// Cranelift can compile very large and complicated functions, but the [implementation has
+ /// limits][limits] that cause compilation to fail when they are exceeded.
+ ///
+ /// [limits]: https://github.com/bytecodealliance/wasmtime/blob/main/cranelift/docs/ir.md#implementation-limits
+ #[error("Implementation limit exceeded")]
+ ImplLimitExceeded,
+
+ /// The code size for the function is too large.
+ ///
+ /// Different target ISAs may impose a limit on the size of a compiled function. If that limit
+ /// is exceeded, compilation fails.
+ #[error("Code for function is too large")]
+ CodeTooLarge,
+
+ /// Something is not supported by the code generator. This might be an indication that a
+ /// feature is used without explicitly enabling it, or that something is temporarily
+ /// unsupported by a given target backend.
+ #[error("Unsupported feature: {0}")]
+ Unsupported(String),
+
+ /// A failure to map Cranelift register representation to a DWARF register representation.
+ #[cfg(feature = "unwind")]
+ #[error("Register mapping error")]
+ RegisterMappingError(crate::isa::unwind::systemv::RegisterMappingError),
+}
+
+/// A convenient alias for a `Result` that uses `CodegenError` as the error type.
+pub type CodegenResult<T> = Result<T, CodegenError>;