[llvm-commits] [llvm] r99539 - in /llvm/trunk: lib/Target/X86/X86.td lib/Target/X86/X86InstrFormats.td lib/Target/X86/X86InstrInfo.td utils/TableGen/InstrInfoEmitter.cpp utils/TableGen/Record.cpp utils/TableGen/Record.h

Jakob Stoklund Olesen stoklund at 2pi.dk
Thu Mar 25 11:52:01 PDT 2010


Author: stoklund
Date: Thu Mar 25 13:52:01 2010
New Revision: 99539

URL: http://llvm.org/viewvc/llvm-project?rev=99539&view=rev
Log:
Teach TableGen to understand X.Y notation in the TSFlagsFields strings.

Remove much horribleness from X86InstrFormats as a result. Similar
simplifications are probably possible for other targets.

Modified:
    llvm/trunk/lib/Target/X86/X86.td
    llvm/trunk/lib/Target/X86/X86InstrFormats.td
    llvm/trunk/lib/Target/X86/X86InstrInfo.td
    llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp
    llvm/trunk/utils/TableGen/Record.cpp
    llvm/trunk/utils/TableGen/Record.h

Modified: llvm/trunk/lib/Target/X86/X86.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86.td?rev=99539&r1=99538&r2=99539&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86.td (original)
+++ llvm/trunk/lib/Target/X86/X86.td Thu Mar 25 13:52:01 2010
@@ -160,11 +160,11 @@
                        "hasAdSizePrefix",
                        "Prefix",
                        "hasREX_WPrefix",
-                       "ImmTypeBits",
-                       "FPFormBits",
+                       "ImmT.Value",
+                       "FPForm.Value",
                        "hasLockPrefix",
                        "SegOvrBits",
-                       "DomainBits",
+                       "ExeDomain.Value",
                        "Opcode"];
   let TSFlagsShifts = [0,
                        6,

Modified: llvm/trunk/lib/Target/X86/X86InstrFormats.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrFormats.td?rev=99539&r1=99538&r2=99539&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrFormats.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrFormats.td Thu Mar 25 13:52:01 2010
@@ -111,7 +111,6 @@
   Format Form = f;
   bits<6> FormBits = Form.Value;
   ImmType ImmT = i;
-  bits<3> ImmTypeBits = ImmT.Value;
 
   dag OutOperandList = outs;
   dag InOperandList = ins;
@@ -125,12 +124,10 @@
 
   bits<4> Prefix = 0;       // Which prefix byte does this inst have?
   bit hasREX_WPrefix  = 0;  // Does this inst requires the REX.W prefix?
-  FPFormat FPForm;          // What flavor of FP instruction is this?
-  bits<3> FPFormBits = 0;
+  FPFormat FPForm = NotFP;  // What flavor of FP instruction is this?
   bit hasLockPrefix = 0;    // Does this inst have a 0xF0 prefix?
   bits<2> SegOvrBits = 0;   // Segment override prefix.
-  Domain Dom = d;
-  bits<2> DomainBits = Dom.Value;
+  Domain ExeDomain = d;
 }
 
 class I<bits<8> o, Format f, dag outs, dag ins, string asm,
@@ -179,7 +176,7 @@
 // FpI_ - Floating Point Psuedo Instruction template. Not Predicated.
 class FpI_<dag outs, dag ins, FPFormat fp, list<dag> pattern>
   : X86Inst<0, Pseudo, NoImm, outs, ins, ""> {
-  let FPForm = fp; let FPFormBits = FPForm.Value;
+  let FPForm = fp;
   let Pattern = pattern;
 }
 

Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=99539&r1=99538&r2=99539&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Thu Mar 25 13:52:01 2010
@@ -587,7 +587,7 @@
 
 // Return instructions.
 let isTerminator = 1, isReturn = 1, isBarrier = 1,
-    hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
+    hasCtrlDep = 1, FPForm = SpecialFP in {
   def RET    : I   <0xC3, RawFrm, (outs), (ins variable_ops),
                     "ret",
                     [(X86retflag 0)]>;

Modified: llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp?rev=99539&r1=99538&r2=99539&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp Thu Mar 25 13:52:01 2010
@@ -337,7 +337,7 @@
                                         IntInit *ShiftInt, raw_ostream &OS) {
   if (Val == 0 || ShiftInt == 0)
     throw std::string("Illegal value or shift amount in TargetInfo*!");
-  RecordVal *RV = R->getValue(Val->getValue());
+  RecordVal *RV = R->getDottedValue(Val->getValue());
   int Shift = ShiftInt->getValue();
 
   if (RV == 0 || RV->getValue() == 0) {

Modified: llvm/trunk/utils/TableGen/Record.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.cpp?rev=99539&r1=99538&r2=99539&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/Record.cpp (original)
+++ llvm/trunk/utils/TableGen/Record.cpp Thu Mar 25 13:52:01 2010
@@ -1307,6 +1307,16 @@
   }
 }
 
+RecordVal *Record::getDottedValue(StringRef Name) {
+  size_t pos = Name.find('.');
+  if (pos == StringRef::npos)
+    return getValue(Name);
+  RecordVal *RV = getValue(Name.substr(0, pos));
+  if (!RV) return 0;
+  DefInit *DI = dynamic_cast<DefInit*>(RV->getValue());
+  if (!DI) return 0;
+  return DI->getDef()->getDottedValue(Name.substr(pos+1));
+}
 
 void Record::dump() const { errs() << *this; }
 

Modified: llvm/trunk/utils/TableGen/Record.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.h?rev=99539&r1=99538&r2=99539&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/Record.h (original)
+++ llvm/trunk/utils/TableGen/Record.h Thu Mar 25 13:52:01 2010
@@ -1262,6 +1262,9 @@
     return 0;
   }
 
+  // Like getValue, but allow dotting into members: X.Y
+  RecordVal *getDottedValue(StringRef Name);
+
   void addTemplateArg(StringRef Name) {
     assert(!isTemplateArg(Name) && "Template arg already defined!");
     TemplateArgs.push_back(Name);





More information about the llvm-commits mailing list