<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Thanks! Committed as r190611.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Craig Topper [mailto:craig.topper@gmail.com]
<br>
<b>Sent:</b> Thursday, September 12, 2013 11:24 AM<br>
<b>To:</b> reviews+D1650+public+96a0704a61516414@llvm-reviews.chandlerc.com<br>
<b>Cc:</b> nrotem@apple.com; Langmuir, Ben; llvm-commits@cs.uiuc.edu<br>
<b>Subject:</b> Re: [PATCH] Partial support for Intel SHA Extensions (sha1rnds4)<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I forgot, the mem form needs mayLoad=1. Otherwise LGTM.<br>
<br>
On Thursday, September 12, 2013, Ben Langmuir wrote:<o:p></o:p></p>
<p class="MsoNormal"> Changes per review:<br>
* FeatureSHA implies FeatureSSE2<br>
* Use i128mem (oops)<br>
* Add sources and constraints for dest registers.<br>
<br>
Hi nadav,<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D1650" target="_blank">http://llvm-reviews.chandlerc.com/D1650</a><br>
<br>
CHANGE SINCE LAST DIFF<br>
<a href="http://llvm-reviews.chandlerc.com/D1650?vs=4210&id=4227#toc" target="_blank">
http://llvm-reviews.chandlerc.com/D1650?vs=4210&id=4227#toc</a><br>
<br>
Files:<br>
lib/Target/X86/X86.td<br>
lib/Target/X86/X86InstrInfo.td<br>
lib/Target/X86/X86InstrSSE.td<br>
lib/Target/X86/X86Subtarget.cpp<br>
lib/Target/X86/X86Subtarget.h<br>
test/MC/Disassembler/X86/x86-64.txt<br>
test/MC/X86/x86_64-encoding.s<br>
<br>
Index: lib/Target/X86/X86.td<br>
===================================================================<br>
--- lib/Target/X86/X86.td<br>
+++ lib/Target/X86/X86.td<br>
@@ -137,6 +137,9 @@<br>
"Support HLE">;<br>
def FeatureADX : SubtargetFeature<"adx", "HasADX", "true",<br>
"Support ADX instructions">;<br>
+def FeatureSHA : SubtargetFeature<"sha", "HasSHA", "true",<br>
+ "Enable SHA instructions",<br>
+ [FeatureSSE2]>;<br>
def FeaturePRFCHW : SubtargetFeature<"prfchw", "HasPRFCHW", "true",<br>
"Support PRFCHW instructions">;<br>
def FeatureRDSEED : SubtargetFeature<"rdseed", "HasRDSEED", "true",<br>
Index: lib/Target/X86/X86InstrInfo.td<br>
===================================================================<br>
--- lib/Target/X86/X86InstrInfo.td<br>
+++ lib/Target/X86/X86InstrInfo.td<br>
@@ -675,6 +675,7 @@<br>
def HasHLE : Predicate<"Subtarget->hasHLE()">;<br>
def HasTSX : Predicate<"Subtarget->hasRTM() || Subtarget->hasHLE()">;<br>
def HasADX : Predicate<"Subtarget->hasADX()">;<br>
+def HasSHA : Predicate<"Subtarget->hasSHA()">;<br>
def HasPRFCHW : Predicate<"Subtarget->hasPRFCHW()">;<br>
def HasRDSEED : Predicate<"Subtarget->hasRDSEED()">;<br>
def HasPrefetchW : Predicate<"Subtarget->has3DNow() || Subtarget->hasPRFCHW()">;<br>
Index: lib/Target/X86/X86InstrSSE.td<br>
===================================================================<br>
--- lib/Target/X86/X86InstrSSE.td<br>
+++ lib/Target/X86/X86InstrSSE.td<br>
@@ -7309,6 +7309,21 @@<br>
}<br>
<br>
//===----------------------------------------------------------------------===//<br>
+// SHA-NI Instructions<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+let Constraints = "$src1 = $dst", hasSideEffects = 0, Predicates = [HasSHA] in {<br>
+ def SHA1RNDS4rri : Ii8<0xCC, MRMSrcReg, (outs VR128:$dst),<br>
+ (ins VR128:$src1, VR128:$src2, i8imm:$src3),<br>
+ "sha1rnds4\t{$src3, $src2, $dst|$dst, $src2, $src3}",<br>
+ []>, TA;<br>
+ def SHA1RNDS4rmi : Ii8<0xCC, MRMSrcMem, (outs VR128:$dst),<br>
+ (ins VR128:$src1, i128mem:$src2, i8imm:$src3),<br>
+ "sha1rnds4\t{$src3, $src2, $dst|$dst, $src2, $src3}",<br>
+ []>, TA;<br>
+}<br>
+<br>
+//===----------------------------------------------------------------------===//<br>
// AES-NI Instructions<br>
//===----------------------------------------------------------------------===//<br>
<br>
Index: lib/Target/X86/X86Subtarget.cpp<br>
===================================================================<br>
--- lib/Target/X86/X86Subtarget.cpp<br>
+++ lib/Target/X86/X86Subtarget.cpp<br>
@@ -375,6 +375,10 @@<br>
HasCDI = true;<br>
ToggleFeature(X86::FeatureCDI);<br>
}<br>
+ if (IsIntel && ((EBX >> 29) & 0x1)) {<br>
+ HasSHA = true;<br>
+ ToggleFeature(X86::FeatureSHA);<br>
+ }<br>
}<br>
}<br>
}<br>
@@ -497,6 +501,7 @@<br>
HasCDI = false;<br>
HasPFI = false;<br>
HasADX = false;<br>
+ HasSHA = false;<br>
HasPRFCHW = false;<br>
HasRDSEED = false;<br>
IsBTMemSlow = false;<br>
Index: lib/Target/X86/X86Subtarget.h<br>
===================================================================<br>
--- lib/Target/X86/X86Subtarget.h<br>
+++ lib/Target/X86/X86Subtarget.h<br>
@@ -127,6 +127,9 @@<br>
/// HasADX - Processor has ADX instructions.<br>
bool HasADX;<br>
<br>
+ /// HasSHA - Processor has SHA instructions.<br>
+ bool HasSHA;<br>
+<br>
/// HasPRFCHW - Processor has PRFCHW instructions.<br>
bool HasPRFCHW;<br>
<br>
@@ -281,6 +284,7 @@<br>
bool hasRTM() const { return HasRTM; }<br>
bool hasHLE() const { return HasHLE; }<br>
bool hasADX() const { return HasADX; }<br>
+ bool hasSHA() const { return HasSHA; }<br>
bool hasPRFCHW() const { return HasPRFCHW; }<br>
bool hasRDSEED() const { return HasRDSEED; }<br>
bool isBTMemSlow() const { return IsBTMemSlow; }<br>
Index: test/MC/Disassembler/X86/x86-64.txt<br>
===================================================================<br>
--- test/MC/Disassembler/X86/x86-64.txt<br>
+++ test/MC/Disassembler/X86/x86-64.txt<br>
@@ -157,3 +157,9 @@<br>
<br>
# CHECK: movabsq %rax, -6066930261531658096<br>
0x48 0xa3 0x90 0x78 0x56 0x34 0x12 0xef 0xcd 0xab<br>
+<br>
+# CHECK: sha1rnds4 $1, %xmm1, %xmm2<br>
+0x0f 0x3a 0xcc 0xd1 0x01<br>
+<br>
+# CHECK: sha1rnds4 $1, (%rax), %xmm2<br>
+0x0f 0x3a 0xcc 0x10 0x01<br>
\ No newline at end of file<br>
Index: test/MC/X86/x86_64-encoding.s<br>
===================================================================<br>
--- test/MC/X86/x86_64-encoding.s<br>
+++ test/MC/X86/x86_64-encoding.s<br>
@@ -120,6 +120,14 @@<br>
// CHECK: fixup A - offset: 5, value: CPI1_0-4<br>
pshufb CPI1_0(%rip), %xmm1<br>
<br>
+// CHECK: sha1rnds4 $1, %xmm1, %xmm2<br>
+// CHECK: encoding: [0x0f,0x3a,0xcc,0xd1,0x01]<br>
+sha1rnds4 $1, %xmm1, %xmm2<br>
+<br>
+// CHECK: sha1rnds4 $1, (%rax), %xmm2<br>
+// CHECK: encoding: [0x0f,0x3a,0xcc,0x10,0x01]<br>
+sha1rnds4 $1, (%rax), %xmm2<br>
+<br>
// CHECK: movq 57005(,%riz), %rbx<br>
// CHECK: encoding: [0x48,0x8b,0x1c,0x25,0xad,0xde,0x00,0x00]<br>
movq 57005(,%riz), %rbx<o:p></o:p></p>
<p class="MsoNormal"><br>
<br>
-- <br>
~Craig<o:p></o:p></p>
</div>
</div>
</body>
</html>