[llvm] r235963 - [MC] Use LShr for constant evaluation of ">>" on ELF/arm64--darwin.
Ahmed Bougacha
ahmed.bougacha at gmail.com
Mon Apr 27 18:50:09 PDT 2015
On Mon, Apr 27, 2015 at 6:37 PM, Ahmed Bougacha
<ahmed.bougacha at gmail.com> wrote:
> Author: ab
> Date: Mon Apr 27 20:37:11 2015
> New Revision: 235963
>
> URL: http://llvm.org/viewvc/llvm-project?rev=235963&view=rev
> Log:
> [MC] Use LShr for constant evaluation of ">>" on ELF/arm64--darwin.
>
> This matches other assemblers and is less unexpected (e.g. PR23227).
> On ELF, I tried binutils gas v2.24 and nasm 2.10.09, and they both
> agree on LShr. On COFF, I couldn't get my hands on an assembler yet,
> so don't change the behavior. For now, don't change it on non-AArch64
> Darwin either, as the other assembler is gas v1.38, which does an AShr.
>
> Added:
> llvm/trunk/test/MC/AArch64/expr-shr.s
> llvm/trunk/test/MC/AsmParser/expr-shr.s
> Modified:
> llvm/trunk/lib/MC/MCAsmInfo.cpp
> llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp
> llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp
> llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp
> llvm/trunk/test/MC/ARM/bracket-exprs.s
> llvm/trunk/test/MC/ELF/bracket-exprs.s
>
> Modified: llvm/trunk/lib/MC/MCAsmInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfo.cpp?rev=235963&r1=235962&r2=235963&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/MCAsmInfo.cpp (original)
> +++ llvm/trunk/lib/MC/MCAsmInfo.cpp Mon Apr 27 20:37:11 2015
> @@ -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.
>
> Modified: llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp?rev=235963&r1=235962&r2=235963&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp (original)
> +++ llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp Mon Apr 27 20:37:11 2015
> @@ -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() { }
>
> Modified: llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp?rev=235963&r1=235962&r2=235963&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp (original)
> +++ llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp Mon Apr 27 20:37:11 2015
> @@ -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;
> }
>
> Modified: llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp?rev=235963&r1=235962&r2=235963&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp (original)
> +++ llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp Mon Apr 27 20:37:11 2015
> @@ -48,6 +48,10 @@ AArch64MCAsmInfoDarwin::AArch64MCAsmInfo
> 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(
>
> Added: llvm/trunk/test/MC/AArch64/expr-shr.s
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AArch64/expr-shr.s?rev=235963&view=auto
> ==============================================================================
> --- llvm/trunk/test/MC/AArch64/expr-shr.s (added)
> +++ llvm/trunk/test/MC/AArch64/expr-shr.s Mon Apr 27 20:37:11 2015
> @@ -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)
>
> Modified: llvm/trunk/test/MC/ARM/bracket-exprs.s
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/bracket-exprs.s?rev=235963&r1=235962&r2=235963&view=diff
> ==============================================================================
> --- llvm/trunk/test/MC/ARM/bracket-exprs.s (original)
> +++ llvm/trunk/test/MC/ARM/bracket-exprs.s Mon Apr 27 20:37:11 2015
> @@ -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
>
> Added: llvm/trunk/test/MC/AsmParser/expr-shr.s
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/expr-shr.s?rev=235963&view=auto
> ==============================================================================
> --- llvm/trunk/test/MC/AsmParser/expr-shr.s (added)
> +++ llvm/trunk/test/MC/AsmParser/expr-shr.s Mon Apr 27 20:37:11 2015
> @@ -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)
>
> Modified: llvm/trunk/test/MC/ELF/bracket-exprs.s
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/bracket-exprs.s?rev=235963&r1=235962&r2=235963&view=diff
> ==============================================================================
> --- llvm/trunk/test/MC/ELF/bracket-exprs.s (original)
> +++ llvm/trunk/test/MC/ELF/bracket-exprs.s Mon Apr 27 20:37:11 2015
> @@ -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
Joerg, you added these tests; let me know if the previous behavior is
actually required on some target. I assumed it wasn't.
-Ahmed
> .byte 1
> .else
> .byte 2
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list