@@ -3,7 +3,7 @@ use crate::arm::types::parse_intrinsic_type;
33use crate :: common:: argument:: { Argument , ArgumentList } ;
44use crate :: common:: constraint:: Constraint ;
55use crate :: common:: intrinsic:: Intrinsic ;
6- use crate :: common:: intrinsic_helpers:: IntrinsicType ;
6+ use crate :: common:: intrinsic_helpers:: { IntrinsicType , TypeKind } ;
77use serde:: Deserialize ;
88use serde_json:: Value ;
99use std:: collections:: HashMap ;
@@ -90,18 +90,37 @@ fn json_to_intrinsic(
9090 . enumerate ( )
9191 . map ( |( i, arg) | {
9292 let ( type_name, arg_name) = Argument :: < ArmIntrinsicType > :: type_and_name_from_c ( & arg) ;
93+
94+ let arg_ty = parse_intrinsic_type ( type_name)
95+ . unwrap_or_else ( |_| panic ! ( "Failed to parse argument '{arg}'" ) ) ;
96+
9397 let metadata = intr. args_prep . as_mut ( ) ;
9498 let metadata = metadata. and_then ( |a| a. remove ( arg_name) ) ;
9599 let arg_prep: Option < ArgPrep > = metadata. and_then ( |a| a. try_into ( ) . ok ( ) ) ;
96- let constraint: Option < Constraint > = arg_prep. and_then ( |a| a. try_into ( ) . ok ( ) ) ;
97- let arg_ty = ArmIntrinsicType (
98- parse_intrinsic_type ( type_name)
99- . unwrap_or_else ( |_| panic ! ( "Failed to parse argument '{arg}'" ) ) ,
100+ let constraint: Option < Constraint > =
101+ arg_prep. and_then ( |a| a. try_into ( ) . ok ( ) ) . or_else ( || {
102+ if arg_ty. kind ( ) == TypeKind :: SvPattern {
103+ Some ( Constraint :: SvPattern )
104+ } else if arg_ty. kind ( ) == TypeKind :: SvPrefetchOp {
105+ Some ( Constraint :: SvPrefetchOp )
106+ } else if arg_name == "imm_rotation" {
107+ if name. starts_with ( "svcadd_" ) || name. starts_with ( "svqcadd_" ) {
108+ Some ( Constraint :: SvImmRotationAdd )
109+ } else {
110+ Some ( Constraint :: SvImmRotation )
111+ }
112+ } else {
113+ None
114+ }
115+ } ) ;
116+
117+ let mut arg = Argument :: < ArmIntrinsicType > :: new (
118+ i,
119+ String :: from ( arg_name) ,
120+ ArmIntrinsicType ( arg_ty) ,
121+ constraint,
100122 ) ;
101123
102- let mut arg =
103- Argument :: < ArmIntrinsicType > :: new ( i, String :: from ( arg_name) , arg_ty, constraint) ;
104-
105124 // The JSON doesn't list immediates as const
106125 let IntrinsicType {
107126 ref mut constant, ..
0 commit comments