]> git.lizzy.rs Git - rust.git/commitdiff
Use cranelift's `Type::int` instead of doing the match myself
authorScott McMurray <scottmcm@users.noreply.github.com>
Tue, 1 Jun 2021 13:19:49 +0000 (06:19 -0700)
committerScott McMurray <scottmcm@users.noreply.github.com>
Thu, 8 Jul 2021 21:55:58 +0000 (14:55 -0700)
<https://docs.rs/cranelift-codegen/0.74.0/cranelift_codegen/ir/types/struct.Type.html#method.int>

src/intrinsics/mod.rs

index 31f7e0d4e37b1aae622523e1a44f3089c084570f..3979886e10cfc17997d1a30362860cdb85adf6c1 100644 (file)
@@ -1118,14 +1118,7 @@ fn swap(bcx: &mut FunctionBuilder<'_>, v: Value) -> Value {
 
         raw_eq, <T>(v lhs_ref, v rhs_ref) {
             fn type_by_size(size: Size) -> Option<Type> {
-                Some(match size.bits() {
-                    8 => types::I8,
-                    16 => types::I16,
-                    32 => types::I32,
-                    64 => types::I64,
-                    128 => types::I128,
-                    _ => return None,
-                })
+                Type::int(size.bits().try_into().ok()?)
             }
 
             let size = fx.layout_of(T).layout.size;