Commit Graph

135 Commits

Author SHA1 Message Date
Craig Topper 7348635232 [X86] Add test case for llvm change r329734
This test ensures the popfd instruction in MS inline assembly can properly find a clobber name for the dirflag register. Previously the register was named 'DF', but it needs to be named 'dirflag' to match the name in the GCC register name list.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329738 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-10 18:43:44 +00:00
Nirav Dave e590cad382 Avoid unecessary opsize byte in segment move to memory
Segment moves to memory are always 16-bit. Remove invalid 32 and 64
bit variants.

Recommiting with missing clang inline assembly test change.

Fixes PR34478.

Reviewers: rnk, craig.topper

Subscribers: llvm-commits, hiraditya

Differential Revision: https://reviews.llvm.org/D39847

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318797 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-21 19:28:13 +00:00
Coby Tayree 08e4943d2e [x86][inline-asm] allow recognition of MPX regs inside ms inline-asm blob
Differential Revision: https://reviews.llvm.org/D38445


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318739 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-21 08:50:10 +00:00
Coby Tayree aecc982abe Fixups to FE tests affected by D36793
Differential Revision: https://reviews.llvm.org/D36794


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@311640 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-24 08:47:26 +00:00
Coby Tayree c0edc15691 [X86][Asm] Allow negative immediate to appear before bracketed expression
Currently, only non-negative immediate is allowed prior to a brac expression (memory reference).
MASM / GAS does not have any problem cope with the left side of the real line, so we should be able to as well.

llvm: D36229

Differential Revision: https://reviews.llvm.org/D36230


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@310529 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-09 21:50:22 +00:00
Coby Tayree 958c61ad20 [X86][Ms-InlineAsm] Extend MS Dot operator to accept "this" + struct/class pointers aliases
MS InlineAsm Dot operator accepts "Bases" such as "this" (cpp) and class/struct pointer typedef.
This patch enhance its implementation with this behavior.

Differential Revision: https://reviews.llvm.org/D36450


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@310472 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-09 13:31:41 +00:00
Coby Tayree 076d1be85c [x86][inline-asm]Allow a pack of Control Debug to be properly picked
Allows the incorporation of legit (x86) Debug Regs within inline asm stataements

Differential Revision: https://reviews.llvm.org/D36074


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@309672 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-01 10:51:09 +00:00
Coby Tayree da7788766d [x86][inline-asm][ms-compat] legalize the use of "jc/jz short <op>"
MS ignores the keyword "short" when used after a jc/jz instruction, LLVM ought to do the same.
llvm: D35892

Differential Revision: https://reviews.llvm.org/D35893


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@309510 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-30 11:13:46 +00:00
Coby Tayree c6f3e165d9 [x86][inline-asm]Allow a pack of Control Regs to be properly picked
Allows the incorporation of legit (x86) Control Regs within inline asm stataements

Differential Revision: https://reviews.llvm.org/D35903


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@309508 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-30 10:19:10 +00:00
Eric Christopher 0b2316f968 Revert "This patch enables the usage of constant Enum identifiers within Microsoft style inline assembly statements." as it is causing msan failures.
This reverts commits r308985 and r308965

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@309004 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-25 19:17:32 +00:00
Matan Haroush cb44e2991d This patch enables the usage of constant Enum identifiers within Microsoft style inline assembly statements.
Differential Revision:
https://reviews.llvm.org/D33277
https://reviews.llvm.org/D33278



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@308965 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-25 10:43:43 +00:00
Marina Yatsina 0426124102 [inline asm] dot operator while using imm generates wrong ir + asm - clang part
Inline asm dot operator while using imm generates wrong ir and asm
This is the test for the llvm changes committed in revision 306300

This also fixes bugzilla 32987:
https://bugs.llvm.org//show_bug.cgi?id=32987

The llvm part of the review that contains the test can be found here:
https://reviews.llvm.org/D33039

commit on behald of zizhar

Differential Revision:
https://reviews.llvm.org/D33040



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306301 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-26 16:09:55 +00:00
Reid Kleckner 1895863dfb [ms-inline-asm] Use the frontend size only for ambiguous instructions
This avoids problems on code like this:
  char buf[16];
  __asm {
    movups xmm0, [buf]
    mov [buf], eax
  }

The frontend size in this case (1) is wrong, and the register makes the
instruction matching unambiguous. There are also enough bytes available
that we shouldn't complain to the user that they are potentially using
an incorrectly sized instruction to access the variable.

Supersedes D32636 and D26586 and fixes PR28266

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302179 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 18:19:52 +00:00
Coby Tayree b9931779a9 [X86][MS-compatability][clang] allow MS TYPE/SIZE/LENGTH operators as a part of a compound expression
This patch introduces X86AsmParser with the ability to handle the aforementioned ops within compound "MS" arithmetical expressions.
Currently - only supported as a stand alone Operand, e.g.:
"TYPE X"
now allowed :
"4 + TYPE X * 128"

LLVM side: https://reviews.llvm.org/D31173
Differential Revision: https://reviews.llvm.org/D31174


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@298426 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-21 19:33:32 +00:00
Reid Kleckner d418b54ac4 MS inline asm: Filter MXCSR out of the inferred clobber list
Since r295004, LLVM has started modelling this new register, but we
don't have GCC constraint inline asm spellings for it yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@295107 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-14 21:38:17 +00:00
Coby Tayree 80283fe1d9 [X86][MS]Adjacent comments within multi-line inline assembly statement
Allowing adjacent comments within MS inline assembly multi-line statement

