Commit Graph

109 Commits

Author SHA1 Message Date
Chandler Carruth 6b547686c5 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351636 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-19 08:50:56 +00:00
Joel Galenson 8352988dc1 [cfi-verify] Support AArch64.
This patch adds support for AArch64 to cfi-verify.

This required three changes to cfi-verify.  First, it generalizes checking if an instruction is a trap by adding a new isTrap flag to TableGen (and defining it for x86 and AArch64).  Second, the code that ensures that the operand register is not clobbered between the CFI check and the indirect call needs to allow a single dereference (in x86 this happens as part of the jump instruction).  Third, we needed to ensure that return instructions are not counted as indirect branches.  Technically, returns are indirect branches and can be covered by CFI, but LLVM's forward-edge CFI does not protect them, and x86 does not consider them, so we keep that behavior.

In addition, we had to improve AArch64's code to evaluate the branch target of a MCInst to handle calls where the destination is not the first operand (which it often is not).

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337007 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-13 15:19:33 +00:00
Craig Topper bd4977bdae [X86] Add NotMemoryFoldable to a bunch of instructions to suppress them from the autogenerated load folding table.
Most of these are system instructions or other instructions we don't use in CodeGen. No point wasting space for them in the table. Removing them from the autogenerated table makes it easier to review the manual table.

A few are real opcode collisions where the memory and register forms are completely different instructions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334474 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-12 04:34:59 +00:00
Gabor Buella 87a4c58e53 [x86] invpcid LLVM intrinsic
Re-add the feature flag for invpcid, which was removed in r294561.
Add an intrinsic, which always uses a 32 bit integer as first argument,
while the instruction actually uses a 64 bit register in 64 bit mode
for the INVPCID_TYPE argument.

Reviewers: craig.topper

Reviewed By: craig.topper

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333255 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-25 06:32:05 +00:00
Alexander Ivchenko 1fcee954a4 [X86][CET] Changing -fcf-protection behavior to comply with gcc (LLVM part)
This patch aims to match the changes introduced in gcc by
https://gcc.gnu.org/ml/gcc-cvs/2018-04/msg00534.html. The
IBT feature definition is removed, with the IBT instructions
being freely available on all X86 targets. The shadow stack
instructions are also being made freely available, and the
use of all these CET instructions is controlled by the module
flags derived from the -fcf-protection clang option. The hasSHSTK
option remains since clang uses it to determine availability of
shadow stack instruction intrinsics, but it is no longer directly used.

Comes with a clang patch (D46881).

Patch by mike.dvoretsky

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332705 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-18 11:58:25 +00:00
Gabor Buella c31146b179 [X86] ptwrite intrinsic
Reviewers: craig.topper, RKSimon

Reviewed By: craig.topper, RKSimon

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331961 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-10 07:26:05 +00:00
Simon Pilgrim 6c961de3ad [X86] Tag PCONFIG instruction with WriteSystem scheduler class
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331773 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-08 15:55:14 +00:00
Gabor Buella a4f2996da0 [x86] Introduce the pconfig instruction
Reviewers: craig.topper, zvi

Reviewed By: craig.topper

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331739 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-08 06:47:36 +00:00
Craig Topper 52c132f528 [X86] Remove 'opaque ptr' from the intel syntax parser and printer.
Previously for instructions like fxsave we would print "opaque ptr" as part of the memory operand. Now we print nothing.

We also no longer accept "opaque ptr" in the parser. We still accept any size to be specified for these instructions, but we may want to consider only parsing when no explicit size is specified. This what gas does.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331243 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-01 04:42:00 +00:00
Craig Topper 9ca2be762b [X86] Use a MnemonicAlias instead of an InstAlias.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331157 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-30 06:21:19 +00:00
Craig Topper e803a9e588 [X86] Make 64-bit sysret/sysexit not ambiguous in Intel assembly syntax.
This also makes it default to the 32-bit non REX.W version in 64-bit mode. This seems to be more consistent with gas.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331149 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-29 22:55:54 +00:00
Craig Topper 519e2e52fa [X86] Add suffixes to the LGDT/LIDT/SGDT/SIDT mnemonics in Intel syntax. Add aliases based on 16/32-bit mode to choose the default.
This allows the instruction selection to follow mode in Intel syntax. And allows a suffix to be used to change size.

This matches gas behavior from what I could tell.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331138 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-29 06:24:09 +00:00
Craig Topper d9a4b27a8f [X86] Remove SLDT64m instruction.
It doesn't really exist. The instruction always writes 16-bits of memory. Putting a REX.w on it won't change anything.

While I was touching the encoding tests to remove it, I added some other missing register form test cases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331135 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-29 04:50:53 +00:00
Craig Topper eb264478e4 [X86] Remove OpSizeIgnore, it's not implemented any differently than OpSizeFixed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330532 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-22 01:24:58 +00:00
Gabor Buella 2d0d5db8e3 [X86] Introduce LLVM wbinvd intrinsic
A previously missing intrinsic for an old instruction.

