Pick argument and return types based on opcode constraints (#5947)
* Pick argument and return types based on opcode constraints Co-authored-by: Jamey Sharp <jsharp@fastly.com> * Lazily build the OPCODE_SIGNATURES list * Skip unsupported isplit/iconcat cases * Add an issue reference for the isplit/iconcat exemption * Refactor the deny lists to use exceptions!, and remove redundant entries --------- Co-authored-by: Jamey Sharp <jsharp@fastly.com>
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -651,6 +651,7 @@ dependencies = [
|
|||||||
"arbitrary",
|
"arbitrary",
|
||||||
"cranelift",
|
"cranelift",
|
||||||
"cranelift-native",
|
"cranelift-native",
|
||||||
|
"once_cell",
|
||||||
"target-lexicon",
|
"target-lexicon",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -16,4 +16,5 @@ cranelift-native = { workspace = true }
|
|||||||
|
|
||||||
anyhow = { workspace = true }
|
anyhow = { workspace = true }
|
||||||
arbitrary = "1.0.0"
|
arbitrary = "1.0.0"
|
||||||
|
once_cell = { workspace = true }
|
||||||
target-lexicon = { workspace = true, features = ["std"] }
|
target-lexicon = { workspace = true, features = ["std"] }
|
||||||
|
|||||||
@@ -23,23 +23,26 @@ pub trait CraneliftArbitrary {
|
|||||||
fn datavalue(&mut self, ty: Type) -> Result<DataValue>;
|
fn datavalue(&mut self, ty: Type) -> Result<DataValue>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CraneliftArbitrary for &mut Unstructured<'a> {
|
/// Returns the set of types that are valid for value generation, dependent on architecture.
|
||||||
fn _type(&mut self, architecture: Architecture) -> Result<Type> {
|
pub fn types_for_architecture(architecture: Architecture) -> &'static [Type] {
|
||||||
// TODO: It would be nice if we could get these directly from cranelift
|
// TODO: It would be nice if we could get these directly from cranelift
|
||||||
// TODO: RISCV does not support SIMD yet
|
// TODO: RISCV does not support SIMD yet
|
||||||
let supports_simd = !matches!(architecture, Architecture::Riscv64(_));
|
let supports_simd = !matches!(architecture, Architecture::Riscv64(_));
|
||||||
let choices = if supports_simd {
|
if supports_simd {
|
||||||
&[
|
&[
|
||||||
I8, I16, I32, I64, I128, // Scalar Integers
|
I8, I16, I32, I64, I128, // Scalar Integers
|
||||||
F32, F64, // Scalar Floats
|
F32, F64, // Scalar Floats
|
||||||
I8X16, I16X8, I32X4, I64X2, // SIMD Integers
|
I8X16, I16X8, I32X4, I64X2, // SIMD Integers
|
||||||
F32X4, F64X2, // SIMD Floats
|
F32X4, F64X2, // SIMD Floats
|
||||||
][..]
|
]
|
||||||
} else {
|
} else {
|
||||||
&[I8, I16, I32, I64, I128, F32, F64][..]
|
&[I8, I16, I32, I64, I128, F32, F64]
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(*self.choose(choices)?)
|
impl<'a> CraneliftArbitrary for &mut Unstructured<'a> {
|
||||||
|
fn _type(&mut self, architecture: Architecture) -> Result<Type> {
|
||||||
|
Ok(*self.choose(types_for_architecture(architecture))?)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn callconv(&mut self) -> Result<CallConv> {
|
fn callconv(&mut self) -> Result<CallConv> {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user