Differential Revision: https://reviews.llvm.org/D28989



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294120 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-05 10:23:06 +00:00
Reid Kleckner 36a98dcd87 Use ${:uid} to generate unique MS asm labels, not {:uid}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@288093 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-29 00:39:37 +00:00
Reid Kleckner dc3ec65843 [MS] Mangle a unique ID into all MS inline asm labels
This solves PR23715 in a way that is compatible with LTO.

MSVC supports jumping to source-level labels and between inline asm
blocks, but we don't.

Also revert the old solution, r255201, which was to mark these calls as
noduplicate.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@288059 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-28 20:52:19 +00:00
Michael Zuckerman fce476b6e9 [x86][ms-inline-asm] use of "jmp short" in asm is not supported
Test linked to: https://reviews.llvm.org/D24957

Committing in the name of Ziv Izhar: After check-all and LGTM .

Differential Revision: https://reviews.llvm.org/D24958



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@284213 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-14 08:13:27 +00:00
Yunzhong Gao 27be2631ce (clang part) Implement MASM-flavor intel syntax behavior for inline MS asm block.
Clang tests for verifying the following syntaxes:
1. 0xNN and NNh are accepted as valid hexadecimal numbers, but 0xNNh is not.     
   0xNN and NNh may come with optional U or L suffix.                            
2. NNb is accepted as a valid binary (base-2) number, but 0bNN is not.           
   NNb may come with optional U or L suffix.                                     
                                                                                 
Differential Revision: https://reviews.llvm.org/D22112



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@280556 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-02 23:16:06 +00:00
Marina Yatsina 770fdd38e9 [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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@262842 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-07 18:10:25 +00:00
Marina Yatsina eb46412435 [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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261618 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-23 08:53:45 +00:00
Marina Yatsina b94e85d194 [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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256545 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-29 08:49:34 +00:00
Marina Yatsina d6adff5350 [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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256382 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-24 12:11:40 +00:00
Marina Yatsina cd80fb3bfd [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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@255890 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-17 12:51:51 +00:00
Hans Wennborg df439c8a28 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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@255201 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-10 01:38:04 +00:00
Reid Kleckner ee6d4bd4f8 [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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246088 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-26 21:57:20 +00:00
Michael Kuperstein 4354e02b6b [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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243632 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-30 10:10:47 +00:00
Michael Kuperstein 131d93e538 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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239696 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-14 13:03:27 +00:00
David Blaikie 1d7abba8db Update Clang tests to handle explicitly typed load changes in LLVM.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230795 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 21:19:58 +00:00
Ehsan Akhgari 8364d0e1cb 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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218271 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-22 20:41:39 +00:00
Ehsan Akhgari d88b0e1b7f 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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218230 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-22 02:21:54 +00:00
Reid Kleckner 3be1b0824b 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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217187 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-04 20:04:38 +00:00
Reid Kleckner 5ac034ccfc MS inline asm: Add a test for xgetbv clobbers
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217174 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-04 16:58:47 +00:00
Reid Kleckner fded34de2a 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214552 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-01 20:23:29 +00:00
Ehsan Akhgari 79cefc56a5 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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214401 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-31 13:43:17 +00:00
Ehsan Akhgari a04b2e4a75 Fix test/CodeGen/ms-inline-asm.c from r213916.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213919 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-25 02:39:33 +00:00
Ehsan Akhgari e26841e34d 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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213916 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-25 02:27:14 +00:00
NAKAMURA Takumi cc6546f2b2 clang/test/CodeGen/ms-inline-asm.c: Fix for -Asserts.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213329 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-17 22:51:49 +00:00
Nico Weber 6042ad3646 Add a test for PR20343 after llvm r213303.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213305 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-17 20:25:36 +00:00
Ehsan Akhgari eb5c8705ec Add support for nested blocks in Microsoft inline assembly
This fixes http://llvm.org/PR20204.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212389 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-06 05:26:54 +00:00
Ehsan Akhgari b514dc79c0 Add a test case for the tilde operator in Microsoft inline assembly
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212373 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-05 15:04:06 +00:00
Reid Kleckner ca240502a5 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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204878 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-27 00:00:03 +00:00
Reid Kleckner cd2a97492e Add tests for MS inline asm change r203146
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203147 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-06 19:19:36 +00:00
Reid Kleckner 2b1e087d47 Test case for clobbers on cpuid in ms inline asm
Tests r200279 in LLVM.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200280 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-28 02:09:28 +00:00
Reid Kleckner 6eb228f6da Update clang MS inline asm tests for r196939
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196940 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-10 18:27:51 +00:00
NAKAMURA Takumi a8fb443f44 clang/test: REQUIRES: s/x86-64-registered-target/x86-registered-target/
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196350 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-04 03:41:33 +00:00
Rafael Espindola a3f55b026f Don't pass -O0 to clang_cc1, it is the default.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189910 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-04 04:12:25 +00:00
Chad Rosier 68ea1d26ff Fix typo.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179811 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-18 23:12:05 +00:00
Chad Rosier abee27ba69 Test cases for r179719.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179720 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-17 21:02:39 +00:00