Author: evancheng
Date: Mon Oct  1 18:44:33 2007
New Revision: 42509

URL: http://llvm.org/viewvc/llvm-project?rev=42509&view=rev
Log:
Refactor code to add load / store folded instructions -> register only
instructions reverse map.

Modified:
    llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
    llvm/trunk/lib/Target/X86/X86RegisterInfo.h

Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=42509&r1=42508&r2=42509&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Mon Oct  1 18:44:33 2007
@@ -63,6 +63,577 @@
     StackPtr = X86::ESP;
     FramePtr = X86::EBP;
   }
+
+  SmallVector<unsigned,16> AmbEntries;
+  static const unsigned OpTbl2Addr[][2] = {
+    { X86::ADC32ri,     X86::ADC32mi },
+    { X86::ADC32ri8,    X86::ADC32mi8 },
+    { X86::ADC32rr,     X86::ADC32mr },
+    { X86::ADC64ri32,   X86::ADC64mi32 },
+    { X86::ADC64ri8,    X86::ADC64mi8 },
+    { X86::ADC64rr,     X86::ADC64mr },
+    { X86::ADD16ri,     X86::ADD16mi },
+    { X86::ADD16ri8,    X86::ADD16mi8 },
+    { X86::ADD16rr,     X86::ADD16mr },
+    { X86::ADD32ri,     X86::ADD32mi },
+    { X86::ADD32ri8,    X86::ADD32mi8 },
+    { X86::ADD32rr,     X86::ADD32mr },
+    { X86::ADD64ri32,   X86::ADD64mi32 },
+    { X86::ADD64ri8,    X86::ADD64mi8 },
+    { X86::ADD64rr,     X86::ADD64mr },
+    { X86::ADD8ri,      X86::ADD8mi },
+    { X86::ADD8rr,      X86::ADD8mr },
+    { X86::AND16ri,     X86::AND16mi },
+    { X86::AND16ri8,    X86::AND16mi8 },
+    { X86::AND16rr,     X86::AND16mr },
+    { X86::AND32ri,     X86::AND32mi },
+    { X86::AND32ri8,    X86::AND32mi8 },
+    { X86::AND32rr,     X86::AND32mr },
+    { X86::AND64ri32,   X86::AND64mi32 },
+    { X86::AND64ri8,    X86::AND64mi8 },
+    { X86::AND64rr,     X86::AND64mr },
+    { X86::AND8ri,      X86::AND8mi },
+    { X86::AND8rr,      X86::AND8mr },
+    { X86::DEC16r,      X86::DEC16m },
+    { X86::DEC32r,      X86::DEC32m },
+    { X86::DEC64_16r,   X86::DEC16m },
+    { X86::DEC64_32r,   X86::DEC32m },
+    { X86::DEC64r,      X86::DEC64m },
+    { X86::DEC8r,       X86::DEC8m },
+    { X86::INC16r,      X86::INC16m },
+    { X86::INC32r,      X86::INC32m },
+    { X86::INC64_16r,   X86::INC16m },
+    { X86::INC64_32r,   X86::INC32m },
+    { X86::INC64r,      X86::INC64m },
+    { X86::INC8r,       X86::INC8m },
+    { X86::NEG16r,      X86::NEG16m },
+    { X86::NEG32r,      X86::NEG32m },
+    { X86::NEG64r,      X86::NEG64m },
+    { X86::NEG8r,       X86::NEG8m },
+    { X86::NOT16r,      X86::NOT16m },
+    { X86::NOT32r,      X86::NOT32m },
+    { X86::NOT64r,      X86::NOT64m },
+    { X86::NOT8r,       X86::NOT8m },
+    { X86::OR16ri,      X86::OR16mi },
+    { X86::OR16ri8,     X86::OR16mi8 },
+    { X86::OR16rr,      X86::OR16mr },
+    { X86::OR32ri,      X86::OR32mi },
+    { X86::OR32ri8,     X86::OR32mi8 },
+    { X86::OR32rr,      X86::OR32mr },
+    { X86::OR64ri32,    X86::OR64mi32 },
+    { X86::OR64ri8,     X86::OR64mi8 },
+    { X86::OR64rr,      X86::OR64mr },
+    { X86::OR8ri,       X86::OR8mi },
+    { X86::OR8rr,       X86::OR8mr },
+    { X86::ROL16r1,     X86::ROL16m1 },
+    { X86::ROL16rCL,    X86::ROL16mCL },
+    { X86::ROL16ri,     X86::ROL16mi },
+    { X86::ROL32r1,     X86::ROL32m1 },
+    { X86::ROL32rCL,    X86::ROL32mCL },
+    { X86::ROL32ri,     X86::ROL32mi },
+    { X86::ROL64r1,     X86::ROL64m1 },
+    { X86::ROL64rCL,    X86::ROL64mCL },
+    { X86::ROL64ri,     X86::ROL64mi },
+    { X86::ROL8r1,      X86::ROL8m1 },
+    { X86::ROL8rCL,     X86::ROL8mCL },
+    { X86::ROL8ri,      X86::ROL8mi },
+    { X86::ROR16r1,     X86::ROR16m1 },
+    { X86::ROR16rCL,    X86::ROR16mCL },
+    { X86::ROR16ri,     X86::ROR16mi },
+    { X86::ROR32r1,     X86::ROR32m1 },
+    { X86::ROR32rCL,    X86::ROR32mCL },
+    { X86::ROR32ri,     X86::ROR32mi },
+    { X86::ROR64r1,     X86::ROR64m1 },
+    { X86::ROR64rCL,    X86::ROR64mCL },
+    { X86::ROR64ri,     X86::ROR64mi },
+    { X86::ROR8r1,      X86::ROR8m1 },
+    { X86::ROR8rCL,     X86::ROR8mCL },
+    { X86::ROR8ri,      X86::ROR8mi },
+    { X86::SAR16r1,     X86::SAR16m1 },
+    { X86::SAR16rCL,    X86::SAR16mCL },
+    { X86::SAR16ri,     X86::SAR16mi },
+    { X86::SAR32r1,     X86::SAR32m1 },
+    { X86::SAR32rCL,    X86::SAR32mCL },
+    { X86::SAR32ri,     X86::SAR32mi },
+    { X86::SAR64r1,     X86::SAR64m1 },
+    { X86::SAR64rCL,    X86::SAR64mCL },
+    { X86::SAR64ri,     X86::SAR64mi },
+    { X86::SAR8r1,      X86::SAR8m1 },
+    { X86::SAR8rCL,     X86::SAR8mCL },
+    { X86::SAR8ri,      X86::SAR8mi },
+    { X86::SBB32ri,     X86::SBB32mi },
+    { X86::SBB32ri8,    X86::SBB32mi8 },
+    { X86::SBB32rr,     X86::SBB32mr },
+    { X86::SBB64ri32,   X86::SBB64mi32 },
+    { X86::SBB64ri8,    X86::SBB64mi8 },
+    { X86::SBB64rr,     X86::SBB64mr },
+    { X86::SHL16r1,     X86::SHL16m1 },
+    { X86::SHL16rCL,    X86::SHL16mCL },
+    { X86::SHL16ri,     X86::SHL16mi },
+    { X86::SHL32r1,     X86::SHL32m1 },
+    { X86::SHL32rCL,    X86::SHL32mCL },
+    { X86::SHL32ri,     X86::SHL32mi },
+    { X86::SHL64r1,     X86::SHL64m1 },
+    { X86::SHL64rCL,    X86::SHL64mCL },
+    { X86::SHL64ri,     X86::SHL64mi },
+    { X86::SHL8r1,      X86::SHL8m1 },
+    { X86::SHL8rCL,     X86::SHL8mCL },
+    { X86::SHL8ri,      X86::SHL8mi },
+    { X86::SHLD16rrCL,  X86::SHLD16mrCL },
+    { X86::SHLD16rri8,  X86::SHLD16mri8 },
+    { X86::SHLD32rrCL,  X86::SHLD32mrCL },
+    { X86::SHLD32rri8,  X86::SHLD32mri8 },
+    { X86::SHLD64rrCL,  X86::SHLD64mrCL },
+    { X86::SHLD64rri8,  X86::SHLD64mri8 },
+    { X86::SHR16r1,     X86::SHR16m1 },
+    { X86::SHR16rCL,    X86::SHR16mCL },
+    { X86::SHR16ri,     X86::SHR16mi },
+    { X86::SHR32r1,     X86::SHR32m1 },
+    { X86::SHR32rCL,    X86::SHR32mCL },
+    { X86::SHR32ri,     X86::SHR32mi },
+    { X86::SHR64r1,     X86::SHR64m1 },
+    { X86::SHR64rCL,    X86::SHR64mCL },
+    { X86::SHR64ri,     X86::SHR64mi },
+    { X86::SHR8r1,      X86::SHR8m1 },
+    { X86::SHR8rCL,     X86::SHR8mCL },
+    { X86::SHR8ri,      X86::SHR8mi },
+    { X86::SHRD16rrCL,  X86::SHRD16mrCL },
+    { X86::SHRD16rri8,  X86::SHRD16mri8 },
+    { X86::SHRD32rrCL,  X86::SHRD32mrCL },
+    { X86::SHRD32rri8,  X86::SHRD32mri8 },
+    { X86::SHRD64rrCL,  X86::SHRD64mrCL },
+    { X86::SHRD64rri8,  X86::SHRD64mri8 },
+    { X86::SUB16ri,     X86::SUB16mi },
+    { X86::SUB16ri8,    X86::SUB16mi8 },
+    { X86::SUB16rr,     X86::SUB16mr },
+    { X86::SUB32ri,     X86::SUB32mi },
+    { X86::SUB32ri8,    X86::SUB32mi8 },
+    { X86::SUB32rr,     X86::SUB32mr },
+    { X86::SUB64ri32,   X86::SUB64mi32 },
+    { X86::SUB64ri8,    X86::SUB64mi8 },
+    { X86::SUB64rr,     X86::SUB64mr },
+    { X86::SUB8ri,      X86::SUB8mi },
+    { X86::SUB8rr,      X86::SUB8mr },
+    { X86::XOR16ri,     X86::XOR16mi },
+    { X86::XOR16ri8,    X86::XOR16mi8 },
+    { X86::XOR16rr,     X86::XOR16mr },
+    { X86::XOR32ri,     X86::XOR32mi },
+    { X86::XOR32ri8,    X86::XOR32mi8 },
+    { X86::XOR32rr,     X86::XOR32mr },
+    { X86::XOR64ri32,   X86::XOR64mi32 },
+    { X86::XOR64ri8,    X86::XOR64mi8 },
+    { X86::XOR64rr,     X86::XOR64mr },
+    { X86::XOR8ri,      X86::XOR8mi },
+    { X86::XOR8rr,      X86::XOR8mr }
+  };
+
+  for (unsigned i = 0, e = array_lengthof(OpTbl2Addr); i != e; ++i) {
+    unsigned RegOp = OpTbl2Addr[i][0];
+    unsigned MemOp = OpTbl2Addr[i][1];
+    if (!RegOp2MemOpTable2Addr.insert(std::make_pair((unsigned*)RegOp, MemOp)))
+      assert(false && "Duplicated entries?");
+    if (!MemOp2RegOpTable.insert(std::make_pair((unsigned*)MemOp, RegOp)))
+      AmbEntries.push_back(MemOp);
+  }
+
+  static const unsigned OpTbl0[][2] = {
+    { X86::CALL32r,     X86::CALL32m },
+    { X86::CALL64r,     X86::CALL64m },
+    { X86::CMP16ri,     X86::CMP16mi },
+    { X86::CMP16ri8,    X86::CMP16mi8 },
+    { X86::CMP32ri,     X86::CMP32mi },
+    { X86::CMP32ri8,    X86::CMP32mi8 },
+    { X86::CMP64ri32,   X86::CMP64mi32 },
+    { X86::CMP64ri8,    X86::CMP64mi8 },
+    { X86::CMP8ri,      X86::CMP8mi },
+    { X86::DIV16r,      X86::DIV16m },
+    { X86::DIV32r,      X86::DIV32m },
+    { X86::DIV64r,      X86::DIV64m },
+    { X86::DIV8r,       X86::DIV8m },
+    { X86::FsMOVAPDrr,  X86::MOVSDmr },
+    { X86::FsMOVAPSrr,  X86::MOVSSmr },
+    { X86::IDIV16r,     X86::IDIV16m },
+    { X86::IDIV32r,     X86::IDIV32m },
+    { X86::IDIV64r,     X86::IDIV64m },
+    { X86::IDIV8r,      X86::IDIV8m },
+    { X86::IMUL16r,     X86::IMUL16m },
+    { X86::IMUL32r,     X86::IMUL32m },
+    { X86::IMUL64r,     X86::IMUL64m },
+    { X86::IMUL8r,      X86::IMUL8m },
+    { X86::JMP32r,      X86::JMP32m },
+    { X86::JMP64r,      X86::JMP64m },
+    { X86::MOV16ri,     X86::MOV16mi },
+    { X86::MOV16rr,     X86::MOV16mr },
+    { X86::MOV32ri,     X86::MOV32mi },
+    { X86::MOV32rr,     X86::MOV32mr },
+    { X86::MOV64ri32,   X86::MOV64mi32 },
+    { X86::MOV64rr,     X86::MOV64mr },
+    { X86::MOV8ri,      X86::MOV8mi },
+    { X86::MOV8rr,      X86::MOV8mr },
+    { X86::MOVAPDrr,    X86::MOVAPDmr },
+    { X86::MOVAPSrr,    X86::MOVAPSmr },
+    { X86::MOVPDI2DIrr, X86::MOVPDI2DImr },
+    { X86::MOVPQIto64rr,X86::MOVPQIto64mr },
+    { X86::MOVPS2SSrr,  X86::MOVPS2SSmr },
+    { X86::MOVSDrr,     X86::MOVSDmr },
+    { X86::MOVSDto64rr, X86::MOVSDto64mr },
+    { X86::MOVSS2DIrr,  X86::MOVSS2DImr },
+    { X86::MOVSSrr,     X86::MOVSSmr },
+    { X86::MOVUPDrr,    X86::MOVUPDmr },
+    { X86::MOVUPSrr,    X86::MOVUPSmr },
+    { X86::MUL16r,      X86::MUL16m },
+    { X86::MUL32r,      X86::MUL32m },
+    { X86::MUL64r,      X86::MUL64m },
+    { X86::MUL8r,       X86::MUL8m },
+    { X86::SETAEr,      X86::SETAEm },
+    { X86::SETAr,       X86::SETAm },
+    { X86::SETBEr,      X86::SETBEm },
+    { X86::SETBr,       X86::SETBm },
+    { X86::SETEr,       X86::SETEm },
+    { X86::SETGEr,      X86::SETGEm },
+    { X86::SETGr,       X86::SETGm },
+    { X86::SETLEr,      X86::SETLEm },
+    { X86::SETLr,       X86::SETLm },
+    { X86::SETNEr,      X86::SETNEm },
+    { X86::SETNPr,      X86::SETNPm },
+    { X86::SETNSr,      X86::SETNSm },
+    { X86::SETPr,       X86::SETPm },
+    { X86::SETSr,       X86::SETSm },
+    { X86::TAILJMPr,    X86::TAILJMPm },
+    { X86::TEST16ri,    X86::TEST16mi },
+    { X86::TEST32ri,    X86::TEST32mi },
+    { X86::TEST64ri32,  X86::TEST64mi32 },
+    { X86::TEST8ri,     X86::TEST8mi },
+    { X86::XCHG16rr,    X86::XCHG16mr },
+    { X86::XCHG32rr,    X86::XCHG32mr },
+    { X86::XCHG64rr,    X86::XCHG64mr },
+    { X86::XCHG8rr,     X86::XCHG8mr }
+  };
+
+  for (unsigned i = 0, e = array_lengthof(OpTbl0); i != e; ++i) {
+    unsigned RegOp = OpTbl0[i][0];
+    unsigned MemOp = OpTbl0[i][1];
+    if (!RegOp2MemOpTable0.insert(std::make_pair((unsigned*)RegOp, MemOp)))
+      assert(false && "Duplicated entries?");
+    if (!MemOp2RegOpTable.insert(std::make_pair((unsigned*)MemOp, RegOp)))
+      AmbEntries.push_back(MemOp);
+  }
+
+  static const unsigned OpTbl1[][2] = {
+    { X86::CMP16rr,         X86::CMP16rm },
+    { X86::CMP32rr,         X86::CMP32rm },
+    { X86::CMP64rr,         X86::CMP64rm },
+    { X86::CMP8rr,          X86::CMP8rm },
+    { X86::CVTSD2SSrr,      X86::CVTSD2SSrm },
+    { X86::CVTSI2SD64rr,    X86::CVTSI2SD64rm },
+    { X86::CVTSI2SDrr,      X86::CVTSI2SDrm },
+    { X86::CVTSI2SS64rr,    X86::CVTSI2SS64rm },
+    { X86::CVTSI2SSrr,      X86::CVTSI2SSrm },
+    { X86::CVTSS2SDrr,      X86::CVTSS2SDrm },
+    { X86::CVTTSD2SI64rr,   X86::CVTTSD2SI64rm },
+    { X86::CVTTSD2SIrr,     X86::CVTTSD2SIrm },
+    { X86::CVTTSS2SI64rr,   X86::CVTTSS2SI64rm },
+    { X86::CVTTSS2SIrr,     X86::CVTTSS2SIrm },
+    { X86::FsMOVAPDrr,      X86::MOVSDrm },
+    { X86::FsMOVAPSrr,      X86::MOVSSrm },
+    { X86::IMUL16rri,       X86::IMUL16rmi },
+    { X86::IMUL16rri8,      X86::IMUL16rmi8 },
+    { X86::IMUL32rri,       X86::IMUL32rmi },
+    { X86::IMUL32rri8,      X86::IMUL32rmi8 },
+    { X86::IMUL64rri32,     X86::IMUL64rmi32 },
+    { X86::IMUL64rri8,      X86::IMUL64rmi8 },
+    { X86::Int_CMPSDrr,     X86::Int_CMPSDrm },
+    { X86::Int_CMPSSrr,     X86::Int_CMPSSrm },
+    { X86::Int_COMISDrr,    X86::Int_COMISDrm },
+    { X86::Int_COMISSrr,    X86::Int_COMISSrm },
+    { X86::Int_CVTDQ2PDrr,  X86::Int_CVTDQ2PDrm },
+    { X86::Int_CVTDQ2PSrr,  X86::Int_CVTDQ2PSrm },
+    { X86::Int_CVTPD2DQrr,  X86::Int_CVTPD2DQrm },
+    { X86::Int_CVTPD2PSrr,  X86::Int_CVTPD2PSrm },
+    { X86::Int_CVTPS2DQrr,  X86::Int_CVTPS2DQrm },
+    { X86::Int_CVTPS2PDrr,  X86::Int_CVTPS2PDrm },
+    { X86::Int_CVTSD2SI64rr,X86::Int_CVTSD2SI64rm },
+    { X86::Int_CVTSD2SIrr,  X86::Int_CVTSD2SIrm },
+    { X86::Int_CVTSD2SSrr,  X86::Int_CVTSD2SSrm },
+    { X86::Int_CVTSI2SD64rr,X86::Int_CVTSI2SD64rm },
+    { X86::Int_CVTSI2SDrr,  X86::Int_CVTSI2SDrm },
+    { X86::Int_CVTSI2SS64rr,X86::Int_CVTSI2SS64rm },
+    { X86::Int_CVTSI2SSrr,  X86::Int_CVTSI2SSrm },
+    { X86::Int_CVTSS2SDrr,  X86::Int_CVTSS2SDrm },
+    { X86::Int_CVTSS2SI64rr,X86::Int_CVTSS2SI64rm },
+    { X86::Int_CVTSS2SIrr,  X86::Int_CVTSS2SIrm },
+    { X86::Int_CVTTPD2DQrr, X86::Int_CVTTPD2DQrm },
+    { X86::Int_CVTTPS2DQrr, X86::Int_CVTTPS2DQrm },
+    { X86::Int_CVTTSD2SI64rr,X86::Int_CVTTSD2SI64rm },
+    { X86::Int_CVTTSD2SIrr, X86::Int_CVTTSD2SIrm },
+    { X86::Int_CVTTSS2SI64rr,X86::Int_CVTTSS2SI64rm },
+    { X86::Int_CVTTSS2SIrr, X86::Int_CVTTSS2SIrm },
+    { X86::Int_UCOMISDrr,   X86::Int_UCOMISDrm },
+    { X86::Int_UCOMISSrr,   X86::Int_UCOMISSrm },
+    { X86::MOV16rr,         X86::MOV16rm },
+    { X86::MOV32rr,         X86::MOV32rm },
+    { X86::MOV64rr,         X86::MOV64rm },
+    { X86::MOV64toPQIrr,    X86::MOV64toPQIrm },
+    { X86::MOV64toSDrr,     X86::MOV64toSDrm },
+    { X86::MOV8rr,          X86::MOV8rm },
+    { X86::MOVAPDrr,        X86::MOVAPDrm },
+    { X86::MOVAPSrr,        X86::MOVAPSrm },
+    { X86::MOVDDUPrr,       X86::MOVDDUPrm },
+    { X86::MOVDI2PDIrr,     X86::MOVDI2PDIrm },
+    { X86::MOVDI2SSrr,      X86::MOVDI2SSrm },
+    { X86::MOVSD2PDrr,      X86::MOVSD2PDrm },
+    { X86::MOVSDrr,         X86::MOVSDrm },
+    { X86::MOVSHDUPrr,      X86::MOVSHDUPrm },
+    { X86::MOVSLDUPrr,      X86::MOVSLDUPrm },
+    { X86::MOVSS2PSrr,      X86::MOVSS2PSrm },
+    { X86::MOVSSrr,         X86::MOVSSrm },
+    { X86::MOVSX16rr8,      X86::MOVSX16rm8 },
+    { X86::MOVSX32rr16,     X86::MOVSX32rm16 },
+    { X86::MOVSX32rr8,      X86::MOVSX32rm8 },
+    { X86::MOVSX64rr16,     X86::MOVSX64rm16 },
+    { X86::MOVSX64rr32,     X86::MOVSX64rm32 },
+    { X86::MOVSX64rr8,      X86::MOVSX64rm8 },
+    { X86::MOVUPDrr,        X86::MOVUPDrm },
+    { X86::MOVUPSrr,        X86::MOVUPSrm },
+    { X86::MOVZX16rr8,      X86::MOVZX16rm8 },
+    { X86::MOVZX32rr16,     X86::MOVZX32rm16 },
+    { X86::MOVZX32rr8,      X86::MOVZX32rm8 },
+    { X86::MOVZX64rr16,     X86::MOVZX64rm16 },
+    { X86::MOVZX64rr8,      X86::MOVZX64rm8 },
+    { X86::PSHUFDri,        X86::PSHUFDmi },
+    { X86::PSHUFHWri,       X86::PSHUFHWmi },
+    { X86::PSHUFLWri,       X86::PSHUFLWmi },
+    { X86::PsMOVZX64rr32,   X86::PsMOVZX64rm32 },
+    { X86::RCPPSr,          X86::RCPPSm },
+    { X86::RCPPSr_Int,      X86::RCPPSm_Int },
+    { X86::RSQRTPSr,        X86::RSQRTPSm },
+    { X86::RSQRTPSr_Int,    X86::RSQRTPSm_Int },
+    { X86::RSQRTSSr,        X86::RSQRTSSm },
+    { X86::RSQRTSSr_Int,    X86::RSQRTSSm_Int },
+    { X86::SQRTPDr,         X86::SQRTPDm },
+    { X86::SQRTPDr_Int,     X86::SQRTPDm_Int },
+    { X86::SQRTPSr,         X86::SQRTPSm },
+    { X86::SQRTPSr_Int,     X86::SQRTPSm_Int },
+    { X86::SQRTSDr,         X86::SQRTSDm },
+    { X86::SQRTSDr_Int,     X86::SQRTSDm_Int },
+    { X86::SQRTSSr,         X86::SQRTSSm },
+    { X86::SQRTSSr_Int,     X86::SQRTSSm_Int },
+    { X86::TEST16rr,        X86::TEST16rm },
+    { X86::TEST32rr,        X86::TEST32rm },
+    { X86::TEST64rr,        X86::TEST64rm },
+    { X86::TEST8rr,         X86::TEST8rm },
+    // FIXME: TEST*rr EAX,EAX ---> CMP [mem], 0
+    { X86::UCOMISDrr,       X86::UCOMISDrm },
+    { X86::UCOMISSrr,       X86::UCOMISSrm },
+    { X86::XCHG16rr,        X86::XCHG16rm },
+    { X86::XCHG32rr,        X86::XCHG32rm },
+    { X86::XCHG64rr,        X86::XCHG64rm },
+    { X86::XCHG8rr,         X86::XCHG8rm }
+  };
+
+  for (unsigned i = 0, e = array_lengthof(OpTbl1); i != e; ++i) {
+    unsigned RegOp = OpTbl1[i][0];
+    unsigned MemOp = OpTbl1[i][1];
+    if (!RegOp2MemOpTable1.insert(std::make_pair((unsigned*)RegOp, MemOp)))
+      assert(false && "Duplicated entries?");
+    if (!MemOp2RegOpTable.insert(std::make_pair((unsigned*)MemOp, RegOp)))
+      AmbEntries.push_back(MemOp);
+  }
+
+  static const unsigned OpTbl2[][2] = {
+    { X86::ADC32rr,         X86::ADC32rm },
+    { X86::ADC64rr,         X86::ADC64rm },
+    { X86::ADD16rr,         X86::ADD16rm },
+    { X86::ADD32rr,         X86::ADD32rm },
+    { X86::ADD64rr,         X86::ADD64rm },
+    { X86::ADD8rr,          X86::ADD8rm },
+    { X86::ADDPDrr,         X86::ADDPDrm },
+    { X86::ADDPSrr,         X86::ADDPSrm },
+    { X86::ADDSDrr,         X86::ADDSDrm },
+    { X86::ADDSSrr,         X86::ADDSSrm },
+    { X86::ADDSUBPDrr,      X86::ADDSUBPDrm },
+    { X86::ADDSUBPSrr,      X86::ADDSUBPSrm },
+    { X86::AND16rr,         X86::AND16rm },
+    { X86::AND32rr,         X86::AND32rm },
+    { X86::AND64rr,         X86::AND64rm },
+    { X86::AND8rr,          X86::AND8rm },
+    { X86::ANDNPDrr,        X86::ANDNPDrm },
+    { X86::ANDNPSrr,        X86::ANDNPSrm },
+    { X86::ANDPDrr,         X86::ANDPDrm },
+    { X86::ANDPSrr,         X86::ANDPSrm },
+    { X86::CMOVA16rr,       X86::CMOVA16rm },
+    { X86::CMOVA32rr,       X86::CMOVA32rm },
+    { X86::CMOVA64rr,       X86::CMOVA64rm },
+    { X86::CMOVAE16rr,      X86::CMOVAE16rm },
+    { X86::CMOVAE32rr,      X86::CMOVAE32rm },
+    { X86::CMOVAE64rr,      X86::CMOVAE64rm },
+    { X86::CMOVB16rr,       X86::CMOVB16rm },
+    { X86::CMOVB32rr,       X86::CMOVB32rm },
+    { X86::CMOVB64rr,       X86::CMOVB64rm },
+    { X86::CMOVBE16rr,      X86::CMOVBE16rm },
+    { X86::CMOVBE32rr,      X86::CMOVBE32rm },
+    { X86::CMOVBE64rr,      X86::CMOVBE64rm },
+    { X86::CMOVE16rr,       X86::CMOVE16rm },
+    { X86::CMOVE32rr,       X86::CMOVE32rm },
+    { X86::CMOVE64rr,       X86::CMOVE64rm },
+    { X86::CMOVG16rr,       X86::CMOVG16rm },
+    { X86::CMOVG32rr,       X86::CMOVG32rm },
+    { X86::CMOVG64rr,       X86::CMOVG64rm },
+    { X86::CMOVGE16rr,      X86::CMOVGE16rm },
+    { X86::CMOVGE32rr,      X86::CMOVGE32rm },
+    { X86::CMOVGE64rr,      X86::CMOVGE64rm },
+    { X86::CMOVL16rr,       X86::CMOVL16rm },
+    { X86::CMOVL32rr,       X86::CMOVL32rm },
+    { X86::CMOVL64rr,       X86::CMOVL64rm },
+    { X86::CMOVLE16rr,      X86::CMOVLE16rm },
+    { X86::CMOVLE32rr,      X86::CMOVLE32rm },
+    { X86::CMOVLE64rr,      X86::CMOVLE64rm },
+    { X86::CMOVNE16rr,      X86::CMOVNE16rm },
+    { X86::CMOVNE32rr,      X86::CMOVNE32rm },
+    { X86::CMOVNE64rr,      X86::CMOVNE64rm },
+    { X86::CMOVNP16rr,      X86::CMOVNP16rm },
+    { X86::CMOVNP32rr,      X86::CMOVNP32rm },
+    { X86::CMOVNP64rr,      X86::CMOVNP64rm },
+    { X86::CMOVNS16rr,      X86::CMOVNS16rm },
+    { X86::CMOVNS32rr,      X86::CMOVNS32rm },
+    { X86::CMOVNS64rr,      X86::CMOVNS64rm },
+    { X86::CMOVP16rr,       X86::CMOVP16rm },
+    { X86::CMOVP32rr,       X86::CMOVP32rm },
+    { X86::CMOVP64rr,       X86::CMOVP64rm },
+    { X86::CMOVS16rr,       X86::CMOVS16rm },
+    { X86::CMOVS32rr,       X86::CMOVS32rm },
+    { X86::CMOVS64rr,       X86::CMOVS64rm },
+    { X86::CMPPDrri,        X86::CMPPDrmi },
+    { X86::CMPPSrri,        X86::CMPPSrmi },
+    { X86::CMPSDrr,         X86::CMPSDrm },
+    { X86::CMPSSrr,         X86::CMPSSrm },
+    { X86::DIVPDrr,         X86::DIVPDrm },
+    { X86::DIVPSrr,         X86::DIVPSrm },
+    { X86::DIVSDrr,         X86::DIVSDrm },
+    { X86::DIVSSrr,         X86::DIVSSrm },
+    { X86::HADDPDrr,        X86::HADDPDrm },
+    { X86::HADDPSrr,        X86::HADDPSrm },
+    { X86::HSUBPDrr,        X86::HSUBPDrm },
+    { X86::HSUBPSrr,        X86::HSUBPSrm },
+    { X86::IMUL16rr,        X86::IMUL16rm },
+    { X86::IMUL32rr,        X86::IMUL32rm },
+    { X86::IMUL64rr,        X86::IMUL64rm },
+    { X86::MAXPDrr,         X86::MAXPDrm },
+    { X86::MAXPDrr_Int,     X86::MAXPDrm_Int },
+    { X86::MAXPSrr,         X86::MAXPSrm },
+    { X86::MAXPSrr_Int,     X86::MAXPSrm_Int },
+    { X86::MAXSDrr,         X86::MAXSDrm },
+    { X86::MAXSDrr_Int,     X86::MAXSDrm_Int },
+    { X86::MAXSSrr,         X86::MAXSSrm },
+    { X86::MAXSSrr_Int,     X86::MAXSSrm_Int },
+    { X86::MINPDrr,         X86::MINPDrm },
+    { X86::MINPDrr_Int,     X86::MINPDrm_Int },
+    { X86::MINPSrr,         X86::MINPSrm },
+    { X86::MINPSrr_Int,     X86::MINPSrm_Int },
+    { X86::MINSDrr,         X86::MINSDrm },
+    { X86::MINSDrr_Int,     X86::MINSDrm_Int },
+    { X86::MINSSrr,         X86::MINSSrm },
+    { X86::MINSSrr_Int,     X86::MINSSrm_Int },
+    { X86::MULPDrr,         X86::MULPDrm },
+    { X86::MULPSrr,         X86::MULPSrm },
+    { X86::MULSDrr,         X86::MULSDrm },
+    { X86::MULSSrr,         X86::MULSSrm },
+    { X86::OR16rr,          X86::OR16rm },
+    { X86::OR32rr,          X86::OR32rm },
+    { X86::OR64rr,          X86::OR64rm },
+    { X86::OR8rr,           X86::OR8rm },
+    { X86::ORPDrr,          X86::ORPDrm },
+    { X86::ORPSrr,          X86::ORPSrm },
+    { X86::PACKSSDWrr,      X86::PACKSSDWrm },
+    { X86::PACKSSWBrr,      X86::PACKSSWBrm },
+    { X86::PACKUSWBrr,      X86::PACKUSWBrm },
+    { X86::PADDBrr,         X86::PADDBrm },
+    { X86::PADDDrr,         X86::PADDDrm },
+    { X86::PADDQrr,         X86::PADDQrm },
+    { X86::PADDSBrr,        X86::PADDSBrm },
+    { X86::PADDSWrr,        X86::PADDSWrm },
+    { X86::PADDWrr,         X86::PADDWrm },
+    { X86::PANDNrr,         X86::PANDNrm },
+    { X86::PANDrr,          X86::PANDrm },
+    { X86::PAVGBrr,         X86::PAVGBrm },
+    { X86::PAVGWrr,         X86::PAVGWrm },
+    { X86::PCMPEQBrr,       X86::PCMPEQBrm },
+    { X86::PCMPEQDrr,       X86::PCMPEQDrm },
+    { X86::PCMPEQWrr,       X86::PCMPEQWrm },
+    { X86::PCMPGTBrr,       X86::PCMPGTBrm },
+    { X86::PCMPGTDrr,       X86::PCMPGTDrm },
+    { X86::PCMPGTWrr,       X86::PCMPGTWrm },
+    { X86::PINSRWrri,       X86::PINSRWrmi },
+    { X86::PMADDWDrr,       X86::PMADDWDrm },
+    { X86::PMAXSWrr,        X86::PMAXSWrm },
+    { X86::PMAXUBrr,        X86::PMAXUBrm },
+    { X86::PMINSWrr,        X86::PMINSWrm },
+    { X86::PMINUBrr,        X86::PMINUBrm },
+    { X86::PMULHUWrr,       X86::PMULHUWrm },
+    { X86::PMULHWrr,        X86::PMULHWrm },
+    { X86::PMULLWrr,        X86::PMULLWrm },
+    { X86::PMULUDQrr,       X86::PMULUDQrm },
+    { X86::PORrr,           X86::PORrm },
+    { X86::PSADBWrr,        X86::PSADBWrm },
+    { X86::PSLLDrr,         X86::PSLLDrm },
+    { X86::PSLLQrr,         X86::PSLLQrm },
+    { X86::PSLLWrr,         X86::PSLLWrm },
+    { X86::PSRADrr,         X86::PSRADrm },
+    { X86::PSRAWrr,         X86::PSRAWrm },
+    { X86::PSRLDrr,         X86::PSRLDrm },
+    { X86::PSRLQrr,         X86::PSRLQrm },
+    { X86::PSRLWrr,         X86::PSRLWrm },
+    { X86::PSUBBrr,         X86::PSUBBrm },
+    { X86::PSUBDrr,         X86::PSUBDrm },
+    { X86::PSUBSBrr,        X86::PSUBSBrm },
+    { X86::PSUBSWrr,        X86::PSUBSWrm },
+    { X86::PSUBWrr,         X86::PSUBWrm },
+    { X86::PUNPCKHBWrr,     X86::PUNPCKHBWrm },
+    { X86::PUNPCKHDQrr,     X86::PUNPCKHDQrm },
+    { X86::PUNPCKHQDQrr,    X86::PUNPCKHQDQrm },
+    { X86::PUNPCKHWDrr,     X86::PUNPCKHWDrm },
+    { X86::PUNPCKLBWrr,     X86::PUNPCKLBWrm },
+    { X86::PUNPCKLDQrr,     X86::PUNPCKLDQrm },
+    { X86::PUNPCKLQDQrr,    X86::PUNPCKLQDQrm },
+    { X86::PUNPCKLWDrr,     X86::PUNPCKLWDrm },
+    { X86::PXORrr,          X86::PXORrm },
+    { X86::SBB32rr,         X86::SBB32rm },
+    { X86::SBB64rr,         X86::SBB64rm },
+    { X86::SHUFPDrri,       X86::SHUFPDrmi },
+    { X86::SHUFPSrri,       X86::SHUFPSrmi },
+    { X86::SUB16rr,         X86::SUB16rm },
+    { X86::SUB32rr,         X86::SUB32rm },
+    { X86::SUB64rr,         X86::SUB64rm },
+    { X86::SUB8rr,          X86::SUB8rm },
+    { X86::SUBPDrr,         X86::SUBPDrm },
+    { X86::SUBPSrr,         X86::SUBPSrm },
+    { X86::SUBSDrr,         X86::SUBSDrm },
+    { X86::SUBSSrr,         X86::SUBSSrm },
+    // FIXME: TEST*rr -> swapped operand of TEST*mr.
+    { X86::UNPCKHPDrr,      X86::UNPCKHPDrm },
+    { X86::UNPCKHPSrr,      X86::UNPCKHPSrm },
+    { X86::UNPCKLPDrr,      X86::UNPCKLPDrm },
+    { X86::UNPCKLPSrr,      X86::UNPCKLPSrm },
+    { X86::XOR16rr,         X86::XOR16rm },
+    { X86::XOR32rr,         X86::XOR32rm },
+    { X86::XOR64rr,         X86::XOR64rm },
+    { X86::XOR8rr,          X86::XOR8rm },
+    { X86::XORPDrr,         X86::XORPDrm },
+    { X86::XORPSrr,         X86::XORPSrm }
+  };
+
+  for (unsigned i = 0, e = array_lengthof(OpTbl2); i != e; ++i) {
+    unsigned RegOp = OpTbl2[i][0];
+    unsigned MemOp = OpTbl2[i][1];
+    if (!RegOp2MemOpTable2.insert(std::make_pair((unsigned*)RegOp, MemOp)))
+      assert(false && "Duplicated entries?");
+    if (!MemOp2RegOpTable.insert(std::make_pair((unsigned*)MemOp, RegOp)))
+      AmbEntries.push_back(MemOp);
+  }
+
+  // Remove ambiguous entries.
+  for (unsigned i = 0, e = AmbEntries.size(); i != e; ++i)
+    MemOp2RegOpTable.erase((unsigned*)AmbEntries[i]);
 }
 
 // getX86RegNum - This function maps LLVM register identifiers to their X86