Reviewers: craig.topper, echristo

Reviewed By: craig.topper

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329936 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-12 18:38:18 +00:00
Simon Pilgrim a1c7785444 [X86] Remove system/control schedule itineraries (PR37093)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329903 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-12 12:09:24 +00:00
Gabor Buella 8822a56047 [X86] Describe wbnoinvd instruction
Similar to the wbinvd instruction, except this
one does not invalidate caches. Ring 0 only.
The encoding matches a wbinvd instruction with
an F3 prefix.

Reviewers: craig.topper, zvi, ashlykov

Reviewed By: craig.topper

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329847 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-11 20:01:57 +00:00
Chandler Carruth 9f8f7c5e8a [x86] Model the direction flag (DF) separately from the rest of EFLAGS.
This cleans up a number of operations that only claimed te use EFLAGS
due to using DF. But no instructions which we think of us setting EFLAGS
actually modify DF (other than things like popf) and so this needlessly
creates uses of EFLAGS that aren't really there.

In fact, DF is so restrictive it is pretty easy to model. Only STD, CLD,
and the whole-flags writes (WRFLAGS and POPF) need to model this.

I've also somewhat cleaned up some of the flag management instruction
definitions to be in the correct .td file.

Adding this extra register also uncovered a failure to use the correct
datatype to hold X86 registers, and I've corrected that as necessary
here.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329673 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-10 06:40:51 +00:00
Craig Topper edfd445801 [X86] Change 32 and 64 bit versions of LSL instruction have a 16-bit memory operand.
This matches the Intel and AMD documentation and is consistent with the LAR instruction.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325197 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-15 01:21:53 +00:00
Simon Pilgrim 3c2ea0e03b [X86] Tag CET-IBT instruction scheduler classes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@324898 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-12 15:57:00 +00:00
Craig Topper 8677133ebc [X86] Add intrinsic support for the RDPID instruction
This adds a new instrinsic to support the rdpid instruction. The implementation is a bit weird because the intrinsic is defined as always returning 32-bits, but the assembler support thinks the instruction produces a 64-bit register in 64-bit mode. But really it zeros the upper 32 bits. So I had to add separate patterns where 64-bit mode uses an extract_subreg.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322910 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-18 23:52:31 +00:00
Craig Topper 176601f826 [X86] Disable sldtq parsing in 64-bit mode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322353 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-12 05:38:15 +00:00
Oren Ben Simhon b89275f988 Instrument Control Flow For Indirect Branch Tracking
CET (Control-Flow Enforcement Technology) introduces a new mechanism called IBT (Indirect Branch Tracking).
According to IBT, each Indirect branch should land on dedicated ENDBR instruction (End Branch).
The new pass adds ENDBR instructions for every indirect jmp/call (including jumps using jump tables / switches).
For more information, please see the following:
https://software.intel.com/sites/default/files/managed/4d/2a/control-flow-enforcement-technology-preview.pdf

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

Change-Id: Icb754489faf483a95248f96982a4e8b1009eb709

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322062 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-09 08:51:18 +00:00
Craig Topper 5386758b51 [X86] Add 'Requires<[In64BitMode]>' to a bunch of instructions that only have memory and immediate operands.
The asm parser wasn't preventing these from being accepted in 32-bit mode. Instructions that use a GR64 register are protected by the parser rejecting the register in 32-bit mode.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320846 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-15 19:01:51 +00:00
Craig Topper 65b5d17d62 [X86] Remove the 'Requires<[In64BitMode]>' from SHSTK instructions.
This has no effect due to a top level "let Predicates =" around the instructions. But its also not required because the GR64 usage in the instruction guarantees it can never match.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320843 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-15 19:01:48 +00:00
Craig Topper 2a6a25b91b [X86] Fix XSAVE64 and similar instructions to not be allowed by the assembler in 32-bit mode.
There was a top level "let Predicates =" in the .td file that was overriding the Requires on each instruction.

I've added an assert to the code emitter to catch more cases like this. I'm sure this isn't the only place where the right predicates aren't being applied. This assert already found that we don't block btq/btsq/btrq in 32-bit mode.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320830 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-15 17:22:58 +00:00
Simon Pilgrim 2057bb76d7 [X86] Add RDMSR/WRMSR, RDPMC + RDTSC/RDTSCP schedule tests
Add missing RDTSCP itinerary

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320581 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-13 14:22:04 +00:00
Simon Pilgrim ff701cc457 Strip trailing whitespace. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320265 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-09 20:44:51 +00:00
Simon Pilgrim d06214010c [X86] Tag FS/GS BASE R/W instruction scheduler classes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320264 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-09 20:42:27 +00:00
Simon Pilgrim e0380a51b7 [X86] Tag segment prefixes as NOP instruction scheduling classes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320257 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-09 16:58:34 +00:00
Simon Pilgrim 90a51e3bbd [X86] Tag VIA PadLock crypto instructions scheduler classes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320159 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-08 16:06:40 +00:00
Simon Pilgrim 705d9d27f4 [X86] Tag PKU/INVPCID/RDPID/SMAP/SMX/PTWRITE system instructions scheduler classes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320158 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-08 15:48:37 +00:00
Oren Ben Simhon 40090f420c Control-Flow Enforcement Technology - Shadow Stack support (LLVM side)
Shadow stack solution introduces a new stack for return addresses only.
The HW has a Shadow Stack Pointer (SSP) that points to the next return address.
If we return to a different address, an exception is triggered.
The shadow stack is managed using a series of intrinsics that are introduced in this patch as well as the new register (SSP).
The intrinsics are mapped to new instruction set that implements CET mechanism.

