Commit Graph

115 Commits

Author SHA1 Message Date
Marina Yatsina 5f77679356 [ms-inline-asm][AVX512] Add ability to use k registers in MS inline asm + fix bag with curly braces
Until now curly braces could only be used in MS inline assembly to mark block start/end.
All curly braces were removed completely at a very early stage.
This approach caused bugs like:
"m{o}v eax, ebx" turned into "mov eax, ebx" without any error.

In addition, AVX-512 added special operands (e.g., k registers), which are also surrounded by curly braces that mark them as such.
Now, we need to keep the curly braces and identify at a later stage if they are marking block start/end (if so, ignore them), or surrounding special AVX-512 operands (if so, parse them as such).

This patch fixes the bug described above and enables the use of AVX-512 special operands.

This commit is the the clang part of the patch.
The clang part of the review is: http://reviews.llvm.org/D17766
The llvm part of the review is: http://reviews.llvm.org/D17767

Differential Revision: http://reviews.llvm.org/D17766

llvm-svn: 262842
2016-03-07 18:10:25 +00:00
Marina Yatsina 146d2ec06d [ms-inline-asm] Fixing bug in single asm statement support
Fixing a crash caused by trying to merge a single-line asm statement with an asm block that follows it, e.g:
asm int 4
asm {
  int 5
}

Now, only adjacent single-line asm statements that are not surrounded by braces will be merged into one asm call.

Differential Revision: http://reviews.llvm.org/D17496

llvm-svn: 261618
2016-02-23 08:53:45 +00:00
Marina Yatsina afb72f38f8 [ms inline asm] Add support for label names with '$' chars
In MS inline asm syntax a label with '$' char produces an error, while in AT&T it does not.
In AT&T inline asm syntax Clang escapes the '$' char and replaces it with "$$". Adopted same approach for MS syntax.

Differential Revision: http://reviews.llvm.org/D15795

llvm-svn: 256545
2015-12-29 08:49:34 +00:00
Marina Yatsina 59d35f1415 [X86][ms-inline asm] Test case for adding support for memory operands that include structs
Test case for commit 256381

Differential Revision: http://reviews.llvm.org/D15749

llvm-svn: 256382
2015-12-24 12:11:40 +00:00
Marina Yatsina 71ebc691f6 [ms-inline-asm] Add support for composite structs in MS inline asm
Add MS inline asm support for structs that contain fields that are also structs.

Differential Revision: http://reviews.llvm.org/D15578

llvm-svn: 255890
2015-12-17 12:51:51 +00:00
Hans Wennborg 2edb8fcf0d Mark MS inline ASM 'nodplicate' it it has labels (PR23715)
Duplicating it can lead to labels being defined twice.

Differential revision: http://reviews.llvm.org/D15399

llvm-svn: 255201
2015-12-10 01:38:04 +00:00
Reid Kleckner 14e96b4930 [ms-inline-asm] Add field access to MS inline asm identifier lookup
Now we can parse code like this:
  struct A {
    int field;
  };
  int f(A o) {
    __asm mov eax, o.field
  }

Fixes PR19117.

llvm-svn: 246088
2015-08-26 21:57:20 +00:00
Michael Kuperstein 2229ca71fd [X86] Recognize "flags" as an identifier, not a register in Intel-syntax inline asm
This contains the test-case for r243630.

Patch by: marina.yatsina@intel.com
Differential Revision: http://reviews.llvm.org/D11513

llvm-svn: 243632
2015-07-30 10:10:47 +00:00
Michael Kuperstein ce1ce989e2 Add test for parsing the XOR operator in Intel syntax inline assembly.
LLVM side of the patch was committed as r239695.

Differential Revision: http://reviews.llvm.org/D10384
Patch by marina.yatsina@intel.com

llvm-svn: 239696
2015-06-14 13:03:27 +00:00
David Blaikie a953f2825b Update Clang tests to handle explicitly typed load changes in LLVM.
llvm-svn: 230795
2015-02-27 21:19:58 +00:00
Ehsan Akhgari 3e2db26efc ms-inline-asm: Add a test case for the usage of labels in bracket expressions
Summary: This is a test for this patch: http://reviews.llvm.org/D5445.

Reviewers: rnk

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D5446

