llvm-project/llvm/test/CodeGen/X86/asm-dialect.ll
Nico Weber bf834b2629 [x86/asm] Let EmitMSInlineAsmStr() handle variants too
This is preparation for D113707, where I want to make `-masm=intel`
emit `asm inteldialect` instructions.

`{movq %rbx, %rax|mov rax, rbx}` is supposed to evaluate to the bit
between { and | for att and to the bit between | and } for intel.
Since intel will become `asm inteldialect`, which alls EmitMSInlineAsmStr(),
EmitMSInlineAsmStr() has to support variants as well.

(clang translates `{...|...}` to `$(...$|...$)`. I'm not sure why
it doesn't just send along only the first `...` or the second `...`
to LLVM, but given the notes in PR23933 let's not do a big
reorganization in this codepath.)

Differential Revision: https://reviews.llvm.org/D113932
2021-11-17 13:31:59 -05:00

35 lines
1.2 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=x86_64-unknown-linux-gnu %s -o - \
; RUN: | FileCheck --check-prefix=OUTPUT_ATT %s
; RUN: llc -mtriple=x86_64-unknown-linux-gnu %s -x86-asm-syntax=intel -o - \
; RUN: | FileCheck --check-prefix=OUTPUT_INTEL %s
define void @f() {
; OUTPUT_ATT-LABEL: f:
; OUTPUT_ATT: # %bb.0:
; OUTPUT_ATT-NEXT: #APP
; OUTPUT_ATT-NEXT: movq %rbx, %rax
; OUTPUT_ATT-NEXT: #NO_APP
; OUTPUT_ATT-NEXT: #APP
; OUTPUT_ATT-EMPTY:
; OUTPUT_ATT-NEXT: movq %rbx, %rax
; OUTPUT_ATT-EMPTY:
; OUTPUT_ATT-NEXT: #NO_APP
; OUTPUT_ATT-NEXT: retq
;
; OUTPUT_INTEL-LABEL: f:
; OUTPUT_INTEL: # %bb.0:
; OUTPUT_INTEL-NEXT: #APP
; OUTPUT_INTEL-NEXT: mov rax, rbx
; OUTPUT_INTEL-NEXT: #NO_APP
; OUTPUT_INTEL-NEXT: #APP
; OUTPUT_INTEL-EMPTY:
; OUTPUT_INTEL-NEXT: mov rax, rbx
; OUTPUT_INTEL-EMPTY:
; OUTPUT_INTEL-NEXT: #NO_APP
; OUTPUT_INTEL-NEXT: ret
call void asm sideeffect "$(movq %rbx, %rax $|mov rax, rbx$)", "~{dirflag},~{fpsr},~{flags}"()
call void asm sideeffect inteldialect "$(movq %rbx, %rax $|mov rax, rbx$)", "~{dirflag},~{fpsr},~{flags}"()
ret void
}