The patch also includes initial infrastructure support for IBT.

For more information, please see the following:
https://software.intel.com/sites/default/files/managed/4d/2a/control-flow-enforcement-technology-preview.pdf

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

Change-Id: I4daa1f27e88176be79a4ac3b4cd26a459e88fed4

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318996 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-26 13:02:45 +00:00
Nirav Dave d35da7d92b 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/llvm/trunk@318797 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-21 19:28:13 +00:00
Richard Trieu 5121f3c7c1 Revert r318678 to fix Clang test
r318678 caused the Clang test CodeGen/ms-inline-asm.c to start failing.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318710 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-21 00:12:18 +00:00
Nirav Dave 7078f99f3b [X86] Avoid unecessary opsize byte in segment move to memory
Summary:

Segment moves to memory are always 16-bit. Remove invalid 32 and 64
bit variants.

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/llvm/trunk@318678 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-20 18:38:55 +00:00
Craig Topper c021be0a0f [X86] Change XRSTOR to use PS instead of TB to match XSAVE.
I don't think this changes anything functionally yet, but I plan to fix the disassembler to use this to disable matching certain instructions with 0xf3/0xf2/0x66 prefixes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316337 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-23 16:11:33 +00:00
Craig Topper 23a29475b9 [X86] Add PTWRITE instruction for assembler and disassembler.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316333 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-23 15:53:21 +00:00
Craig Topper 63ea643e1f [X86] Add RDPID instruction for assembler and disassembler.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316332 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-23 15:53:16 +00:00
Andrew V. Tischenko 1f42b92202 'into' instruction should not be decoded as a valid instr in 64-bit mode
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313735 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-20 08:17:17 +00:00
Ayman Musa 67b50524f6 [X86] Added missing mayLoad/mayStore attributes to some X86 instructions.
Throughout the effort of automatically generating the X86 memory folding tables these missing information were encountered.
This is a preparation work for a future patch including the automation of these tables.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300190 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-13 10:03:45 +00:00
Guy Blank 6f26a8e23e [X86] Add xgetbv/xsetbv intrinsics to non-windows platforms
Differential Revision: https://reviews.llvm.org/D21958

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278782 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-16 06:41:00 +00:00
David Majnemer 543ae79447 [X86] Don't model UD2/UD2B as a terminator
A UD2 might make its way into the program via a call to @llvm.trap.
Obviously, calls are not terminators.  However, we modeled the X86
instruction, UD2, as a terminator.  Later on, this confuses the epilogue
insertion machinery which results in the epilogue getting inserted
before the UD2.  For some platforms, like x64, the result is a
violation of the ABI.

Instead, model UD2/UD2B as a side effecting instruction which may
observe memory.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278144 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-09 17:55:12 +00:00
Zvi Rackover a72116dbfd test commit: remove trailing whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273094 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-18 19:13:38 +00:00
Craig Topper db96b37522 [X86] Remove many operands that represent memory stores from outs to ins. These operands are the registers and immediates that specify the memory address not the memory itself thus they are inputs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263354 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-13 02:56:31 +00:00
Craig Topper a57544039b [X86] Mark LDS/LES as not being allowed in 64-bit mode.
Their opcodes are used as part of the VEX prefix in 64-bit mode. Clearly the disassembler implicitly decoded them as AVX instructions in 64-bit mode, but I think the AsmParser would have encoded them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@258793 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-26 06:10:15 +00:00
Craig Topper 5205089191 [X86] Use PS instead of TB for instructions that have PD/XS/XD variations. Use OpSize32 on an instruction that has an OpSize16 variant.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256918 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-06 06:18:41 +00:00
Asaf Badouh 7b8bd88d45 [X86][PKU] Add {RD,WR}PKRU intrinsics
Differential Revision: http://reviews.llvm.org/D15808

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256670 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-31 08:31:13 +00:00
Asaf Badouh 5c7343b3a6 [X86][PKU] Add {RD,WR}PKRU encoding
Differential Revision: http://reviews.llvm.org/D15711

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256366 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-24 08:25:00 +00:00
Amjad Aboud 9889174ead Implemented Support of IA interrupt and exception handlers:
http://lists.llvm.org/pipermail/cfe-dev/2015-September/045171.html

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256155 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-21 14:07:14 +00:00