Skip to content

Commit 5e8b150

Browse files
committed
[AArch64InstPrinter] Change printAddSubImm to comment imm value when shifted
Add a comment when there is a shifted value, add x9, x0, #291, lsl #12 ; =1191936 but not when the immediate value is unshifted, subs x9, x0, #256 ; =256 when the comment adds nothing additional to the reader. Differential Revision: https://reviews.llvm.org/D107196 (cherry picked from commit 0d8cd4e)
1 parent 1f54181 commit 5e8b150

File tree

117 files changed

+1025
-1025
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+1025
-1025
lines changed

llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1026,11 +1026,11 @@ void AArch64InstPrinter::printAddSubImm(const MCInst *MI, unsigned OpNum,
10261026
unsigned Shift =
10271027
AArch64_AM::getShiftValue(MI->getOperand(OpNum + 1).getImm());
10281028
O << '#' << formatImm(Val);
1029-
if (Shift != 0)
1029+
if (Shift != 0) {
10301030
printShifter(MI, OpNum + 1, STI, O);
1031-
1032-
if (CommentStream)
1033-
*CommentStream << '=' << formatImm(Val << Shift) << '\n';
1031+
if (CommentStream)
1032+
*CommentStream << '=' << formatImm(Val << Shift) << '\n';
1033+
}
10341034
} else {
10351035
assert(MO.isExpr() && "Unexpected operand type!");
10361036
MO.getExpr()->print(O, &MAI);

llvm/test/CodeGen/AArch64/GlobalISel/arm64-atomic-128.ll

+32-32
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ define void @val_compare_and_swap(i128* %p, i128 %oldval, i128 %newval) {
6565
;
6666
; CHECK-CAS-O0-LABEL: val_compare_and_swap:
6767
; CHECK-CAS-O0: // %bb.0:
68-
; CHECK-CAS-O0-NEXT: sub sp, sp, #16 // =16
68+
; CHECK-CAS-O0-NEXT: sub sp, sp, #16
6969
; CHECK-CAS-O0-NEXT: .cfi_def_cfa_offset 16
7070
; CHECK-CAS-O0-NEXT: str x3, [sp, #8] // 8-byte Folded Spill
7171
; CHECK-CAS-O0-NEXT: mov x1, x5
@@ -81,7 +81,7 @@ define void @val_compare_and_swap(i128* %p, i128 %oldval, i128 %newval) {
8181
; CHECK-CAS-O0-NEXT: mov v0.d[0], x9
8282
; CHECK-CAS-O0-NEXT: mov v0.d[1], x8
8383
; CHECK-CAS-O0-NEXT: str q0, [x0]
84-
; CHECK-CAS-O0-NEXT: add sp, sp, #16 // =16
84+
; CHECK-CAS-O0-NEXT: add sp, sp, #16
8585
; CHECK-CAS-O0-NEXT: ret
8686

8787
%pair = cmpxchg i128* %p, i128 %oldval, i128 %newval acquire acquire
@@ -150,7 +150,7 @@ define void @val_compare_and_swap_monotonic_seqcst(i128* %p, i128 %oldval, i128
150150
;
151151
; CHECK-CAS-O0-LABEL: val_compare_and_swap_monotonic_seqcst:
152152
; CHECK-CAS-O0: // %bb.0:
153-
; CHECK-CAS-O0-NEXT: sub sp, sp, #16 // =16
153+
; CHECK-CAS-O0-NEXT: sub sp, sp, #16
154154
; CHECK-CAS-O0-NEXT: .cfi_def_cfa_offset 16
155155
; CHECK-CAS-O0-NEXT: str x3, [sp, #8] // 8-byte Folded Spill
156156
; CHECK-CAS-O0-NEXT: mov x1, x5
@@ -166,7 +166,7 @@ define void @val_compare_and_swap_monotonic_seqcst(i128* %p, i128 %oldval, i128
166166
; CHECK-CAS-O0-NEXT: mov v0.d[0], x9
167167
; CHECK-CAS-O0-NEXT: mov v0.d[1], x8
168168
; CHECK-CAS-O0-NEXT: str q0, [x0]
169-
; CHECK-CAS-O0-NEXT: add sp, sp, #16 // =16
169+
; CHECK-CAS-O0-NEXT: add sp, sp, #16
170170
; CHECK-CAS-O0-NEXT: ret
171171

172172
%pair = cmpxchg i128* %p, i128 %oldval, i128 %newval monotonic seq_cst
@@ -235,7 +235,7 @@ define void @val_compare_and_swap_release_acquire(i128* %p, i128 %oldval, i128 %
235235
;
236236
; CHECK-CAS-O0-LABEL: val_compare_and_swap_release_acquire:
237237
; CHECK-CAS-O0: // %bb.0:
238-
; CHECK-CAS-O0-NEXT: sub sp, sp, #16 // =16
238+
; CHECK-CAS-O0-NEXT: sub sp, sp, #16
239239
; CHECK-CAS-O0-NEXT: .cfi_def_cfa_offset 16
240240
; CHECK-CAS-O0-NEXT: str x3, [sp, #8] // 8-byte Folded Spill
241241
; CHECK-CAS-O0-NEXT: mov x1, x5
@@ -251,7 +251,7 @@ define void @val_compare_and_swap_release_acquire(i128* %p, i128 %oldval, i128 %
251251
; CHECK-CAS-O0-NEXT: mov v0.d[0], x9
252252
; CHECK-CAS-O0-NEXT: mov v0.d[1], x8
253253
; CHECK-CAS-O0-NEXT: str q0, [x0]
254-
; CHECK-CAS-O0-NEXT: add sp, sp, #16 // =16
254+
; CHECK-CAS-O0-NEXT: add sp, sp, #16
255255
; CHECK-CAS-O0-NEXT: ret
256256

257257
%pair = cmpxchg i128* %p, i128 %oldval, i128 %newval release acquire
@@ -320,7 +320,7 @@ define void @val_compare_and_swap_monotonic(i128* %p, i128 %oldval, i128 %newval
320320
;
321321
; CHECK-CAS-O0-LABEL: val_compare_and_swap_monotonic:
322322
; CHECK-CAS-O0: // %bb.0:
323-
; CHECK-CAS-O0-NEXT: sub sp, sp, #16 // =16
323+
; CHECK-CAS-O0-NEXT: sub sp, sp, #16
324324
; CHECK-CAS-O0-NEXT: .cfi_def_cfa_offset 16
325325
; CHECK-CAS-O0-NEXT: str x3, [sp, #8] // 8-byte Folded Spill
326326
; CHECK-CAS-O0-NEXT: mov x1, x5
@@ -336,7 +336,7 @@ define void @val_compare_and_swap_monotonic(i128* %p, i128 %oldval, i128 %newval
336336
; CHECK-CAS-O0-NEXT: mov v0.d[0], x9
337337
; CHECK-CAS-O0-NEXT: mov v0.d[1], x8
338338
; CHECK-CAS-O0-NEXT: str q0, [x0]
339-
; CHECK-CAS-O0-NEXT: add sp, sp, #16 // =16
339+
; CHECK-CAS-O0-NEXT: add sp, sp, #16
340340
; CHECK-CAS-O0-NEXT: ret
341341
%pair = cmpxchg i128* %p, i128 %oldval, i128 %newval release acquire
342342
%val = extractvalue { i128, i1 } %pair, 0
@@ -348,7 +348,7 @@ define void @atomic_load_relaxed(i64, i64, i128* %p, i128* %p2) {
348348
; CHECK-LLSC-O1-LABEL: atomic_load_relaxed:
349349
; CHECK-LLSC-O1: // %bb.0:
350350
; CHECK-LLSC-O1-NEXT: mov w8, #64
351-
; CHECK-LLSC-O1-NEXT: sub x9, x8, #64 // =64
351+
; CHECK-LLSC-O1-NEXT: sub x9, x8, #64
352352
; CHECK-LLSC-O1-NEXT: .LBB4_1: // %atomicrmw.start
353353
; CHECK-LLSC-O1-NEXT: // =>This Inner Loop Header: Depth=1
354354
; CHECK-LLSC-O1-NEXT: ldxp x10, x8, [x2]
@@ -365,7 +365,7 @@ define void @atomic_load_relaxed(i64, i64, i128* %p, i128* %p2) {
365365
; CHECK-CAS-O1-LABEL: atomic_load_relaxed:
366366
; CHECK-CAS-O1: // %bb.0:
367367
; CHECK-CAS-O1-NEXT: mov w8, #64
368-
; CHECK-CAS-O1-NEXT: sub x9, x8, #64 // =64
368+
; CHECK-CAS-O1-NEXT: sub x9, x8, #64
369369
; CHECK-CAS-O1-NEXT: .LBB4_1: // %atomicrmw.start
370370
; CHECK-CAS-O1-NEXT: // =>This Inner Loop Header: Depth=1
371371
; CHECK-CAS-O1-NEXT: ldxp x10, x8, [x2]
@@ -381,7 +381,7 @@ define void @atomic_load_relaxed(i64, i64, i128* %p, i128* %p2) {
381381
;
382382
; CHECK-LLSC-O0-LABEL: atomic_load_relaxed:
383383
; CHECK-LLSC-O0: // %bb.0:
384-
; CHECK-LLSC-O0-NEXT: sub sp, sp, #64 // =64
384+
; CHECK-LLSC-O0-NEXT: sub sp, sp, #64
385385
; CHECK-LLSC-O0-NEXT: .cfi_def_cfa_offset 64
386386
; CHECK-LLSC-O0-NEXT: str x2, [sp, #48] // 8-byte Folded Spill
387387
; CHECK-LLSC-O0-NEXT: str x3, [sp, #56] // 8-byte Folded Spill
@@ -395,17 +395,17 @@ define void @atomic_load_relaxed(i64, i64, i128* %p, i128* %p2) {
395395
; CHECK-LLSC-O0-NEXT: mov w10, #64
396396
; CHECK-LLSC-O0-NEXT: // kill: def $x10 killed $w10
397397
; CHECK-LLSC-O0-NEXT: str x10, [sp, #8] // 8-byte Folded Spill
398-
; CHECK-LLSC-O0-NEXT: subs x16, x10, #64 // =64
399-
; CHECK-LLSC-O0-NEXT: subs x13, x8, #64 // =64
398+
; CHECK-LLSC-O0-NEXT: subs x16, x10, #64
399+
; CHECK-LLSC-O0-NEXT: subs x13, x8, #64
400400
; CHECK-LLSC-O0-NEXT: lsl x14, x15, x10
401401
; CHECK-LLSC-O0-NEXT: lsr x13, x15, x13
402402
; CHECK-LLSC-O0-NEXT: orr x13, x13, x12
403403
; CHECK-LLSC-O0-NEXT: lsl x15, x15, x16
404-
; CHECK-LLSC-O0-NEXT: subs x16, x10, #64 // =64
404+
; CHECK-LLSC-O0-NEXT: subs x16, x10, #64
405405
; CHECK-LLSC-O0-NEXT: csel x14, x14, x12, lo
406-
; CHECK-LLSC-O0-NEXT: subs x16, x10, #64 // =64
406+
; CHECK-LLSC-O0-NEXT: subs x16, x10, #64
407407
; CHECK-LLSC-O0-NEXT: csel x13, x13, x15, lo
408-
; CHECK-LLSC-O0-NEXT: subs x15, x10, #0 // =0
408+
; CHECK-LLSC-O0-NEXT: subs x15, x10, #0
409409
; CHECK-LLSC-O0-NEXT: csel x13, x12, x13, eq
410410
; CHECK-LLSC-O0-NEXT: orr x9, x9, x14
411411
; CHECK-LLSC-O0-NEXT: orr x12, x12, x13
@@ -414,27 +414,27 @@ define void @atomic_load_relaxed(i64, i64, i128* %p, i128* %p2) {
414414
; CHECK-LLSC-O0-NEXT: str q0, [sp, #16] // 16-byte Folded Spill
415415
; CHECK-LLSC-O0-NEXT: mov v0.d[1], x12
416416
; CHECK-LLSC-O0-NEXT: str q0, [sp, #32] // 16-byte Folded Spill
417-
; CHECK-LLSC-O0-NEXT: subs x13, x10, #64 // =64
418-
; CHECK-LLSC-O0-NEXT: subs x8, x8, #64 // =64
417+
; CHECK-LLSC-O0-NEXT: subs x13, x10, #64
418+
; CHECK-LLSC-O0-NEXT: subs x8, x8, #64
419419
; CHECK-LLSC-O0-NEXT: lsl x8, x12, x8
420420
; CHECK-LLSC-O0-NEXT: orr x8, x8, x9, lsr #0
421421
; CHECK-LLSC-O0-NEXT: lsr x12, x12, x13
422-
; CHECK-LLSC-O0-NEXT: subs x13, x10, #64 // =64
422+
; CHECK-LLSC-O0-NEXT: subs x13, x10, #64
423423
; CHECK-LLSC-O0-NEXT: csel x8, x8, x12, lo
424-
; CHECK-LLSC-O0-NEXT: subs x10, x10, #0 // =0
424+
; CHECK-LLSC-O0-NEXT: subs x10, x10, #0
425425
; CHECK-LLSC-O0-NEXT: csel x10, x9, x8, eq
426426
; CHECK-LLSC-O0-NEXT: stxp w8, x9, x10, [x11]
427427
; CHECK-LLSC-O0-NEXT: cbnz w8, .LBB4_1
428428
; CHECK-LLSC-O0-NEXT: // %bb.2: // %atomicrmw.end
429429
; CHECK-LLSC-O0-NEXT: ldr q0, [sp, #32] // 16-byte Folded Reload
430430
; CHECK-LLSC-O0-NEXT: ldr x8, [sp, #56] // 8-byte Folded Reload
431431
; CHECK-LLSC-O0-NEXT: str q0, [x8]
432-
; CHECK-LLSC-O0-NEXT: add sp, sp, #64 // =64
432+
; CHECK-LLSC-O0-NEXT: add sp, sp, #64
433433
; CHECK-LLSC-O0-NEXT: ret
434434
;
435435
; CHECK-CAS-O0-LABEL: atomic_load_relaxed:
436436
; CHECK-CAS-O0: // %bb.0:
437-
; CHECK-CAS-O0-NEXT: sub sp, sp, #64 // =64
437+
; CHECK-CAS-O0-NEXT: sub sp, sp, #64
438438
; CHECK-CAS-O0-NEXT: .cfi_def_cfa_offset 64
439439
; CHECK-CAS-O0-NEXT: str x2, [sp, #48] // 8-byte Folded Spill
440440
; CHECK-CAS-O0-NEXT: str x3, [sp, #56] // 8-byte Folded Spill
@@ -448,17 +448,17 @@ define void @atomic_load_relaxed(i64, i64, i128* %p, i128* %p2) {
448448
; CHECK-CAS-O0-NEXT: mov w10, #64
449449
; CHECK-CAS-O0-NEXT: // kill: def $x10 killed $w10
450450
; CHECK-CAS-O0-NEXT: str x10, [sp, #8] // 8-byte Folded Spill
451-
; CHECK-CAS-O0-NEXT: subs x16, x10, #64 // =64
452-
; CHECK-CAS-O0-NEXT: subs x13, x8, #64 // =64
451+
; CHECK-CAS-O0-NEXT: subs x16, x10, #64
452+
; CHECK-CAS-O0-NEXT: subs x13, x8, #64
453453
; CHECK-CAS-O0-NEXT: lsl x14, x15, x10
454454
; CHECK-CAS-O0-NEXT: lsr x13, x15, x13
455455
; CHECK-CAS-O0-NEXT: orr x13, x13, x12
456456
; CHECK-CAS-O0-NEXT: lsl x15, x15, x16
457-
; CHECK-CAS-O0-NEXT: subs x16, x10, #64 // =64
457+
; CHECK-CAS-O0-NEXT: subs x16, x10, #64
458458
; CHECK-CAS-O0-NEXT: csel x14, x14, x12, lo
459-
; CHECK-CAS-O0-NEXT: subs x16, x10, #64 // =64
459+
; CHECK-CAS-O0-NEXT: subs x16, x10, #64
460460
; CHECK-CAS-O0-NEXT: csel x13, x13, x15, lo
461-
; CHECK-CAS-O0-NEXT: subs x15, x10, #0 // =0
461+
; CHECK-CAS-O0-NEXT: subs x15, x10, #0
462462
; CHECK-CAS-O0-NEXT: csel x13, x12, x13, eq
463463
; CHECK-CAS-O0-NEXT: orr x9, x9, x14
464464
; CHECK-CAS-O0-NEXT: orr x12, x12, x13
@@ -467,22 +467,22 @@ define void @atomic_load_relaxed(i64, i64, i128* %p, i128* %p2) {
467467
; CHECK-CAS-O0-NEXT: str q0, [sp, #16] // 16-byte Folded Spill
468468
; CHECK-CAS-O0-NEXT: mov v0.d[1], x12
469469
; CHECK-CAS-O0-NEXT: str q0, [sp, #32] // 16-byte Folded Spill
470-
; CHECK-CAS-O0-NEXT: subs x13, x10, #64 // =64
471-
; CHECK-CAS-O0-NEXT: subs x8, x8, #64 // =64
470+
; CHECK-CAS-O0-NEXT: subs x13, x10, #64
471+
; CHECK-CAS-O0-NEXT: subs x8, x8, #64
472472
; CHECK-CAS-O0-NEXT: lsl x8, x12, x8
473473
; CHECK-CAS-O0-NEXT: orr x8, x8, x9, lsr #0
474474
; CHECK-CAS-O0-NEXT: lsr x12, x12, x13
475-
; CHECK-CAS-O0-NEXT: subs x13, x10, #64 // =64
475+
; CHECK-CAS-O0-NEXT: subs x13, x10, #64
476476
; CHECK-CAS-O0-NEXT: csel x8, x8, x12, lo
477-
; CHECK-CAS-O0-NEXT: subs x10, x10, #0 // =0
477+
; CHECK-CAS-O0-NEXT: subs x10, x10, #0
478478
; CHECK-CAS-O0-NEXT: csel x10, x9, x8, eq
479479
; CHECK-CAS-O0-NEXT: stxp w8, x9, x10, [x11]
480480
; CHECK-CAS-O0-NEXT: cbnz w8, .LBB4_1
481481
; CHECK-CAS-O0-NEXT: // %bb.2: // %atomicrmw.end
482482
; CHECK-CAS-O0-NEXT: ldr q0, [sp, #32] // 16-byte Folded Reload
483483
; CHECK-CAS-O0-NEXT: ldr x8, [sp, #56] // 8-byte Folded Reload
484484
; CHECK-CAS-O0-NEXT: str q0, [x8]
485-
; CHECK-CAS-O0-NEXT: add sp, sp, #64 // =64
485+
; CHECK-CAS-O0-NEXT: add sp, sp, #64
486486
; CHECK-CAS-O0-NEXT: ret
487487

488488
%r = load atomic i128, i128* %p monotonic, align 16

0 commit comments

Comments
 (0)