@@ -16,8 +16,8 @@ use crate::{
1616 arch:: Arch ,
1717 diff:: { display:: InstructionPart , ArmArchVersion , ArmR9Usage , DiffObjConfig } ,
1818 obj:: {
19- InstructionArg , InstructionArgValue , InstructionRef , RelocationFlags , ResolvedRelocation ,
20- ScannedInstruction , SymbolFlag , SymbolFlagSet , SymbolKind ,
19+ InstructionRef , RelocationFlags , ResolvedRelocation , ScannedInstruction , SymbolFlag ,
20+ SymbolFlagSet , SymbolKind ,
2121 } ,
2222} ;
2323
@@ -261,9 +261,9 @@ impl Arch for ArchArm {
261261 cb : & mut dyn FnMut ( InstructionPart ) -> Result < ( ) > ,
262262 ) -> Result < ( ) > {
263263 let ( ins, parsed_ins) = self . parse_ins_ref ( ins_ref, code, diff_config) ?;
264- cb ( InstructionPart :: Opcode ( Cow :: Borrowed ( parsed_ins. mnemonic ) , ins_ref. opcode ) ) ?;
264+ cb ( InstructionPart :: opcode ( parsed_ins. mnemonic , ins_ref. opcode ) ) ?;
265265 if ins == unarm:: Ins :: Data && relocation. is_some ( ) {
266- cb ( InstructionPart :: Arg ( InstructionArg :: Reloc ) ) ?;
266+ cb ( InstructionPart :: reloc ( ) ) ?;
267267 } else {
268268 push_args (
269269 & parsed_ins,
@@ -396,143 +396,109 @@ fn push_args(
396396 } )
397397 | args:: Argument :: CoOption ( _) => {
398398 deref = false ;
399- arg_cb ( InstructionPart :: Basic ( "]" ) ) ?;
399+ arg_cb ( InstructionPart :: basic ( "]" ) ) ?;
400400 if writeback {
401401 writeback = false ;
402- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Value (
403- InstructionArgValue :: Opaque ( "!" . into ( ) ) ,
404- ) ) ) ?;
402+ arg_cb ( InstructionPart :: opaque ( "!" ) ) ?;
405403 }
406404 }
407405 _ => { }
408406 }
409407 }
410408
411409 if i > 0 {
412- arg_cb ( InstructionPart :: Separator ) ?;
410+ arg_cb ( InstructionPart :: separator ( ) ) ?;
413411 }
414412
415413 if reloc_arg == Some ( i) {
416- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Reloc ) ) ?;
414+ arg_cb ( InstructionPart :: reloc ( ) ) ?;
417415 } else {
418416 match arg {
419417 args:: Argument :: None => { }
420418 args:: Argument :: Reg ( reg) => {
421419 if reg. deref {
422420 deref = true ;
423- arg_cb ( InstructionPart :: Basic ( "[" ) ) ?;
421+ arg_cb ( InstructionPart :: basic ( "[" ) ) ?;
424422 }
425- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Value (
426- InstructionArgValue :: Opaque (
427- reg. reg . display ( display_options. reg_names ) . to_string ( ) . into ( ) ,
428- ) ,
429- ) ) ) ?;
423+ arg_cb ( InstructionPart :: opaque (
424+ reg. reg . display ( display_options. reg_names ) . to_string ( ) ,
425+ ) ) ?;
430426 if reg. writeback {
431427 if reg. deref {
432428 writeback = true ;
433429 } else {
434- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Value (
435- InstructionArgValue :: Opaque ( "!" . into ( ) ) ,
436- ) ) ) ?;
430+ arg_cb ( InstructionPart :: opaque ( "!" ) ) ?;
437431 }
438432 }
439433 }
440434 args:: Argument :: RegList ( reg_list) => {
441- arg_cb ( InstructionPart :: Basic ( "{" ) ) ?;
435+ arg_cb ( InstructionPart :: basic ( "{" ) ) ?;
442436 let mut first = true ;
443437 for i in 0 ..16 {
444438 if ( reg_list. regs & ( 1 << i) ) != 0 {
445439 if !first {
446- arg_cb ( InstructionPart :: Separator ) ?;
440+ arg_cb ( InstructionPart :: separator ( ) ) ?;
447441 }
448- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Value (
449- InstructionArgValue :: Opaque (
450- args:: Register :: parse ( i)
451- . display ( display_options. reg_names )
452- . to_string ( )
453- . into ( ) ,
454- ) ,
455- ) ) ) ?;
442+ arg_cb ( InstructionPart :: opaque (
443+ args:: Register :: parse ( i)
444+ . display ( display_options. reg_names )
445+ . to_string ( ) ,
446+ ) ) ?;
456447 first = false ;
457448 }
458449 }
459- arg_cb ( InstructionPart :: Basic ( "}" ) ) ?;
450+ arg_cb ( InstructionPart :: basic ( "}" ) ) ?;
460451 if reg_list. user_mode {
461- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Value (
462- InstructionArgValue :: Opaque ( "^" . into ( ) ) ,
463- ) ) ) ?;
452+ arg_cb ( InstructionPart :: opaque ( "^" ) ) ?;
464453 }
465454 }
466455 args:: Argument :: UImm ( value)
467456 | args:: Argument :: CoOpcode ( value)
468457 | args:: Argument :: SatImm ( value) => {
469- arg_cb ( InstructionPart :: Basic ( "#" ) ) ?;
470- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Value (
471- InstructionArgValue :: Unsigned ( * value as u64 ) ,
472- ) ) ) ?;
458+ arg_cb ( InstructionPart :: basic ( "#" ) ) ?;
459+ arg_cb ( InstructionPart :: unsigned ( * value) ) ?;
473460 }
474461 args:: Argument :: SImm ( value)
475462 | args:: Argument :: OffsetImm ( args:: OffsetImm { post_indexed : _, value } ) => {
476- arg_cb ( InstructionPart :: Basic ( "#" ) ) ?;
477- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Value (
478- InstructionArgValue :: Signed ( * value as i64 ) ,
479- ) ) ) ?;
463+ arg_cb ( InstructionPart :: basic ( "#" ) ) ?;
464+ arg_cb ( InstructionPart :: signed ( * value) ) ?;
480465 }
481466 args:: Argument :: BranchDest ( value) => {
482- let dest = cur_addr. wrapping_add_signed ( * value) as u64 ;
483- arg_cb ( InstructionPart :: Arg ( InstructionArg :: BranchDest ( dest) ) ) ?;
467+ arg_cb ( InstructionPart :: branch_dest ( cur_addr. wrapping_add_signed ( * value) ) ) ?;
484468 }
485469 args:: Argument :: CoOption ( value) => {
486- arg_cb ( InstructionPart :: Basic ( "{" ) ) ?;
487- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Value (
488- InstructionArgValue :: Unsigned ( * value as u64 ) ,
489- ) ) ) ?;
490- arg_cb ( InstructionPart :: Basic ( "}" ) ) ?;
470+ arg_cb ( InstructionPart :: basic ( "{" ) ) ?;
471+ arg_cb ( InstructionPart :: unsigned ( * value) ) ?;
472+ arg_cb ( InstructionPart :: basic ( "}" ) ) ?;
491473 }
492474 args:: Argument :: CoprocNum ( value) => {
493- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Value (
494- InstructionArgValue :: Opaque ( format ! ( "p{}" , value) . into ( ) ) ,
495- ) ) ) ?;
475+ arg_cb ( InstructionPart :: opaque ( format ! ( "p{}" , value) ) ) ?;
496476 }
497477 args:: Argument :: ShiftImm ( shift) => {
498- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Value (
499- InstructionArgValue :: Opaque ( shift. op . to_string ( ) . into ( ) ) ,
500- ) ) ) ?;
501- arg_cb ( InstructionPart :: Basic ( " #" ) ) ?;
502- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Value (
503- InstructionArgValue :: Unsigned ( shift. imm as u64 ) ,
504- ) ) ) ?;
478+ arg_cb ( InstructionPart :: opaque ( shift. op . to_string ( ) ) ) ?;
479+ arg_cb ( InstructionPart :: basic ( " #" ) ) ?;
480+ arg_cb ( InstructionPart :: unsigned ( shift. imm ) ) ?;
505481 }
506482 args:: Argument :: ShiftReg ( shift) => {
507- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Value (
508- InstructionArgValue :: Opaque ( shift. op . to_string ( ) . into ( ) ) ,
509- ) ) ) ?;
510- arg_cb ( InstructionPart :: Basic ( " " ) ) ?;
511- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Value (
512- InstructionArgValue :: Opaque (
513- shift. reg . display ( display_options. reg_names ) . to_string ( ) . into ( ) ,
514- ) ,
515- ) ) ) ?;
483+ arg_cb ( InstructionPart :: opaque ( shift. op . to_string ( ) ) ) ?;
484+ arg_cb ( InstructionPart :: basic ( " " ) ) ?;
485+ arg_cb ( InstructionPart :: opaque (
486+ shift. reg . display ( display_options. reg_names ) . to_string ( ) ,
487+ ) ) ?;
516488 }
517489 args:: Argument :: OffsetReg ( offset) => {
518490 if !offset. add {
519- arg_cb ( InstructionPart :: Basic ( "-" ) ) ?;
491+ arg_cb ( InstructionPart :: basic ( "-" ) ) ?;
520492 }
521- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Value (
522- InstructionArgValue :: Opaque (
523- offset. reg . display ( display_options. reg_names ) . to_string ( ) . into ( ) ,
524- ) ,
525- ) ) ) ?;
493+ arg_cb ( InstructionPart :: opaque (
494+ offset. reg . display ( display_options. reg_names ) . to_string ( ) ,
495+ ) ) ?;
526496 }
527497 args:: Argument :: CpsrMode ( mode) => {
528- arg_cb ( InstructionPart :: Basic ( "#" ) ) ?;
529- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Value (
530- InstructionArgValue :: Unsigned ( mode. mode as u64 ) ,
531- ) ) ) ?;
498+ arg_cb ( InstructionPart :: basic ( "#" ) ) ?;
499+ arg_cb ( InstructionPart :: unsigned ( mode. mode ) ) ?;
532500 if mode. writeback {
533- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Value (
534- InstructionArgValue :: Opaque ( "!" . into ( ) ) ,
535- ) ) ) ?;
501+ arg_cb ( InstructionPart :: opaque ( "!" ) ) ?;
536502 }
537503 }
538504 args:: Argument :: CoReg ( _)
@@ -541,21 +507,17 @@ fn push_args(
541507 | args:: Argument :: Shift ( _)
542508 | args:: Argument :: CpsrFlags ( _)
543509 | args:: Argument :: Endian ( _) => {
544- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Value (
545- InstructionArgValue :: Opaque (
546- arg. display ( display_options, None ) . to_string ( ) . into ( ) ,
547- ) ,
548- ) ) ) ?;
510+ arg_cb ( InstructionPart :: opaque (
511+ arg. display ( display_options, None ) . to_string ( ) ,
512+ ) ) ?;
549513 }
550514 }
551515 }
552516 }
553517 if deref {
554- arg_cb ( InstructionPart :: Basic ( "]" ) ) ?;
518+ arg_cb ( InstructionPart :: basic ( "]" ) ) ?;
555519 if writeback {
556- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Value ( InstructionArgValue :: Opaque (
557- "!" . into ( ) ,
558- ) ) ) ) ?;
520+ arg_cb ( InstructionPart :: opaque ( "!" ) ) ?;
559521 }
560522 }
561523 Ok ( ( ) )
0 commit comments