@@ -411,70 +982,11 @@
   return MIB.addImm(0);
 }
 
-
-//===----------------------------------------------------------------------===//
-// Efficient Lookup Table Support
-//===----------------------------------------------------------------------===//
-
-namespace {
-  /// TableEntry - Maps the 'from' opcode to a fused form of the 'to' opcode.
-  ///
-  struct TableEntry {
-    unsigned from;                      // Original opcode.
-    unsigned to;                        // New opcode.
-                                        
-    // less operators used by STL search.                                    
-    bool operator<(const TableEntry &TE) const { return from < TE.from; }
-    friend bool operator<(const TableEntry &TE, unsigned V) {
-      return TE.from < V;
-    }
-    friend bool operator<(unsigned V, const TableEntry &TE) {
-      return V < TE.from;
-    }
-  };
-}
-
-/// TableIsSorted - Return true if the table is in 'from' opcode order.
-///
-static bool TableIsSorted(const TableEntry *Table, unsigned NumEntries) {
-  for (unsigned i = 1; i != NumEntries; ++i)
-    if (!(Table[i-1] < Table[i])) {
-      cerr << "Entries out of order " << Table[i-1].from
-           << " " << Table[i].from << "\n";
-      return false;
-    }
-  return true;
-}
-
-/// TableLookup - Return the table entry matching the specified opcode.
-/// Otherwise return NULL.
-static const TableEntry *TableLookup(const TableEntry *Table, unsigned N,
-                                unsigned Opcode) {
-  const TableEntry *I = std::lower_bound(Table, Table+N, Opcode);
-  if (I != Table+N && I->from == Opcode)
-    return I;
-  return NULL;
-}
-
-#ifdef NDEBUG
-#define ASSERT_SORTED(TABLE)
-#else
-#define ASSERT_SORTED(TABLE)                                              \
-  { static bool TABLE##Checked = false;                                   \
-    if (!TABLE##Checked) {                                                \
-       assert(TableIsSorted(TABLE, array_lengthof(TABLE)) &&              \
-              "All lookup tables must be sorted for efficient access!");  \
-       TABLE##Checked = true;                                             \
-    }                                                                     \
-  }
-#endif
-
 MachineInstr*
 X86RegisterInfo::foldMemoryOperand(MachineInstr *MI, unsigned i,
                                    SmallVector<MachineOperand,4> &MOs) const {
   // Table (and size) to search
-  const TableEntry *OpcodeTablePtr = NULL;
-  unsigned OpcodeTableSize = 0;
+  const DenseMap<unsigned*, unsigned> *OpcodeTablePtr = NULL;
   bool isTwoAddrFold = false;
   unsigned NumOps = TII.getNumOperands(MI->getOpcode());
   bool isTwoAddr = NumOps > 1 &&
@@ -488,170 +1000,7 @@
       MI->getOperand(0).isRegister() && 
       MI->getOperand(1).isRegister() &&
       MI->getOperand(0).getReg() == MI->getOperand(1).getReg()) { 
-    static const TableEntry OpcodeTable[] = {
-      { X86::ADC32ri,     X86::ADC32mi },
-      { X86::ADC32ri8,    X86::ADC32mi8 },
-      { X86::ADC32rr,     X86::ADC32mr },
-      { X86::ADC64ri32,   X86::ADC64mi32 },
-      { X86::ADC64ri8,    X86::ADC64mi8 },
-      { X86::ADC64rr,     X86::ADC64mr },
-      { X86::ADD16ri,     X86::ADD16mi },
-      { X86::ADD16ri8,    X86::ADD16mi8 },
-      { X86::ADD16rr,     X86::ADD16mr },
-      { X86::ADD32ri,     X86::ADD32mi },
-      { X86::ADD32ri8,    X86::ADD32mi8 },
-      { X86::ADD32rr,     X86::ADD32mr },
-      { X86::ADD64ri32,   X86::ADD64mi32 },
-      { X86::ADD64ri8,    X86::ADD64mi8 },
-      { X86::ADD64rr,     X86::ADD64mr },
-      { X86::ADD8ri,      X86::ADD8mi },
-      { X86::ADD8rr,      X86::ADD8mr },
-      { X86::AND16ri,     X86::AND16mi },
-      { X86::AND16ri8,    X86::AND16mi8 },
-      { X86::AND16rr,     X86::AND16mr },
-      { X86::AND32ri,     X86::AND32mi },
-      { X86::AND32ri8,    X86::AND32mi8 },
-      { X86::AND32rr,     X86::AND32mr },
-      { X86::AND64ri32,   X86::AND64mi32 },
-      { X86::AND64ri8,    X86::AND64mi8 },
-      { X86::AND64rr,     X86::AND64mr },
-      { X86::AND8ri,      X86::AND8mi },
-      { X86::AND8rr,      X86::AND8mr },
-      { X86::DEC16r,      X86::DEC16m },
-      { X86::DEC32r,      X86::DEC32m },
-      { X86::DEC64_16r,   X86::DEC16m },
-      { X86::DEC64_32r,   X86::DEC32m },
-      { X86::DEC64r,      X86::DEC64m },
-      { X86::DEC8r,       X86::DEC8m },
-      { X86::INC16r,      X86::INC16m },
-      { X86::INC32r,      X86::INC32m },
-      { X86::INC64_16r,   X86::INC16m },
-      { X86::INC64_32r,   X86::INC32m },
-      { X86::INC64r,      X86::INC64m },
-      { X86::INC8r,       X86::INC8m },
-      { X86::NEG16r,      X86::NEG16m },
-      { X86::NEG32r,      X86::NEG32m },
-      { X86::NEG64r,      X86::NEG64m },
-      { X86::NEG8r,       X86::NEG8m },
-      { X86::NOT16r,      X86::NOT16m },
-      { X86::NOT32r,      X86::NOT32m },
-      { X86::NOT64r,      X86::NOT64m },
-      { X86::NOT8r,       X86::NOT8m },
-      { X86::OR16ri,      X86::OR16mi },
-      { X86::OR16ri8,     X86::OR16mi8 },
-      { X86::OR16rr,      X86::OR16mr },
-      { X86::OR32ri,      X86::OR32mi },
-      { X86::OR32ri8,     X86::OR32mi8 },
-      { X86::OR32rr,      X86::OR32mr },
-      { X86::OR64ri32,    X86::OR64mi32 },
-      { X86::OR64ri8,     X86::OR64mi8 },
-      { X86::OR64rr,      X86::OR64mr },
-      { X86::OR8ri,       X86::OR8mi },
-      { X86::OR8rr,       X86::OR8mr },
-      { X86::ROL16r1,     X86::ROL16m1 },
-      { X86::ROL16rCL,    X86::ROL16mCL },
-      { X86::ROL16ri,     X86::ROL16mi },
-      { X86::ROL32r1,     X86::ROL32m1 },
-      { X86::ROL32rCL,    X86::ROL32mCL },
-      { X86::ROL32ri,     X86::ROL32mi },
-      { X86::ROL64r1,     X86::ROL64m1 },
-      { X86::ROL64rCL,    X86::ROL64mCL },
-      { X86::ROL64ri,     X86::ROL64mi },
-      { X86::ROL8r1,      X86::ROL8m1 },
-      { X86::ROL8rCL,     X86::ROL8mCL },
-      { X86::ROL8ri,      X86::ROL8mi },
-      { X86::ROR16r1,     X86::ROR16m1 },
-      { X86::ROR16rCL,    X86::ROR16mCL },
-      { X86::ROR16ri,     X86::ROR16mi },
-      { X86::ROR32r1,     X86::ROR32m1 },
-      { X86::ROR32rCL,    X86::ROR32mCL },
-      { X86::ROR32ri,     X86::ROR32mi },
-      { X86::ROR64r1,     X86::ROR64m1 },
-      { X86::ROR64rCL,    X86::ROR64mCL },
-      { X86::ROR64ri,     X86::ROR64mi },
-      { X86::ROR8r1,      X86::ROR8m1 },
-      { X86::ROR8rCL,     X86::ROR8mCL },
-      { X86::ROR8ri,      X86::ROR8mi },
-      { X86::SAR16r1,     X86::SAR16m1 },
-      { X86::SAR16rCL,    X86::SAR16mCL },
-      { X86::SAR16ri,     X86::SAR16mi },
-      { X86::SAR32r1,     X86::SAR32m1 },
-      { X86::SAR32rCL,    X86::SAR32mCL },
-      { X86::SAR32ri,     X86::SAR32mi },
-      { X86::SAR64r1,     X86::SAR64m1 },
-      { X86::SAR64rCL,    X86::SAR64mCL },
-      { X86::SAR64ri,     X86::SAR64mi },
-      { X86::SAR8r1,      X86::SAR8m1 },
-      { X86::SAR8rCL,     X86::SAR8mCL },
-      { X86::SAR8ri,      X86::SAR8mi },
-      { X86::SBB32ri,     X86::SBB32mi },
-      { X86::SBB32ri8,    X86::SBB32mi8 },
-      { X86::SBB32rr,     X86::SBB32mr },
-      { X86::SBB64ri32,   X86::SBB64mi32 },
-      { X86::SBB64ri8,    X86::SBB64mi8 },
-      { X86::SBB64rr,     X86::SBB64mr },
-      { X86::SHL16r1,     X86::SHL16m1 },
-      { X86::SHL16rCL,    X86::SHL16mCL },
-      { X86::SHL16ri,     X86::SHL16mi },
-      { X86::SHL32r1,     X86::SHL32m1 },
-      { X86::SHL32rCL,    X86::SHL32mCL },
-      { X86::SHL32ri,     X86::SHL32mi },
-      { X86::SHL64r1,     X86::SHL64m1 },
-      { X86::SHL64rCL,    X86::SHL64mCL },
-      { X86::SHL64ri,     X86::SHL64mi },
-      { X86::SHL8r1,      X86::SHL8m1 },
-      { X86::SHL8rCL,     X86::SHL8mCL },
-      { X86::SHL8ri,      X86::SHL8mi },
-      { X86::SHLD16rrCL,  X86::SHLD16mrCL },
-      { X86::SHLD16rri8,  X86::SHLD16mri8 },
-      { X86::SHLD32rrCL,  X86::SHLD32mrCL },
-      { X86::SHLD32rri8,  X86::SHLD32mri8 },
-      { X86::SHLD64rrCL,  X86::SHLD64mrCL },
-      { X86::SHLD64rri8,  X86::SHLD64mri8 },
-      { X86::SHR16r1,     X86::SHR16m1 },
-      { X86::SHR16rCL,    X86::SHR16mCL },
-      { X86::SHR16ri,     X86::SHR16mi },
-      { X86::SHR32r1,     X86::SHR32m1 },
-      { X86::SHR32rCL,    X86::SHR32mCL },
-      { X86::SHR32ri,     X86::SHR32mi },
-      { X86::SHR64r1,     X86::SHR64m1 },
-      { X86::SHR64rCL,    X86::SHR64mCL },
-      { X86::SHR64ri,     X86::SHR64mi },
-      { X86::SHR8r1,      X86::SHR8m1 },
-      { X86::SHR8rCL,     X86::SHR8mCL },
-      { X86::SHR8ri,      X86::SHR8mi },
-      { X86::SHRD16rrCL,  X86::SHRD16mrCL },
-      { X86::SHRD16rri8,  X86::SHRD16mri8 },
-      { X86::SHRD32rrCL,  X86::SHRD32mrCL },
-      { X86::SHRD32rri8,  X86::SHRD32mri8 },
-      { X86::SHRD64rrCL,  X86::SHRD64mrCL },
-      { X86::SHRD64rri8,  X86::SHRD64mri8 },
-      { X86::SUB16ri,     X86::SUB16mi },
-      { X86::SUB16ri8,    X86::SUB16mi8 },
-      { X86::SUB16rr,     X86::SUB16mr },
-      { X86::SUB32ri,     X86::SUB32mi },
-      { X86::SUB32ri8,    X86::SUB32mi8 },
-      { X86::SUB32rr,     X86::SUB32mr },
-      { X86::SUB64ri32,   X86::SUB64mi32 },
-      { X86::SUB64ri8,    X86::SUB64mi8 },
-      { X86::SUB64rr,     X86::SUB64mr },
-      { X86::SUB8ri,      X86::SUB8mi },
-      { X86::SUB8rr,      X86::SUB8mr },
-      { X86::XOR16ri,     X86::XOR16mi },
-      { X86::XOR16ri8,    X86::XOR16mi8 },
-      { X86::XOR16rr,     X86::XOR16mr },
-      { X86::XOR32ri,     X86::XOR32mi },
-      { X86::XOR32ri8,    X86::XOR32mi8 },
-      { X86::XOR32rr,     X86::XOR32mr },
-      { X86::XOR64ri32,   X86::XOR64mi32 },
-      { X86::XOR64ri8,    X86::XOR64mi8 },
-      { X86::XOR64rr,     X86::XOR64mr },
-      { X86::XOR8ri,      X86::XOR8mi },
-      { X86::XOR8rr,      X86::XOR8mr }
-    };
-    ASSERT_SORTED(OpcodeTable);
-    OpcodeTablePtr = OpcodeTable;
-    OpcodeTableSize = array_lengthof(OpcodeTable);
+    OpcodeTablePtr = &RegOp2MemOpTable2Addr;
     isTwoAddrFold = true;
   } else if (i == 0) { // If operand 0
     if (MI->getOpcode() == X86::MOV16r0)
@@ -667,398 +1016,23 @@
       return NewMI;
     }
     
