-
Notifications
You must be signed in to change notification settings - Fork 14k
[X86][MOVRS] Support MOVRS #116181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
[X86][MOVRS] Support MOVRS #116181
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/*===---------------- movrsintrin.h - MOVRS intrinsics ----------------------=== | ||
* | ||
* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
* See https://llvm.org/LICENSE.txt for license information. | ||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
* | ||
*===----------------------------------------------------------------------===*/ | ||
|
||
#ifndef __IMMINTRIN_H | ||
#error "Never use <movrsintrin.h> directly; include <immintrin.h> instead." | ||
#endif // __IMMINTRIN_H | ||
|
||
#ifndef __MOVRSINTRIN_H | ||
#define __MOVRSINTRIN_H | ||
|
||
#define __DEFAULT_FN_ATTRS \ | ||
__attribute__((__always_inline__, __nodebug__, __target__("movrs"))) | ||
|
||
#ifdef __x86_64__ | ||
static __inline__ char __DEFAULT_FN_ATTRS _movrs_i8(const void *__A) { | ||
return (char)__builtin_ia32_movrsqi((const void *)__A); | ||
} | ||
|
||
static __inline__ short __DEFAULT_FN_ATTRS _movrs_i16(const void *__A) { | ||
return (short)__builtin_ia32_movrshi((const void *)__A); | ||
} | ||
|
||
static __inline__ int __DEFAULT_FN_ATTRS _movrs_i32(const void *__A) { | ||
return (int)__builtin_ia32_movrssi((const void *)__A); | ||
} | ||
|
||
static __inline__ long long __DEFAULT_FN_ATTRS _movrs_i64(const void *__A) { | ||
return (long long)__builtin_ia32_movrsdi((const void *)__A); | ||
} | ||
#endif // __x86_64__ | ||
|
||
// Loads a memory sequence containing the specified memory address into | ||
/// the L3 data cache. Data will be shared (read/written) to by requesting | ||
/// core and other cores. | ||
/// | ||
/// Note that the effect of this intrinsic is dependent on the processor | ||
/// implementation. | ||
/// | ||
/// \headerfile <x86intrin.h> | ||
/// | ||
/// This intrinsic corresponds to the \c PREFETCHRS instruction. | ||
/// | ||
/// \param __P | ||
/// A pointer specifying the memory address to be prefetched. | ||
static __inline__ void __DEFAULT_FN_ATTRS | ||
_m_prefetchrs(volatile const void *__P) { | ||
#pragma clang diagnostic push | ||
#pragma clang diagnostic ignored "-Wcast-qual" | ||
__builtin_ia32_prefetchrs((const void *)__P); | ||
#pragma clang diagnostic pop | ||
} | ||
|
||
#undef __DEFAULT_FN_ATTRS | ||
#endif // __MOVRSINTRIN_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// RUN: %clang_cc1 %s -flax-vector-conversions=none -ffreestanding -triple=x86_64-unknown-unknown -target-feature +movrs \ | ||
// RUN: -emit-llvm -o - -Wall -Werror -pedantic -Wno-gnu-statement-expression | FileCheck %s | ||
|
||
#include <immintrin.h> | ||
#include <stddef.h> | ||
|
||
char test_movrs_si8(const char * __A) { | ||
// CHECK-LABEL: @test_movrs_si8( | ||
// CHECK: call i8 @llvm.x86.movrsqi( | ||
return _movrs_i8(__A); | ||
} | ||
|
||
short test_movrs_si16(const short * __A) { | ||
// CHECK-LABEL: @test_movrs_si16( | ||
// CHECK: call i16 @llvm.x86.movrshi( | ||
return _movrs_i16(__A); | ||
} | ||
|
||
int test_movrs_si32(const int * __A) { | ||
// CHECK-LABEL: @test_movrs_si32( | ||
// CHECK: call i32 @llvm.x86.movrssi( | ||
return _movrs_i32(__A); | ||
} | ||
|
||
long long test_movrs_si64(const long long * __A) { | ||
// CHECK-LABEL: @test_movrs_si64( | ||
// CHECK: call i64 @llvm.x86.movrsdi( | ||
return _movrs_i64(__A); | ||
} | ||
|
||
void test_m_prefetch_rs(void *p) { | ||
_m_prefetchrs(p); | ||
// CHECK-LABEL: define{{.*}} void @test_m_prefetch_rs | ||
// CHECK: call void @llvm.x86.prefetchrs({{.*}}) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3 | ||
; RUN: llc < %s -verify-machineinstrs -mtriple=x86_64-unknown-unknown --show-mc-encoding -mattr=+movrs | FileCheck %s | ||
|
||
define i8 @test_movrs_si8(ptr %__A) { | ||
; CHECK-LABEL: test_movrs_si8: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: movrsb (%rdi), %al # encoding: [0x0f,0x38,0x8a,0x07] | ||
; CHECK-NEXT: retq # encoding: [0xc3] | ||
entry: | ||
%0 = call i8 @llvm.x86.movrsqi(ptr %__A) | ||
ret i8 %0 | ||
} | ||
declare i8 @llvm.x86.movrsqi(ptr) | ||
|
||
define i16 @test_movrs_si16(ptr %__A) { | ||
; CHECK-LABEL: test_movrs_si16: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: movrsw (%rdi), %ax # encoding: [0x66,0x0f,0x38,0x8b,0x07] | ||
; CHECK-NEXT: retq # encoding: [0xc3] | ||
entry: | ||
%0 = call i16 @llvm.x86.movrshi(ptr %__A) | ||
ret i16 %0 | ||
} | ||
declare i16 @llvm.x86.movrshi(ptr) | ||
|
||
define i32 @test_movrs_si32(ptr %__A) { | ||
; CHECK-LABEL: test_movrs_si32: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: movrsl (%rdi), %eax # encoding: [0x0f,0x38,0x8b,0x07] | ||
; CHECK-NEXT: retq # encoding: [0xc3] | ||
entry: | ||
%0 = call i32 @llvm.x86.movrssi(ptr %__A) | ||
ret i32 %0 | ||
} | ||
declare i32 @llvm.x86.movrssi(ptr) | ||
|
||
define i64 @test_movrs_si64(ptr %__A) { | ||
; CHECK-LABEL: test_movrs_si64: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: movrsq (%rdi), %rax # encoding: [0x48,0x0f,0x38,0x8b,0x07] | ||
; CHECK-NEXT: retq # encoding: [0xc3] | ||
entry: | ||
%0 = call i64 @llvm.x86.movrsdi(ptr %__A) | ||
ret i64 %0 | ||
} | ||
declare i64 @llvm.x86.movrsdi(ptr) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: llc < %s -mtriple=i686-- -mattr=+sse,+prfchw,+movrs | FileCheck %s | ||
; RUN: llc < %s -mtriple=i686-- -mattr=-sse,+prfchw,+movrs | FileCheck %s | ||
|
||
define void @t(ptr %ptr) nounwind { | ||
; CHECK-LABEL: t: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax | ||
; CHECK-NEXT: prefetchrst2 (%eax) | ||
; CHECK-NEXT: retl | ||
entry: | ||
tail call void @llvm.x86.prefetchrs( ptr %ptr ) | ||
ret void | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# RUN: llvm-mc --disassemble %s -triple=x86_64 | FileCheck %s --check-prefixes=ATT | ||
# RUN: llvm-mc --disassemble %s -triple=x86_64 --output-asm-variant=1 | FileCheck %s --check-prefixes=INTEL | ||
|
||
# ATT: movrsb 268435456(%rbp,%r14,8), %bl | ||
# INTEL: movrs bl, byte ptr [rbp + 8*r14 + 268435456] | ||
0x42,0x0f,0x38,0x8a,0x9c,0xf5,0x00,0x00,0x00,0x10 | ||
|
||
# ATT: movrsb 291(%r8,%rax,4), %bl | ||
# INTEL: movrs bl, byte ptr [r8 + 4*rax + 291] | ||
0x41,0x0f,0x38,0x8a,0x9c,0x80,0x23,0x01,0x00,0x00 | ||
|
||
# ATT: movrsb (%rip), %bl | ||
# INTEL: movrs bl, byte ptr [rip] | ||
0x0f,0x38,0x8a,0x1d,0x00,0x00,0x00,0x00 | ||
|
||
# ATT: movrsb -32(,%rbp,2), %bl | ||
# INTEL: movrs bl, byte ptr [2*rbp - 32] | ||
0x0f,0x38,0x8a,0x1c,0x6d,0xe0,0xff,0xff,0xff | ||
|
||
# ATT: movrsb 127(%rcx), %bl | ||
# INTEL: movrs bl, byte ptr [rcx + 127] | ||
0x0f,0x38,0x8a,0x59,0x7f | ||
|
||
# ATT: movrsb -128(%rdx), %bl | ||
# INTEL: movrs bl, byte ptr [rdx - 128] | ||
0x0f,0x38,0x8a,0x5a,0x80 | ||
|
||
# ATT: movrsw 268435456(%rbp,%r14,8), %bx | ||
# INTEL: movrs bx, word ptr [rbp + 8*r14 + 268435456] | ||
0x66,0x42,0x0f,0x38,0x8b,0x9c,0xf5,0x00,0x00,0x00,0x10 | ||
|
||
# ATT: movrsw 291(%r8,%rax,4), %bx | ||
# INTEL: movrs bx, word ptr [r8 + 4*rax + 291] | ||
0x66,0x41,0x0f,0x38,0x8b,0x9c,0x80,0x23,0x01,0x00,0x00 | ||
|
||
# ATT: movrsw (%rip), %bx | ||
# INTEL: movrs bx, word ptr [rip] | ||
0x66,0x0f,0x38,0x8b,0x1d,0x00,0x00,0x00,0x00 | ||
|
||
# ATT: movrsw -32(,%rbp,2), %bx | ||
# INTEL: movrs bx, word ptr [2*rbp - 32] | ||
0x66,0x0f,0x38,0x8b,0x1c,0x6d,0xe0,0xff,0xff,0xff | ||
|
||
# ATT: movrsw 127(%rcx), %bx | ||
# INTEL: movrs bx, word ptr [rcx + 127] | ||
0x66,0x0f,0x38,0x8b,0x59,0x7f | ||
|
||
# ATT: movrsw -128(%rdx), %bx | ||
# INTEL: movrs bx, word ptr [rdx - 128] | ||
0x66,0x0f,0x38,0x8b,0x5a,0x80 | ||
|
||
# ATT: movrsl 268435456(%rbp,%r14,8), %ebx | ||
# INTEL: movrs ebx, dword ptr [rbp + 8*r14 + 268435456] | ||
0x42,0x0f,0x38,0x8b,0x9c,0xf5,0x00,0x00,0x00,0x10 | ||
|
||
# ATT: movrsl 291(%r8,%rax,4), %ebx | ||
# INTEL: movrs ebx, dword ptr [r8 + 4*rax + 291] | ||
0x41,0x0f,0x38,0x8b,0x9c,0x80,0x23,0x01,0x00,0x00 | ||
|
||
# ATT: movrsl (%rip), %ebx | ||
# INTEL: movrs ebx, dword ptr [rip] | ||
0x0f,0x38,0x8b,0x1d,0x00,0x00,0x00,0x00 | ||
|
||
# ATT: movrsl -32(,%rbp,2), %ebx | ||
# INTEL: movrs ebx, dword ptr [2*rbp - 32] | ||
0x0f,0x38,0x8b,0x1c,0x6d,0xe0,0xff,0xff,0xff | ||
|
||
# ATT: movrsl 127(%rcx), %ebx | ||
# INTEL: movrs ebx, dword ptr [rcx + 127] | ||
0x0f,0x38,0x8b,0x59,0x7f | ||
|
||
# ATT: movrsl -128(%rdx), %ebx | ||
# INTEL: movrs ebx, dword ptr [rdx - 128] | ||
0x0f,0x38,0x8b,0x5a,0x80 | ||
|
||
# ATT: movrsq 268435456(%rbp,%r14,8), %rbx | ||
# INTEL: movrs rbx, qword ptr [rbp + 8*r14 + 268435456] | ||
0x4a,0x0f,0x38,0x8b,0x9c,0xf5,0x00,0x00,0x00,0x10 | ||
|
||
# ATT: movrsq 291(%r8,%rax,4), %rbx | ||
# INTEL: movrs rbx, qword ptr [r8 + 4*rax + 291] | ||
0x49,0x0f,0x38,0x8b,0x9c,0x80,0x23,0x01,0x00,0x00 | ||
|
||
# ATT: movrsq (%rip), %rbx | ||
# INTEL: movrs rbx, qword ptr [rip] | ||
0x48,0x0f,0x38,0x8b,0x1d,0x00,0x00,0x00,0x00 | ||
|
||
# ATT: movrsq -32(,%rbp,2), %rbx | ||
# INTEL: movrs rbx, qword ptr [2*rbp - 32] | ||
0x48,0x0f,0x38,0x8b,0x1c,0x6d,0xe0,0xff,0xff,0xff | ||
|
||
# ATT: movrsq 127(%rcx), %rbx | ||
# INTEL: movrs rbx, qword ptr [rcx + 127] | ||
0x48,0x0f,0x38,0x8b,0x59,0x7f | ||
|
||
# ATT: movrsq -128(%rdx), %rbx | ||
# INTEL: movrs rbx, qword ptr [rdx - 128] | ||
0x48,0x0f,0x38,0x8b,0x5a,0x80 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# RUN: llvm-mc --disassemble %s -triple=i386 | FileCheck %s --check-prefixes=ATT | ||
# RUN: llvm-mc --disassemble %s -triple=i386 --output-asm-variant=1 | FileCheck %s --check-prefixes=INTEL | ||
|
||
# ATT: prefetchrst2 268435456(%esp,%esi,8) | ||
# INTEL: prefetchrst2 byte ptr [esp + 8*esi + 268435456] | ||
0x0f,0x18,0xa4,0xf4,0x00,0x00,0x00,0x10 | ||
|
||
# ATT: prefetchrst2 291(%edi,%eax,4) | ||
# INTEL: prefetchrst2 byte ptr [edi + 4*eax + 291] | ||
0x0f,0x18,0xa4,0x87,0x23,0x01,0x00,0x00 | ||
|
||
# ATT: prefetchrst2 (%eax) | ||
# INTEL: prefetchrst2 byte ptr [eax] | ||
0x0f,0x18,0x20 | ||
|
||
# ATT: prefetchrst2 -32(,%ebp,2) | ||
# INTEL: prefetchrst2 byte ptr [2*ebp - 32] | ||
0x0f,0x18,0x24,0x6d,0xe0,0xff,0xff,0xff | ||
|
||
# ATT: prefetchrst2 127(%ecx) | ||
# INTEL: prefetchrst2 byte ptr [ecx + 127] | ||
0x0f,0x18,0x61,0x7f | ||
|
||
# ATT: prefetchrst2 -128(%edx) | ||
# INTEL: prefetchrst2 byte ptr [edx - 128] | ||
0x0f,0x18,0x62,0x80 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stray change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thanks for pointing out! Unfortunately, I met network problem when committing the fix to GH. @MalaySanghi could you commit a fix instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The network is recovered, fixed by 9e1faa8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies, this escaped my notice. Thanks phoebe for fixing this