diff --git a/llvm/lib/MC/MCAsmInfo.cpp b/llvm/lib/MC/MCAsmInfo.cpp index 22de8bd13dcb..1a45b5a389f6 100644 --- a/llvm/lib/MC/MCAsmInfo.cpp +++ b/llvm/lib/MC/MCAsmInfo.cpp @@ -90,7 +90,7 @@ MCAsmInfo::MCAsmInfo() { DwarfRegNumForCFI = false; NeedsDwarfSectionOffsetDirective = false; UseParensForSymbolVariant = false; - UseLogicalShr = false; + UseLogicalShr = true; // FIXME: Clang's logic should be synced with the logic used to initialize // this member and the two implementations should be merged. diff --git a/llvm/lib/MC/MCAsmInfoCOFF.cpp b/llvm/lib/MC/MCAsmInfoCOFF.cpp index bb3f0d3a4297..97fc76a9adb1 100644 --- a/llvm/lib/MC/MCAsmInfoCOFF.cpp +++ b/llvm/lib/MC/MCAsmInfoCOFF.cpp @@ -36,6 +36,10 @@ MCAsmInfoCOFF::MCAsmInfoCOFF() { NeedsDwarfSectionOffsetDirective = true; UseIntegratedAssembler = true; + + // FIXME: For now keep the previous behavior, AShr. Need to double-check + // other COFF-targeting assemblers and change this if necessary. + UseLogicalShr = false; } void MCAsmInfoMicrosoft::anchor() { } diff --git a/llvm/lib/MC/MCAsmInfoDarwin.cpp b/llvm/lib/MC/MCAsmInfoDarwin.cpp index ae9486d3db4d..bb90ff2c350a 100644 --- a/llvm/lib/MC/MCAsmInfoDarwin.cpp +++ b/llvm/lib/MC/MCAsmInfoDarwin.cpp @@ -93,4 +93,9 @@ MCAsmInfoDarwin::MCAsmInfoDarwin() { UseIntegratedAssembler = true; SetDirectiveSuppressesReloc = true; + + // FIXME: For now keep the previous behavior, AShr, matching the previous + // behavior of as(1) (both -q and -Q: resp. LLVM and gas v1.38). + // If/when this changes, the AArch64 Darwin special case can go away. + UseLogicalShr = false; } diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp index f048474fd4a9..c41220400410 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp @@ -48,6 +48,10 @@ AArch64MCAsmInfoDarwin::AArch64MCAsmInfoDarwin() { UseDataRegionDirectives = true; ExceptionsType = ExceptionHandling::DwarfCFI; + + // AArch64 Darwin doesn't have the baggage of X86/ARM, so it's fine to use + // LShr instead of AShr. + UseLogicalShr = true; } const MCExpr *AArch64MCAsmInfoDarwin::getExprForPersonalitySymbol( diff --git a/llvm/test/MC/AArch64/expr-shr.s b/llvm/test/MC/AArch64/expr-shr.s new file mode 100644 index 000000000000..aa23878e5adc --- /dev/null +++ b/llvm/test/MC/AArch64/expr-shr.s @@ -0,0 +1,8 @@ +// RUN: llvm-mc -triple aarch64-unknown-unknown-elf %s | FileCheck %s --check-prefix=ELF +// RUN: llvm-mc -triple aarch64-unknown-darwin %s | FileCheck %s --check-prefix=DARWIN + +.data + +// ELF: .xword 3 +// DARWIN: .quad 3 +.quad (~0 >> 62) diff --git a/llvm/test/MC/ARM/bracket-exprs.s b/llvm/test/MC/ARM/bracket-exprs.s index 922bf7037019..74f3323cd2d5 100644 --- a/llvm/test/MC/ARM/bracket-exprs.s +++ b/llvm/test/MC/ARM/bracket-exprs.s @@ -1,7 +1,7 @@ // RUN: llvm-mc -triple arm-unknown-linux %s | FileCheck %s // CHECK: .byte 1 -.if [~0 >> 1] == -1 +.if [~0 >> 63] == 1 .byte 1 .else .byte 2 diff --git a/llvm/test/MC/AsmParser/expr-shr.s b/llvm/test/MC/AsmParser/expr-shr.s new file mode 100644 index 000000000000..fc117b64e95a --- /dev/null +++ b/llvm/test/MC/AsmParser/expr-shr.s @@ -0,0 +1,13 @@ +// RUN: llvm-mc -triple x86_64-unknown-unknown-elf %s | FileCheck %s --check-prefix=CHECK +// RUN: llvm-mc -triple x86_64-pc-windows-msvc %s | FileCheck %s --check-prefix=MSVC +// RUN: llvm-mc -triple x86_64-unknown-darwin %s | FileCheck %s --check-prefix=DARWIN + +.data + +// CHECK: .quad 3 + +// Both COFF and Darwin still use AShr. +// MSVC: .quad -1 +// DARWIN: .quad -1 + +.quad (~0 >> 62) diff --git a/llvm/test/MC/ELF/bracket-exprs.s b/llvm/test/MC/ELF/bracket-exprs.s index 96f9f9aa450a..e7299fde7009 100644 --- a/llvm/test/MC/ELF/bracket-exprs.s +++ b/llvm/test/MC/ELF/bracket-exprs.s @@ -1,7 +1,7 @@ // RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s // CHECK: .byte 1 -.if [~0 >> 1] == -1 +.if [~0 >> 63] == 1 .byte 1 .else .byte 2