llvm-svn: 218271
2014-09-22 20:41:39 +00:00
Ehsan Akhgari 31097581aa ms-inline-asm: Scope inline asm labels to functions
Summary:
This fixes PR20023.  In order to implement this scoping rule, we piggy
back on the existing LabelDecl machinery, by creating LabelDecl's that
will carry the "internal" name of the inline assembly label, which we
will rewrite the asm label to.

Reviewers: rnk

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D4589

llvm-svn: 218230
2014-09-22 02:21:54 +00:00
Reid Kleckner 9b3e3dfc54 MS inline asm: Allow __asm blocks to set a return value
If control falls off the end of a function after an __asm block, MSVC
assumes that the inline assembly filled the EAX and possibly EDX
registers with an appropriate return value. This functionality is used
in inline functions returning 64-bit integers in system headers, so we
need some amount of compatibility.

This is implemented in Clang by adding extra output constraints to every
inline asm block, and storing the resulting output registers into the
return value slot. If we see an asm block somewhere in the function
body, we emit a normal epilogue instead of marking the end of the
function with a return type unreachable.

Normal returns in functions not using this functionality will overwrite
the return value slot, and in most cases LLVM should be able to
eliminate the dead stores.

Fixes PR17201.

Reviewed By: majnemer

Differential Revision: http://reviews.llvm.org/D5177

llvm-svn: 217187
2014-09-04 20:04:38 +00:00
Reid Kleckner a4ab03ec21 MS inline asm: Add a test for xgetbv clobbers
llvm-svn: 217174
2014-09-04 16:58:47 +00:00
Reid Kleckner e2d6429493 MS inline asm: Tests for r214550
These tests seem like an exception to the rule against assembly emitting
tests in clang.  I made an LLVM side change that can only be tested by
setting up the inline assembly machinery that is only implemented by
Clang.

llvm-svn: 214552
2014-08-01 20:23:29 +00:00
Ehsan Akhgari 9f507382dd ms-inline-asm: Add a test to ensure that call doesn't clobber eax.
Note that it's not clear whether this is the right behavior, please see
the review for the discussion.

Reviewers: rnk

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D4577

llvm-svn: 214401
2014-07-31 13:43:17 +00:00
Ehsan Akhgari 755597c83d Fix test/CodeGen/ms-inline-asm.c from r213916.
llvm-svn: 213919
2014-07-25 02:39:33 +00:00
Ehsan Akhgari 2f93b448a8 clang-cl: Merge adjacent single-line __asm blocks
Summary:
This patch extends the __asm parser to make it keep parsing input tokens
as inline assembly if a single-line __asm line is followed by another line
starting with __asm too.  It also makes sure that we correctly keep
matching braces in such situations by separating the notions of how many
braces we are matching and whether we are in single-line asm block mode.

Reviewers: rnk

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D4598

llvm-svn: 213916
2014-07-25 02:27:14 +00:00
NAKAMURA Takumi 0c5f4edba4 clang/test/CodeGen/ms-inline-asm.c: Fix for -Asserts.
llvm-svn: 213329
2014-07-17 22:51:49 +00:00
Nico Weber 9a08847e6d Add a test for PR20343 after llvm r213303.
llvm-svn: 213305
2014-07-17 20:25:36 +00:00
Ehsan Akhgari 0f89fac7a5 Add support for nested blocks in Microsoft inline assembly
This fixes http://llvm.org/PR20204.

llvm-svn: 212389
2014-07-06 05:26:54 +00:00
Ehsan Akhgari 3e0dd89adf Add a test case for the tilde operator in Microsoft inline assembly
llvm-svn: 212373
2014-07-05 15:04:06 +00:00
Reid Kleckner 185940a765 MS asm: Filter out fpsw clobbers
When parsing MS inline assembly, we note that fpsw is an implicit def of
most x87 FP operations, and add it to the clobber list.  However, we
don't recognize fpsw as a gcc register name, and we assert.  Clang
always adds an fpsr clobber, which means the same thing to LLVM, so we
can just use that.

This test case was broken by my LLVM change r196939.

Reviewers: echristo

Differential Revision: http://llvm-reviews.chandlerc.com/D2993

llvm-svn: 204878
2014-03-27 00:00:03 +00:00
Reid Kleckner 8d4a16ec3a Add tests for MS inline asm change r203146
llvm-svn: 203147
2014-03-06 19:19:36 +00:00
Reid Kleckner 020acd88ec Test case for clobbers on cpuid in ms inline asm
Tests r200279 in LLVM.