-    static const TableEntry OpcodeTable[] = {
-      { X86::CALL32r,     X86::CALL32m },
-      { X86::CALL64r,     X86::CALL64m },
-      { X86::CMP16ri,     X86::CMP16mi },
-      { X86::CMP16ri8,    X86::CMP16mi8 },
-      { X86::CMP32ri,     X86::CMP32mi },
-      { X86::CMP32ri8,    X86::CMP32mi8 },
-      { X86::CMP64ri32,   X86::CMP64mi32 },
-      { X86::CMP64ri8,    X86::CMP64mi8 },
-      { X86::CMP8ri,      X86::CMP8mi },
-      { X86::DIV16r,      X86::DIV16m },
-      { X86::DIV32r,      X86::DIV32m },
-      { X86::DIV64r,      X86::DIV64m },
-      { X86::DIV8r,       X86::DIV8m },
-      { X86::FsMOVAPDrr,  X86::MOVSDmr },
-      { X86::FsMOVAPSrr,  X86::MOVSSmr },
-      { X86::IDIV16r,     X86::IDIV16m },
-      { X86::IDIV32r,     X86::IDIV32m },
-      { X86::IDIV64r,     X86::IDIV64m },
-      { X86::IDIV8r,      X86::IDIV8m },
-      { X86::IMUL16r,     X86::IMUL16m },
-      { X86::IMUL32r,     X86::IMUL32m },
-      { X86::IMUL64r,     X86::IMUL64m },
-      { X86::IMUL8r,      X86::IMUL8m },
-      { X86::JMP32r,      X86::JMP32m },
-      { X86::JMP64r,      X86::JMP64m },
-      { X86::MOV16ri,     X86::MOV16mi },
-      { X86::MOV16rr,     X86::MOV16mr },
-      { X86::MOV32ri,     X86::MOV32mi },
-      { X86::MOV32rr,     X86::MOV32mr },
-      { X86::MOV64ri32,   X86::MOV64mi32 },
-      { X86::MOV64rr,     X86::MOV64mr },
-      { X86::MOV8ri,      X86::MOV8mi },
-      { X86::MOV8rr,      X86::MOV8mr },
-      { X86::MOVAPDrr,    X86::MOVAPDmr },
-      { X86::MOVAPSrr,    X86::MOVAPSmr },
-      { X86::MOVPDI2DIrr, X86::MOVPDI2DImr },
-      { X86::MOVPQIto64rr,X86::MOVPQIto64mr },
-      { X86::MOVPS2SSrr,  X86::MOVPS2SSmr },
-      { X86::MOVSDrr,     X86::MOVSDmr },
-      { X86::MOVSDto64rr, X86::MOVSDto64mr },
-      { X86::MOVSS2DIrr,  X86::MOVSS2DImr },
-      { X86::MOVSSrr,     X86::MOVSSmr },
-      { X86::MOVUPDrr,    X86::MOVUPDmr },
-      { X86::MOVUPSrr,    X86::MOVUPSmr },
-      { X86::MUL16r,      X86::MUL16m },
-      { X86::MUL32r,      X86::MUL32m },
-      { X86::MUL64r,      X86::MUL64m },
-      { X86::MUL8r,       X86::MUL8m },
-      { X86::SETAEr,      X86::SETAEm },
-      { X86::SETAr,       X86::SETAm },
-      { X86::SETBEr,      X86::SETBEm },
-      { X86::SETBr,       X86::SETBm },
-      { X86::SETEr,       X86::SETEm },
-      { X86::SETGEr,      X86::SETGEm },
-      { X86::SETGr,       X86::SETGm },
-      { X86::SETLEr,      X86::SETLEm },
-      { X86::SETLr,       X86::SETLm },
-      { X86::SETNEr,      X86::SETNEm },
-      { X86::SETNPr,      X86::SETNPm },
-      { X86::SETNSr,      X86::SETNSm },
-      { X86::SETPr,       X86::SETPm },
-      { X86::SETSr,       X86::SETSm },
-      { X86::TAILJMPr,    X86::TAILJMPm },
-      { X86::TEST16ri,    X86::TEST16mi },
-      { X86::TEST32ri,    X86::TEST32mi },
-      { X86::TEST64ri32,  X86::TEST64mi32 },
-      { X86::TEST8ri,     X86::TEST8mi },
-      { X86::XCHG16rr,    X86::XCHG16mr },
-      { X86::XCHG32rr,    X86::XCHG32mr },
-      { X86::XCHG64rr,    X86::XCHG64mr },
-      { X86::XCHG8rr,     X86::XCHG8mr }
-    };
-
-    ASSERT_SORTED(OpcodeTable);
-    OpcodeTablePtr = OpcodeTable;
-    OpcodeTableSize = array_lengthof(OpcodeTable);
+    OpcodeTablePtr = &RegOp2MemOpTable0;
   } else if (i == 1) {
-    static const TableEntry OpcodeTable[] = {
-      { X86::CMP16rr,         X86::CMP16rm },
-      { X86::CMP32rr,         X86::CMP32rm },
-      { X86::CMP64rr,         X86::CMP64rm },
-      { X86::CMP8rr,          X86::CMP8rm },
-      { X86::CVTSD2SSrr,      X86::CVTSD2SSrm },
-      { X86::CVTSI2SD64rr,    X86::CVTSI2SD64rm },
-      { X86::CVTSI2SDrr,      X86::CVTSI2SDrm },
-      { X86::CVTSI2SS64rr,    X86::CVTSI2SS64rm },
-      { X86::CVTSI2SSrr,      X86::CVTSI2SSrm },
-      { X86::CVTSS2SDrr,      X86::CVTSS2SDrm },
-      { X86::CVTTSD2SI64rr,   X86::CVTTSD2SI64rm },
-      { X86::CVTTSD2SIrr,     X86::CVTTSD2SIrm },
-      { X86::CVTTSS2SI64rr,   X86::CVTTSS2SI64rm },
-      { X86::CVTTSS2SIrr,     X86::CVTTSS2SIrm },
-      { X86::FsMOVAPDrr,      X86::MOVSDrm },
-      { X86::FsMOVAPSrr,      X86::MOVSSrm },
-      { X86::IMUL16rri,       X86::IMUL16rmi },
-      { X86::IMUL16rri8,      X86::IMUL16rmi8 },
-      { X86::IMUL32rri,       X86::IMUL32rmi },
-      { X86::IMUL32rri8,      X86::IMUL32rmi8 },
-      { X86::IMUL64rri32,     X86::IMUL64rmi32 },
-      { X86::IMUL64rri8,      X86::IMUL64rmi8 },
-      { X86::Int_CMPSDrr,     X86::Int_CMPSDrm },
-      { X86::Int_CMPSSrr,     X86::Int_CMPSSrm },
-      { X86::Int_COMISDrr,    X86::Int_COMISDrm },
-      { X86::Int_COMISSrr,    X86::Int_COMISSrm },
-      { X86::Int_CVTDQ2PDrr,  X86::Int_CVTDQ2PDrm },
-      { X86::Int_CVTDQ2PSrr,  X86::Int_CVTDQ2PSrm },
-      { X86::Int_CVTPD2DQrr,  X86::Int_CVTPD2DQrm },
-      { X86::Int_CVTPD2PSrr,  X86::Int_CVTPD2PSrm },
-      { X86::Int_CVTPS2DQrr,  X86::Int_CVTPS2DQrm },
-      { X86::Int_CVTPS2PDrr,  X86::Int_CVTPS2PDrm },
-      { X86::Int_CVTSD2SI64rr,X86::Int_CVTSD2SI64rm },
-      { X86::Int_CVTSD2SIrr,  X86::Int_CVTSD2SIrm },
-      { X86::Int_CVTSD2SSrr,  X86::Int_CVTSD2SSrm },
-      { X86::Int_CVTSI2SD64rr,X86::Int_CVTSI2SD64rm },
-      { X86::Int_CVTSI2SDrr,  X86::Int_CVTSI2SDrm },
-      { X86::Int_CVTSI2SS64rr,X86::Int_CVTSI2SS64rm },
-      { X86::Int_CVTSI2SSrr,  X86::Int_CVTSI2SSrm },
-      { X86::Int_CVTSS2SDrr,  X86::Int_CVTSS2SDrm },
-      { X86::Int_CVTSS2SI64rr,X86::Int_CVTSS2SI64rm },
-      { X86::Int_CVTSS2SIrr,  X86::Int_CVTSS2SIrm },
-      { X86::Int_CVTTPD2DQrr, X86::Int_CVTTPD2DQrm },
-      { X86::Int_CVTTPS2DQrr, X86::Int_CVTTPS2DQrm },
-      { X86::Int_CVTTSD2SI64rr,X86::Int_CVTTSD2SI64rm },
-      { X86::Int_CVTTSD2SIrr, X86::Int_CVTTSD2SIrm },
-      { X86::Int_CVTTSS2SI64rr,X86::Int_CVTTSS2SI64rm },
-      { X86::Int_CVTTSS2SIrr, X86::Int_CVTTSS2SIrm },
-      { X86::Int_UCOMISDrr,   X86::Int_UCOMISDrm },
-      { X86::Int_UCOMISSrr,   X86::Int_UCOMISSrm },
-      { X86::MOV16rr,         X86::MOV16rm },
-      { X86::MOV32rr,         X86::MOV32rm },
-      { X86::MOV64rr,         X86::MOV64rm },
-      { X86::MOV64toPQIrr,    X86::MOV64toPQIrm },
-      { X86::MOV64toSDrr,     X86::MOV64toSDrm },
-      { X86::MOV8rr,          X86::MOV8rm },
-      { X86::MOVAPDrr,        X86::MOVAPDrm },
-      { X86::MOVAPSrr,        X86::MOVAPSrm },
-      { X86::MOVDDUPrr,       X86::MOVDDUPrm },
-      { X86::MOVDI2PDIrr,     X86::MOVDI2PDIrm },
-      { X86::MOVDI2SSrr,      X86::MOVDI2SSrm },
-      { X86::MOVSD2PDrr,      X86::MOVSD2PDrm },
-      { X86::MOVSDrr,         X86::MOVSDrm },
-      { X86::MOVSHDUPrr,      X86::MOVSHDUPrm },
-      { X86::MOVSLDUPrr,      X86::MOVSLDUPrm },
-      { X86::MOVSS2PSrr,      X86::MOVSS2PSrm },
-      { X86::MOVSSrr,         X86::MOVSSrm },
-      { X86::MOVSX16rr8,      X86::MOVSX16rm8 },
-      { X86::MOVSX32rr16,     X86::MOVSX32rm16 },
-      { X86::MOVSX32rr8,      X86::MOVSX32rm8 },
-      { X86::MOVSX64rr16,     X86::MOVSX64rm16 },
-      { X86::MOVSX64rr32,     X86::MOVSX64rm32 },
-      { X86::MOVSX64rr8,      X86::MOVSX64rm8 },
-      { X86::MOVUPDrr,        X86::MOVUPDrm },
-      { X86::MOVUPSrr,        X86::MOVUPSrm },
-      { X86::MOVZX16rr8,      X86::MOVZX16rm8 },
-      { X86::MOVZX32rr16,     X86::MOVZX32rm16 },
-      { X86::MOVZX32rr8,      X86::MOVZX32rm8 },
-      { X86::MOVZX64rr16,     X86::MOVZX64rm16 },
-      { X86::MOVZX64rr8,      X86::MOVZX64rm8 },
-      { X86::PSHUFDri,        X86::PSHUFDmi },
-      { X86::PSHUFHWri,       X86::PSHUFHWmi },
-      { X86::PSHUFLWri,       X86::PSHUFLWmi },
-      { X86::PsMOVZX64rr32,   X86::PsMOVZX64rm32 },
-      { X86::RCPPSr,          X86::RCPPSm },
-      { X86::RCPPSr_Int,      X86::RCPPSm_Int },
-      { X86::RSQRTPSr,        X86::RSQRTPSm },
-      { X86::RSQRTPSr_Int,    X86::RSQRTPSm_Int },
-      { X86::RSQRTSSr,        X86::RSQRTSSm },
-      { X86::RSQRTSSr_Int,    X86::RSQRTSSm_Int },
-      { X86::SQRTPDr,         X86::SQRTPDm },
-      { X86::SQRTPDr_Int,     X86::SQRTPDm_Int },
-      { X86::SQRTPSr,         X86::SQRTPSm },
-      { X86::SQRTPSr_Int,     X86::SQRTPSm_Int },
-      { X86::SQRTSDr,         X86::SQRTSDm },
-      { X86::SQRTSDr_Int,     X86::SQRTSDm_Int },
-      { X86::SQRTSSr,         X86::SQRTSSm },
-      { X86::SQRTSSr_Int,     X86::SQRTSSm_Int },
-      { X86::TEST16rr,        X86::TEST16rm },
-      { X86::TEST32rr,        X86::TEST32rm },
-      { X86::TEST64rr,        X86::TEST64rm },
-      { X86::TEST8rr,         X86::TEST8rm },
-      // FIXME: TEST*rr EAX,EAX ---> CMP [mem], 0
-      { X86::UCOMISDrr,       X86::UCOMISDrm },
-      { X86::UCOMISSrr,       X86::UCOMISSrm },
-      { X86::XCHG16rr,        X86::XCHG16rm },
-      { X86::XCHG32rr,        X86::XCHG32rm },
-      { X86::XCHG64rr,        X86::XCHG64rm },
-      { X86::XCHG8rr,         X86::XCHG8rm }
-    };
-
-    ASSERT_SORTED(OpcodeTable);
-    OpcodeTablePtr = OpcodeTable;
-    OpcodeTableSize = array_lengthof(OpcodeTable);
+    OpcodeTablePtr = &RegOp2MemOpTable1;
   } else if (i == 2) {
-    static const TableEntry OpcodeTable[] = {
-      { X86::ADC32rr,         X86::ADC32rm },
-      { X86::ADC64rr,         X86::ADC64rm },
-      { X86::ADD16rr,         X86::ADD16rm },
-      { X86::ADD32rr,         X86::ADD32rm },
-      { X86::ADD64rr,         X86::ADD64rm },
-      { X86::ADD8rr,          X86::ADD8rm },
-      { X86::ADDPDrr,         X86::ADDPDrm },
-      { X86::ADDPSrr,         X86::ADDPSrm },
-      { X86::ADDSDrr,         X86::ADDSDrm },
-      { X86::ADDSSrr,         X86::ADDSSrm },
-      { X86::ADDSUBPDrr,      X86::ADDSUBPDrm },
-      { X86::ADDSUBPSrr,      X86::ADDSUBPSrm },
-      { X86::AND16rr,         X86::AND16rm },
-      { X86::AND32rr,         X86::AND32rm },
-      { X86::AND64rr,         X86::AND64rm },
-      { X86::AND8rr,          X86::AND8rm },
-      { X86::ANDNPDrr,        X86::ANDNPDrm },
-      { X86::ANDNPSrr,        X86::ANDNPSrm },
-      { X86::ANDPDrr,         X86::ANDPDrm },
-      { X86::ANDPSrr,         X86::ANDPSrm },
-      { X86::CMOVA16rr,       X86::CMOVA16rm },
-      { X86::CMOVA32rr,       X86::CMOVA32rm },
-      { X86::CMOVA64rr,       X86::CMOVA64rm },
-      { X86::CMOVAE16rr,      X86::CMOVAE16rm },
-      { X86::CMOVAE32rr,      X86::CMOVAE32rm },
-      { X86::CMOVAE64rr,      X86::CMOVAE64rm },
-      { X86::CMOVB16rr,       X86::CMOVB16rm },
-      { X86::CMOVB32rr,       X86::CMOVB32rm },
-      { X86::CMOVB64rr,       X86::CMOVB64rm },
-      { X86::CMOVBE16rr,      X86::CMOVBE16rm },
-      { X86::CMOVBE32rr,      X86::CMOVBE32rm },
-      { X86::CMOVBE64rr,      X86::CMOVBE64rm },
-      { X86::CMOVE16rr,       X86::CMOVE16rm },
-      { X86::CMOVE32rr,       X86::CMOVE32rm },
-      { X86::CMOVE64rr,       X86::CMOVE64rm },
-      { X86::CMOVG16rr,       X86::CMOVG16rm },
-      { X86::CMOVG32rr,       X86::CMOVG32rm },
-      { X86::CMOVG64rr,       X86::CMOVG64rm },
-      { X86::CMOVGE16rr,      X86::CMOVGE16rm },
-      { X86::CMOVGE32rr,      X86::CMOVGE32rm },
-      { X86::CMOVGE64rr,      X86::CMOVGE64rm },
-      { X86::CMOVL16rr,       X86::CMOVL16rm },
-      { X86::CMOVL32rr,       X86::CMOVL32rm },
-      { X86::CMOVL64rr,       X86::CMOVL64rm },
-      { X86::CMOVLE16rr,      X86::CMOVLE16rm },
-      { X86::CMOVLE32rr,      X86::CMOVLE32rm },
-      { X86::CMOVLE64rr,      X86::CMOVLE64rm },
-      { X86::CMOVNE16rr,      X86::CMOVNE16rm },
-      { X86::CMOVNE32rr,      X86::CMOVNE32rm },
-      { X86::CMOVNE64rr,      X86::CMOVNE64rm },
-      { X86::CMOVNP16rr,      X86::CMOVNP16rm },
-      { X86::CMOVNP32rr,      X86::CMOVNP32rm },
-      { X86::CMOVNP64rr,      X86::CMOVNP64rm },
-      { X86::CMOVNS16rr,      X86::CMOVNS16rm },
-      { X86::CMOVNS32rr,      X86::CMOVNS32rm },
-      { X86::CMOVNS64rr,      X86::CMOVNS64rm },
-      { X86::CMOVP16rr,       X86::CMOVP16rm },
-      { X86::CMOVP32rr,       X86::CMOVP32rm },
-      { X86::CMOVP64rr,       X86::CMOVP64rm },
-      { X86::CMOVS16rr,       X86::CMOVS16rm },
-      { X86::CMOVS32rr,       X86::CMOVS32rm },
-      { X86::CMOVS64rr,       X86::CMOVS64rm },
-      { X86::CMPPDrri,        X86::CMPPDrmi },
-      { X86::CMPPSrri,        X86::CMPPSrmi },
-      { X86::CMPSDrr,         X86::CMPSDrm },
-      { X86::CMPSSrr,         X86::CMPSSrm },
-      { X86::DIVPDrr,         X86::DIVPDrm },
-      { X86::DIVPSrr,         X86::DIVPSrm },
-      { X86::DIVSDrr,         X86::DIVSDrm },
-      { X86::DIVSSrr,         X86::DIVSSrm },
-      { X86::HADDPDrr,        X86::HADDPDrm },
-      { X86::HADDPSrr,        X86::HADDPSrm },
-      { X86::HSUBPDrr,        X86::HSUBPDrm },
-      { X86::HSUBPSrr,        X86::HSUBPSrm },
-      { X86::IMUL16rr,        X86::IMUL16rm },
-      { X86::IMUL32rr,        X86::IMUL32rm },
-      { X86::IMUL64rr,        X86::IMUL64rm },
-      { X86::MAXPDrr,         X86::MAXPDrm },
-      { X86::MAXPDrr_Int,     X86::MAXPDrm_Int },
-      { X86::MAXPSrr,         X86::MAXPSrm },
-      { X86::MAXPSrr_Int,     X86::MAXPSrm_Int },
-      { X86::MAXSDrr,         X86::MAXSDrm },
-      { X86::MAXSDrr_Int,     X86::MAXSDrm_Int },
-      { X86::MAXSSrr,         X86::MAXSSrm },
-      { X86::MAXSSrr_Int,     X86::MAXSSrm_Int },
-      { X86::MINPDrr,         X86::MINPDrm },
-      { X86::MINPDrr_Int,     X86::MINPDrm_Int },
-      { X86::MINPSrr,         X86::MINPSrm },
-      { X86::MINPSrr_Int,     X86::MINPSrm_Int },
-      { X86::MINSDrr,         X86::MINSDrm },
-      { X86::MINSDrr_Int,     X86::MINSDrm_Int },
-      { X86::MINSSrr,         X86::MINSSrm },
-      { X86::MINSSrr_Int,     X86::MINSSrm_Int },
-      { X86::MULPDrr,         X86::MULPDrm },
-      { X86::MULPSrr,         X86::MULPSrm },
-      { X86::MULSDrr,         X86::MULSDrm },
-      { X86::MULSSrr,         X86::MULSSrm },
-      { X86::OR16rr,          X86::OR16rm },
-      { X86::OR32rr,          X86::OR32rm },
-      { X86::OR64rr,          X86::OR64rm },
-      { X86::OR8rr,           X86::OR8rm },
-      { X86::ORPDrr,          X86::ORPDrm },
-      { X86::ORPSrr,          X86::ORPSrm },
-      { X86::PACKSSDWrr,      X86::PACKSSDWrm },
-      { X86::PACKSSWBrr,      X86::PACKSSWBrm },
-      { X86::PACKUSWBrr,      X86::PACKUSWBrm },
-      { X86::PADDBrr,         X86::PADDBrm },
-      { X86::PADDDrr,         X86::PADDDrm },
-      { X86::PADDQrr,         X86::PADDQrm },
-      { X86::PADDSBrr,        X86::PADDSBrm },
-      { X86::PADDSWrr,        X86::PADDSWrm },
-      { X86::PADDWrr,         X86::PADDWrm },
-      { X86::PANDNrr,         X86::PANDNrm },
-      { X86::PANDrr,          X86::PANDrm },
-      { X86::PAVGBrr,         X86::PAVGBrm },
-      { X86::PAVGWrr,         X86::PAVGWrm },
-      { X86::PCMPEQBrr,       X86::PCMPEQBrm },
-      { X86::PCMPEQDrr,       X86::PCMPEQDrm },
-      { X86::PCMPEQWrr,       X86::PCMPEQWrm },
-      { X86::PCMPGTBrr,       X86::PCMPGTBrm },
-      { X86::PCMPGTDrr,       X86::PCMPGTDrm },
-      { X86::PCMPGTWrr,       X86::PCMPGTWrm },
-      { X86::PINSRWrri,       X86::PINSRWrmi },
-      { X86::PMADDWDrr,       X86::PMADDWDrm },
-      { X86::PMAXSWrr,        X86::PMAXSWrm },
-      { X86::PMAXUBrr,        X86::PMAXUBrm },
-      { X86::PMINSWrr,        X86::PMINSWrm },
-      { X86::PMINUBrr,        X86::PMINUBrm },
-      { X86::PMULHUWrr,       X86::PMULHUWrm },
-      { X86::PMULHWrr,        X86::PMULHWrm },
-      { X86::PMULLWrr,        X86::PMULLWrm },
-      { X86::PMULUDQrr,       X86::PMULUDQrm },
-      { X86::PORrr,           X86::PORrm },
-      { X86::PSADBWrr,        X86::PSADBWrm },
-      { X86::PSLLDrr,         X86::PSLLDrm },
-      { X86::PSLLQrr,         X86::PSLLQrm },
-      { X86::PSLLWrr,         X86::PSLLWrm },
-      { X86::PSRADrr,         X86::PSRADrm },
-      { X86::PSRAWrr,         X86::PSRAWrm },
-      { X86::PSRLDrr,         X86::PSRLDrm },
-      { X86::PSRLQrr,         X86::PSRLQrm },
-      { X86::PSRLWrr,         X86::PSRLWrm },
-      { X86::PSUBBrr,         X86::PSUBBrm },
-      { X86::PSUBDrr,         X86::PSUBDrm },
-      { X86::PSUBSBrr,        X86::PSUBSBrm },
-      { X86::PSUBSWrr,        X86::PSUBSWrm },
-      { X86::PSUBWrr,         X86::PSUBWrm },
-      { X86::PUNPCKHBWrr,     X86::PUNPCKHBWrm },
-      { X86::PUNPCKHDQrr,     X86::PUNPCKHDQrm },
-      { X86::PUNPCKHQDQrr,    X86::PUNPCKHQDQrm },
-      { X86::PUNPCKHWDrr,     X86::PUNPCKHWDrm },
-      { X86::PUNPCKLBWrr,     X86::PUNPCKLBWrm },
-      { X86::PUNPCKLDQrr,     X86::PUNPCKLDQrm },
-      { X86::PUNPCKLQDQrr,    X86::PUNPCKLQDQrm },
-      { X86::PUNPCKLWDrr,     X86::PUNPCKLWDrm },
-      { X86::PXORrr,          X86::PXORrm },
-      { X86::SBB32rr,         X86::SBB32rm },
-      { X86::SBB64rr,         X86::SBB64rm },
-      { X86::SHUFPDrri,       X86::SHUFPDrmi },
-      { X86::SHUFPSrri,       X86::SHUFPSrmi },
-      { X86::SUB16rr,         X86::SUB16rm },
-      { X86::SUB32rr,         X86::SUB32rm },
-      { X86::SUB64rr,         X86::SUB64rm },
-      { X86::SUB8rr,          X86::SUB8rm },
-      { X86::SUBPDrr,         X86::SUBPDrm },
-      { X86::SUBPSrr,         X86::SUBPSrm },
-      { X86::SUBSDrr,         X86::SUBSDrm },
-      { X86::SUBSSrr,         X86::SUBSSrm },
-      // FIXME: TEST*rr -> swapped operand of TEST*mr.
-      { X86::UNPCKHPDrr,      X86::UNPCKHPDrm },
-      { X86::UNPCKHPSrr,      X86::UNPCKHPSrm },
-      { X86::UNPCKLPDrr,      X86::UNPCKLPDrm },
-      { X86::UNPCKLPSrr,      X86::UNPCKLPSrm },
-      { X86::XOR16rr,         X86::XOR16rm },
-      { X86::XOR32rr,         X86::XOR32rm },
-      { X86::XOR64rr,         X86::XOR64rm },
-      { X86::XOR8rr,          X86::XOR8rm },
-      { X86::XORPDrr,         X86::XORPDrm },
-      { X86::XORPSrr,         X86::XORPSrm }
-    };
-
-    ASSERT_SORTED(OpcodeTable);
-    OpcodeTablePtr = OpcodeTable;
-    OpcodeTableSize = array_lengthof(OpcodeTable);
+    OpcodeTablePtr = &RegOp2MemOpTable2;
   }
   
   // If table selected...
   if (OpcodeTablePtr) {
     // Find the Opcode to fuse
-    unsigned fromOpcode = MI->getOpcode();
-    // Lookup fromOpcode in table
-    if (const TableEntry *Entry = TableLookup(OpcodeTablePtr, OpcodeTableSize,
-                                              fromOpcode)) {
+    DenseMap<unsigned*, unsigned>::iterator I =
+      OpcodeTablePtr->find((unsigned*)MI->getOpcode());
+    if (I != OpcodeTablePtr->end()) {
       if (isTwoAddrFold)
-        NewMI = FuseTwoAddrInst(Entry->to, MOs, MI, TII);
+        NewMI = FuseTwoAddrInst(I->second, MOs, MI, TII);
       else
-        NewMI = FuseInst(Entry->to, i, MOs, MI, TII);
+        NewMI = FuseInst(I->second, i, MOs, MI, TII);
       NewMI->copyKillDeadInfo(MI);
       return NewMI;
     }

Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.h?rev=42509&r1=42508&r2=42509&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86RegisterInfo.h (original)
+++ llvm/trunk/lib/Target/X86/X86RegisterInfo.h Mon Oct  1 18:44:33 2007
@@ -14,6 +14,7 @@
 #ifndef X86REGISTERINFO_H
 #define X86REGISTERINFO_H
 
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Target/MRegisterInfo.h"
 #include "X86GenRegisterInfo.h.inc"
@@ -38,17 +39,33 @@
 
 private:
   /// Is64Bit - Is the target 64-bits.
+  ///
   bool Is64Bit;
 
   /// SlotSize - Stack slot size in bytes.
+  ///
   unsigned SlotSize;
 
   /// StackPtr - X86 physical register used as stack ptr.
+  ///
   unsigned StackPtr;
 
   /// FramePtr - X86 physical register used as frame ptr.
+  ///
   unsigned FramePtr;
 
+  /// RegOp2MemOpTable2Addr, RegOp2MemOpTable0, RegOp2MemOpTable1,
+  /// RegOp2MemOpTable2 - Load / store folding opcode maps.
+  ///
+  DenseMap<unsigned*, unsigned> RegOp2MemOpTable2Addr;
+  DenseMap<unsigned*, unsigned> RegOp2MemOpTable0;
+  DenseMap<unsigned*, unsigned> RegOp2MemOpTable1;
+  DenseMap<unsigned*, unsigned> RegOp2MemOpTable2;
+
+  /// MemOp2RegOpTable - Load / store unfolding opcode map.
+  ///
+  DenseMap<unsigned*, unsigned> MemOp2RegOpTable;
+
 public:
   X86RegisterInfo(X86TargetMachine &tm, const TargetInstrInfo &tii);
 
@@ -57,6 +74,7 @@
   unsigned getX86RegNum(unsigned RegNo);
 
   /// Code Generation virtual methods...
+  ///
   bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
                                  MachineBasicBlock::iterator MI,
                                  const std::vector<CalleeSavedInfo> &CSI) 
const;


_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to