[PATCH] D32638: [x86][inline-asm][clang]Amend size directive deduction mechanism of unsized memory operands

coby via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 28 00:19:22 PDT 2017


coby created this revision.

This is an extension of the work being carried by the following change:
https://reviews.llvm.org/D26586
This commit handles cases where the size qualifier of an indirect memory reference operand in Intel syntax is missing (e.g. "vaddps xmm1, xmm2, [a]").
GCC will deduce the size qualifier based on the possible matches:
"vaddps xmm1, xmm2, [a]" matches only “XMMWORD PTR” qualifier.
"vaddps xmm1, xmm2, [a]{1to4}" matches only “DWORD PTR” qualifier.
"mov rax, [a]" matches only "QWORD PTR"

Currently, size directive will be deduced based on the size of the memory operand (apart from those cases which were handled by https://reviews.llvm.org/D26586).
For example:
"vaddps xmm1, xmm2, [a]"
"char a;" will imply "BYTE PTR" qualifier
"short a;" will imply "WORD PTR" qualifier.

This commit aligns LLVM to GCC’s behavior.

This is the Clang part of the review.
The LLVM part can be found here:
https://reviews.llvm.org/D32636


Repository:
  rL LLVM

https://reviews.llvm.org/D32638

Files:
  test/CodeGen/ms-inline-asm-memory-adjustments.c


Index: test/CodeGen/ms-inline-asm-memory-adjustments.c
===================================================================
--- test/CodeGen/ms-inline-asm-memory-adjustments.c
+++ test/CodeGen/ms-inline-asm-memory-adjustments.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu skylake-avx512 -fasm-blocks -o - | FileCheck %s
+
+void t() {
+  char c;
+  // CHECK: vaddps xmm1, xmm2, dword ptr $1{1to4}
+  __asm vaddps xmm1, xmm2, [c]{1to4}
+  // CHECK: vaddps xmm1, xmm2, xmmword ptr $2
+  __asm vaddps xmm1, xmm2, [c]
+  // CHECK: mov eax, dword ptr $3
+  __asm mov eax, [c]
+  // CHECK: mov qword ptr $0, rax
+  __asm mov [c], rax
+}
+


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32638.97057.patch
Type: text/x-patch
Size: 697 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170428/db602914/attachment.bin>


More information about the cfe-commits mailing list