@@ -16,8 +16,8 @@ use crate::{
16
16
arch:: Arch ,
17
17
diff:: { display:: InstructionPart , ArmArchVersion , ArmR9Usage , DiffObjConfig } ,
18
18
obj:: {
19
- InstructionArg , InstructionArgValue , InstructionRef , RelocationFlags , ResolvedRelocation ,
20
- ScannedInstruction , SymbolFlag , SymbolFlagSet , SymbolKind ,
19
+ InstructionRef , RelocationFlags , ResolvedRelocation , ScannedInstruction , SymbolFlag ,
20
+ SymbolFlagSet , SymbolKind ,
21
21
} ,
22
22
} ;
23
23
@@ -261,9 +261,9 @@ impl Arch for ArchArm {
261
261
cb : & mut dyn FnMut ( InstructionPart ) -> Result < ( ) > ,
262
262
) -> Result < ( ) > {
263
263
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 ) ) ?;
265
265
if ins == unarm:: Ins :: Data && relocation. is_some ( ) {
266
- cb ( InstructionPart :: Arg ( InstructionArg :: Reloc ) ) ?;
266
+ cb ( InstructionPart :: reloc ( ) ) ?;
267
267
} else {
268
268
push_args (
269
269
& parsed_ins,
@@ -396,143 +396,109 @@ fn push_args(
396
396
} )
397
397
| args:: Argument :: CoOption ( _) => {
398
398
deref = false ;
399
- arg_cb ( InstructionPart :: Basic ( "]" ) ) ?;
399
+ arg_cb ( InstructionPart :: basic ( "]" ) ) ?;
400
400
if writeback {
401
401
writeback = false ;
402
- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Value (
403
- InstructionArgValue :: Opaque ( "!" . into ( ) ) ,
404
- ) ) ) ?;
402
+ arg_cb ( InstructionPart :: opaque ( "!" ) ) ?;
405
403
}
406
404
}
407
405
_ => { }
408
406
}
409
407
}
410
408
411
409
if i > 0 {
412
- arg_cb ( InstructionPart :: Separator ) ?;
410
+ arg_cb ( InstructionPart :: separator ( ) ) ?;
413
411
}
414
412
415
413
if reloc_arg == Some ( i) {
416
- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Reloc ) ) ?;
414
+ arg_cb ( InstructionPart :: reloc ( ) ) ?;
417
415
} else {
418
416
match arg {
419
417
args:: Argument :: None => { }
420
418
args:: Argument :: Reg ( reg) => {
421
419
if reg. deref {
422
420
deref = true ;
423
- arg_cb ( InstructionPart :: Basic ( "[" ) ) ?;
421
+ arg_cb ( InstructionPart :: basic ( "[" ) ) ?;
424
422
}
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
+ ) ) ?;
430
426
if reg. writeback {
431
427
if reg. deref {
432
428
writeback = true ;
433
429
} else {
434
- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Value (
435
- InstructionArgValue :: Opaque ( "!" . into ( ) ) ,
436
- ) ) ) ?;
430
+ arg_cb ( InstructionPart :: opaque ( "!" ) ) ?;
437
431
}
438
432
}
439
433
}
440
434
args:: Argument :: RegList ( reg_list) => {
441
- arg_cb ( InstructionPart :: Basic ( "{" ) ) ?;
435
+ arg_cb ( InstructionPart :: basic ( "{" ) ) ?;
442
436
let mut first = true ;
443
437
for i in 0 ..16 {
444
438
if ( reg_list. regs & ( 1 << i) ) != 0 {
445
439
if !first {
446
- arg_cb ( InstructionPart :: Separator ) ?;
440
+ arg_cb ( InstructionPart :: separator ( ) ) ?;
447
441
}
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
+ ) ) ?;
456
447
first = false ;
457
448
}
458
449
}
459
- arg_cb ( InstructionPart :: Basic ( "}" ) ) ?;
450
+ arg_cb ( InstructionPart :: basic ( "}" ) ) ?;
460
451
if reg_list. user_mode {
461
- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Value (
462
- InstructionArgValue :: Opaque ( "^" . into ( ) ) ,
463
- ) ) ) ?;
452
+ arg_cb ( InstructionPart :: opaque ( "^" ) ) ?;
464
453
}
465
454
}
466
455
args:: Argument :: UImm ( value)
467
456
| args:: Argument :: CoOpcode ( value)
468
457
| 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) ) ?;
473
460
}
474
461
args:: Argument :: SImm ( value)
475
462
| 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) ) ?;
480
465
}
481
466
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) ) ) ?;
484
468
}
485
469
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 ( "}" ) ) ?;
491
473
}
492
474
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) ) ) ?;
496
476
}
497
477
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 ) ) ?;
505
481
}
506
482
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
+ ) ) ?;
516
488
}
517
489
args:: Argument :: OffsetReg ( offset) => {
518
490
if !offset. add {
519
- arg_cb ( InstructionPart :: Basic ( "-" ) ) ?;
491
+ arg_cb ( InstructionPart :: basic ( "-" ) ) ?;
520
492
}
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
+ ) ) ?;
526
496
}
527
497
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 ) ) ?;
532
500
if mode. writeback {
533
- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Value (
534
- InstructionArgValue :: Opaque ( "!" . into ( ) ) ,
535
- ) ) ) ?;
501
+ arg_cb ( InstructionPart :: opaque ( "!" ) ) ?;
536
502
}
537
503
}
538
504
args:: Argument :: CoReg ( _)
@@ -541,21 +507,17 @@ fn push_args(
541
507
| args:: Argument :: Shift ( _)
542
508
| args:: Argument :: CpsrFlags ( _)
543
509
| 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
+ ) ) ?;
549
513
}
550
514
}
551
515
}
552
516
}
553
517
if deref {
554
- arg_cb ( InstructionPart :: Basic ( "]" ) ) ?;
518
+ arg_cb ( InstructionPart :: basic ( "]" ) ) ?;
555
519
if writeback {
556
- arg_cb ( InstructionPart :: Arg ( InstructionArg :: Value ( InstructionArgValue :: Opaque (
557
- "!" . into ( ) ,
558
- ) ) ) ) ?;
520
+ arg_cb ( InstructionPart :: opaque ( "!" ) ) ?;
559
521
}
560
522
}
561
523
Ok ( ( ) )
0 commit comments