llvm-svn: 200280
2014-01-28 02:09:28 +00:00
Reid Kleckner 5dc20b13e7 Update clang MS inline asm tests for r196939
llvm-svn: 196940
2013-12-10 18:27:51 +00:00
NAKAMURA Takumi 0acd8a7561 clang/test: REQUIRES: s/x86-64-registered-target/x86-registered-target/
llvm-svn: 196350
2013-12-04 03:41:33 +00:00
Rafael Espindola ff7cea8c1a Don't pass -O0 to clang_cc1, it is the default.
llvm-svn: 189910
2013-09-04 04:12:25 +00:00
Chad Rosier 274800025a Fix typo.
llvm-svn: 179811
2013-04-18 23:12:05 +00:00
Chad Rosier efd87c8f4b Test cases for r179719.
llvm-svn: 179720
2013-04-17 21:02:39 +00:00
Chad Rosier eb294538c3 Test cases for r179655.
llvm-svn: 179656
2013-04-17 00:12:09 +00:00
Chad Rosier 7181ed3346 Add test case for r179403.
llvm-svn: 179404
2013-04-12 19:52:07 +00:00
Chad Rosier 4a3b160d4f Add test case for r179399.
llvm-svn: 179400
2013-04-12 18:54:40 +00:00
Chad Rosier f8bcfbdd5f Add test case for r179383 and r179393.
llvm-svn: 179394
2013-04-12 18:22:08 +00:00
Chad Rosier ea1d1a2d05 [ms-inline asm] Move a few test cases from the 32-bit version to the 64-bit
version as lea is only available in 64-bit mode.

llvm-svn: 179190
2013-04-10 18:08:17 +00:00
Chad Rosier e6956c3ec5 [ms-inline asm] Add a few test cases that were regressed by r179115. That
commit was reverted in r179120, but I do plan on reapplying with a fix shortly.
Part of rdar://13611297

llvm-svn: 179182
2013-04-10 16:33:34 +00:00
Chad Rosier 6bec4f9af3 Test case for r179030.
llvm-svn: 179031
2013-04-08 17:44:05 +00:00
Chad Rosier 26949f1345 Add test case for r178881.
llvm-svn: 178882
2013-04-05 16:29:17 +00:00
Chad Rosier 459d3ee1dd Remove unnecessary attributes from test case.
llvm-svn: 178188
2013-03-27 21:54:09 +00:00
Chad Rosier a0ef404973 Add a front-end test case for r178186.
llvm-svn: 178187
2013-03-27 21:50:39 +00:00
Chad Rosier 993bd120bc Test case for r177439 and r177440.
llvm-svn: 177441
2013-03-19 21:12:57 +00:00
Chad Rosier 4f667e88d0 Update test for r177413.
llvm-svn: 177414
2013-03-19 17:32:36 +00:00
Chad Rosier 47abcf83a3 Test case for r177347.
llvm-svn: 177349
2013-03-18 23:32:33 +00:00
Chad Rosier 1ef5d51ade Add a front-end test case for r176036.
llvm-svn: 176038
2013-02-25 19:13:23 +00:00
Bill Wendling e1c4a1babd Update to use references to attribute groups instead of listing the attributes on the call/invoke instructions.
llvm-svn: 175878
2013-02-22 09:10:20 +00:00
Chad Rosier 7ef6fd3402 [ms-inline asm] Remove this test while I investigate why eax isn't being clobbered.
llvm-svn: 175637
2013-02-20 17:39:31 +00:00
Chad Rosier 77d56be3f0 Add test case for r175312.
llvm-svn: 175313
2013-02-15 21:58:41 +00:00
Chad Rosier 5bdd8ed74d [ms-inline asm] Add test case for r175083.
llvm-svn: 175084
2013-02-13 21:34:54 +00:00
Chad Rosier 8356d091bf [ms-inline-asm] Test cases to ensure the AsmRewrite list is sorted (r175021).
Part of rdar://13202662

llvm-svn: 175022
2013-02-13 01:06:08 +00:00
Chad Rosier 3ea602cd30 [ms-inline-asm] Add test cases for the align/emit directives.
Part of rdar://13200215

llvm-svn: 175009
2013-02-12 21:34:14 +00:00