[PATCH] D70874: [X86] Add initialization of MXCSR in llvm-exegesis

Pengfei Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 1 01:59:48 PST 2019


pengfei updated this revision to Diff 231613.
pengfei marked an inline comment as done.
pengfei added a comment.

Fix typo.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70874/new/

https://reviews.llvm.org/D70874

Files:
  llvm/test/tools/llvm-exegesis/X86/uops-VFMADDSS4rm.s
  llvm/tools/llvm-exegesis/lib/X86/Target.cpp


Index: llvm/tools/llvm-exegesis/lib/X86/Target.cpp
===================================================================
--- llvm/tools/llvm-exegesis/lib/X86/Target.cpp
+++ llvm/tools/llvm-exegesis/lib/X86/Target.cpp
@@ -439,6 +439,8 @@
 
   std::vector<MCInst> popFlagAndFinalize();
 
+  std::vector<MCInst> loadMXCSRAndFinalize(bool HasAVX);
+
 private:
   ConstantInliner &add(const MCInst &Inst) {
     Instructions.push_back(Inst);
@@ -499,6 +501,19 @@
   return std::move(Instructions);
 }
 
+std::vector<MCInst> ConstantInliner::loadMXCSRAndFinalize(bool HasAVX) {
+  add(allocateStackSpace(4));
+  add(fillStackSpace(X86::MOV32mi, 0, 0x1f80)); // Mask all FP exceptions
+  add(MCInstBuilder(HasAVX ? X86::VLDMXCSR : X86::LDMXCSR)
+          // Address = ESP
+          .addReg(X86::RSP) // BaseReg
+          .addImm(1)        // ScaleAmt
+          .addReg(0)        // IndexReg
+          .addImm(0)        // Disp
+          .addReg(0));      // Segment
+  return std::move(Instructions);
+}
+
 void ConstantInliner::initStack(unsigned Bytes) {
   assert(Constant_.getBitWidth() <= Bytes * 8 &&
          "Value does not have the correct size");
@@ -699,6 +714,8 @@
   }
   if (Reg == X86::EFLAGS)
     return CI.popFlagAndFinalize();
+  if (Reg == X86::MXCSR)
+    return CI.loadMXCSRAndFinalize(STI.getFeatureBits()[X86::FeatureAVX]);
   return {}; // Not yet implemented.
 }
 
Index: llvm/test/tools/llvm-exegesis/X86/uops-VFMADDSS4rm.s
===================================================================
--- llvm/test/tools/llvm-exegesis/X86/uops-VFMADDSS4rm.s
+++ llvm/test/tools/llvm-exegesis/X86/uops-VFMADDSS4rm.s
@@ -5,3 +5,6 @@
 CHECK-NEXT: key:
 CHECK-NEXT:   instructions:
 CHECK-NEXT:     VFMADDSS4rm
+CHECK:      register_initial_values:
+# FIXME: This will be changed to CHECK by the following patch that modeling MXCSR to VFMADDSS.
+CHECK-NOT:      MXCSR


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70874.231613.patch
Type: text/x-patch
Size: 1880 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191201/c0df20aa/attachment.bin>


More information about the llvm-commits mailing list