github.com/decomp/exp@v0.0.0-20210624183419-6d058f5e1da6/lift/x86/instruction.go (about)

     1  package x86
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/decomp/exp/disasm/x86"
     7  	"github.com/kr/pretty"
     8  	"github.com/llir/llvm/ir"
     9  	"github.com/llir/llvm/ir/constant"
    10  	"github.com/llir/llvm/ir/enum"
    11  	"github.com/llir/llvm/ir/types"
    12  	"github.com/llir/llvm/ir/value"
    13  	"github.com/pkg/errors"
    14  	"golang.org/x/arch/x86/x86asm"
    15  )
    16  
    17  // liftInst lifts the given x86 instruction to LLVM IR, emitting code to f.
    18  func (f *Func) liftInst(inst *x86.Inst) error {
    19  	dbg.Println("lifting instruction:", inst.Inst)
    20  
    21  	// Check if prefix is present.
    22  	var (
    23  		hasREP  bool
    24  		hasREPN bool
    25  	)
    26  	for _, prefix := range inst.Prefix[:] {
    27  		// The first zero in the array marks the end of the prefixes.
    28  		if prefix == 0 {
    29  			break
    30  		}
    31  		switch prefix &^ x86asm.PrefixImplicit {
    32  		case x86asm.PrefixData16:
    33  			// prefix already supported.
    34  		case x86asm.PrefixREP:
    35  			hasREP = true
    36  		case x86asm.PrefixREPN:
    37  			hasREPN = true
    38  		case x86asm.PrefixREX | x86asm.PrefixREXW:
    39  			// TODO: Implement support for REX.W
    40  		default:
    41  			pretty.Println("instruction with prefix:", inst)
    42  			panic(fmt.Errorf("support for %v instruction with prefix %v (0x%04X) not yet implemented", inst.Op, prefix, uint16(prefix)))
    43  		}
    44  	}
    45  
    46  	// Repeat instruction.
    47  	switch {
    48  	case hasREP:
    49  		return f.liftREPInst(inst)
    50  	case hasREPN:
    51  		return f.liftREPNInst(inst)
    52  	}
    53  
    54  	// Translate instruction.
    55  	switch inst.Op {
    56  	case x86asm.AAA:
    57  		return f.liftInstAAA(inst)
    58  	case x86asm.AAD:
    59  		return f.liftInstAAD(inst)
    60  	case x86asm.AAM:
    61  		return f.liftInstAAM(inst)
    62  	case x86asm.AAS:
    63  		return f.liftInstAAS(inst)
    64  	case x86asm.ADC:
    65  		return f.liftInstADC(inst)
    66  	case x86asm.ADD:
    67  		return f.liftInstADD(inst)
    68  	case x86asm.ADDPD:
    69  		return f.liftInstADDPD(inst)
    70  	case x86asm.ADDPS:
    71  		return f.liftInstADDPS(inst)
    72  	case x86asm.ADDSD:
    73  		return f.liftInstADDSD(inst)
    74  	case x86asm.ADDSS:
    75  		return f.liftInstADDSS(inst)
    76  	case x86asm.ADDSUBPD:
    77  		return f.liftInstADDSUBPD(inst)
    78  	case x86asm.ADDSUBPS:
    79  		return f.liftInstADDSUBPS(inst)
    80  	case x86asm.AESDEC:
    81  		return f.liftInstAESDEC(inst)
    82  	case x86asm.AESDECLAST:
    83  		return f.liftInstAESDECLAST(inst)
    84  	case x86asm.AESENC:
    85  		return f.liftInstAESENC(inst)
    86  	case x86asm.AESENCLAST:
    87  		return f.liftInstAESENCLAST(inst)
    88  	case x86asm.AESIMC:
    89  		return f.liftInstAESIMC(inst)
    90  	case x86asm.AESKEYGENASSIST:
    91  		return f.liftInstAESKEYGENASSIST(inst)
    92  	case x86asm.AND:
    93  		return f.liftInstAND(inst)
    94  	case x86asm.ANDNPD:
    95  		return f.liftInstANDNPD(inst)
    96  	case x86asm.ANDNPS:
    97  		return f.liftInstANDNPS(inst)
    98  	case x86asm.ANDPD:
    99  		return f.liftInstANDPD(inst)
   100  	case x86asm.ANDPS:
   101  		return f.liftInstANDPS(inst)
   102  	case x86asm.ARPL:
   103  		return f.liftInstARPL(inst)
   104  	case x86asm.BLENDPD:
   105  		return f.liftInstBLENDPD(inst)
   106  	case x86asm.BLENDPS:
   107  		return f.liftInstBLENDPS(inst)
   108  	case x86asm.BLENDVPD:
   109  		return f.liftInstBLENDVPD(inst)
   110  	case x86asm.BLENDVPS:
   111  		return f.liftInstBLENDVPS(inst)
   112  	case x86asm.BOUND:
   113  		return f.liftInstBOUND(inst)
   114  	case x86asm.BSF:
   115  		return f.liftInstBSF(inst)
   116  	case x86asm.BSR:
   117  		return f.liftInstBSR(inst)
   118  	case x86asm.BSWAP:
   119  		return f.liftInstBSWAP(inst)
   120  	case x86asm.BT:
   121  		return f.liftInstBT(inst)
   122  	case x86asm.BTC:
   123  		return f.liftInstBTC(inst)
   124  	case x86asm.BTR:
   125  		return f.liftInstBTR(inst)
   126  	case x86asm.BTS:
   127  		return f.liftInstBTS(inst)
   128  	case x86asm.CALL:
   129  		return f.liftInstCALL(inst)
   130  	case x86asm.CBW:
   131  		return f.liftInstCBW(inst)
   132  	case x86asm.CDQ:
   133  		return f.liftInstCDQ(inst)
   134  	case x86asm.CDQE:
   135  		return f.liftInstCDQE(inst)
   136  	case x86asm.CLC:
   137  		return f.liftInstCLC(inst)
   138  	case x86asm.CLD:
   139  		return f.liftInstCLD(inst)
   140  	case x86asm.CLFLUSH:
   141  		return f.liftInstCLFLUSH(inst)
   142  	case x86asm.CLI:
   143  		return f.liftInstCLI(inst)
   144  	case x86asm.CLTS:
   145  		return f.liftInstCLTS(inst)
   146  	case x86asm.CMC:
   147  		return f.liftInstCMC(inst)
   148  	case x86asm.CMOVA:
   149  		return f.liftInstCMOVA(inst)
   150  	case x86asm.CMOVAE:
   151  		return f.liftInstCMOVAE(inst)
   152  	case x86asm.CMOVB:
   153  		return f.liftInstCMOVB(inst)
   154  	case x86asm.CMOVBE:
   155  		return f.liftInstCMOVBE(inst)
   156  	case x86asm.CMOVE:
   157  		return f.liftInstCMOVE(inst)
   158  	case x86asm.CMOVG:
   159  		return f.liftInstCMOVG(inst)
   160  	case x86asm.CMOVGE:
   161  		return f.liftInstCMOVGE(inst)
   162  	case x86asm.CMOVL:
   163  		return f.liftInstCMOVL(inst)
   164  	case x86asm.CMOVLE:
   165  		return f.liftInstCMOVLE(inst)
   166  	case x86asm.CMOVNE:
   167  		return f.liftInstCMOVNE(inst)
   168  	case x86asm.CMOVNO:
   169  		return f.liftInstCMOVNO(inst)
   170  	case x86asm.CMOVNP:
   171  		return f.liftInstCMOVNP(inst)
   172  	case x86asm.CMOVNS:
   173  		return f.liftInstCMOVNS(inst)
   174  	case x86asm.CMOVO:
   175  		return f.liftInstCMOVO(inst)
   176  	case x86asm.CMOVP:
   177  		return f.liftInstCMOVP(inst)
   178  	case x86asm.CMOVS:
   179  		return f.liftInstCMOVS(inst)
   180  	case x86asm.CMP:
   181  		return f.liftInstCMP(inst)
   182  	case x86asm.CMPPD:
   183  		return f.liftInstCMPPD(inst)
   184  	case x86asm.CMPPS:
   185  		return f.liftInstCMPPS(inst)
   186  	case x86asm.CMPSB:
   187  		return f.liftInstCMPSB(inst)
   188  	case x86asm.CMPSD:
   189  		return f.liftInstCMPSD(inst)
   190  	case x86asm.CMPSD_XMM:
   191  		return f.liftInstCMPSD_XMM(inst)
   192  	case x86asm.CMPSQ:
   193  		return f.liftInstCMPSQ(inst)
   194  	case x86asm.CMPSS:
   195  		return f.liftInstCMPSS(inst)
   196  	case x86asm.CMPSW:
   197  		return f.liftInstCMPSW(inst)
   198  	case x86asm.CMPXCHG:
   199  		return f.liftInstCMPXCHG(inst)
   200  	case x86asm.CMPXCHG16B:
   201  		return f.liftInstCMPXCHG16B(inst)
   202  	case x86asm.CMPXCHG8B:
   203  		return f.liftInstCMPXCHG8B(inst)
   204  	case x86asm.COMISD:
   205  		return f.liftInstCOMISD(inst)
   206  	case x86asm.COMISS:
   207  		return f.liftInstCOMISS(inst)
   208  	case x86asm.CPUID:
   209  		return f.liftInstCPUID(inst)
   210  	case x86asm.CQO:
   211  		return f.liftInstCQO(inst)
   212  	case x86asm.CRC32:
   213  		return f.liftInstCRC32(inst)
   214  	case x86asm.CVTDQ2PD:
   215  		return f.liftInstCVTDQ2PD(inst)
   216  	case x86asm.CVTDQ2PS:
   217  		return f.liftInstCVTDQ2PS(inst)
   218  	case x86asm.CVTPD2DQ:
   219  		return f.liftInstCVTPD2DQ(inst)
   220  	case x86asm.CVTPD2PI:
   221  		return f.liftInstCVTPD2PI(inst)
   222  	case x86asm.CVTPD2PS:
   223  		return f.liftInstCVTPD2PS(inst)
   224  	case x86asm.CVTPI2PD:
   225  		return f.liftInstCVTPI2PD(inst)
   226  	case x86asm.CVTPI2PS:
   227  		return f.liftInstCVTPI2PS(inst)
   228  	case x86asm.CVTPS2DQ:
   229  		return f.liftInstCVTPS2DQ(inst)
   230  	case x86asm.CVTPS2PD:
   231  		return f.liftInstCVTPS2PD(inst)
   232  	case x86asm.CVTPS2PI:
   233  		return f.liftInstCVTPS2PI(inst)
   234  	case x86asm.CVTSD2SI:
   235  		return f.liftInstCVTSD2SI(inst)
   236  	case x86asm.CVTSD2SS:
   237  		return f.liftInstCVTSD2SS(inst)
   238  	case x86asm.CVTSI2SD:
   239  		return f.liftInstCVTSI2SD(inst)
   240  	case x86asm.CVTSI2SS:
   241  		return f.liftInstCVTSI2SS(inst)
   242  	case x86asm.CVTSS2SD:
   243  		return f.liftInstCVTSS2SD(inst)
   244  	case x86asm.CVTSS2SI:
   245  		return f.liftInstCVTSS2SI(inst)
   246  	case x86asm.CVTTPD2DQ:
   247  		return f.liftInstCVTTPD2DQ(inst)
   248  	case x86asm.CVTTPD2PI:
   249  		return f.liftInstCVTTPD2PI(inst)
   250  	case x86asm.CVTTPS2DQ:
   251  		return f.liftInstCVTTPS2DQ(inst)
   252  	case x86asm.CVTTPS2PI:
   253  		return f.liftInstCVTTPS2PI(inst)
   254  	case x86asm.CVTTSD2SI:
   255  		return f.liftInstCVTTSD2SI(inst)
   256  	case x86asm.CVTTSS2SI:
   257  		return f.liftInstCVTTSS2SI(inst)
   258  	case x86asm.CWD:
   259  		return f.liftInstCWD(inst)
   260  	case x86asm.CWDE:
   261  		return f.liftInstCWDE(inst)
   262  	case x86asm.DAA:
   263  		return f.liftInstDAA(inst)
   264  	case x86asm.DAS:
   265  		return f.liftInstDAS(inst)
   266  	case x86asm.DEC:
   267  		return f.liftInstDEC(inst)
   268  	case x86asm.DIV:
   269  		return f.liftInstDIV(inst)
   270  	case x86asm.DIVPD:
   271  		return f.liftInstDIVPD(inst)
   272  	case x86asm.DIVPS:
   273  		return f.liftInstDIVPS(inst)
   274  	case x86asm.DIVSD:
   275  		return f.liftInstDIVSD(inst)
   276  	case x86asm.DIVSS:
   277  		return f.liftInstDIVSS(inst)
   278  	case x86asm.DPPD:
   279  		return f.liftInstDPPD(inst)
   280  	case x86asm.DPPS:
   281  		return f.liftInstDPPS(inst)
   282  	case x86asm.EMMS:
   283  		return f.liftInstEMMS(inst)
   284  	case x86asm.ENTER:
   285  		return f.liftInstENTER(inst)
   286  	case x86asm.EXTRACTPS:
   287  		return f.liftInstEXTRACTPS(inst)
   288  	case x86asm.F2XM1:
   289  		return f.liftInstF2XM1(inst)
   290  	case x86asm.FABS:
   291  		return f.liftInstFABS(inst)
   292  	case x86asm.FADD:
   293  		return f.liftInstFADD(inst)
   294  	case x86asm.FADDP:
   295  		return f.liftInstFADDP(inst)
   296  	case x86asm.FBLD:
   297  		return f.liftInstFBLD(inst)
   298  	case x86asm.FBSTP:
   299  		return f.liftInstFBSTP(inst)
   300  	case x86asm.FCHS:
   301  		return f.liftInstFCHS(inst)
   302  	case x86asm.FCMOVB:
   303  		return f.liftInstFCMOVB(inst)
   304  	case x86asm.FCMOVBE:
   305  		return f.liftInstFCMOVBE(inst)
   306  	case x86asm.FCMOVE:
   307  		return f.liftInstFCMOVE(inst)
   308  	case x86asm.FCMOVNB:
   309  		return f.liftInstFCMOVNB(inst)
   310  	case x86asm.FCMOVNBE:
   311  		return f.liftInstFCMOVNBE(inst)
   312  	case x86asm.FCMOVNE:
   313  		return f.liftInstFCMOVNE(inst)
   314  	case x86asm.FCMOVNU:
   315  		return f.liftInstFCMOVNU(inst)
   316  	case x86asm.FCMOVU:
   317  		return f.liftInstFCMOVU(inst)
   318  	case x86asm.FCOM:
   319  		return f.liftInstFCOM(inst)
   320  	case x86asm.FCOMI:
   321  		return f.liftInstFCOMI(inst)
   322  	case x86asm.FCOMIP:
   323  		return f.liftInstFCOMIP(inst)
   324  	case x86asm.FCOMP:
   325  		return f.liftInstFCOMP(inst)
   326  	case x86asm.FCOMPP:
   327  		return f.liftInstFCOMPP(inst)
   328  	case x86asm.FCOS:
   329  		return f.liftInstFCOS(inst)
   330  	case x86asm.FDECSTP:
   331  		return f.liftInstFDECSTP(inst)
   332  	case x86asm.FDIV:
   333  		return f.liftInstFDIV(inst)
   334  	case x86asm.FDIVP:
   335  		return f.liftInstFDIVP(inst)
   336  	case x86asm.FDIVR:
   337  		return f.liftInstFDIVR(inst)
   338  	case x86asm.FDIVRP:
   339  		return f.liftInstFDIVRP(inst)
   340  	case x86asm.FFREE:
   341  		return f.liftInstFFREE(inst)
   342  	case x86asm.FFREEP:
   343  		return f.liftInstFFREEP(inst)
   344  	case x86asm.FIADD:
   345  		return f.liftInstFIADD(inst)
   346  	case x86asm.FICOM:
   347  		return f.liftInstFICOM(inst)
   348  	case x86asm.FICOMP:
   349  		return f.liftInstFICOMP(inst)
   350  	case x86asm.FIDIV:
   351  		return f.liftInstFIDIV(inst)
   352  	case x86asm.FIDIVR:
   353  		return f.liftInstFIDIVR(inst)
   354  	case x86asm.FILD:
   355  		return f.liftInstFILD(inst)
   356  	case x86asm.FIMUL:
   357  		return f.liftInstFIMUL(inst)
   358  	case x86asm.FINCSTP:
   359  		return f.liftInstFINCSTP(inst)
   360  	case x86asm.FIST:
   361  		return f.liftInstFIST(inst)
   362  	case x86asm.FISTP:
   363  		return f.liftInstFISTP(inst)
   364  	case x86asm.FISTTP:
   365  		return f.liftInstFISTTP(inst)
   366  	case x86asm.FISUB:
   367  		return f.liftInstFISUB(inst)
   368  	case x86asm.FISUBR:
   369  		return f.liftInstFISUBR(inst)
   370  	case x86asm.FLD:
   371  		return f.liftInstFLD(inst)
   372  	case x86asm.FLD1:
   373  		return f.liftInstFLD1(inst)
   374  	case x86asm.FLDCW:
   375  		return f.liftInstFLDCW(inst)
   376  	case x86asm.FLDENV:
   377  		return f.liftInstFLDENV(inst)
   378  	case x86asm.FLDL2E:
   379  		return f.liftInstFLDL2E(inst)
   380  	case x86asm.FLDL2T:
   381  		return f.liftInstFLDL2T(inst)
   382  	case x86asm.FLDLG2:
   383  		return f.liftInstFLDLG2(inst)
   384  	case x86asm.FLDLN2:
   385  		return f.liftInstFLDLN2(inst)
   386  	case x86asm.FLDPI:
   387  		return f.liftInstFLDPI(inst)
   388  	case x86asm.FLDZ:
   389  		return f.liftInstFLDZ(inst)
   390  	case x86asm.FMUL:
   391  		return f.liftInstFMUL(inst)
   392  	case x86asm.FMULP:
   393  		return f.liftInstFMULP(inst)
   394  	case x86asm.FNCLEX:
   395  		return f.liftInstFNCLEX(inst)
   396  	case x86asm.FNINIT:
   397  		return f.liftInstFNINIT(inst)
   398  	case x86asm.FNOP:
   399  		return f.liftInstFNOP(inst)
   400  	case x86asm.FNSAVE:
   401  		return f.liftInstFNSAVE(inst)
   402  	case x86asm.FNSTCW:
   403  		return f.liftInstFNSTCW(inst)
   404  	case x86asm.FNSTENV:
   405  		return f.liftInstFNSTENV(inst)
   406  	case x86asm.FNSTSW:
   407  		return f.liftInstFNSTSW(inst)
   408  	case x86asm.FPATAN:
   409  		return f.liftInstFPATAN(inst)
   410  	case x86asm.FPREM:
   411  		return f.liftInstFPREM(inst)
   412  	case x86asm.FPREM1:
   413  		return f.liftInstFPREM1(inst)
   414  	case x86asm.FPTAN:
   415  		return f.liftInstFPTAN(inst)
   416  	case x86asm.FRNDINT:
   417  		return f.liftInstFRNDINT(inst)
   418  	case x86asm.FRSTOR:
   419  		return f.liftInstFRSTOR(inst)
   420  	case x86asm.FSCALE:
   421  		return f.liftInstFSCALE(inst)
   422  	case x86asm.FSIN:
   423  		return f.liftInstFSIN(inst)
   424  	case x86asm.FSINCOS:
   425  		return f.liftInstFSINCOS(inst)
   426  	case x86asm.FSQRT:
   427  		return f.liftInstFSQRT(inst)
   428  	case x86asm.FST:
   429  		return f.liftInstFST(inst)
   430  	case x86asm.FSTP:
   431  		return f.liftInstFSTP(inst)
   432  	case x86asm.FSUB:
   433  		return f.liftInstFSUB(inst)
   434  	case x86asm.FSUBP:
   435  		return f.liftInstFSUBP(inst)
   436  	case x86asm.FSUBR:
   437  		return f.liftInstFSUBR(inst)
   438  	case x86asm.FSUBRP:
   439  		return f.liftInstFSUBRP(inst)
   440  	case x86asm.FTST:
   441  		return f.liftInstFTST(inst)
   442  	case x86asm.FUCOM:
   443  		return f.liftInstFUCOM(inst)
   444  	case x86asm.FUCOMI:
   445  		return f.liftInstFUCOMI(inst)
   446  	case x86asm.FUCOMIP:
   447  		return f.liftInstFUCOMIP(inst)
   448  	case x86asm.FUCOMP:
   449  		return f.liftInstFUCOMP(inst)
   450  	case x86asm.FUCOMPP:
   451  		return f.liftInstFUCOMPP(inst)
   452  	case x86asm.FWAIT:
   453  		return f.liftInstFWAIT(inst)
   454  	case x86asm.FXAM:
   455  		return f.liftInstFXAM(inst)
   456  	case x86asm.FXCH:
   457  		return f.liftInstFXCH(inst)
   458  	case x86asm.FXRSTOR:
   459  		return f.liftInstFXRSTOR(inst)
   460  	case x86asm.FXRSTOR64:
   461  		return f.liftInstFXRSTOR64(inst)
   462  	case x86asm.FXSAVE:
   463  		return f.liftInstFXSAVE(inst)
   464  	case x86asm.FXSAVE64:
   465  		return f.liftInstFXSAVE64(inst)
   466  	case x86asm.FXTRACT:
   467  		return f.liftInstFXTRACT(inst)
   468  	case x86asm.FYL2X:
   469  		return f.liftInstFYL2X(inst)
   470  	case x86asm.FYL2XP1:
   471  		return f.liftInstFYL2XP1(inst)
   472  	case x86asm.HADDPD:
   473  		return f.liftInstHADDPD(inst)
   474  	case x86asm.HADDPS:
   475  		return f.liftInstHADDPS(inst)
   476  	case x86asm.HLT:
   477  		return f.liftInstHLT(inst)
   478  	case x86asm.HSUBPD:
   479  		return f.liftInstHSUBPD(inst)
   480  	case x86asm.HSUBPS:
   481  		return f.liftInstHSUBPS(inst)
   482  	case x86asm.ICEBP:
   483  		return f.liftInstICEBP(inst)
   484  	case x86asm.IDIV:
   485  		return f.liftInstIDIV(inst)
   486  	case x86asm.IMUL:
   487  		return f.liftInstIMUL(inst)
   488  	case x86asm.IN:
   489  		return f.liftInstIN(inst)
   490  	case x86asm.INC:
   491  		return f.liftInstINC(inst)
   492  	case x86asm.INSB:
   493  		return f.liftInstINSB(inst)
   494  	case x86asm.INSD:
   495  		return f.liftInstINSD(inst)
   496  	case x86asm.INSERTPS:
   497  		return f.liftInstINSERTPS(inst)
   498  	case x86asm.INSW:
   499  		return f.liftInstINSW(inst)
   500  	case x86asm.INT:
   501  		return f.liftInstINT(inst)
   502  	case x86asm.INTO:
   503  		return f.liftInstINTO(inst)
   504  	case x86asm.INVD:
   505  		return f.liftInstINVD(inst)
   506  	case x86asm.INVLPG:
   507  		return f.liftInstINVLPG(inst)
   508  	case x86asm.INVPCID:
   509  		return f.liftInstINVPCID(inst)
   510  	case x86asm.IRET:
   511  		return f.liftInstIRET(inst)
   512  	case x86asm.IRETD:
   513  		return f.liftInstIRETD(inst)
   514  	case x86asm.IRETQ:
   515  		return f.liftInstIRETQ(inst)
   516  	case x86asm.LAHF:
   517  		return f.liftInstLAHF(inst)
   518  	case x86asm.LAR:
   519  		return f.liftInstLAR(inst)
   520  	case x86asm.LCALL:
   521  		return f.liftInstLCALL(inst)
   522  	case x86asm.LDDQU:
   523  		return f.liftInstLDDQU(inst)
   524  	case x86asm.LDMXCSR:
   525  		return f.liftInstLDMXCSR(inst)
   526  	case x86asm.LDS:
   527  		return f.liftInstLDS(inst)
   528  	case x86asm.LEA:
   529  		return f.liftInstLEA(inst)
   530  	case x86asm.LEAVE:
   531  		return f.liftInstLEAVE(inst)
   532  	case x86asm.LES:
   533  		return f.liftInstLES(inst)
   534  	case x86asm.LFENCE:
   535  		return f.liftInstLFENCE(inst)
   536  	case x86asm.LFS:
   537  		return f.liftInstLFS(inst)
   538  	case x86asm.LGDT:
   539  		return f.liftInstLGDT(inst)
   540  	case x86asm.LGS:
   541  		return f.liftInstLGS(inst)
   542  	case x86asm.LIDT:
   543  		return f.liftInstLIDT(inst)
   544  	case x86asm.LJMP:
   545  		return f.liftInstLJMP(inst)
   546  	case x86asm.LLDT:
   547  		return f.liftInstLLDT(inst)
   548  	case x86asm.LMSW:
   549  		return f.liftInstLMSW(inst)
   550  	case x86asm.LODSB:
   551  		return f.liftInstLODSB(inst)
   552  	case x86asm.LODSD:
   553  		return f.liftInstLODSD(inst)
   554  	case x86asm.LODSQ:
   555  		return f.liftInstLODSQ(inst)
   556  	case x86asm.LODSW:
   557  		return f.liftInstLODSW(inst)
   558  	case x86asm.LRET:
   559  		return f.liftInstLRET(inst)
   560  	case x86asm.LSL:
   561  		return f.liftInstLSL(inst)
   562  	case x86asm.LSS:
   563  		return f.liftInstLSS(inst)
   564  	case x86asm.LTR:
   565  		return f.liftInstLTR(inst)
   566  	case x86asm.LZCNT:
   567  		return f.liftInstLZCNT(inst)
   568  	case x86asm.MASKMOVDQU:
   569  		return f.liftInstMASKMOVDQU(inst)
   570  	case x86asm.MASKMOVQ:
   571  		return f.liftInstMASKMOVQ(inst)
   572  	case x86asm.MAXPD:
   573  		return f.liftInstMAXPD(inst)
   574  	case x86asm.MAXPS:
   575  		return f.liftInstMAXPS(inst)
   576  	case x86asm.MAXSD:
   577  		return f.liftInstMAXSD(inst)
   578  	case x86asm.MAXSS:
   579  		return f.liftInstMAXSS(inst)
   580  	case x86asm.MFENCE:
   581  		return f.liftInstMFENCE(inst)
   582  	case x86asm.MINPD:
   583  		return f.liftInstMINPD(inst)
   584  	case x86asm.MINPS:
   585  		return f.liftInstMINPS(inst)
   586  	case x86asm.MINSD:
   587  		return f.liftInstMINSD(inst)
   588  	case x86asm.MINSS:
   589  		return f.liftInstMINSS(inst)
   590  	case x86asm.MONITOR:
   591  		return f.liftInstMONITOR(inst)
   592  	case x86asm.MOV:
   593  		return f.liftInstMOV(inst)
   594  	case x86asm.MOVAPD:
   595  		return f.liftInstMOVAPD(inst)
   596  	case x86asm.MOVAPS:
   597  		return f.liftInstMOVAPS(inst)
   598  	case x86asm.MOVBE:
   599  		return f.liftInstMOVBE(inst)
   600  	case x86asm.MOVD:
   601  		return f.liftInstMOVD(inst)
   602  	case x86asm.MOVDDUP:
   603  		return f.liftInstMOVDDUP(inst)
   604  	case x86asm.MOVDQ2Q:
   605  		return f.liftInstMOVDQ2Q(inst)
   606  	case x86asm.MOVDQA:
   607  		return f.liftInstMOVDQA(inst)
   608  	case x86asm.MOVDQU:
   609  		return f.liftInstMOVDQU(inst)
   610  	case x86asm.MOVHLPS:
   611  		return f.liftInstMOVHLPS(inst)
   612  	case x86asm.MOVHPD:
   613  		return f.liftInstMOVHPD(inst)
   614  	case x86asm.MOVHPS:
   615  		return f.liftInstMOVHPS(inst)
   616  	case x86asm.MOVLHPS:
   617  		return f.liftInstMOVLHPS(inst)
   618  	case x86asm.MOVLPD:
   619  		return f.liftInstMOVLPD(inst)
   620  	case x86asm.MOVLPS:
   621  		return f.liftInstMOVLPS(inst)
   622  	case x86asm.MOVMSKPD:
   623  		return f.liftInstMOVMSKPD(inst)
   624  	case x86asm.MOVMSKPS:
   625  		return f.liftInstMOVMSKPS(inst)
   626  	case x86asm.MOVNTDQ:
   627  		return f.liftInstMOVNTDQ(inst)
   628  	case x86asm.MOVNTDQA:
   629  		return f.liftInstMOVNTDQA(inst)
   630  	case x86asm.MOVNTI:
   631  		return f.liftInstMOVNTI(inst)
   632  	case x86asm.MOVNTPD:
   633  		return f.liftInstMOVNTPD(inst)
   634  	case x86asm.MOVNTPS:
   635  		return f.liftInstMOVNTPS(inst)
   636  	case x86asm.MOVNTQ:
   637  		return f.liftInstMOVNTQ(inst)
   638  	case x86asm.MOVNTSD:
   639  		return f.liftInstMOVNTSD(inst)
   640  	case x86asm.MOVNTSS:
   641  		return f.liftInstMOVNTSS(inst)
   642  	case x86asm.MOVQ:
   643  		return f.liftInstMOVQ(inst)
   644  	case x86asm.MOVQ2DQ:
   645  		return f.liftInstMOVQ2DQ(inst)
   646  	case x86asm.MOVSB:
   647  		return f.liftInstMOVSB(inst)
   648  	case x86asm.MOVSD:
   649  		return f.liftInstMOVSD(inst)
   650  	case x86asm.MOVSD_XMM:
   651  		return f.liftInstMOVSD_XMM(inst)
   652  	case x86asm.MOVSHDUP:
   653  		return f.liftInstMOVSHDUP(inst)
   654  	case x86asm.MOVSLDUP:
   655  		return f.liftInstMOVSLDUP(inst)
   656  	case x86asm.MOVSQ:
   657  		return f.liftInstMOVSQ(inst)
   658  	case x86asm.MOVSS:
   659  		return f.liftInstMOVSS(inst)
   660  	case x86asm.MOVSW:
   661  		return f.liftInstMOVSW(inst)
   662  	case x86asm.MOVSX:
   663  		return f.liftInstMOVSX(inst)
   664  	case x86asm.MOVSXD:
   665  		return f.liftInstMOVSXD(inst)
   666  	case x86asm.MOVUPD:
   667  		return f.liftInstMOVUPD(inst)
   668  	case x86asm.MOVUPS:
   669  		return f.liftInstMOVUPS(inst)
   670  	case x86asm.MOVZX:
   671  		return f.liftInstMOVZX(inst)
   672  	case x86asm.MPSADBW:
   673  		return f.liftInstMPSADBW(inst)
   674  	case x86asm.MUL:
   675  		return f.liftInstMUL(inst)
   676  	case x86asm.MULPD:
   677  		return f.liftInstMULPD(inst)
   678  	case x86asm.MULPS:
   679  		return f.liftInstMULPS(inst)
   680  	case x86asm.MULSD:
   681  		return f.liftInstMULSD(inst)
   682  	case x86asm.MULSS:
   683  		return f.liftInstMULSS(inst)
   684  	case x86asm.MWAIT:
   685  		return f.liftInstMWAIT(inst)
   686  	case x86asm.NEG:
   687  		return f.liftInstNEG(inst)
   688  	case x86asm.NOP:
   689  		return f.liftInstNOP(inst)
   690  	case x86asm.NOT:
   691  		return f.liftInstNOT(inst)
   692  	case x86asm.OR:
   693  		return f.liftInstOR(inst)
   694  	case x86asm.ORPD:
   695  		return f.liftInstORPD(inst)
   696  	case x86asm.ORPS:
   697  		return f.liftInstORPS(inst)
   698  	case x86asm.OUT:
   699  		return f.liftInstOUT(inst)
   700  	case x86asm.OUTSB:
   701  		return f.liftInstOUTSB(inst)
   702  	case x86asm.OUTSD:
   703  		return f.liftInstOUTSD(inst)
   704  	case x86asm.OUTSW:
   705  		return f.liftInstOUTSW(inst)
   706  	case x86asm.PABSB:
   707  		return f.liftInstPABSB(inst)
   708  	case x86asm.PABSD:
   709  		return f.liftInstPABSD(inst)
   710  	case x86asm.PABSW:
   711  		return f.liftInstPABSW(inst)
   712  	case x86asm.PACKSSDW:
   713  		return f.liftInstPACKSSDW(inst)
   714  	case x86asm.PACKSSWB:
   715  		return f.liftInstPACKSSWB(inst)
   716  	case x86asm.PACKUSDW:
   717  		return f.liftInstPACKUSDW(inst)
   718  	case x86asm.PACKUSWB:
   719  		return f.liftInstPACKUSWB(inst)
   720  	case x86asm.PADDB:
   721  		return f.liftInstPADDB(inst)
   722  	case x86asm.PADDD:
   723  		return f.liftInstPADDD(inst)
   724  	case x86asm.PADDQ:
   725  		return f.liftInstPADDQ(inst)
   726  	case x86asm.PADDSB:
   727  		return f.liftInstPADDSB(inst)
   728  	case x86asm.PADDSW:
   729  		return f.liftInstPADDSW(inst)
   730  	case x86asm.PADDUSB:
   731  		return f.liftInstPADDUSB(inst)
   732  	case x86asm.PADDUSW:
   733  		return f.liftInstPADDUSW(inst)
   734  	case x86asm.PADDW:
   735  		return f.liftInstPADDW(inst)
   736  	case x86asm.PALIGNR:
   737  		return f.liftInstPALIGNR(inst)
   738  	case x86asm.PAND:
   739  		return f.liftInstPAND(inst)
   740  	case x86asm.PANDN:
   741  		return f.liftInstPANDN(inst)
   742  	case x86asm.PAUSE:
   743  		return f.liftInstPAUSE(inst)
   744  	case x86asm.PAVGB:
   745  		return f.liftInstPAVGB(inst)
   746  	case x86asm.PAVGW:
   747  		return f.liftInstPAVGW(inst)
   748  	case x86asm.PBLENDVB:
   749  		return f.liftInstPBLENDVB(inst)
   750  	case x86asm.PBLENDW:
   751  		return f.liftInstPBLENDW(inst)
   752  	case x86asm.PCLMULQDQ:
   753  		return f.liftInstPCLMULQDQ(inst)
   754  	case x86asm.PCMPEQB:
   755  		return f.liftInstPCMPEQB(inst)
   756  	case x86asm.PCMPEQD:
   757  		return f.liftInstPCMPEQD(inst)
   758  	case x86asm.PCMPEQQ:
   759  		return f.liftInstPCMPEQQ(inst)
   760  	case x86asm.PCMPEQW:
   761  		return f.liftInstPCMPEQW(inst)
   762  	case x86asm.PCMPESTRI:
   763  		return f.liftInstPCMPESTRI(inst)
   764  	case x86asm.PCMPESTRM:
   765  		return f.liftInstPCMPESTRM(inst)
   766  	case x86asm.PCMPGTB:
   767  		return f.liftInstPCMPGTB(inst)
   768  	case x86asm.PCMPGTD:
   769  		return f.liftInstPCMPGTD(inst)
   770  	case x86asm.PCMPGTQ:
   771  		return f.liftInstPCMPGTQ(inst)
   772  	case x86asm.PCMPGTW:
   773  		return f.liftInstPCMPGTW(inst)
   774  	case x86asm.PCMPISTRI:
   775  		return f.liftInstPCMPISTRI(inst)
   776  	case x86asm.PCMPISTRM:
   777  		return f.liftInstPCMPISTRM(inst)
   778  	case x86asm.PEXTRB:
   779  		return f.liftInstPEXTRB(inst)
   780  	case x86asm.PEXTRD:
   781  		return f.liftInstPEXTRD(inst)
   782  	case x86asm.PEXTRQ:
   783  		return f.liftInstPEXTRQ(inst)
   784  	case x86asm.PEXTRW:
   785  		return f.liftInstPEXTRW(inst)
   786  	case x86asm.PHADDD:
   787  		return f.liftInstPHADDD(inst)
   788  	case x86asm.PHADDSW:
   789  		return f.liftInstPHADDSW(inst)
   790  	case x86asm.PHADDW:
   791  		return f.liftInstPHADDW(inst)
   792  	case x86asm.PHMINPOSUW:
   793  		return f.liftInstPHMINPOSUW(inst)
   794  	case x86asm.PHSUBD:
   795  		return f.liftInstPHSUBD(inst)
   796  	case x86asm.PHSUBSW:
   797  		return f.liftInstPHSUBSW(inst)
   798  	case x86asm.PHSUBW:
   799  		return f.liftInstPHSUBW(inst)
   800  	case x86asm.PINSRB:
   801  		return f.liftInstPINSRB(inst)
   802  	case x86asm.PINSRD:
   803  		return f.liftInstPINSRD(inst)
   804  	case x86asm.PINSRQ:
   805  		return f.liftInstPINSRQ(inst)
   806  	case x86asm.PINSRW:
   807  		return f.liftInstPINSRW(inst)
   808  	case x86asm.PMADDUBSW:
   809  		return f.liftInstPMADDUBSW(inst)
   810  	case x86asm.PMADDWD:
   811  		return f.liftInstPMADDWD(inst)
   812  	case x86asm.PMAXSB:
   813  		return f.liftInstPMAXSB(inst)
   814  	case x86asm.PMAXSD:
   815  		return f.liftInstPMAXSD(inst)
   816  	case x86asm.PMAXSW:
   817  		return f.liftInstPMAXSW(inst)
   818  	case x86asm.PMAXUB:
   819  		return f.liftInstPMAXUB(inst)
   820  	case x86asm.PMAXUD:
   821  		return f.liftInstPMAXUD(inst)
   822  	case x86asm.PMAXUW:
   823  		return f.liftInstPMAXUW(inst)
   824  	case x86asm.PMINSB:
   825  		return f.liftInstPMINSB(inst)
   826  	case x86asm.PMINSD:
   827  		return f.liftInstPMINSD(inst)
   828  	case x86asm.PMINSW:
   829  		return f.liftInstPMINSW(inst)
   830  	case x86asm.PMINUB:
   831  		return f.liftInstPMINUB(inst)
   832  	case x86asm.PMINUD:
   833  		return f.liftInstPMINUD(inst)
   834  	case x86asm.PMINUW:
   835  		return f.liftInstPMINUW(inst)
   836  	case x86asm.PMOVMSKB:
   837  		return f.liftInstPMOVMSKB(inst)
   838  	case x86asm.PMOVSXBD:
   839  		return f.liftInstPMOVSXBD(inst)
   840  	case x86asm.PMOVSXBQ:
   841  		return f.liftInstPMOVSXBQ(inst)
   842  	case x86asm.PMOVSXBW:
   843  		return f.liftInstPMOVSXBW(inst)
   844  	case x86asm.PMOVSXDQ:
   845  		return f.liftInstPMOVSXDQ(inst)
   846  	case x86asm.PMOVSXWD:
   847  		return f.liftInstPMOVSXWD(inst)
   848  	case x86asm.PMOVSXWQ:
   849  		return f.liftInstPMOVSXWQ(inst)
   850  	case x86asm.PMOVZXBD:
   851  		return f.liftInstPMOVZXBD(inst)
   852  	case x86asm.PMOVZXBQ:
   853  		return f.liftInstPMOVZXBQ(inst)
   854  	case x86asm.PMOVZXBW:
   855  		return f.liftInstPMOVZXBW(inst)
   856  	case x86asm.PMOVZXDQ:
   857  		return f.liftInstPMOVZXDQ(inst)
   858  	case x86asm.PMOVZXWD:
   859  		return f.liftInstPMOVZXWD(inst)
   860  	case x86asm.PMOVZXWQ:
   861  		return f.liftInstPMOVZXWQ(inst)
   862  	case x86asm.PMULDQ:
   863  		return f.liftInstPMULDQ(inst)
   864  	case x86asm.PMULHRSW:
   865  		return f.liftInstPMULHRSW(inst)
   866  	case x86asm.PMULHUW:
   867  		return f.liftInstPMULHUW(inst)
   868  	case x86asm.PMULHW:
   869  		return f.liftInstPMULHW(inst)
   870  	case x86asm.PMULLD:
   871  		return f.liftInstPMULLD(inst)
   872  	case x86asm.PMULLW:
   873  		return f.liftInstPMULLW(inst)
   874  	case x86asm.PMULUDQ:
   875  		return f.liftInstPMULUDQ(inst)
   876  	case x86asm.POP:
   877  		return f.liftInstPOP(inst)
   878  	case x86asm.POPA:
   879  		return f.liftInstPOPA(inst)
   880  	case x86asm.POPAD:
   881  		return f.liftInstPOPAD(inst)
   882  	case x86asm.POPCNT:
   883  		return f.liftInstPOPCNT(inst)
   884  	case x86asm.POPF:
   885  		return f.liftInstPOPF(inst)
   886  	case x86asm.POPFD:
   887  		return f.liftInstPOPFD(inst)
   888  	case x86asm.POPFQ:
   889  		return f.liftInstPOPFQ(inst)
   890  	case x86asm.POR:
   891  		return f.liftInstPOR(inst)
   892  	case x86asm.PREFETCHNTA:
   893  		return f.liftInstPREFETCHNTA(inst)
   894  	case x86asm.PREFETCHT0:
   895  		return f.liftInstPREFETCHT0(inst)
   896  	case x86asm.PREFETCHT1:
   897  		return f.liftInstPREFETCHT1(inst)
   898  	case x86asm.PREFETCHT2:
   899  		return f.liftInstPREFETCHT2(inst)
   900  	case x86asm.PREFETCHW:
   901  		return f.liftInstPREFETCHW(inst)
   902  	case x86asm.PSADBW:
   903  		return f.liftInstPSADBW(inst)
   904  	case x86asm.PSHUFB:
   905  		return f.liftInstPSHUFB(inst)
   906  	case x86asm.PSHUFD:
   907  		return f.liftInstPSHUFD(inst)
   908  	case x86asm.PSHUFHW:
   909  		return f.liftInstPSHUFHW(inst)
   910  	case x86asm.PSHUFLW:
   911  		return f.liftInstPSHUFLW(inst)
   912  	case x86asm.PSHUFW:
   913  		return f.liftInstPSHUFW(inst)
   914  	case x86asm.PSIGNB:
   915  		return f.liftInstPSIGNB(inst)
   916  	case x86asm.PSIGND:
   917  		return f.liftInstPSIGND(inst)
   918  	case x86asm.PSIGNW:
   919  		return f.liftInstPSIGNW(inst)
   920  	case x86asm.PSLLD:
   921  		return f.liftInstPSLLD(inst)
   922  	case x86asm.PSLLDQ:
   923  		return f.liftInstPSLLDQ(inst)
   924  	case x86asm.PSLLQ:
   925  		return f.liftInstPSLLQ(inst)
   926  	case x86asm.PSLLW:
   927  		return f.liftInstPSLLW(inst)
   928  	case x86asm.PSRAD:
   929  		return f.liftInstPSRAD(inst)
   930  	case x86asm.PSRAW:
   931  		return f.liftInstPSRAW(inst)
   932  	case x86asm.PSRLD:
   933  		return f.liftInstPSRLD(inst)
   934  	case x86asm.PSRLDQ:
   935  		return f.liftInstPSRLDQ(inst)
   936  	case x86asm.PSRLQ:
   937  		return f.liftInstPSRLQ(inst)
   938  	case x86asm.PSRLW:
   939  		return f.liftInstPSRLW(inst)
   940  	case x86asm.PSUBB:
   941  		return f.liftInstPSUBB(inst)
   942  	case x86asm.PSUBD:
   943  		return f.liftInstPSUBD(inst)
   944  	case x86asm.PSUBQ:
   945  		return f.liftInstPSUBQ(inst)
   946  	case x86asm.PSUBSB:
   947  		return f.liftInstPSUBSB(inst)
   948  	case x86asm.PSUBSW:
   949  		return f.liftInstPSUBSW(inst)
   950  	case x86asm.PSUBUSB:
   951  		return f.liftInstPSUBUSB(inst)
   952  	case x86asm.PSUBUSW:
   953  		return f.liftInstPSUBUSW(inst)
   954  	case x86asm.PSUBW:
   955  		return f.liftInstPSUBW(inst)
   956  	case x86asm.PTEST:
   957  		return f.liftInstPTEST(inst)
   958  	case x86asm.PUNPCKHBW:
   959  		return f.liftInstPUNPCKHBW(inst)
   960  	case x86asm.PUNPCKHDQ:
   961  		return f.liftInstPUNPCKHDQ(inst)
   962  	case x86asm.PUNPCKHQDQ:
   963  		return f.liftInstPUNPCKHQDQ(inst)
   964  	case x86asm.PUNPCKHWD:
   965  		return f.liftInstPUNPCKHWD(inst)
   966  	case x86asm.PUNPCKLBW:
   967  		return f.liftInstPUNPCKLBW(inst)
   968  	case x86asm.PUNPCKLDQ:
   969  		return f.liftInstPUNPCKLDQ(inst)
   970  	case x86asm.PUNPCKLQDQ:
   971  		return f.liftInstPUNPCKLQDQ(inst)
   972  	case x86asm.PUNPCKLWD:
   973  		return f.liftInstPUNPCKLWD(inst)
   974  	case x86asm.PUSH:
   975  		return f.liftInstPUSH(inst)
   976  	case x86asm.PUSHA:
   977  		return f.liftInstPUSHA(inst)
   978  	case x86asm.PUSHAD:
   979  		return f.liftInstPUSHAD(inst)
   980  	case x86asm.PUSHF:
   981  		return f.liftInstPUSHF(inst)
   982  	case x86asm.PUSHFD:
   983  		return f.liftInstPUSHFD(inst)
   984  	case x86asm.PUSHFQ:
   985  		return f.liftInstPUSHFQ(inst)
   986  	case x86asm.PXOR:
   987  		return f.liftInstPXOR(inst)
   988  	case x86asm.RCL:
   989  		return f.liftInstRCL(inst)
   990  	case x86asm.RCPPS:
   991  		return f.liftInstRCPPS(inst)
   992  	case x86asm.RCPSS:
   993  		return f.liftInstRCPSS(inst)
   994  	case x86asm.RCR:
   995  		return f.liftInstRCR(inst)
   996  	case x86asm.RDFSBASE:
   997  		return f.liftInstRDFSBASE(inst)
   998  	case x86asm.RDGSBASE:
   999  		return f.liftInstRDGSBASE(inst)
  1000  	case x86asm.RDMSR:
  1001  		return f.liftInstRDMSR(inst)
  1002  	case x86asm.RDPMC:
  1003  		return f.liftInstRDPMC(inst)
  1004  	case x86asm.RDRAND:
  1005  		return f.liftInstRDRAND(inst)
  1006  	case x86asm.RDTSC:
  1007  		return f.liftInstRDTSC(inst)
  1008  	case x86asm.RDTSCP:
  1009  		return f.liftInstRDTSCP(inst)
  1010  	case x86asm.ROL:
  1011  		return f.liftInstROL(inst)
  1012  	case x86asm.ROR:
  1013  		return f.liftInstROR(inst)
  1014  	case x86asm.ROUNDPD:
  1015  		return f.liftInstROUNDPD(inst)
  1016  	case x86asm.ROUNDPS:
  1017  		return f.liftInstROUNDPS(inst)
  1018  	case x86asm.ROUNDSD:
  1019  		return f.liftInstROUNDSD(inst)
  1020  	case x86asm.ROUNDSS:
  1021  		return f.liftInstROUNDSS(inst)
  1022  	case x86asm.RSM:
  1023  		return f.liftInstRSM(inst)
  1024  	case x86asm.RSQRTPS:
  1025  		return f.liftInstRSQRTPS(inst)
  1026  	case x86asm.RSQRTSS:
  1027  		return f.liftInstRSQRTSS(inst)
  1028  	case x86asm.SAHF:
  1029  		return f.liftInstSAHF(inst)
  1030  	case x86asm.SAR:
  1031  		return f.liftInstSAR(inst)
  1032  	case x86asm.SBB:
  1033  		return f.liftInstSBB(inst)
  1034  	case x86asm.SCASB:
  1035  		return f.liftInstSCASB(inst)
  1036  	case x86asm.SCASD:
  1037  		return f.liftInstSCASD(inst)
  1038  	case x86asm.SCASQ:
  1039  		return f.liftInstSCASQ(inst)
  1040  	case x86asm.SCASW:
  1041  		return f.liftInstSCASW(inst)
  1042  	case x86asm.SETA:
  1043  		return f.liftInstSETA(inst)
  1044  	case x86asm.SETAE:
  1045  		return f.liftInstSETAE(inst)
  1046  	case x86asm.SETB:
  1047  		return f.liftInstSETB(inst)
  1048  	case x86asm.SETBE:
  1049  		return f.liftInstSETBE(inst)
  1050  	case x86asm.SETE:
  1051  		return f.liftInstSETE(inst)
  1052  	case x86asm.SETG:
  1053  		return f.liftInstSETG(inst)
  1054  	case x86asm.SETGE:
  1055  		return f.liftInstSETGE(inst)
  1056  	case x86asm.SETL:
  1057  		return f.liftInstSETL(inst)
  1058  	case x86asm.SETLE:
  1059  		return f.liftInstSETLE(inst)
  1060  	case x86asm.SETNE:
  1061  		return f.liftInstSETNE(inst)
  1062  	case x86asm.SETNO:
  1063  		return f.liftInstSETNO(inst)
  1064  	case x86asm.SETNP:
  1065  		return f.liftInstSETNP(inst)
  1066  	case x86asm.SETNS:
  1067  		return f.liftInstSETNS(inst)
  1068  	case x86asm.SETO:
  1069  		return f.liftInstSETO(inst)
  1070  	case x86asm.SETP:
  1071  		return f.liftInstSETP(inst)
  1072  	case x86asm.SETS:
  1073  		return f.liftInstSETS(inst)
  1074  	case x86asm.SFENCE:
  1075  		return f.liftInstSFENCE(inst)
  1076  	case x86asm.SGDT:
  1077  		return f.liftInstSGDT(inst)
  1078  	case x86asm.SHL:
  1079  		return f.liftInstSHL(inst)
  1080  	case x86asm.SHLD:
  1081  		return f.liftInstSHLD(inst)
  1082  	case x86asm.SHR:
  1083  		return f.liftInstSHR(inst)
  1084  	case x86asm.SHRD:
  1085  		return f.liftInstSHRD(inst)
  1086  	case x86asm.SHUFPD:
  1087  		return f.liftInstSHUFPD(inst)
  1088  	case x86asm.SHUFPS:
  1089  		return f.liftInstSHUFPS(inst)
  1090  	case x86asm.SIDT:
  1091  		return f.liftInstSIDT(inst)
  1092  	case x86asm.SLDT:
  1093  		return f.liftInstSLDT(inst)
  1094  	case x86asm.SMSW:
  1095  		return f.liftInstSMSW(inst)
  1096  	case x86asm.SQRTPD:
  1097  		return f.liftInstSQRTPD(inst)
  1098  	case x86asm.SQRTPS:
  1099  		return f.liftInstSQRTPS(inst)
  1100  	case x86asm.SQRTSD:
  1101  		return f.liftInstSQRTSD(inst)
  1102  	case x86asm.SQRTSS:
  1103  		return f.liftInstSQRTSS(inst)
  1104  	case x86asm.STC:
  1105  		return f.liftInstSTC(inst)
  1106  	case x86asm.STD:
  1107  		return f.liftInstSTD(inst)
  1108  	case x86asm.STI:
  1109  		return f.liftInstSTI(inst)
  1110  	case x86asm.STMXCSR:
  1111  		return f.liftInstSTMXCSR(inst)
  1112  	case x86asm.STOSB:
  1113  		return f.liftInstSTOSB(inst)
  1114  	case x86asm.STOSD:
  1115  		return f.liftInstSTOSD(inst)
  1116  	case x86asm.STOSQ:
  1117  		return f.liftInstSTOSQ(inst)
  1118  	case x86asm.STOSW:
  1119  		return f.liftInstSTOSW(inst)
  1120  	case x86asm.STR:
  1121  		return f.liftInstSTR(inst)
  1122  	case x86asm.SUB:
  1123  		return f.liftInstSUB(inst)
  1124  	case x86asm.SUBPD:
  1125  		return f.liftInstSUBPD(inst)
  1126  	case x86asm.SUBPS:
  1127  		return f.liftInstSUBPS(inst)
  1128  	case x86asm.SUBSD:
  1129  		return f.liftInstSUBSD(inst)
  1130  	case x86asm.SUBSS:
  1131  		return f.liftInstSUBSS(inst)
  1132  	case x86asm.SWAPGS:
  1133  		return f.liftInstSWAPGS(inst)
  1134  	case x86asm.SYSCALL:
  1135  		return f.liftInstSYSCALL(inst)
  1136  	case x86asm.SYSENTER:
  1137  		return f.liftInstSYSENTER(inst)
  1138  	case x86asm.SYSEXIT:
  1139  		return f.liftInstSYSEXIT(inst)
  1140  	case x86asm.SYSRET:
  1141  		return f.liftInstSYSRET(inst)
  1142  	case x86asm.TEST:
  1143  		return f.liftInstTEST(inst)
  1144  	case x86asm.TZCNT:
  1145  		return f.liftInstTZCNT(inst)
  1146  	case x86asm.UCOMISD:
  1147  		return f.liftInstUCOMISD(inst)
  1148  	case x86asm.UCOMISS:
  1149  		return f.liftInstUCOMISS(inst)
  1150  	case x86asm.UD1:
  1151  		return f.liftInstUD1(inst)
  1152  	case x86asm.UD2:
  1153  		return f.liftInstUD2(inst)
  1154  	case x86asm.UNPCKHPD:
  1155  		return f.liftInstUNPCKHPD(inst)
  1156  	case x86asm.UNPCKHPS:
  1157  		return f.liftInstUNPCKHPS(inst)
  1158  	case x86asm.UNPCKLPD:
  1159  		return f.liftInstUNPCKLPD(inst)
  1160  	case x86asm.UNPCKLPS:
  1161  		return f.liftInstUNPCKLPS(inst)
  1162  	case x86asm.VERR:
  1163  		return f.liftInstVERR(inst)
  1164  	case x86asm.VERW:
  1165  		return f.liftInstVERW(inst)
  1166  	case x86asm.VMOVDQA:
  1167  		return f.liftInstVMOVDQA(inst)
  1168  	case x86asm.VMOVDQU:
  1169  		return f.liftInstVMOVDQU(inst)
  1170  	case x86asm.VMOVNTDQ:
  1171  		return f.liftInstVMOVNTDQ(inst)
  1172  	case x86asm.VMOVNTDQA:
  1173  		return f.liftInstVMOVNTDQA(inst)
  1174  	case x86asm.VZEROUPPER:
  1175  		return f.liftInstVZEROUPPER(inst)
  1176  	case x86asm.WBINVD:
  1177  		return f.liftInstWBINVD(inst)
  1178  	case x86asm.WRFSBASE:
  1179  		return f.liftInstWRFSBASE(inst)
  1180  	case x86asm.WRGSBASE:
  1181  		return f.liftInstWRGSBASE(inst)
  1182  	case x86asm.WRMSR:
  1183  		return f.liftInstWRMSR(inst)
  1184  	case x86asm.XABORT:
  1185  		return f.liftInstXABORT(inst)
  1186  	case x86asm.XADD:
  1187  		return f.liftInstXADD(inst)
  1188  	case x86asm.XBEGIN:
  1189  		return f.liftInstXBEGIN(inst)
  1190  	case x86asm.XCHG:
  1191  		return f.liftInstXCHG(inst)
  1192  	case x86asm.XEND:
  1193  		return f.liftInstXEND(inst)
  1194  	case x86asm.XGETBV:
  1195  		return f.liftInstXGETBV(inst)
  1196  	case x86asm.XLATB:
  1197  		return f.liftInstXLATB(inst)
  1198  	case x86asm.XOR:
  1199  		return f.liftInstXOR(inst)
  1200  	case x86asm.XORPD:
  1201  		return f.liftInstXORPD(inst)
  1202  	case x86asm.XORPS:
  1203  		return f.liftInstXORPS(inst)
  1204  	case x86asm.XRSTOR:
  1205  		return f.liftInstXRSTOR(inst)
  1206  	case x86asm.XRSTOR64:
  1207  		return f.liftInstXRSTOR64(inst)
  1208  	case x86asm.XRSTORS:
  1209  		return f.liftInstXRSTORS(inst)
  1210  	case x86asm.XRSTORS64:
  1211  		return f.liftInstXRSTORS64(inst)
  1212  	case x86asm.XSAVE:
  1213  		return f.liftInstXSAVE(inst)
  1214  	case x86asm.XSAVE64:
  1215  		return f.liftInstXSAVE64(inst)
  1216  	case x86asm.XSAVEC:
  1217  		return f.liftInstXSAVEC(inst)
  1218  	case x86asm.XSAVEC64:
  1219  		return f.liftInstXSAVEC64(inst)
  1220  	case x86asm.XSAVEOPT:
  1221  		return f.liftInstXSAVEOPT(inst)
  1222  	case x86asm.XSAVEOPT64:
  1223  		return f.liftInstXSAVEOPT64(inst)
  1224  	case x86asm.XSAVES:
  1225  		return f.liftInstXSAVES(inst)
  1226  	case x86asm.XSAVES64:
  1227  		return f.liftInstXSAVES64(inst)
  1228  	case x86asm.XSETBV:
  1229  		return f.liftInstXSETBV(inst)
  1230  	case x86asm.XTEST:
  1231  		return f.liftInstXTEST(inst)
  1232  	default:
  1233  		panic(fmt.Errorf("support for x86 instruction opcode %v not yet implemented", inst.Op))
  1234  	}
  1235  }
  1236  
  1237  // --- [ AAA ] -----------------------------------------------------------------
  1238  
  1239  // liftInstAAA lifts the given x86 AAA instruction to LLVM IR, emitting code to
  1240  // f.
  1241  func (f *Func) liftInstAAA(inst *x86.Inst) error {
  1242  	pretty.Println("inst:", inst)
  1243  	panic("emitInstAAA: not yet implemented")
  1244  }
  1245  
  1246  // --- [ AAD ] -----------------------------------------------------------------
  1247  
  1248  // liftInstAAD lifts the given x86 AAD instruction to LLVM IR, emitting code to
  1249  // f.
  1250  func (f *Func) liftInstAAD(inst *x86.Inst) error {
  1251  	pretty.Println("inst:", inst)
  1252  	panic("emitInstAAD: not yet implemented")
  1253  }
  1254  
  1255  // --- [ AAM ] -----------------------------------------------------------------
  1256  
  1257  // liftInstAAM lifts the given x86 AAM instruction to LLVM IR, emitting code to
  1258  // f.
  1259  func (f *Func) liftInstAAM(inst *x86.Inst) error {
  1260  	pretty.Println("inst:", inst)
  1261  	panic("emitInstAAM: not yet implemented")
  1262  }
  1263  
  1264  // --- [ AAS ] -----------------------------------------------------------------
  1265  
  1266  // liftInstAAS lifts the given x86 AAS instruction to LLVM IR, emitting code to
  1267  // f.
  1268  func (f *Func) liftInstAAS(inst *x86.Inst) error {
  1269  	pretty.Println("inst:", inst)
  1270  	panic("emitInstAAS: not yet implemented")
  1271  }
  1272  
  1273  // --- [ ADC ] -----------------------------------------------------------------
  1274  
  1275  // liftInstADC lifts the given x86 ADC instruction to LLVM IR, emitting code to
  1276  // f.
  1277  func (f *Func) liftInstADC(inst *x86.Inst) error {
  1278  	// ADC - Add with Carry.
  1279  	//
  1280  	//    ADC AL, imm8        Add with carry imm8 to AL.
  1281  	//    ADC AX, imm16       Add with carry imm16 to AX.
  1282  	//    ADC EAX, imm32      Add with carry imm32 to EAX.
  1283  	//    ADC r/m8, imm8      Add with carry imm8 to r/m8.
  1284  	//    ADC r/m8, r8        Add with carry byte register to r/m8.
  1285  	//    ADC r/m8, r8        Add with carry byte register to r/m64.
  1286  	//    ADC r/m16, imm16    Add with carry imm16 to r/m16.
  1287  	//    ADC r/m16, imm8     Add with CF sign-extended imm8 to r/m16.
  1288  	//    ADC r/m16, r16      Add with carry r16 to r/m16.
  1289  	//    ADC r/m32, imm32    Add with CF imm32 to r/m32.
  1290  	//    ADC r/m32, imm8     Add with CF sign-extended imm8 into r/m32.
  1291  	//    ADC r/m32, r32      Add with CF r32 to r/m32.
  1292  	//    ADC r/m64, imm32    Add with CF imm32 sign extended to 64-bits to r/m64.
  1293  	//    ADC r/m64, imm8     Add with CF sign-extended imm8 into r/m64.
  1294  	//    ADC r/m64, r64      Add with CF r64 to r/m64.
  1295  	//    ADC r16, r/m16      Add with carry r/m16 to r16.
  1296  	//    ADC r32, r/m32      Add with CF r/m32 to r32.
  1297  	//    ADC r64, r/m64      Add with CF r/m64 to r64.
  1298  	//    ADC r8, r/m8        Add with carry r/m8 to byte register.
  1299  	//    ADC r8, r/m8        Add with carry r/m64 to byte register.
  1300  	//    ADC RAX, imm32      Add with carry imm32 sign extended to 64-bits to RAX.
  1301  	//
  1302  	// Adds the destination operand (first operand), the source operand (second
  1303  	// operand), and the carry (CF) flag and stores the result in the destination
  1304  	// operand.
  1305  	dst := f.useArg(inst.Arg(0))
  1306  	src := f.useArg(inst.Arg(1))
  1307  	cf := f.useStatus(CF)
  1308  	v := f.cur.NewAdd(src, cf)
  1309  	result := f.cur.NewAdd(dst, v)
  1310  	f.defArg(inst.Arg(0), result)
  1311  	return nil
  1312  }
  1313  
  1314  // --- [ ADD ] -----------------------------------------------------------------
  1315  
  1316  // liftInstADD lifts the given x86 ADD instruction to LLVM IR, emitting code to
  1317  // f.
  1318  func (f *Func) liftInstADD(inst *x86.Inst) error {
  1319  	x, y := f.useArg(inst.Arg(0)), f.useArg(inst.Arg(1))
  1320  	result := f.cur.NewAdd(x, y)
  1321  	f.defArg(inst.Arg(0), result)
  1322  	return nil
  1323  }
  1324  
  1325  // --- [ ADDPD ] ---------------------------------------------------------------
  1326  
  1327  // liftInstADDPD lifts the given x86 ADDPD instruction to LLVM IR, emitting code
  1328  // to f.
  1329  func (f *Func) liftInstADDPD(inst *x86.Inst) error {
  1330  	pretty.Println("inst:", inst)
  1331  	panic("emitInstADDPD: not yet implemented")
  1332  }
  1333  
  1334  // --- [ ADDPS ] ---------------------------------------------------------------
  1335  
  1336  // liftInstADDPS lifts the given x86 ADDPS instruction to LLVM IR, emitting code
  1337  // to f.
  1338  func (f *Func) liftInstADDPS(inst *x86.Inst) error {
  1339  	pretty.Println("inst:", inst)
  1340  	panic("emitInstADDPS: not yet implemented")
  1341  }
  1342  
  1343  // --- [ ADDSD ] ---------------------------------------------------------------
  1344  
  1345  // liftInstADDSD lifts the given x86 ADDSD instruction to LLVM IR, emitting code
  1346  // to f.
  1347  func (f *Func) liftInstADDSD(inst *x86.Inst) error {
  1348  	pretty.Println("inst:", inst)
  1349  	panic("emitInstADDSD: not yet implemented")
  1350  }
  1351  
  1352  // --- [ ADDSS ] ---------------------------------------------------------------
  1353  
  1354  // liftInstADDSS lifts the given x86 ADDSS instruction to LLVM IR, emitting code
  1355  // to f.
  1356  func (f *Func) liftInstADDSS(inst *x86.Inst) error {
  1357  	pretty.Println("inst:", inst)
  1358  	panic("emitInstADDSS: not yet implemented")
  1359  }
  1360  
  1361  // --- [ ADDSUBPD ] ------------------------------------------------------------
  1362  
  1363  // liftInstADDSUBPD lifts the given x86 ADDSUBPD instruction to LLVM IR,
  1364  // emitting code to f.
  1365  func (f *Func) liftInstADDSUBPD(inst *x86.Inst) error {
  1366  	pretty.Println("inst:", inst)
  1367  	panic("emitInstADDSUBPD: not yet implemented")
  1368  }
  1369  
  1370  // --- [ ADDSUBPS ] ------------------------------------------------------------
  1371  
  1372  // liftInstADDSUBPS lifts the given x86 ADDSUBPS instruction to LLVM IR,
  1373  // emitting code to f.
  1374  func (f *Func) liftInstADDSUBPS(inst *x86.Inst) error {
  1375  	pretty.Println("inst:", inst)
  1376  	panic("emitInstADDSUBPS: not yet implemented")
  1377  }
  1378  
  1379  // --- [ AESDEC ] --------------------------------------------------------------
  1380  
  1381  // liftInstAESDEC lifts the given x86 AESDEC instruction to LLVM IR, emitting
  1382  // code to f.
  1383  func (f *Func) liftInstAESDEC(inst *x86.Inst) error {
  1384  	pretty.Println("inst:", inst)
  1385  	panic("emitInstAESDEC: not yet implemented")
  1386  }
  1387  
  1388  // --- [ AESDECLAST ] ----------------------------------------------------------
  1389  
  1390  // liftInstAESDECLAST lifts the given x86 AESDECLAST instruction to LLVM IR,
  1391  // emitting code to f.
  1392  func (f *Func) liftInstAESDECLAST(inst *x86.Inst) error {
  1393  	pretty.Println("inst:", inst)
  1394  	panic("emitInstAESDECLAST: not yet implemented")
  1395  }
  1396  
  1397  // --- [ AESENC ] --------------------------------------------------------------
  1398  
  1399  // liftInstAESENC lifts the given x86 AESENC instruction to LLVM IR, emitting
  1400  // code to f.
  1401  func (f *Func) liftInstAESENC(inst *x86.Inst) error {
  1402  	pretty.Println("inst:", inst)
  1403  	panic("emitInstAESENC: not yet implemented")
  1404  }
  1405  
  1406  // --- [ AESENCLAST ] ----------------------------------------------------------
  1407  
  1408  // liftInstAESENCLAST lifts the given x86 AESENCLAST instruction to LLVM IR,
  1409  // emitting code to f.
  1410  func (f *Func) liftInstAESENCLAST(inst *x86.Inst) error {
  1411  	pretty.Println("inst:", inst)
  1412  	panic("emitInstAESENCLAST: not yet implemented")
  1413  }
  1414  
  1415  // --- [ AESIMC ] --------------------------------------------------------------
  1416  
  1417  // liftInstAESIMC lifts the given x86 AESIMC instruction to LLVM IR, emitting
  1418  // code to f.
  1419  func (f *Func) liftInstAESIMC(inst *x86.Inst) error {
  1420  	pretty.Println("inst:", inst)
  1421  	panic("emitInstAESIMC: not yet implemented")
  1422  }
  1423  
  1424  // --- [ AESKEYGENASSIST ] -----------------------------------------------------
  1425  
  1426  // liftInstAESKEYGENASSIST lifts the given x86 AESKEYGENASSIST instruction to
  1427  // LLVM IR, emitting code to f.
  1428  func (f *Func) liftInstAESKEYGENASSIST(inst *x86.Inst) error {
  1429  	pretty.Println("inst:", inst)
  1430  	panic("emitInstAESKEYGENASSIST: not yet implemented")
  1431  }
  1432  
  1433  // --- [ AND ] -----------------------------------------------------------------
  1434  
  1435  // liftInstAND lifts the given x86 AND instruction to LLVM IR, emitting code to
  1436  // f.
  1437  func (f *Func) liftInstAND(inst *x86.Inst) error {
  1438  	x, y := f.useArg(inst.Arg(0)), f.useArg(inst.Arg(1))
  1439  	result := f.cur.NewAnd(x, y)
  1440  	f.defArg(inst.Arg(0), result)
  1441  	return nil
  1442  }
  1443  
  1444  // --- [ ANDNPD ] --------------------------------------------------------------
  1445  
  1446  // liftInstANDNPD lifts the given x86 ANDNPD instruction to LLVM IR, emitting
  1447  // code to f.
  1448  func (f *Func) liftInstANDNPD(inst *x86.Inst) error {
  1449  	pretty.Println("inst:", inst)
  1450  	panic("emitInstANDNPD: not yet implemented")
  1451  }
  1452  
  1453  // --- [ ANDNPS ] --------------------------------------------------------------
  1454  
  1455  // liftInstANDNPS lifts the given x86 ANDNPS instruction to LLVM IR, emitting
  1456  // code to f.
  1457  func (f *Func) liftInstANDNPS(inst *x86.Inst) error {
  1458  	pretty.Println("inst:", inst)
  1459  	panic("emitInstANDNPS: not yet implemented")
  1460  }
  1461  
  1462  // --- [ ANDPD ] ---------------------------------------------------------------
  1463  
  1464  // liftInstANDPD lifts the given x86 ANDPD instruction to LLVM IR, emitting code
  1465  // to f.
  1466  func (f *Func) liftInstANDPD(inst *x86.Inst) error {
  1467  	pretty.Println("inst:", inst)
  1468  	panic("emitInstANDPD: not yet implemented")
  1469  }
  1470  
  1471  // --- [ ANDPS ] ---------------------------------------------------------------
  1472  
  1473  // liftInstANDPS lifts the given x86 ANDPS instruction to LLVM IR, emitting code
  1474  // to f.
  1475  func (f *Func) liftInstANDPS(inst *x86.Inst) error {
  1476  	pretty.Println("inst:", inst)
  1477  	panic("emitInstANDPS: not yet implemented")
  1478  }
  1479  
  1480  // --- [ ARPL ] ----------------------------------------------------------------
  1481  
  1482  // liftInstARPL lifts the given x86 ARPL instruction to LLVM IR, emitting code
  1483  // to f.
  1484  func (f *Func) liftInstARPL(inst *x86.Inst) error {
  1485  	pretty.Println("inst:", inst)
  1486  	panic("emitInstARPL: not yet implemented")
  1487  }
  1488  
  1489  // --- [ BLENDPD ] -------------------------------------------------------------
  1490  
  1491  // liftInstBLENDPD lifts the given x86 BLENDPD instruction to LLVM IR, emitting
  1492  // code to f.
  1493  func (f *Func) liftInstBLENDPD(inst *x86.Inst) error {
  1494  	pretty.Println("inst:", inst)
  1495  	panic("emitInstBLENDPD: not yet implemented")
  1496  }
  1497  
  1498  // --- [ BLENDPS ] -------------------------------------------------------------
  1499  
  1500  // liftInstBLENDPS lifts the given x86 BLENDPS instruction to LLVM IR, emitting
  1501  // code to f.
  1502  func (f *Func) liftInstBLENDPS(inst *x86.Inst) error {
  1503  	pretty.Println("inst:", inst)
  1504  	panic("emitInstBLENDPS: not yet implemented")
  1505  }
  1506  
  1507  // --- [ BLENDVPD ] ------------------------------------------------------------
  1508  
  1509  // liftInstBLENDVPD lifts the given x86 BLENDVPD instruction to LLVM IR,
  1510  // emitting code to f.
  1511  func (f *Func) liftInstBLENDVPD(inst *x86.Inst) error {
  1512  	pretty.Println("inst:", inst)
  1513  	panic("emitInstBLENDVPD: not yet implemented")
  1514  }
  1515  
  1516  // --- [ BLENDVPS ] ------------------------------------------------------------
  1517  
  1518  // liftInstBLENDVPS lifts the given x86 BLENDVPS instruction to LLVM IR,
  1519  // emitting code to f.
  1520  func (f *Func) liftInstBLENDVPS(inst *x86.Inst) error {
  1521  	pretty.Println("inst:", inst)
  1522  	panic("emitInstBLENDVPS: not yet implemented")
  1523  }
  1524  
  1525  // --- [ BOUND ] ---------------------------------------------------------------
  1526  
  1527  // liftInstBOUND lifts the given x86 BOUND instruction to LLVM IR, emitting code
  1528  // to f.
  1529  func (f *Func) liftInstBOUND(inst *x86.Inst) error {
  1530  	pretty.Println("inst:", inst)
  1531  	panic("emitInstBOUND: not yet implemented")
  1532  }
  1533  
  1534  // --- [ BSF ] -----------------------------------------------------------------
  1535  
  1536  // liftInstBSF lifts the given x86 BSF instruction to LLVM IR, emitting code to
  1537  // f.
  1538  func (f *Func) liftInstBSF(inst *x86.Inst) error {
  1539  	pretty.Println("inst:", inst)
  1540  	panic("emitInstBSF: not yet implemented")
  1541  }
  1542  
  1543  // --- [ BSR ] -----------------------------------------------------------------
  1544  
  1545  // liftInstBSR lifts the given x86 BSR instruction to LLVM IR, emitting code to
  1546  // f.
  1547  func (f *Func) liftInstBSR(inst *x86.Inst) error {
  1548  	pretty.Println("inst:", inst)
  1549  	panic("emitInstBSR: not yet implemented")
  1550  }
  1551  
  1552  // --- [ BSWAP ] ---------------------------------------------------------------
  1553  
  1554  // liftInstBSWAP lifts the given x86 BSWAP instruction to LLVM IR, emitting code
  1555  // to f.
  1556  func (f *Func) liftInstBSWAP(inst *x86.Inst) error {
  1557  	pretty.Println("inst:", inst)
  1558  	panic("emitInstBSWAP: not yet implemented")
  1559  }
  1560  
  1561  // --- [ BT ] ------------------------------------------------------------------
  1562  
  1563  // liftInstBT lifts the given x86 BT instruction to LLVM IR, emitting code to f.
  1564  func (f *Func) liftInstBT(inst *x86.Inst) error {
  1565  	pretty.Println("inst:", inst)
  1566  	panic("emitInstBT: not yet implemented")
  1567  }
  1568  
  1569  // --- [ BTC ] -----------------------------------------------------------------
  1570  
  1571  // liftInstBTC lifts the given x86 BTC instruction to LLVM IR, emitting code to
  1572  // f.
  1573  func (f *Func) liftInstBTC(inst *x86.Inst) error {
  1574  	pretty.Println("inst:", inst)
  1575  	panic("emitInstBTC: not yet implemented")
  1576  }
  1577  
  1578  // --- [ BTR ] -----------------------------------------------------------------
  1579  
  1580  // liftInstBTR lifts the given x86 BTR instruction to LLVM IR, emitting code to
  1581  // f.
  1582  func (f *Func) liftInstBTR(inst *x86.Inst) error {
  1583  	pretty.Println("inst:", inst)
  1584  	panic("emitInstBTR: not yet implemented")
  1585  }
  1586  
  1587  // --- [ BTS ] -----------------------------------------------------------------
  1588  
  1589  // liftInstBTS lifts the given x86 BTS instruction to LLVM IR, emitting code to
  1590  // f.
  1591  func (f *Func) liftInstBTS(inst *x86.Inst) error {
  1592  	pretty.Println("inst:", inst)
  1593  	panic("emitInstBTS: not yet implemented")
  1594  }
  1595  
  1596  // --- [ CALL ] ----------------------------------------------------------------
  1597  
  1598  // liftInstCALL lifts the given x86 CALL instruction to LLVM IR, emitting code
  1599  // to f.
  1600  func (f *Func) liftInstCALL(inst *x86.Inst) error {
  1601  	// Locate callee information.
  1602  	callee, sig, callconv, ok := f.getFunc(inst.Arg(0))
  1603  	if !ok {
  1604  		panic(fmt.Errorf("unable to locate function for argument %v of instruction at address %v", inst.Arg(0), inst.Addr))
  1605  	}
  1606  
  1607  	// Handle function arguments.
  1608  	var args []value.Value
  1609  	purge := int64(0)
  1610  	for i := range sig.Params {
  1611  		// Pass argument in register.
  1612  		switch callconv {
  1613  		case enum.CallingConvX86FastCall:
  1614  			switch i {
  1615  			case 0:
  1616  				arg := f.useReg(x86.ECX)
  1617  				args = append(args, arg)
  1618  				continue
  1619  			case 1:
  1620  				arg := f.useReg(x86.EDX)
  1621  				args = append(args, arg)
  1622  				continue
  1623  			}
  1624  		default:
  1625  			// TODO: Add support for more calling conventions.
  1626  		}
  1627  		// Pass argument on stack.
  1628  		arg := f.pop()
  1629  		args = append(args, arg)
  1630  		switch callconv {
  1631  		case enum.CallingConvX86FastCall, enum.CallingConvX86StdCall:
  1632  			// callee purge.
  1633  			purge += 4
  1634  		case enum.CallingConvC:
  1635  			// caller purge; nothing to do.
  1636  		default:
  1637  			// TODO: Add support for more calling conventions.
  1638  		}
  1639  	}
  1640  
  1641  	// Emit call instruction.
  1642  	result := f.cur.NewCall(callee, args...)
  1643  
  1644  	// Handle purged arguments by callee.
  1645  	f.espDisp += purge
  1646  
  1647  	// Handle return value.
  1648  	if !types.Equal(sig.RetType, types.Void) {
  1649  		f.defReg(x86.EAX, result)
  1650  	}
  1651  	return nil
  1652  }
  1653  
  1654  // --- [ CBW ] -----------------------------------------------------------------
  1655  
  1656  // liftInstCBW lifts the given x86 CBW instruction to LLVM IR, emitting code to
  1657  // f.
  1658  func (f *Func) liftInstCBW(inst *x86.Inst) error {
  1659  	pretty.Println("inst:", inst)
  1660  	panic("emitInstCBW: not yet implemented")
  1661  }
  1662  
  1663  // --- [ CDQ ] -----------------------------------------------------------------
  1664  
  1665  // liftInstCDQ lifts the given x86 CDQ instruction to LLVM IR, emitting code to
  1666  // f.
  1667  func (f *Func) liftInstCDQ(inst *x86.Inst) error {
  1668  	// EDX:EAX = sign-extend of EAX.
  1669  	eax := f.useReg(x86.EAX)
  1670  	tmp := f.cur.NewLShr(eax, constant.NewInt(types.I32, 31))
  1671  	cond := f.cur.NewTrunc(tmp, types.I1)
  1672  	targetTrue := &ir.Block{}
  1673  	targetFalse := &ir.Block{}
  1674  	exit := &ir.Block{}
  1675  	f.Blocks = append(f.Blocks, targetTrue)
  1676  	f.Blocks = append(f.Blocks, targetFalse)
  1677  	f.Blocks = append(f.Blocks, exit)
  1678  	f.cur.NewCondBr(cond, targetTrue, targetFalse)
  1679  	f.cur = targetTrue
  1680  	f.defReg(x86.EDX, constant.NewInt(types.I32, 0xFFFFFFFF))
  1681  	f.cur = targetFalse
  1682  	f.defReg(x86.EDX, constant.NewInt(types.I32, 0))
  1683  	targetTrue.NewBr(exit)
  1684  	targetFalse.NewBr(exit)
  1685  	f.cur = exit
  1686  	return nil
  1687  }
  1688  
  1689  // --- [ CDQE ] ----------------------------------------------------------------
  1690  
  1691  // liftInstCDQE lifts the given x86 CDQE instruction to LLVM IR, emitting code
  1692  // to f.
  1693  func (f *Func) liftInstCDQE(inst *x86.Inst) error {
  1694  	pretty.Println("inst:", inst)
  1695  	panic("emitInstCDQE: not yet implemented")
  1696  }
  1697  
  1698  // --- [ CLC ] -----------------------------------------------------------------
  1699  
  1700  // liftInstCLC lifts the given x86 CLC instruction to LLVM IR, emitting code to
  1701  // f.
  1702  func (f *Func) liftInstCLC(inst *x86.Inst) error {
  1703  	pretty.Println("inst:", inst)
  1704  	panic("emitInstCLC: not yet implemented")
  1705  }
  1706  
  1707  // --- [ CLD ] -----------------------------------------------------------------
  1708  
  1709  // liftInstCLD lifts the given x86 CLD instruction to LLVM IR, emitting code to
  1710  // f.
  1711  func (f *Func) liftInstCLD(inst *x86.Inst) error {
  1712  	pretty.Println("inst:", inst)
  1713  	panic("emitInstCLD: not yet implemented")
  1714  }
  1715  
  1716  // --- [ CLFLUSH ] -------------------------------------------------------------
  1717  
  1718  // liftInstCLFLUSH lifts the given x86 CLFLUSH instruction to LLVM IR, emitting
  1719  // code to f.
  1720  func (f *Func) liftInstCLFLUSH(inst *x86.Inst) error {
  1721  	pretty.Println("inst:", inst)
  1722  	panic("emitInstCLFLUSH: not yet implemented")
  1723  }
  1724  
  1725  // --- [ CLI ] -----------------------------------------------------------------
  1726  
  1727  // liftInstCLI lifts the given x86 CLI instruction to LLVM IR, emitting code to
  1728  // f.
  1729  func (f *Func) liftInstCLI(inst *x86.Inst) error {
  1730  	pretty.Println("inst:", inst)
  1731  	panic("emitInstCLI: not yet implemented")
  1732  }
  1733  
  1734  // --- [ CLTS ] ----------------------------------------------------------------
  1735  
  1736  // liftInstCLTS lifts the given x86 CLTS instruction to LLVM IR, emitting code
  1737  // to f.
  1738  func (f *Func) liftInstCLTS(inst *x86.Inst) error {
  1739  	pretty.Println("inst:", inst)
  1740  	panic("emitInstCLTS: not yet implemented")
  1741  }
  1742  
  1743  // --- [ CMC ] -----------------------------------------------------------------
  1744  
  1745  // liftInstCMC lifts the given x86 CMC instruction to LLVM IR, emitting code to
  1746  // f.
  1747  func (f *Func) liftInstCMC(inst *x86.Inst) error {
  1748  	pretty.Println("inst:", inst)
  1749  	panic("emitInstCMC: not yet implemented")
  1750  }
  1751  
  1752  // --- [ CMOVA ] ---------------------------------------------------------------
  1753  
  1754  // liftInstCMOVA lifts the given x86 CMOVA instruction to LLVM IR, emitting code
  1755  // to f.
  1756  func (f *Func) liftInstCMOVA(inst *x86.Inst) error {
  1757  	pretty.Println("inst:", inst)
  1758  	panic("emitInstCMOVA: not yet implemented")
  1759  }
  1760  
  1761  // --- [ CMOVAE ] --------------------------------------------------------------
  1762  
  1763  // liftInstCMOVAE lifts the given x86 CMOVAE instruction to LLVM IR, emitting
  1764  // code to f.
  1765  func (f *Func) liftInstCMOVAE(inst *x86.Inst) error {
  1766  	pretty.Println("inst:", inst)
  1767  	panic("emitInstCMOVAE: not yet implemented")
  1768  }
  1769  
  1770  // --- [ CMOVB ] ---------------------------------------------------------------
  1771  
  1772  // liftInstCMOVB lifts the given x86 CMOVB instruction to LLVM IR, emitting code
  1773  // to f.
  1774  func (f *Func) liftInstCMOVB(inst *x86.Inst) error {
  1775  	pretty.Println("inst:", inst)
  1776  	panic("emitInstCMOVB: not yet implemented")
  1777  }
  1778  
  1779  // --- [ CMOVBE ] --------------------------------------------------------------
  1780  
  1781  // liftInstCMOVBE lifts the given x86 CMOVBE instruction to LLVM IR, emitting
  1782  // code to f.
  1783  func (f *Func) liftInstCMOVBE(inst *x86.Inst) error {
  1784  	pretty.Println("inst:", inst)
  1785  	panic("emitInstCMOVBE: not yet implemented")
  1786  }
  1787  
  1788  // --- [ CMOVE ] ---------------------------------------------------------------
  1789  
  1790  // liftInstCMOVE lifts the given x86 CMOVE instruction to LLVM IR, emitting code
  1791  // to f.
  1792  func (f *Func) liftInstCMOVE(inst *x86.Inst) error {
  1793  	pretty.Println("inst:", inst)
  1794  	panic("emitInstCMOVE: not yet implemented")
  1795  }
  1796  
  1797  // --- [ CMOVG ] ---------------------------------------------------------------
  1798  
  1799  // liftInstCMOVG lifts the given x86 CMOVG instruction to LLVM IR, emitting code
  1800  // to f.
  1801  func (f *Func) liftInstCMOVG(inst *x86.Inst) error {
  1802  	pretty.Println("inst:", inst)
  1803  	panic("emitInstCMOVG: not yet implemented")
  1804  }
  1805  
  1806  // --- [ CMOVGE ] --------------------------------------------------------------
  1807  
  1808  // liftInstCMOVGE lifts the given x86 CMOVGE instruction to LLVM IR, emitting
  1809  // code to f.
  1810  func (f *Func) liftInstCMOVGE(inst *x86.Inst) error {
  1811  	pretty.Println("inst:", inst)
  1812  	panic("emitInstCMOVGE: not yet implemented")
  1813  }
  1814  
  1815  // --- [ CMOVL ] ---------------------------------------------------------------
  1816  
  1817  // liftInstCMOVL lifts the given x86 CMOVL instruction to LLVM IR, emitting code
  1818  // to f.
  1819  func (f *Func) liftInstCMOVL(inst *x86.Inst) error {
  1820  	pretty.Println("inst:", inst)
  1821  	panic("emitInstCMOVL: not yet implemented")
  1822  }
  1823  
  1824  // --- [ CMOVLE ] --------------------------------------------------------------
  1825  
  1826  // liftInstCMOVLE lifts the given x86 CMOVLE instruction to LLVM IR, emitting
  1827  // code to f.
  1828  func (f *Func) liftInstCMOVLE(inst *x86.Inst) error {
  1829  	pretty.Println("inst:", inst)
  1830  	panic("emitInstCMOVLE: not yet implemented")
  1831  }
  1832  
  1833  // --- [ CMOVNE ] --------------------------------------------------------------
  1834  
  1835  // liftInstCMOVNE lifts the given x86 CMOVNE instruction to LLVM IR, emitting
  1836  // code to f.
  1837  func (f *Func) liftInstCMOVNE(inst *x86.Inst) error {
  1838  	pretty.Println("inst:", inst)
  1839  	panic("emitInstCMOVNE: not yet implemented")
  1840  }
  1841  
  1842  // --- [ CMOVNO ] --------------------------------------------------------------
  1843  
  1844  // liftInstCMOVNO lifts the given x86 CMOVNO instruction to LLVM IR, emitting
  1845  // code to f.
  1846  func (f *Func) liftInstCMOVNO(inst *x86.Inst) error {
  1847  	pretty.Println("inst:", inst)
  1848  	panic("emitInstCMOVNO: not yet implemented")
  1849  }
  1850  
  1851  // --- [ CMOVNP ] --------------------------------------------------------------
  1852  
  1853  // liftInstCMOVNP lifts the given x86 CMOVNP instruction to LLVM IR, emitting
  1854  // code to f.
  1855  func (f *Func) liftInstCMOVNP(inst *x86.Inst) error {
  1856  	pretty.Println("inst:", inst)
  1857  	panic("emitInstCMOVNP: not yet implemented")
  1858  }
  1859  
  1860  // --- [ CMOVNS ] --------------------------------------------------------------
  1861  
  1862  // liftInstCMOVNS lifts the given x86 CMOVNS instruction to LLVM IR, emitting
  1863  // code to f.
  1864  func (f *Func) liftInstCMOVNS(inst *x86.Inst) error {
  1865  	pretty.Println("inst:", inst)
  1866  	panic("emitInstCMOVNS: not yet implemented")
  1867  }
  1868  
  1869  // --- [ CMOVO ] ---------------------------------------------------------------
  1870  
  1871  // liftInstCMOVO lifts the given x86 CMOVO instruction to LLVM IR, emitting code
  1872  // to f.
  1873  func (f *Func) liftInstCMOVO(inst *x86.Inst) error {
  1874  	pretty.Println("inst:", inst)
  1875  	panic("emitInstCMOVO: not yet implemented")
  1876  }
  1877  
  1878  // --- [ CMOVP ] ---------------------------------------------------------------
  1879  
  1880  // liftInstCMOVP lifts the given x86 CMOVP instruction to LLVM IR, emitting code
  1881  // to f.
  1882  func (f *Func) liftInstCMOVP(inst *x86.Inst) error {
  1883  	pretty.Println("inst:", inst)
  1884  	panic("emitInstCMOVP: not yet implemented")
  1885  }
  1886  
  1887  // --- [ CMOVS ] ---------------------------------------------------------------
  1888  
  1889  // liftInstCMOVS lifts the given x86 CMOVS instruction to LLVM IR, emitting code
  1890  // to f.
  1891  func (f *Func) liftInstCMOVS(inst *x86.Inst) error {
  1892  	pretty.Println("inst:", inst)
  1893  	panic("emitInstCMOVS: not yet implemented")
  1894  }
  1895  
  1896  // --- [ CMP ] -----------------------------------------------------------------
  1897  
  1898  // liftInstCMP lifts the given x86 CMP instruction to LLVM IR, emitting code to
  1899  // f.
  1900  func (f *Func) liftInstCMP(inst *x86.Inst) error {
  1901  	// result = x SUB y; set CF, PF, AF, ZF, SF, and OF according to result.
  1902  	x, y := f.useArg(inst.Arg(0)), f.useArg(inst.Arg(1))
  1903  	result := f.cur.NewSub(x, y)
  1904  
  1905  	// CF (bit 0) Carry flag - Set if an arithmetic operation generates a carry
  1906  	// or a borrow out of the most- significant bit of the result; cleared
  1907  	// otherwise. This flag indicates an overflow condition for unsigned-integer
  1908  	// arithmetic. It is also used in multiple-precision arithmetic.
  1909  
  1910  	// TODO: Add support for the CF status flag.
  1911  
  1912  	// PF (bit 2) Parity flag - Set if the least-significant byte of the result
  1913  	// contains an even number of 1 bits; cleared otherwise.
  1914  
  1915  	// TODO: Add support for the PF status flag.
  1916  
  1917  	// AF (bit 4) Auxiliary Carry flag - Set if an arithmetic operation generates
  1918  	// a carry or a borrow out of bit 3 of the result; cleared otherwise. This
  1919  	// flag is used in binary-coded decimal (BCD) arithmetic.
  1920  
  1921  	// TODO: Add support for the AF status flag.
  1922  
  1923  	// ZF (bit 6) Zero flag - Set if the result is zero; cleared otherwise.
  1924  	zero := constant.NewInt(types.I32, 0)
  1925  	zf := f.cur.NewICmp(enum.IPredEQ, result, zero)
  1926  	f.defStatus(ZF, zf)
  1927  
  1928  	// SF (bit 7) Sign flag - Set equal to the most-significant bit of the
  1929  	// result, which is the sign bit of a signed integer. (0 indicates a positive
  1930  	// value and 1 indicates a negative value.)
  1931  
  1932  	// TODO: Add support for SF flag.
  1933  
  1934  	// OF (bit 11) Overflow flag - Set if the integer result is too large a
  1935  	// positive number or too small a negative number (excluding the sign-bit) to
  1936  	// fit in the destination operand; cleared otherwise. This flag indicates an
  1937  	// overflow condition for signed-integer (two's complement) arithmetic.
  1938  
  1939  	// TODO: Add support for the OF status flag.
  1940  
  1941  	return nil
  1942  }
  1943  
  1944  // --- [ CMPPD ] ---------------------------------------------------------------
  1945  
  1946  // liftInstCMPPD lifts the given x86 CMPPD instruction to LLVM IR, emitting code
  1947  // to f.
  1948  func (f *Func) liftInstCMPPD(inst *x86.Inst) error {
  1949  	pretty.Println("inst:", inst)
  1950  	panic("emitInstCMPPD: not yet implemented")
  1951  }
  1952  
  1953  // --- [ CMPPS ] ---------------------------------------------------------------
  1954  
  1955  // liftInstCMPPS lifts the given x86 CMPPS instruction to LLVM IR, emitting code
  1956  // to f.
  1957  func (f *Func) liftInstCMPPS(inst *x86.Inst) error {
  1958  	pretty.Println("inst:", inst)
  1959  	panic("emitInstCMPPS: not yet implemented")
  1960  }
  1961  
  1962  // --- [ CMPSB ] ---------------------------------------------------------------
  1963  
  1964  // liftInstCMPSB lifts the given x86 CMPSB instruction to LLVM IR, emitting code
  1965  // to f.
  1966  func (f *Func) liftInstCMPSB(inst *x86.Inst) error {
  1967  	pretty.Println("inst:", inst)
  1968  	panic("emitInstCMPSB: not yet implemented")
  1969  }
  1970  
  1971  // --- [ CMPSD ] ---------------------------------------------------------------
  1972  
  1973  // liftInstCMPSD lifts the given x86 CMPSD instruction to LLVM IR, emitting code
  1974  // to f.
  1975  func (f *Func) liftInstCMPSD(inst *x86.Inst) error {
  1976  	pretty.Println("inst:", inst)
  1977  	panic("emitInstCMPSD: not yet implemented")
  1978  }
  1979  
  1980  // --- [ CMPSD_XMM ] -----------------------------------------------------------
  1981  
  1982  // liftInstCMPSD_XMM lifts the given x86 CMPSD_XMM instruction to LLVM IR,
  1983  // emitting code to f.
  1984  func (f *Func) liftInstCMPSD_XMM(inst *x86.Inst) error {
  1985  	pretty.Println("inst:", inst)
  1986  	panic("emitInstCMPSD_XMM: not yet implemented")
  1987  }
  1988  
  1989  // --- [ CMPSQ ] ---------------------------------------------------------------
  1990  
  1991  // liftInstCMPSQ lifts the given x86 CMPSQ instruction to LLVM IR, emitting code
  1992  // to f.
  1993  func (f *Func) liftInstCMPSQ(inst *x86.Inst) error {
  1994  	pretty.Println("inst:", inst)
  1995  	panic("emitInstCMPSQ: not yet implemented")
  1996  }
  1997  
  1998  // --- [ CMPSS ] ---------------------------------------------------------------
  1999  
  2000  // liftInstCMPSS lifts the given x86 CMPSS instruction to LLVM IR, emitting code
  2001  // to f.
  2002  func (f *Func) liftInstCMPSS(inst *x86.Inst) error {
  2003  	pretty.Println("inst:", inst)
  2004  	panic("emitInstCMPSS: not yet implemented")
  2005  }
  2006  
  2007  // --- [ CMPSW ] ---------------------------------------------------------------
  2008  
  2009  // liftInstCMPSW lifts the given x86 CMPSW instruction to LLVM IR, emitting code
  2010  // to f.
  2011  func (f *Func) liftInstCMPSW(inst *x86.Inst) error {
  2012  	pretty.Println("inst:", inst)
  2013  	panic("emitInstCMPSW: not yet implemented")
  2014  }
  2015  
  2016  // --- [ CMPXCHG ] -------------------------------------------------------------
  2017  
  2018  // liftInstCMPXCHG lifts the given x86 CMPXCHG instruction to LLVM IR, emitting
  2019  // code to f.
  2020  func (f *Func) liftInstCMPXCHG(inst *x86.Inst) error {
  2021  	pretty.Println("inst:", inst)
  2022  	panic("emitInstCMPXCHG: not yet implemented")
  2023  }
  2024  
  2025  // --- [ CMPXCHG16B ] ----------------------------------------------------------
  2026  
  2027  // liftInstCMPXCHG16B lifts the given x86 CMPXCHG16B instruction to LLVM IR,
  2028  // emitting code to f.
  2029  func (f *Func) liftInstCMPXCHG16B(inst *x86.Inst) error {
  2030  	pretty.Println("inst:", inst)
  2031  	panic("emitInstCMPXCHG16B: not yet implemented")
  2032  }
  2033  
  2034  // --- [ CMPXCHG8B ] -----------------------------------------------------------
  2035  
  2036  // liftInstCMPXCHG8B lifts the given x86 CMPXCHG8B instruction to LLVM IR,
  2037  // emitting code to f.
  2038  func (f *Func) liftInstCMPXCHG8B(inst *x86.Inst) error {
  2039  	pretty.Println("inst:", inst)
  2040  	panic("emitInstCMPXCHG8B: not yet implemented")
  2041  }
  2042  
  2043  // --- [ COMISD ] --------------------------------------------------------------
  2044  
  2045  // liftInstCOMISD lifts the given x86 COMISD instruction to LLVM IR, emitting
  2046  // code to f.
  2047  func (f *Func) liftInstCOMISD(inst *x86.Inst) error {
  2048  	pretty.Println("inst:", inst)
  2049  	panic("emitInstCOMISD: not yet implemented")
  2050  }
  2051  
  2052  // --- [ COMISS ] --------------------------------------------------------------
  2053  
  2054  // liftInstCOMISS lifts the given x86 COMISS instruction to LLVM IR, emitting
  2055  // code to f.
  2056  func (f *Func) liftInstCOMISS(inst *x86.Inst) error {
  2057  	pretty.Println("inst:", inst)
  2058  	panic("emitInstCOMISS: not yet implemented")
  2059  }
  2060  
  2061  // --- [ CPUID ] ---------------------------------------------------------------
  2062  
  2063  // liftInstCPUID lifts the given x86 CPUID instruction to LLVM IR, emitting code
  2064  // to f.
  2065  func (f *Func) liftInstCPUID(inst *x86.Inst) error {
  2066  	pretty.Println("inst:", inst)
  2067  	panic("emitInstCPUID: not yet implemented")
  2068  }
  2069  
  2070  // --- [ CQO ] -----------------------------------------------------------------
  2071  
  2072  // liftInstCQO lifts the given x86 CQO instruction to LLVM IR, emitting code to
  2073  // f.
  2074  func (f *Func) liftInstCQO(inst *x86.Inst) error {
  2075  	pretty.Println("inst:", inst)
  2076  	panic("emitInstCQO: not yet implemented")
  2077  }
  2078  
  2079  // --- [ CRC32 ] ---------------------------------------------------------------
  2080  
  2081  // liftInstCRC32 lifts the given x86 CRC32 instruction to LLVM IR, emitting code
  2082  // to f.
  2083  func (f *Func) liftInstCRC32(inst *x86.Inst) error {
  2084  	pretty.Println("inst:", inst)
  2085  	panic("emitInstCRC32: not yet implemented")
  2086  }
  2087  
  2088  // --- [ CVTDQ2PD ] ------------------------------------------------------------
  2089  
  2090  // liftInstCVTDQ2PD lifts the given x86 CVTDQ2PD instruction to LLVM IR,
  2091  // emitting code to f.
  2092  func (f *Func) liftInstCVTDQ2PD(inst *x86.Inst) error {
  2093  	pretty.Println("inst:", inst)
  2094  	panic("emitInstCVTDQ2PD: not yet implemented")
  2095  }
  2096  
  2097  // --- [ CVTDQ2PS ] ------------------------------------------------------------
  2098  
  2099  // liftInstCVTDQ2PS lifts the given x86 CVTDQ2PS instruction to LLVM IR,
  2100  // emitting code to f.
  2101  func (f *Func) liftInstCVTDQ2PS(inst *x86.Inst) error {
  2102  	pretty.Println("inst:", inst)
  2103  	panic("emitInstCVTDQ2PS: not yet implemented")
  2104  }
  2105  
  2106  // --- [ CVTPD2DQ ] ------------------------------------------------------------
  2107  
  2108  // liftInstCVTPD2DQ lifts the given x86 CVTPD2DQ instruction to LLVM IR,
  2109  // emitting code to f.
  2110  func (f *Func) liftInstCVTPD2DQ(inst *x86.Inst) error {
  2111  	pretty.Println("inst:", inst)
  2112  	panic("emitInstCVTPD2DQ: not yet implemented")
  2113  }
  2114  
  2115  // --- [ CVTPD2PI ] ------------------------------------------------------------
  2116  
  2117  // liftInstCVTPD2PI lifts the given x86 CVTPD2PI instruction to LLVM IR,
  2118  // emitting code to f.
  2119  func (f *Func) liftInstCVTPD2PI(inst *x86.Inst) error {
  2120  	pretty.Println("inst:", inst)
  2121  	panic("emitInstCVTPD2PI: not yet implemented")
  2122  }
  2123  
  2124  // --- [ CVTPD2PS ] ------------------------------------------------------------
  2125  
  2126  // liftInstCVTPD2PS lifts the given x86 CVTPD2PS instruction to LLVM IR,
  2127  // emitting code to f.
  2128  func (f *Func) liftInstCVTPD2PS(inst *x86.Inst) error {
  2129  	pretty.Println("inst:", inst)
  2130  	panic("emitInstCVTPD2PS: not yet implemented")
  2131  }
  2132  
  2133  // --- [ CVTPI2PD ] ------------------------------------------------------------
  2134  
  2135  // liftInstCVTPI2PD lifts the given x86 CVTPI2PD instruction to LLVM IR,
  2136  // emitting code to f.
  2137  func (f *Func) liftInstCVTPI2PD(inst *x86.Inst) error {
  2138  	pretty.Println("inst:", inst)
  2139  	panic("emitInstCVTPI2PD: not yet implemented")
  2140  }
  2141  
  2142  // --- [ CVTPI2PS ] ------------------------------------------------------------
  2143  
  2144  // liftInstCVTPI2PS lifts the given x86 CVTPI2PS instruction to LLVM IR,
  2145  // emitting code to f.
  2146  func (f *Func) liftInstCVTPI2PS(inst *x86.Inst) error {
  2147  	pretty.Println("inst:", inst)
  2148  	panic("emitInstCVTPI2PS: not yet implemented")
  2149  }
  2150  
  2151  // --- [ CVTPS2DQ ] ------------------------------------------------------------
  2152  
  2153  // liftInstCVTPS2DQ lifts the given x86 CVTPS2DQ instruction to LLVM IR,
  2154  // emitting code to f.
  2155  func (f *Func) liftInstCVTPS2DQ(inst *x86.Inst) error {
  2156  	pretty.Println("inst:", inst)
  2157  	panic("emitInstCVTPS2DQ: not yet implemented")
  2158  }
  2159  
  2160  // --- [ CVTPS2PD ] ------------------------------------------------------------
  2161  
  2162  // liftInstCVTPS2PD lifts the given x86 CVTPS2PD instruction to LLVM IR,
  2163  // emitting code to f.
  2164  func (f *Func) liftInstCVTPS2PD(inst *x86.Inst) error {
  2165  	pretty.Println("inst:", inst)
  2166  	panic("emitInstCVTPS2PD: not yet implemented")
  2167  }
  2168  
  2169  // --- [ CVTPS2PI ] ------------------------------------------------------------
  2170  
  2171  // liftInstCVTPS2PI lifts the given x86 CVTPS2PI instruction to LLVM IR,
  2172  // emitting code to f.
  2173  func (f *Func) liftInstCVTPS2PI(inst *x86.Inst) error {
  2174  	pretty.Println("inst:", inst)
  2175  	panic("emitInstCVTPS2PI: not yet implemented")
  2176  }
  2177  
  2178  // --- [ CVTSD2SI ] ------------------------------------------------------------
  2179  
  2180  // liftInstCVTSD2SI lifts the given x86 CVTSD2SI instruction to LLVM IR,
  2181  // emitting code to f.
  2182  func (f *Func) liftInstCVTSD2SI(inst *x86.Inst) error {
  2183  	pretty.Println("inst:", inst)
  2184  	panic("emitInstCVTSD2SI: not yet implemented")
  2185  }
  2186  
  2187  // --- [ CVTSD2SS ] ------------------------------------------------------------
  2188  
  2189  // liftInstCVTSD2SS lifts the given x86 CVTSD2SS instruction to LLVM IR,
  2190  // emitting code to f.
  2191  func (f *Func) liftInstCVTSD2SS(inst *x86.Inst) error {
  2192  	pretty.Println("inst:", inst)
  2193  	panic("emitInstCVTSD2SS: not yet implemented")
  2194  }
  2195  
  2196  // --- [ CVTSI2SD ] ------------------------------------------------------------
  2197  
  2198  // liftInstCVTSI2SD lifts the given x86 CVTSI2SD instruction to LLVM IR,
  2199  // emitting code to f.
  2200  func (f *Func) liftInstCVTSI2SD(inst *x86.Inst) error {
  2201  	pretty.Println("inst:", inst)
  2202  	panic("emitInstCVTSI2SD: not yet implemented")
  2203  }
  2204  
  2205  // --- [ CVTSI2SS ] ------------------------------------------------------------
  2206  
  2207  // liftInstCVTSI2SS lifts the given x86 CVTSI2SS instruction to LLVM IR,
  2208  // emitting code to f.
  2209  func (f *Func) liftInstCVTSI2SS(inst *x86.Inst) error {
  2210  	pretty.Println("inst:", inst)
  2211  	panic("emitInstCVTSI2SS: not yet implemented")
  2212  }
  2213  
  2214  // --- [ CVTSS2SD ] ------------------------------------------------------------
  2215  
  2216  // liftInstCVTSS2SD lifts the given x86 CVTSS2SD instruction to LLVM IR,
  2217  // emitting code to f.
  2218  func (f *Func) liftInstCVTSS2SD(inst *x86.Inst) error {
  2219  	pretty.Println("inst:", inst)
  2220  	panic("emitInstCVTSS2SD: not yet implemented")
  2221  }
  2222  
  2223  // --- [ CVTSS2SI ] ------------------------------------------------------------
  2224  
  2225  // liftInstCVTSS2SI lifts the given x86 CVTSS2SI instruction to LLVM IR,
  2226  // emitting code to f.
  2227  func (f *Func) liftInstCVTSS2SI(inst *x86.Inst) error {
  2228  	pretty.Println("inst:", inst)
  2229  	panic("emitInstCVTSS2SI: not yet implemented")
  2230  }
  2231  
  2232  // --- [ CVTTPD2DQ ] -----------------------------------------------------------
  2233  
  2234  // liftInstCVTTPD2DQ lifts the given x86 CVTTPD2DQ instruction to LLVM IR,
  2235  // emitting code to f.
  2236  func (f *Func) liftInstCVTTPD2DQ(inst *x86.Inst) error {
  2237  	pretty.Println("inst:", inst)
  2238  	panic("emitInstCVTTPD2DQ: not yet implemented")
  2239  }
  2240  
  2241  // --- [ CVTTPD2PI ] -----------------------------------------------------------
  2242  
  2243  // liftInstCVTTPD2PI lifts the given x86 CVTTPD2PI instruction to LLVM IR,
  2244  // emitting code to f.
  2245  func (f *Func) liftInstCVTTPD2PI(inst *x86.Inst) error {
  2246  	pretty.Println("inst:", inst)
  2247  	panic("emitInstCVTTPD2PI: not yet implemented")
  2248  }
  2249  
  2250  // --- [ CVTTPS2DQ ] -----------------------------------------------------------
  2251  
  2252  // liftInstCVTTPS2DQ lifts the given x86 CVTTPS2DQ instruction to LLVM IR,
  2253  // emitting code to f.
  2254  func (f *Func) liftInstCVTTPS2DQ(inst *x86.Inst) error {
  2255  	pretty.Println("inst:", inst)
  2256  	panic("emitInstCVTTPS2DQ: not yet implemented")
  2257  }
  2258  
  2259  // --- [ CVTTPS2PI ] -----------------------------------------------------------
  2260  
  2261  // liftInstCVTTPS2PI lifts the given x86 CVTTPS2PI instruction to LLVM IR,
  2262  // emitting code to f.
  2263  func (f *Func) liftInstCVTTPS2PI(inst *x86.Inst) error {
  2264  	pretty.Println("inst:", inst)
  2265  	panic("emitInstCVTTPS2PI: not yet implemented")
  2266  }
  2267  
  2268  // --- [ CVTTSD2SI ] -----------------------------------------------------------
  2269  
  2270  // liftInstCVTTSD2SI lifts the given x86 CVTTSD2SI instruction to LLVM IR,
  2271  // emitting code to f.
  2272  func (f *Func) liftInstCVTTSD2SI(inst *x86.Inst) error {
  2273  	pretty.Println("inst:", inst)
  2274  	panic("emitInstCVTTSD2SI: not yet implemented")
  2275  }
  2276  
  2277  // --- [ CVTTSS2SI ] -----------------------------------------------------------
  2278  
  2279  // liftInstCVTTSS2SI lifts the given x86 CVTTSS2SI instruction to LLVM IR,
  2280  // emitting code to f.
  2281  func (f *Func) liftInstCVTTSS2SI(inst *x86.Inst) error {
  2282  	pretty.Println("inst:", inst)
  2283  	panic("emitInstCVTTSS2SI: not yet implemented")
  2284  }
  2285  
  2286  // --- [ CWD ] -----------------------------------------------------------------
  2287  
  2288  // liftInstCWD lifts the given x86 CWD instruction to LLVM IR, emitting code to
  2289  // f.
  2290  func (f *Func) liftInstCWD(inst *x86.Inst) error {
  2291  	pretty.Println("inst:", inst)
  2292  	panic("emitInstCWD: not yet implemented")
  2293  }
  2294  
  2295  // --- [ CWDE ] ----------------------------------------------------------------
  2296  
  2297  // liftInstCWDE lifts the given x86 CWDE instruction to LLVM IR, emitting code
  2298  // to f.
  2299  func (f *Func) liftInstCWDE(inst *x86.Inst) error {
  2300  	pretty.Println("inst:", inst)
  2301  	panic("emitInstCWDE: not yet implemented")
  2302  }
  2303  
  2304  // --- [ DAA ] -----------------------------------------------------------------
  2305  
  2306  // liftInstDAA lifts the given x86 DAA instruction to LLVM IR, emitting code to
  2307  // f.
  2308  func (f *Func) liftInstDAA(inst *x86.Inst) error {
  2309  	pretty.Println("inst:", inst)
  2310  	panic("emitInstDAA: not yet implemented")
  2311  }
  2312  
  2313  // --- [ DAS ] -----------------------------------------------------------------
  2314  
  2315  // liftInstDAS lifts the given x86 DAS instruction to LLVM IR, emitting code to
  2316  // f.
  2317  func (f *Func) liftInstDAS(inst *x86.Inst) error {
  2318  	pretty.Println("inst:", inst)
  2319  	panic("emitInstDAS: not yet implemented")
  2320  }
  2321  
  2322  // --- [ DEC ] -----------------------------------------------------------------
  2323  
  2324  // liftInstDEC lifts the given x86 DEC instruction to LLVM IR, emitting code to
  2325  // f.
  2326  func (f *Func) liftInstDEC(inst *x86.Inst) error {
  2327  	f.dec(inst.Arg(0))
  2328  	return nil
  2329  }
  2330  
  2331  // dec decrements the given argument by 1, stores and returns the result.
  2332  func (f *Func) dec(arg *x86.Arg) value.Value {
  2333  	x := f.useArg(arg)
  2334  	one := constant.NewInt(x.Type().(*types.IntType), 1)
  2335  	result := f.cur.NewSub(x, one)
  2336  	f.defArg(arg, result)
  2337  	return result
  2338  }
  2339  
  2340  // --- [ DIV ] -----------------------------------------------------------------
  2341  
  2342  // liftInstDIV lifts the given x86 DIV instruction to LLVM IR, emitting code to
  2343  // f.
  2344  func (f *Func) liftInstDIV(inst *x86.Inst) error {
  2345  	// DIV - Unsigned Divide
  2346  	//
  2347  	//    div arg
  2348  	arg := f.useArg(inst.Arg(0))
  2349  	typ, ok := arg.Type().(*types.IntType)
  2350  	if !ok {
  2351  		return errors.Errorf("invalid argument type in instruction %v; expected *types.IntType, got %T", inst, arg.Type())
  2352  	}
  2353  	switch typ.BitSize {
  2354  	case 8:
  2355  		// Unsigned divide AX by r/m8, with result stored in:
  2356  		//
  2357  		//    AL = quotient
  2358  		//    AH = remainder
  2359  		ax := f.useReg(x86.AX)
  2360  		arg = f.cur.NewZExt(arg, types.I16)
  2361  		quo := f.cur.NewUDiv(ax, arg)
  2362  		rem := f.cur.NewURem(ax, arg)
  2363  		f.defReg(x86.AL, quo)
  2364  		f.defReg(x86.AH, rem)
  2365  	case 16:
  2366  		// Unsigned divide DX:AX by r/m16, with result stored in:
  2367  		//
  2368  		//    AX = quotient
  2369  		//    DX = remainder
  2370  		dx_ax := f.useReg(x86.DX_AX)
  2371  		arg = f.cur.NewZExt(arg, types.I32)
  2372  		quo := f.cur.NewUDiv(dx_ax, arg)
  2373  		rem := f.cur.NewURem(dx_ax, arg)
  2374  		f.defReg(x86.AX, quo)
  2375  		f.defReg(x86.DX, rem)
  2376  	case 32:
  2377  		// Unsigned divide EDX:EAX by r/m32, with result stored in:
  2378  		//
  2379  		//    EAX = quotient
  2380  		//    EDX = remainder
  2381  		edx_eax := f.useReg(x86.EDX_EAX)
  2382  		arg = f.cur.NewZExt(arg, types.I64)
  2383  		quo := f.cur.NewUDiv(edx_eax, arg)
  2384  		rem := f.cur.NewURem(edx_eax, arg)
  2385  		f.defReg(x86.EAX, quo)
  2386  		f.defReg(x86.EDX, rem)
  2387  	case 64:
  2388  		// Unsigned divide RDX:RAX by r/m64, with result stored in:
  2389  		//
  2390  		//    RAX = quotient
  2391  		//    RDX = remainder
  2392  		rdx_rax := f.useReg(x86.RDX_RAX)
  2393  		arg = f.cur.NewZExt(arg, types.I128)
  2394  		quo := f.cur.NewUDiv(rdx_rax, arg)
  2395  		rem := f.cur.NewURem(rdx_rax, arg)
  2396  		f.defReg(x86.RAX, quo)
  2397  		f.defReg(x86.RDX, rem)
  2398  	default:
  2399  		panic(fmt.Errorf("support for argument bit size %d not yet implemented", typ.BitSize))
  2400  	}
  2401  	return nil
  2402  }
  2403  
  2404  // --- [ DIVPD ] ---------------------------------------------------------------
  2405  
  2406  // liftInstDIVPD lifts the given x86 DIVPD instruction to LLVM IR, emitting code
  2407  // to f.
  2408  func (f *Func) liftInstDIVPD(inst *x86.Inst) error {
  2409  	pretty.Println("inst:", inst)
  2410  	panic("emitInstDIVPD: not yet implemented")
  2411  }
  2412  
  2413  // --- [ DIVPS ] ---------------------------------------------------------------
  2414  
  2415  // liftInstDIVPS lifts the given x86 DIVPS instruction to LLVM IR, emitting code
  2416  // to f.
  2417  func (f *Func) liftInstDIVPS(inst *x86.Inst) error {
  2418  	pretty.Println("inst:", inst)
  2419  	panic("emitInstDIVPS: not yet implemented")
  2420  }
  2421  
  2422  // --- [ DIVSD ] ---------------------------------------------------------------
  2423  
  2424  // liftInstDIVSD lifts the given x86 DIVSD instruction to LLVM IR, emitting code
  2425  // to f.
  2426  func (f *Func) liftInstDIVSD(inst *x86.Inst) error {
  2427  	pretty.Println("inst:", inst)
  2428  	panic("emitInstDIVSD: not yet implemented")
  2429  }
  2430  
  2431  // --- [ DIVSS ] ---------------------------------------------------------------
  2432  
  2433  // liftInstDIVSS lifts the given x86 DIVSS instruction to LLVM IR, emitting code
  2434  // to f.
  2435  func (f *Func) liftInstDIVSS(inst *x86.Inst) error {
  2436  	pretty.Println("inst:", inst)
  2437  	panic("emitInstDIVSS: not yet implemented")
  2438  }
  2439  
  2440  // --- [ DPPD ] ----------------------------------------------------------------
  2441  
  2442  // liftInstDPPD lifts the given x86 DPPD instruction to LLVM IR, emitting code
  2443  // to f.
  2444  func (f *Func) liftInstDPPD(inst *x86.Inst) error {
  2445  	pretty.Println("inst:", inst)
  2446  	panic("emitInstDPPD: not yet implemented")
  2447  }
  2448  
  2449  // --- [ DPPS ] ----------------------------------------------------------------
  2450  
  2451  // liftInstDPPS lifts the given x86 DPPS instruction to LLVM IR, emitting code
  2452  // to f.
  2453  func (f *Func) liftInstDPPS(inst *x86.Inst) error {
  2454  	pretty.Println("inst:", inst)
  2455  	panic("emitInstDPPS: not yet implemented")
  2456  }
  2457  
  2458  // --- [ EMMS ] ----------------------------------------------------------------
  2459  
  2460  // liftInstEMMS lifts the given x86 EMMS instruction to LLVM IR, emitting code
  2461  // to f.
  2462  func (f *Func) liftInstEMMS(inst *x86.Inst) error {
  2463  	pretty.Println("inst:", inst)
  2464  	panic("emitInstEMMS: not yet implemented")
  2465  }
  2466  
  2467  // --- [ ENTER ] ---------------------------------------------------------------
  2468  
  2469  // liftInstENTER lifts the given x86 ENTER instruction to LLVM IR, emitting code
  2470  // to f.
  2471  func (f *Func) liftInstENTER(inst *x86.Inst) error {
  2472  	pretty.Println("inst:", inst)
  2473  	panic("emitInstENTER: not yet implemented")
  2474  }
  2475  
  2476  // --- [ EXTRACTPS ] -----------------------------------------------------------
  2477  
  2478  // liftInstEXTRACTPS lifts the given x86 EXTRACTPS instruction to LLVM IR,
  2479  // emitting code to f.
  2480  func (f *Func) liftInstEXTRACTPS(inst *x86.Inst) error {
  2481  	pretty.Println("inst:", inst)
  2482  	panic("emitInstEXTRACTPS: not yet implemented")
  2483  }
  2484  
  2485  // --- [ FFREEP ] --------------------------------------------------------------
  2486  
  2487  // liftInstFFREEP lifts the given x86 FFREEP instruction to LLVM IR, emitting
  2488  // code to f.
  2489  func (f *Func) liftInstFFREEP(inst *x86.Inst) error {
  2490  	pretty.Println("inst:", inst)
  2491  	panic("emitInstFFREEP: not yet implemented")
  2492  }
  2493  
  2494  // --- [ FISTTP ] --------------------------------------------------------------
  2495  
  2496  // liftInstFISTTP lifts the given x86 FISTTP instruction to LLVM IR, emitting
  2497  // code to f.
  2498  func (f *Func) liftInstFISTTP(inst *x86.Inst) error {
  2499  	pretty.Println("inst:", inst)
  2500  	panic("emitInstFISTTP: not yet implemented")
  2501  }
  2502  
  2503  // --- [ FXRSTOR ] -------------------------------------------------------------
  2504  
  2505  // liftInstFXRSTOR lifts the given x86 FXRSTOR instruction to LLVM IR, emitting
  2506  // code to f.
  2507  func (f *Func) liftInstFXRSTOR(inst *x86.Inst) error {
  2508  	pretty.Println("inst:", inst)
  2509  	panic("emitInstFXRSTOR: not yet implemented")
  2510  }
  2511  
  2512  // --- [ FXRSTOR64 ] -----------------------------------------------------------
  2513  
  2514  // liftInstFXRSTOR64 lifts the given x86 FXRSTOR64 instruction to LLVM IR,
  2515  // emitting code to f.
  2516  func (f *Func) liftInstFXRSTOR64(inst *x86.Inst) error {
  2517  	pretty.Println("inst:", inst)
  2518  	panic("emitInstFXRSTOR64: not yet implemented")
  2519  }
  2520  
  2521  // --- [ FXSAVE ] --------------------------------------------------------------
  2522  
  2523  // liftInstFXSAVE lifts the given x86 FXSAVE instruction to LLVM IR, emitting
  2524  // code to f.
  2525  func (f *Func) liftInstFXSAVE(inst *x86.Inst) error {
  2526  	pretty.Println("inst:", inst)
  2527  	panic("emitInstFXSAVE: not yet implemented")
  2528  }
  2529  
  2530  // --- [ FXSAVE64 ] ------------------------------------------------------------
  2531  
  2532  // liftInstFXSAVE64 lifts the given x86 FXSAVE64 instruction to LLVM IR,
  2533  // emitting code to f.
  2534  func (f *Func) liftInstFXSAVE64(inst *x86.Inst) error {
  2535  	pretty.Println("inst:", inst)
  2536  	panic("emitInstFXSAVE64: not yet implemented")
  2537  }
  2538  
  2539  // --- [ HADDPD ] --------------------------------------------------------------
  2540  
  2541  // liftInstHADDPD lifts the given x86 HADDPD instruction to LLVM IR, emitting
  2542  // code to f.
  2543  func (f *Func) liftInstHADDPD(inst *x86.Inst) error {
  2544  	pretty.Println("inst:", inst)
  2545  	panic("emitInstHADDPD: not yet implemented")
  2546  }
  2547  
  2548  // --- [ HADDPS ] --------------------------------------------------------------
  2549  
  2550  // liftInstHADDPS lifts the given x86 HADDPS instruction to LLVM IR, emitting
  2551  // code to f.
  2552  func (f *Func) liftInstHADDPS(inst *x86.Inst) error {
  2553  	pretty.Println("inst:", inst)
  2554  	panic("emitInstHADDPS: not yet implemented")
  2555  }
  2556  
  2557  // --- [ HLT ] -----------------------------------------------------------------
  2558  
  2559  // liftInstHLT lifts the given x86 HLT instruction to LLVM IR, emitting code to
  2560  // f.
  2561  func (f *Func) liftInstHLT(inst *x86.Inst) error {
  2562  	pretty.Println("inst:", inst)
  2563  	panic("emitInstHLT: not yet implemented")
  2564  }
  2565  
  2566  // --- [ HSUBPD ] --------------------------------------------------------------
  2567  
  2568  // liftInstHSUBPD lifts the given x86 HSUBPD instruction to LLVM IR, emitting
  2569  // code to f.
  2570  func (f *Func) liftInstHSUBPD(inst *x86.Inst) error {
  2571  	pretty.Println("inst:", inst)
  2572  	panic("emitInstHSUBPD: not yet implemented")
  2573  }
  2574  
  2575  // --- [ HSUBPS ] --------------------------------------------------------------
  2576  
  2577  // liftInstHSUBPS lifts the given x86 HSUBPS instruction to LLVM IR, emitting
  2578  // code to f.
  2579  func (f *Func) liftInstHSUBPS(inst *x86.Inst) error {
  2580  	pretty.Println("inst:", inst)
  2581  	panic("emitInstHSUBPS: not yet implemented")
  2582  }
  2583  
  2584  // --- [ ICEBP ] ---------------------------------------------------------------
  2585  
  2586  // liftInstICEBP lifts the given x86 ICEBP instruction to LLVM IR, emitting code
  2587  // to f.
  2588  func (f *Func) liftInstICEBP(inst *x86.Inst) error {
  2589  	pretty.Println("inst:", inst)
  2590  	panic("emitInstICEBP: not yet implemented")
  2591  }
  2592  
  2593  // --- [ IDIV ] ----------------------------------------------------------------
  2594  
  2595  // liftInstIDIV lifts the given x86 IDIV instruction to LLVM IR, emitting code
  2596  // to f.
  2597  func (f *Func) liftInstIDIV(inst *x86.Inst) error {
  2598  	// IDIV - Signed Divide
  2599  
  2600  	// Signed divide EDX:EAX by r/m32, with result stored in:
  2601  	//
  2602  	//    EAX = Quotient
  2603  	//    EDX = Remainder
  2604  	x := f.useArg(inst.Arg(0))
  2605  	edx_eax := f.useReg(x86.EDX_EAX)
  2606  	if !types.Equal(x.Type(), types.I64) {
  2607  		x = f.cur.NewSExt(x, types.I64)
  2608  	}
  2609  	quo := f.cur.NewSDiv(edx_eax, x)
  2610  	rem := f.cur.NewSRem(edx_eax, x)
  2611  	f.defReg(x86.EAX, quo)
  2612  	f.defReg(x86.EDX, rem)
  2613  	return nil
  2614  }
  2615  
  2616  // --- [ IMUL ] ----------------------------------------------------------------
  2617  
  2618  // liftInstIMUL lifts the given x86 IMUL instruction to LLVM IR, emitting code
  2619  // to f.
  2620  func (f *Func) liftInstIMUL(inst *x86.Inst) error {
  2621  	// IMUL - Signed Multiply
  2622  	//
  2623  	//    IMUL r/m8                     AX = AL * r/m byte.
  2624  	//    IMUL r/m16                    DX:AX = AX * r/m word.
  2625  	//    IMUL r/m32                    EDX:EAX = EAX * r/m32.
  2626  	//    IMUL r/m64                    RDX:RAX = RAX * r/m64.
  2627  	//    IMUL r16, r/m16               Word register = word register * r/m16.
  2628  	//    IMUL r32, r/m32               Doubleword register = doubleword register * r/m32.
  2629  	//    IMUL r64, r/m64               Quadword register = quadword register * r/m64.
  2630  	//    IMUL r16, r/m16, imm8         Word register = r/m16 * sign-extended immediate byte.
  2631  	//    IMUL r32, r/m32, imm8         Doubleword register = r/m32 * sign-extended immediate byte.
  2632  	//    IMUL r64, r/m64, imm8         Quadword register = r/m64 * sign-extended immediate byte.
  2633  	//    IMUL r16, r/m16, imm16        Word register = r/m16 ∗ immediate word.
  2634  	//    IMUL r32, r/m32, imm32        Doubleword register = r/m32 * immediate doubleword.
  2635  	//    IMUL r64, r/m64, imm32        Quadword register = r/m64 * immediate doubleword.
  2636  	//
  2637  	// Performs a signed multiplication of two operands.
  2638  	var x, y value.Value
  2639  	switch {
  2640  	case inst.Args[2] != nil:
  2641  		// Three-operand form.
  2642  		x, y = f.useArg(inst.Arg(1)), f.useArg(inst.Arg(2))
  2643  	case inst.Args[1] != nil:
  2644  		// Two-operand form.
  2645  		x, y = f.useArg(inst.Arg(0)), f.useArg(inst.Arg(1))
  2646  	case inst.Args[0] != nil:
  2647  		// One-operand form.
  2648  		y := f.useArg(inst.Arg(0))
  2649  		size := f.l.sizeOfType(y.Type())
  2650  		var dst value.Value
  2651  		switch size {
  2652  		case 1:
  2653  			x = f.useReg(x86.AL)
  2654  			dst = f.reg(x86asm.AX)
  2655  		case 2:
  2656  			x = f.useReg(x86.AX)
  2657  			dst = f.reg(x86.X86asm_DX_AX)
  2658  		case 3:
  2659  			x = f.useReg(x86.EAX)
  2660  			dst = f.reg(x86.X86asm_EDX_EAX)
  2661  		case 4:
  2662  			x = f.useReg(x86.RAX)
  2663  			dst = f.reg(x86.X86asm_RDX_RAX)
  2664  		default:
  2665  			panic(fmt.Errorf("support for operand type of byte size %d not yet implemented", size))
  2666  		}
  2667  		result := f.cur.NewMul(x, y)
  2668  		f.cur.NewStore(result, dst)
  2669  		return nil
  2670  	}
  2671  	result := f.cur.NewMul(x, y)
  2672  	f.defArg(inst.Arg(0), result)
  2673  	return nil
  2674  }
  2675  
  2676  // --- [ IN ] ------------------------------------------------------------------
  2677  
  2678  // liftInstIN lifts the given x86 IN instruction to LLVM IR, emitting code to f.
  2679  func (f *Func) liftInstIN(inst *x86.Inst) error {
  2680  	pretty.Println("inst:", inst)
  2681  	panic("emitInstIN: not yet implemented")
  2682  }
  2683  
  2684  // --- [ INC ] -----------------------------------------------------------------
  2685  
  2686  // liftInstINC lifts the given x86 INC instruction to LLVM IR, emitting code to
  2687  // f.
  2688  func (f *Func) liftInstINC(inst *x86.Inst) error {
  2689  	x := f.useArg(inst.Arg(0))
  2690  	one := constant.NewInt(types.I32, 1)
  2691  	result := f.cur.NewAdd(x, one)
  2692  	f.defArg(inst.Arg(0), result)
  2693  	return nil
  2694  }
  2695  
  2696  // --- [ INSB ] ----------------------------------------------------------------
  2697  
  2698  // liftInstINSB lifts the given x86 INSB instruction to LLVM IR, emitting code
  2699  // to f.
  2700  func (f *Func) liftInstINSB(inst *x86.Inst) error {
  2701  	pretty.Println("inst:", inst)
  2702  	panic("emitInstINSB: not yet implemented")
  2703  }
  2704  
  2705  // --- [ INSD ] ----------------------------------------------------------------
  2706  
  2707  // liftInstINSD lifts the given x86 INSD instruction to LLVM IR, emitting code
  2708  // to f.
  2709  func (f *Func) liftInstINSD(inst *x86.Inst) error {
  2710  	pretty.Println("inst:", inst)
  2711  	panic("emitInstINSD: not yet implemented")
  2712  }
  2713  
  2714  // --- [ INSERTPS ] ------------------------------------------------------------
  2715  
  2716  // liftInstINSERTPS lifts the given x86 INSERTPS instruction to LLVM IR,
  2717  // emitting code to f.
  2718  func (f *Func) liftInstINSERTPS(inst *x86.Inst) error {
  2719  	pretty.Println("inst:", inst)
  2720  	panic("emitInstINSERTPS: not yet implemented")
  2721  }
  2722  
  2723  // --- [ INSW ] ----------------------------------------------------------------
  2724  
  2725  // liftInstINSW lifts the given x86 INSW instruction to LLVM IR, emitting code
  2726  // to f.
  2727  func (f *Func) liftInstINSW(inst *x86.Inst) error {
  2728  	pretty.Println("inst:", inst)
  2729  	panic("emitInstINSW: not yet implemented")
  2730  }
  2731  
  2732  // --- [ INT ] -----------------------------------------------------------------
  2733  
  2734  // liftInstINT lifts the given x86 INT instruction to LLVM IR, emitting code to
  2735  // f.
  2736  func (f *Func) liftInstINT(inst *x86.Inst) error {
  2737  	pretty.Println("inst:", inst)
  2738  	panic("emitInstINT: not yet implemented")
  2739  }
  2740  
  2741  // --- [ INTO ] ----------------------------------------------------------------
  2742  
  2743  // liftInstINTO lifts the given x86 INTO instruction to LLVM IR, emitting code
  2744  // to f.
  2745  func (f *Func) liftInstINTO(inst *x86.Inst) error {
  2746  	pretty.Println("inst:", inst)
  2747  	panic("emitInstINTO: not yet implemented")
  2748  }
  2749  
  2750  // --- [ INVD ] ----------------------------------------------------------------
  2751  
  2752  // liftInstINVD lifts the given x86 INVD instruction to LLVM IR, emitting code
  2753  // to f.
  2754  func (f *Func) liftInstINVD(inst *x86.Inst) error {
  2755  	pretty.Println("inst:", inst)
  2756  	panic("emitInstINVD: not yet implemented")
  2757  }
  2758  
  2759  // --- [ INVLPG ] --------------------------------------------------------------
  2760  
  2761  // liftInstINVLPG lifts the given x86 INVLPG instruction to LLVM IR, emitting
  2762  // code to f.
  2763  func (f *Func) liftInstINVLPG(inst *x86.Inst) error {
  2764  	pretty.Println("inst:", inst)
  2765  	panic("emitInstINVLPG: not yet implemented")
  2766  }
  2767  
  2768  // --- [ INVPCID ] -------------------------------------------------------------
  2769  
  2770  // liftInstINVPCID lifts the given x86 INVPCID instruction to LLVM IR, emitting
  2771  // code to f.
  2772  func (f *Func) liftInstINVPCID(inst *x86.Inst) error {
  2773  	pretty.Println("inst:", inst)
  2774  	panic("emitInstINVPCID: not yet implemented")
  2775  }
  2776  
  2777  // --- [ IRET ] ----------------------------------------------------------------
  2778  
  2779  // liftInstIRET lifts the given x86 IRET instruction to LLVM IR, emitting code
  2780  // to f.
  2781  func (f *Func) liftInstIRET(inst *x86.Inst) error {
  2782  	pretty.Println("inst:", inst)
  2783  	panic("emitInstIRET: not yet implemented")
  2784  }
  2785  
  2786  // --- [ IRETD ] ---------------------------------------------------------------
  2787  
  2788  // liftInstIRETD lifts the given x86 IRETD instruction to LLVM IR, emitting code
  2789  // to f.
  2790  func (f *Func) liftInstIRETD(inst *x86.Inst) error {
  2791  	pretty.Println("inst:", inst)
  2792  	panic("emitInstIRETD: not yet implemented")
  2793  }
  2794  
  2795  // --- [ IRETQ ] ---------------------------------------------------------------
  2796  
  2797  // liftInstIRETQ lifts the given x86 IRETQ instruction to LLVM IR, emitting code
  2798  // to f.
  2799  func (f *Func) liftInstIRETQ(inst *x86.Inst) error {
  2800  	pretty.Println("inst:", inst)
  2801  	panic("emitInstIRETQ: not yet implemented")
  2802  }
  2803  
  2804  // --- [ LAHF ] ----------------------------------------------------------------
  2805  
  2806  // liftInstLAHF lifts the given x86 LAHF instruction to LLVM IR, emitting code
  2807  // to f.
  2808  func (f *Func) liftInstLAHF(inst *x86.Inst) error {
  2809  	pretty.Println("inst:", inst)
  2810  	panic("emitInstLAHF: not yet implemented")
  2811  }
  2812  
  2813  // --- [ LAR ] -----------------------------------------------------------------
  2814  
  2815  // liftInstLAR lifts the given x86 LAR instruction to LLVM IR, emitting code to
  2816  // f.
  2817  func (f *Func) liftInstLAR(inst *x86.Inst) error {
  2818  	pretty.Println("inst:", inst)
  2819  	panic("emitInstLAR: not yet implemented")
  2820  }
  2821  
  2822  // --- [ LCALL ] ---------------------------------------------------------------
  2823  
  2824  // liftInstLCALL lifts the given x86 LCALL instruction to LLVM IR, emitting code
  2825  // to f.
  2826  func (f *Func) liftInstLCALL(inst *x86.Inst) error {
  2827  	pretty.Println("inst:", inst)
  2828  	panic("emitInstLCALL: not yet implemented")
  2829  }
  2830  
  2831  // --- [ LDDQU ] ---------------------------------------------------------------
  2832  
  2833  // liftInstLDDQU lifts the given x86 LDDQU instruction to LLVM IR, emitting code
  2834  // to f.
  2835  func (f *Func) liftInstLDDQU(inst *x86.Inst) error {
  2836  	pretty.Println("inst:", inst)
  2837  	panic("emitInstLDDQU: not yet implemented")
  2838  }
  2839  
  2840  // --- [ LDMXCSR ] -------------------------------------------------------------
  2841  
  2842  // liftInstLDMXCSR lifts the given x86 LDMXCSR instruction to LLVM IR, emitting
  2843  // code to f.
  2844  func (f *Func) liftInstLDMXCSR(inst *x86.Inst) error {
  2845  	pretty.Println("inst:", inst)
  2846  	panic("emitInstLDMXCSR: not yet implemented")
  2847  }
  2848  
  2849  // --- [ LDS ] -----------------------------------------------------------------
  2850  
  2851  // liftInstLDS lifts the given x86 LDS instruction to LLVM IR, emitting code to
  2852  // f.
  2853  func (f *Func) liftInstLDS(inst *x86.Inst) error {
  2854  	pretty.Println("inst:", inst)
  2855  	panic("emitInstLDS: not yet implemented")
  2856  }
  2857  
  2858  // --- [ LEA ] -----------------------------------------------------------------
  2859  
  2860  // liftInstLEA lifts the given x86 LEA instruction to LLVM IR, emitting code to
  2861  // f.
  2862  func (f *Func) liftInstLEA(inst *x86.Inst) error {
  2863  	y := f.mem(inst.Mem(1))
  2864  	f.defArg(inst.Arg(0), y)
  2865  	return nil
  2866  }
  2867  
  2868  // --- [ LEAVE ] ---------------------------------------------------------------
  2869  
  2870  // liftInstLEAVE lifts the given x86 LEAVE instruction to LLVM IR, emitting code
  2871  // to f.
  2872  func (f *Func) liftInstLEAVE(inst *x86.Inst) error {
  2873  	// Pseudo-instruction for:
  2874  	//
  2875  	//    mov esp, ebp
  2876  	//    pop ebp
  2877  
  2878  	//    mov esp, ebp
  2879  	ebp := f.useReg(x86.EBP)
  2880  	f.defReg(x86.ESP, ebp)
  2881  	// TODO: Explicitly setting espDisp to -4 should not be needed once espDisp
  2882  	// is stored per basic block and its changes tracked through the CFG. Remove
  2883  	// when handling of espDisp has matured.
  2884  	f.espDisp = -4
  2885  
  2886  	//    pop ebp
  2887  	ebp = f.pop()
  2888  	f.defReg(x86.EBP, ebp)
  2889  
  2890  	return nil
  2891  }
  2892  
  2893  // --- [ LES ] -----------------------------------------------------------------
  2894  
  2895  // liftInstLES lifts the given x86 LES instruction to LLVM IR, emitting code to
  2896  // f.
  2897  func (f *Func) liftInstLES(inst *x86.Inst) error {
  2898  	pretty.Println("inst:", inst)
  2899  	panic("emitInstLES: not yet implemented")
  2900  }
  2901  
  2902  // --- [ LFENCE ] --------------------------------------------------------------
  2903  
  2904  // liftInstLFENCE lifts the given x86 LFENCE instruction to LLVM IR, emitting
  2905  // code to f.
  2906  func (f *Func) liftInstLFENCE(inst *x86.Inst) error {
  2907  	pretty.Println("inst:", inst)
  2908  	panic("emitInstLFENCE: not yet implemented")
  2909  }
  2910  
  2911  // --- [ LFS ] -----------------------------------------------------------------
  2912  
  2913  // liftInstLFS lifts the given x86 LFS instruction to LLVM IR, emitting code to
  2914  // f.
  2915  func (f *Func) liftInstLFS(inst *x86.Inst) error {
  2916  	pretty.Println("inst:", inst)
  2917  	panic("emitInstLFS: not yet implemented")
  2918  }
  2919  
  2920  // --- [ LGDT ] ----------------------------------------------------------------
  2921  
  2922  // liftInstLGDT lifts the given x86 LGDT instruction to LLVM IR, emitting code
  2923  // to f.
  2924  func (f *Func) liftInstLGDT(inst *x86.Inst) error {
  2925  	pretty.Println("inst:", inst)
  2926  	panic("emitInstLGDT: not yet implemented")
  2927  }
  2928  
  2929  // --- [ LGS ] -----------------------------------------------------------------
  2930  
  2931  // liftInstLGS lifts the given x86 LGS instruction to LLVM IR, emitting code to
  2932  // f.
  2933  func (f *Func) liftInstLGS(inst *x86.Inst) error {
  2934  	pretty.Println("inst:", inst)
  2935  	panic("emitInstLGS: not yet implemented")
  2936  }
  2937  
  2938  // --- [ LIDT ] ----------------------------------------------------------------
  2939  
  2940  // liftInstLIDT lifts the given x86 LIDT instruction to LLVM IR, emitting code
  2941  // to f.
  2942  func (f *Func) liftInstLIDT(inst *x86.Inst) error {
  2943  	pretty.Println("inst:", inst)
  2944  	panic("emitInstLIDT: not yet implemented")
  2945  }
  2946  
  2947  // --- [ LJMP ] ----------------------------------------------------------------
  2948  
  2949  // liftInstLJMP lifts the given x86 LJMP instruction to LLVM IR, emitting code
  2950  // to f.
  2951  func (f *Func) liftInstLJMP(inst *x86.Inst) error {
  2952  	pretty.Println("inst:", inst)
  2953  	panic("emitInstLJMP: not yet implemented")
  2954  }
  2955  
  2956  // --- [ LLDT ] ----------------------------------------------------------------
  2957  
  2958  // liftInstLLDT lifts the given x86 LLDT instruction to LLVM IR, emitting code
  2959  // to f.
  2960  func (f *Func) liftInstLLDT(inst *x86.Inst) error {
  2961  	pretty.Println("inst:", inst)
  2962  	panic("emitInstLLDT: not yet implemented")
  2963  }
  2964  
  2965  // --- [ LMSW ] ----------------------------------------------------------------
  2966  
  2967  // liftInstLMSW lifts the given x86 LMSW instruction to LLVM IR, emitting code
  2968  // to f.
  2969  func (f *Func) liftInstLMSW(inst *x86.Inst) error {
  2970  	pretty.Println("inst:", inst)
  2971  	panic("emitInstLMSW: not yet implemented")
  2972  }
  2973  
  2974  // --- [ LODSB ] ---------------------------------------------------------------
  2975  
  2976  // liftInstLODSB lifts the given x86 LODSB instruction to LLVM IR, emitting code
  2977  // to f.
  2978  func (f *Func) liftInstLODSB(inst *x86.Inst) error {
  2979  	src := f.useArg(inst.Arg(1))
  2980  	f.defArgElem(inst.Arg(0), src, types.I8)
  2981  	return nil
  2982  }
  2983  
  2984  // --- [ LODSD ] ---------------------------------------------------------------
  2985  
  2986  // liftInstLODSD lifts the given x86 LODSD instruction to LLVM IR, emitting code
  2987  // to f.
  2988  func (f *Func) liftInstLODSD(inst *x86.Inst) error {
  2989  	src := f.useArg(inst.Arg(1))
  2990  	f.defArgElem(inst.Arg(0), src, types.I32)
  2991  	return nil
  2992  }
  2993  
  2994  // --- [ LODSQ ] ---------------------------------------------------------------
  2995  
  2996  // liftInstLODSQ lifts the given x86 LODSQ instruction to LLVM IR, emitting code
  2997  // to f.
  2998  func (f *Func) liftInstLODSQ(inst *x86.Inst) error {
  2999  	src := f.useArg(inst.Arg(1))
  3000  	f.defArgElem(inst.Arg(0), src, types.I64)
  3001  	return nil
  3002  }
  3003  
  3004  // --- [ LODSW ] ---------------------------------------------------------------
  3005  
  3006  // liftInstLODSW lifts the given x86 LODSW instruction to LLVM IR, emitting code
  3007  // to f.
  3008  func (f *Func) liftInstLODSW(inst *x86.Inst) error {
  3009  	src := f.useArg(inst.Arg(1))
  3010  	f.defArgElem(inst.Arg(0), src, types.I16)
  3011  	return nil
  3012  }
  3013  
  3014  // --- [ LRET ] ----------------------------------------------------------------
  3015  
  3016  // liftInstLRET lifts the given x86 LRET instruction to LLVM IR, emitting code
  3017  // to f.
  3018  func (f *Func) liftInstLRET(inst *x86.Inst) error {
  3019  	pretty.Println("inst:", inst)
  3020  	panic("emitInstLRET: not yet implemented")
  3021  }
  3022  
  3023  // --- [ LSL ] -----------------------------------------------------------------
  3024  
  3025  // liftInstLSL lifts the given x86 LSL instruction to LLVM IR, emitting code to
  3026  // f.
  3027  func (f *Func) liftInstLSL(inst *x86.Inst) error {
  3028  	pretty.Println("inst:", inst)
  3029  	panic("emitInstLSL: not yet implemented")
  3030  }
  3031  
  3032  // --- [ LSS ] -----------------------------------------------------------------
  3033  
  3034  // liftInstLSS lifts the given x86 LSS instruction to LLVM IR, emitting code to
  3035  // f.
  3036  func (f *Func) liftInstLSS(inst *x86.Inst) error {
  3037  	pretty.Println("inst:", inst)
  3038  	panic("emitInstLSS: not yet implemented")
  3039  }
  3040  
  3041  // --- [ LTR ] -----------------------------------------------------------------
  3042  
  3043  // liftInstLTR lifts the given x86 LTR instruction to LLVM IR, emitting code to
  3044  // f.
  3045  func (f *Func) liftInstLTR(inst *x86.Inst) error {
  3046  	pretty.Println("inst:", inst)
  3047  	panic("emitInstLTR: not yet implemented")
  3048  }
  3049  
  3050  // --- [ LZCNT ] ---------------------------------------------------------------
  3051  
  3052  // liftInstLZCNT lifts the given x86 LZCNT instruction to LLVM IR, emitting code
  3053  // to f.
  3054  func (f *Func) liftInstLZCNT(inst *x86.Inst) error {
  3055  	pretty.Println("inst:", inst)
  3056  	panic("emitInstLZCNT: not yet implemented")
  3057  }
  3058  
  3059  // --- [ MASKMOVDQU ] ----------------------------------------------------------
  3060  
  3061  // liftInstMASKMOVDQU lifts the given x86 MASKMOVDQU instruction to LLVM IR,
  3062  // emitting code to f.
  3063  func (f *Func) liftInstMASKMOVDQU(inst *x86.Inst) error {
  3064  	pretty.Println("inst:", inst)
  3065  	panic("emitInstMASKMOVDQU: not yet implemented")
  3066  }
  3067  
  3068  // --- [ MASKMOVQ ] ------------------------------------------------------------
  3069  
  3070  // liftInstMASKMOVQ lifts the given x86 MASKMOVQ instruction to LLVM IR,
  3071  // emitting code to f.
  3072  func (f *Func) liftInstMASKMOVQ(inst *x86.Inst) error {
  3073  	pretty.Println("inst:", inst)
  3074  	panic("emitInstMASKMOVQ: not yet implemented")
  3075  }
  3076  
  3077  // --- [ MAXPD ] ---------------------------------------------------------------
  3078  
  3079  // liftInstMAXPD lifts the given x86 MAXPD instruction to LLVM IR, emitting code
  3080  // to f.
  3081  func (f *Func) liftInstMAXPD(inst *x86.Inst) error {
  3082  	pretty.Println("inst:", inst)
  3083  	panic("emitInstMAXPD: not yet implemented")
  3084  }
  3085  
  3086  // --- [ MAXPS ] ---------------------------------------------------------------
  3087  
  3088  // liftInstMAXPS lifts the given x86 MAXPS instruction to LLVM IR, emitting code
  3089  // to f.
  3090  func (f *Func) liftInstMAXPS(inst *x86.Inst) error {
  3091  	pretty.Println("inst:", inst)
  3092  	panic("emitInstMAXPS: not yet implemented")
  3093  }
  3094  
  3095  // --- [ MAXSD ] ---------------------------------------------------------------
  3096  
  3097  // liftInstMAXSD lifts the given x86 MAXSD instruction to LLVM IR, emitting code
  3098  // to f.
  3099  func (f *Func) liftInstMAXSD(inst *x86.Inst) error {
  3100  	pretty.Println("inst:", inst)
  3101  	panic("emitInstMAXSD: not yet implemented")
  3102  }
  3103  
  3104  // --- [ MAXSS ] ---------------------------------------------------------------
  3105  
  3106  // liftInstMAXSS lifts the given x86 MAXSS instruction to LLVM IR, emitting code
  3107  // to f.
  3108  func (f *Func) liftInstMAXSS(inst *x86.Inst) error {
  3109  	pretty.Println("inst:", inst)
  3110  	panic("emitInstMAXSS: not yet implemented")
  3111  }
  3112  
  3113  // --- [ MFENCE ] --------------------------------------------------------------
  3114  
  3115  // liftInstMFENCE lifts the given x86 MFENCE instruction to LLVM IR, emitting
  3116  // code to f.
  3117  func (f *Func) liftInstMFENCE(inst *x86.Inst) error {
  3118  	pretty.Println("inst:", inst)
  3119  	panic("emitInstMFENCE: not yet implemented")
  3120  }
  3121  
  3122  // --- [ MINPD ] ---------------------------------------------------------------
  3123  
  3124  // liftInstMINPD lifts the given x86 MINPD instruction to LLVM IR, emitting code
  3125  // to f.
  3126  func (f *Func) liftInstMINPD(inst *x86.Inst) error {
  3127  	pretty.Println("inst:", inst)
  3128  	panic("emitInstMINPD: not yet implemented")
  3129  }
  3130  
  3131  // --- [ MINPS ] ---------------------------------------------------------------
  3132  
  3133  // liftInstMINPS lifts the given x86 MINPS instruction to LLVM IR, emitting code
  3134  // to f.
  3135  func (f *Func) liftInstMINPS(inst *x86.Inst) error {
  3136  	pretty.Println("inst:", inst)
  3137  	panic("emitInstMINPS: not yet implemented")
  3138  }
  3139  
  3140  // --- [ MINSD ] ---------------------------------------------------------------
  3141  
  3142  // liftInstMINSD lifts the given x86 MINSD instruction to LLVM IR, emitting code
  3143  // to f.
  3144  func (f *Func) liftInstMINSD(inst *x86.Inst) error {
  3145  	pretty.Println("inst:", inst)
  3146  	panic("emitInstMINSD: not yet implemented")
  3147  }
  3148  
  3149  // --- [ MINSS ] ---------------------------------------------------------------
  3150  
  3151  // liftInstMINSS lifts the given x86 MINSS instruction to LLVM IR, emitting code
  3152  // to f.
  3153  func (f *Func) liftInstMINSS(inst *x86.Inst) error {
  3154  	pretty.Println("inst:", inst)
  3155  	panic("emitInstMINSS: not yet implemented")
  3156  }
  3157  
  3158  // --- [ MONITOR ] -------------------------------------------------------------
  3159  
  3160  // liftInstMONITOR lifts the given x86 MONITOR instruction to LLVM IR, emitting
  3161  // code to f.
  3162  func (f *Func) liftInstMONITOR(inst *x86.Inst) error {
  3163  	pretty.Println("inst:", inst)
  3164  	panic("emitInstMONITOR: not yet implemented")
  3165  }
  3166  
  3167  // --- [ MOV ] -----------------------------------------------------------------
  3168  
  3169  // liftInstMOV lifts the given x86 MOV instruction to LLVM IR, emitting code to
  3170  // f.
  3171  func (f *Func) liftInstMOV(inst *x86.Inst) error {
  3172  	src := f.useArg(inst.Arg(1))
  3173  	f.defArg(inst.Arg(0), src)
  3174  	return nil
  3175  }
  3176  
  3177  // --- [ MOVAPD ] --------------------------------------------------------------
  3178  
  3179  // liftInstMOVAPD lifts the given x86 MOVAPD instruction to LLVM IR, emitting
  3180  // code to f.
  3181  func (f *Func) liftInstMOVAPD(inst *x86.Inst) error {
  3182  	pretty.Println("inst:", inst)
  3183  	panic("emitInstMOVAPD: not yet implemented")
  3184  }
  3185  
  3186  // --- [ MOVAPS ] --------------------------------------------------------------
  3187  
  3188  // liftInstMOVAPS lifts the given x86 MOVAPS instruction to LLVM IR, emitting
  3189  // code to f.
  3190  func (f *Func) liftInstMOVAPS(inst *x86.Inst) error {
  3191  	pretty.Println("inst:", inst)
  3192  	panic("emitInstMOVAPS: not yet implemented")
  3193  }
  3194  
  3195  // --- [ MOVBE ] ---------------------------------------------------------------
  3196  
  3197  // liftInstMOVBE lifts the given x86 MOVBE instruction to LLVM IR, emitting code
  3198  // to f.
  3199  func (f *Func) liftInstMOVBE(inst *x86.Inst) error {
  3200  	pretty.Println("inst:", inst)
  3201  	panic("emitInstMOVBE: not yet implemented")
  3202  }
  3203  
  3204  // --- [ MOVD ] ----------------------------------------------------------------
  3205  
  3206  // liftInstMOVD lifts the given x86 MOVD instruction to LLVM IR, emitting code
  3207  // to f.
  3208  func (f *Func) liftInstMOVD(inst *x86.Inst) error {
  3209  	pretty.Println("inst:", inst)
  3210  	panic("emitInstMOVD: not yet implemented")
  3211  }
  3212  
  3213  // --- [ MOVDDUP ] -------------------------------------------------------------
  3214  
  3215  // liftInstMOVDDUP lifts the given x86 MOVDDUP instruction to LLVM IR, emitting
  3216  // code to f.
  3217  func (f *Func) liftInstMOVDDUP(inst *x86.Inst) error {
  3218  	pretty.Println("inst:", inst)
  3219  	panic("emitInstMOVDDUP: not yet implemented")
  3220  }
  3221  
  3222  // --- [ MOVDQ2Q ] -------------------------------------------------------------
  3223  
  3224  // liftInstMOVDQ2Q lifts the given x86 MOVDQ2Q instruction to LLVM IR, emitting
  3225  // code to f.
  3226  func (f *Func) liftInstMOVDQ2Q(inst *x86.Inst) error {
  3227  	pretty.Println("inst:", inst)
  3228  	panic("emitInstMOVDQ2Q: not yet implemented")
  3229  }
  3230  
  3231  // --- [ MOVDQA ] --------------------------------------------------------------
  3232  
  3233  // liftInstMOVDQA lifts the given x86 MOVDQA instruction to LLVM IR, emitting
  3234  // code to f.
  3235  func (f *Func) liftInstMOVDQA(inst *x86.Inst) error {
  3236  	pretty.Println("inst:", inst)
  3237  	panic("emitInstMOVDQA: not yet implemented")
  3238  }
  3239  
  3240  // --- [ MOVDQU ] --------------------------------------------------------------
  3241  
  3242  // liftInstMOVDQU lifts the given x86 MOVDQU instruction to LLVM IR, emitting
  3243  // code to f.
  3244  func (f *Func) liftInstMOVDQU(inst *x86.Inst) error {
  3245  	pretty.Println("inst:", inst)
  3246  	panic("emitInstMOVDQU: not yet implemented")
  3247  }
  3248  
  3249  // --- [ MOVHLPS ] -------------------------------------------------------------
  3250  
  3251  // liftInstMOVHLPS lifts the given x86 MOVHLPS instruction to LLVM IR, emitting
  3252  // code to f.
  3253  func (f *Func) liftInstMOVHLPS(inst *x86.Inst) error {
  3254  	pretty.Println("inst:", inst)
  3255  	panic("emitInstMOVHLPS: not yet implemented")
  3256  }
  3257  
  3258  // --- [ MOVHPD ] --------------------------------------------------------------
  3259  
  3260  // liftInstMOVHPD lifts the given x86 MOVHPD instruction to LLVM IR, emitting
  3261  // code to f.
  3262  func (f *Func) liftInstMOVHPD(inst *x86.Inst) error {
  3263  	pretty.Println("inst:", inst)
  3264  	panic("emitInstMOVHPD: not yet implemented")
  3265  }
  3266  
  3267  // --- [ MOVHPS ] --------------------------------------------------------------
  3268  
  3269  // liftInstMOVHPS lifts the given x86 MOVHPS instruction to LLVM IR, emitting
  3270  // code to f.
  3271  func (f *Func) liftInstMOVHPS(inst *x86.Inst) error {
  3272  	pretty.Println("inst:", inst)
  3273  	panic("emitInstMOVHPS: not yet implemented")
  3274  }
  3275  
  3276  // --- [ MOVLHPS ] -------------------------------------------------------------
  3277  
  3278  // liftInstMOVLHPS lifts the given x86 MOVLHPS instruction to LLVM IR, emitting
  3279  // code to f.
  3280  func (f *Func) liftInstMOVLHPS(inst *x86.Inst) error {
  3281  	pretty.Println("inst:", inst)
  3282  	panic("emitInstMOVLHPS: not yet implemented")
  3283  }
  3284  
  3285  // --- [ MOVLPD ] --------------------------------------------------------------
  3286  
  3287  // liftInstMOVLPD lifts the given x86 MOVLPD instruction to LLVM IR, emitting
  3288  // code to f.
  3289  func (f *Func) liftInstMOVLPD(inst *x86.Inst) error {
  3290  	pretty.Println("inst:", inst)
  3291  	panic("emitInstMOVLPD: not yet implemented")
  3292  }
  3293  
  3294  // --- [ MOVLPS ] --------------------------------------------------------------
  3295  
  3296  // liftInstMOVLPS lifts the given x86 MOVLPS instruction to LLVM IR, emitting
  3297  // code to f.
  3298  func (f *Func) liftInstMOVLPS(inst *x86.Inst) error {
  3299  	pretty.Println("inst:", inst)
  3300  	panic("emitInstMOVLPS: not yet implemented")
  3301  }
  3302  
  3303  // --- [ MOVMSKPD ] ------------------------------------------------------------
  3304  
  3305  // liftInstMOVMSKPD lifts the given x86 MOVMSKPD instruction to LLVM IR,
  3306  // emitting code to f.
  3307  func (f *Func) liftInstMOVMSKPD(inst *x86.Inst) error {
  3308  	pretty.Println("inst:", inst)
  3309  	panic("emitInstMOVMSKPD: not yet implemented")
  3310  }
  3311  
  3312  // --- [ MOVMSKPS ] ------------------------------------------------------------
  3313  
  3314  // liftInstMOVMSKPS lifts the given x86 MOVMSKPS instruction to LLVM IR,
  3315  // emitting code to f.
  3316  func (f *Func) liftInstMOVMSKPS(inst *x86.Inst) error {
  3317  	pretty.Println("inst:", inst)
  3318  	panic("emitInstMOVMSKPS: not yet implemented")
  3319  }
  3320  
  3321  // --- [ MOVNTDQ ] -------------------------------------------------------------
  3322  
  3323  // liftInstMOVNTDQ lifts the given x86 MOVNTDQ instruction to LLVM IR, emitting
  3324  // code to f.
  3325  func (f *Func) liftInstMOVNTDQ(inst *x86.Inst) error {
  3326  	pretty.Println("inst:", inst)
  3327  	panic("emitInstMOVNTDQ: not yet implemented")
  3328  }
  3329  
  3330  // --- [ MOVNTDQA ] ------------------------------------------------------------
  3331  
  3332  // liftInstMOVNTDQA lifts the given x86 MOVNTDQA instruction to LLVM IR,
  3333  // emitting code to f.
  3334  func (f *Func) liftInstMOVNTDQA(inst *x86.Inst) error {
  3335  	pretty.Println("inst:", inst)
  3336  	panic("emitInstMOVNTDQA: not yet implemented")
  3337  }
  3338  
  3339  // --- [ MOVNTI ] --------------------------------------------------------------
  3340  
  3341  // liftInstMOVNTI lifts the given x86 MOVNTI instruction to LLVM IR, emitting
  3342  // code to f.
  3343  func (f *Func) liftInstMOVNTI(inst *x86.Inst) error {
  3344  	pretty.Println("inst:", inst)
  3345  	panic("emitInstMOVNTI: not yet implemented")
  3346  }
  3347  
  3348  // --- [ MOVNTPD ] -------------------------------------------------------------
  3349  
  3350  // liftInstMOVNTPD lifts the given x86 MOVNTPD instruction to LLVM IR, emitting
  3351  // code to f.
  3352  func (f *Func) liftInstMOVNTPD(inst *x86.Inst) error {
  3353  	pretty.Println("inst:", inst)
  3354  	panic("emitInstMOVNTPD: not yet implemented")
  3355  }
  3356  
  3357  // --- [ MOVNTPS ] -------------------------------------------------------------
  3358  
  3359  // liftInstMOVNTPS lifts the given x86 MOVNTPS instruction to LLVM IR, emitting
  3360  // code to f.
  3361  func (f *Func) liftInstMOVNTPS(inst *x86.Inst) error {
  3362  	pretty.Println("inst:", inst)
  3363  	panic("emitInstMOVNTPS: not yet implemented")
  3364  }
  3365  
  3366  // --- [ MOVNTQ ] --------------------------------------------------------------
  3367  
  3368  // liftInstMOVNTQ lifts the given x86 MOVNTQ instruction to LLVM IR, emitting
  3369  // code to f.
  3370  func (f *Func) liftInstMOVNTQ(inst *x86.Inst) error {
  3371  	pretty.Println("inst:", inst)
  3372  	panic("emitInstMOVNTQ: not yet implemented")
  3373  }
  3374  
  3375  // --- [ MOVNTSD ] -------------------------------------------------------------
  3376  
  3377  // liftInstMOVNTSD lifts the given x86 MOVNTSD instruction to LLVM IR, emitting
  3378  // code to f.
  3379  func (f *Func) liftInstMOVNTSD(inst *x86.Inst) error {
  3380  	pretty.Println("inst:", inst)
  3381  	panic("emitInstMOVNTSD: not yet implemented")
  3382  }
  3383  
  3384  // --- [ MOVNTSS ] -------------------------------------------------------------
  3385  
  3386  // liftInstMOVNTSS lifts the given x86 MOVNTSS instruction to LLVM IR, emitting
  3387  // code to f.
  3388  func (f *Func) liftInstMOVNTSS(inst *x86.Inst) error {
  3389  	pretty.Println("inst:", inst)
  3390  	panic("emitInstMOVNTSS: not yet implemented")
  3391  }
  3392  
  3393  // --- [ MOVQ ] ----------------------------------------------------------------
  3394  
  3395  // liftInstMOVQ lifts the given x86 MOVQ instruction to LLVM IR, emitting code
  3396  // to f.
  3397  func (f *Func) liftInstMOVQ(inst *x86.Inst) error {
  3398  	pretty.Println("inst:", inst)
  3399  	panic("emitInstMOVQ: not yet implemented")
  3400  }
  3401  
  3402  // --- [ MOVQ2DQ ] -------------------------------------------------------------
  3403  
  3404  // liftInstMOVQ2DQ lifts the given x86 MOVQ2DQ instruction to LLVM IR, emitting
  3405  // code to f.
  3406  func (f *Func) liftInstMOVQ2DQ(inst *x86.Inst) error {
  3407  	pretty.Println("inst:", inst)
  3408  	panic("emitInstMOVQ2DQ: not yet implemented")
  3409  }
  3410  
  3411  // --- [ MOVSB ] ---------------------------------------------------------------
  3412  
  3413  // liftInstMOVSB lifts the given x86 MOVSB instruction to LLVM IR, emitting code
  3414  // to f.
  3415  func (f *Func) liftInstMOVSB(inst *x86.Inst) error {
  3416  	src := f.useArgElem(inst.Arg(1), types.I8)
  3417  	f.defArg(inst.Arg(0), src)
  3418  	return nil
  3419  }
  3420  
  3421  // --- [ MOVSD ] ---------------------------------------------------------------
  3422  
  3423  // liftInstMOVSD lifts the given x86 MOVSD instruction to LLVM IR, emitting code
  3424  // to f.
  3425  func (f *Func) liftInstMOVSD(inst *x86.Inst) error {
  3426  	src := f.useArgElem(inst.Arg(1), types.I32)
  3427  	f.defArg(inst.Arg(0), src)
  3428  	return nil
  3429  }
  3430  
  3431  // --- [ MOVSD_XMM ] -----------------------------------------------------------
  3432  
  3433  // liftInstMOVSD_XMM lifts the given x86 MOVSD_XMM instruction to LLVM IR,
  3434  // emitting code to f.
  3435  func (f *Func) liftInstMOVSD_XMM(inst *x86.Inst) error {
  3436  	pretty.Println("inst:", inst)
  3437  	panic("emitInstMOVSD_XMM: not yet implemented")
  3438  }
  3439  
  3440  // --- [ MOVSHDUP ] ------------------------------------------------------------
  3441  
  3442  // liftInstMOVSHDUP lifts the given x86 MOVSHDUP instruction to LLVM IR,
  3443  // emitting code to f.
  3444  func (f *Func) liftInstMOVSHDUP(inst *x86.Inst) error {
  3445  	pretty.Println("inst:", inst)
  3446  	panic("emitInstMOVSHDUP: not yet implemented")
  3447  }
  3448  
  3449  // --- [ MOVSLDUP ] ------------------------------------------------------------
  3450  
  3451  // liftInstMOVSLDUP lifts the given x86 MOVSLDUP instruction to LLVM IR,
  3452  // emitting code to f.
  3453  func (f *Func) liftInstMOVSLDUP(inst *x86.Inst) error {
  3454  	pretty.Println("inst:", inst)
  3455  	panic("emitInstMOVSLDUP: not yet implemented")
  3456  }
  3457  
  3458  // --- [ MOVSQ ] ---------------------------------------------------------------
  3459  
  3460  // liftInstMOVSQ lifts the given x86 MOVSQ instruction to LLVM IR, emitting code
  3461  // to f.
  3462  func (f *Func) liftInstMOVSQ(inst *x86.Inst) error {
  3463  	pretty.Println("inst:", inst)
  3464  	panic("emitInstMOVSQ: not yet implemented")
  3465  }
  3466  
  3467  // --- [ MOVSS ] ---------------------------------------------------------------
  3468  
  3469  // liftInstMOVSS lifts the given x86 MOVSS instruction to LLVM IR, emitting code
  3470  // to f.
  3471  func (f *Func) liftInstMOVSS(inst *x86.Inst) error {
  3472  	pretty.Println("inst:", inst)
  3473  	panic("emitInstMOVSS: not yet implemented")
  3474  }
  3475  
  3476  // --- [ MOVSW ] ---------------------------------------------------------------
  3477  
  3478  // liftInstMOVSW lifts the given x86 MOVSW instruction to LLVM IR, emitting code
  3479  // to f.
  3480  func (f *Func) liftInstMOVSW(inst *x86.Inst) error {
  3481  	src := f.useArgElem(inst.Arg(1), types.I16)
  3482  	f.defArg(inst.Arg(0), src)
  3483  	return nil
  3484  }
  3485  
  3486  // --- [ MOVSX ] ---------------------------------------------------------------
  3487  
  3488  // liftInstMOVSX lifts the given x86 MOVSX instruction to LLVM IR, emitting code
  3489  // to f.
  3490  func (f *Func) liftInstMOVSX(inst *x86.Inst) error {
  3491  	size := uint64(inst.MemBytes) * 8
  3492  	elem := types.NewInt(size)
  3493  	src := f.useArgElem(inst.Arg(1), elem)
  3494  	// TODO: Handle dst type dynamically.
  3495  	src = f.cur.NewSExt(src, types.I32)
  3496  	f.defArg(inst.Arg(0), src)
  3497  	return nil
  3498  }
  3499  
  3500  // --- [ MOVSXD ] --------------------------------------------------------------
  3501  
  3502  // liftInstMOVSXD lifts the given x86 MOVSXD instruction to LLVM IR, emitting
  3503  // code to f.
  3504  func (f *Func) liftInstMOVSXD(inst *x86.Inst) error {
  3505  	pretty.Println("inst:", inst)
  3506  	panic("emitInstMOVSXD: not yet implemented")
  3507  }
  3508  
  3509  // --- [ MOVUPD ] --------------------------------------------------------------
  3510  
  3511  // liftInstMOVUPD lifts the given x86 MOVUPD instruction to LLVM IR, emitting
  3512  // code to f.
  3513  func (f *Func) liftInstMOVUPD(inst *x86.Inst) error {
  3514  	pretty.Println("inst:", inst)
  3515  	panic("emitInstMOVUPD: not yet implemented")
  3516  }
  3517  
  3518  // --- [ MOVUPS ] --------------------------------------------------------------
  3519  
  3520  // liftInstMOVUPS lifts the given x86 MOVUPS instruction to LLVM IR, emitting
  3521  // code to f.
  3522  func (f *Func) liftInstMOVUPS(inst *x86.Inst) error {
  3523  	pretty.Println("inst:", inst)
  3524  	panic("emitInstMOVUPS: not yet implemented")
  3525  }
  3526  
  3527  // --- [ MOVZX ] ---------------------------------------------------------------
  3528  
  3529  // liftInstMOVZX lifts the given x86 MOVZX instruction to LLVM IR, emitting code
  3530  // to f.
  3531  func (f *Func) liftInstMOVZX(inst *x86.Inst) error {
  3532  	size := uint64(inst.MemBytes) * 8
  3533  	elem := types.NewInt(size)
  3534  	src := f.useArgElem(inst.Arg(1), elem)
  3535  	// TODO: Handle dst type dynamically.
  3536  	src = f.cur.NewZExt(src, types.I32)
  3537  	f.defArg(inst.Arg(0), src)
  3538  	return nil
  3539  }
  3540  
  3541  // --- [ MPSADBW ] -------------------------------------------------------------
  3542  
  3543  // liftInstMPSADBW lifts the given x86 MPSADBW instruction to LLVM IR, emitting
  3544  // code to f.
  3545  func (f *Func) liftInstMPSADBW(inst *x86.Inst) error {
  3546  	pretty.Println("inst:", inst)
  3547  	panic("emitInstMPSADBW: not yet implemented")
  3548  }
  3549  
  3550  // --- [ MUL ] -----------------------------------------------------------------
  3551  
  3552  // liftInstMUL lifts the given x86 MUL instruction to LLVM IR, emitting code to
  3553  // f.
  3554  func (f *Func) liftInstMUL(inst *x86.Inst) error {
  3555  	// MUL - Unsigned Multiply
  3556  	//
  3557  	//    MUL r/m8       Unsigned multiply (AX = AL ∗ r/m8).
  3558  	//    MUL r/m8       Unsigned multiply (AX = AL ∗ r/m8).
  3559  	//    MUL r/m16      Unsigned multiply (DX:AX = AX ∗ r/m16).
  3560  	//    MUL r/m32      Unsigned multiply (EDX:EAX = EAX ∗ r/m32).
  3561  	//    MUL r/m64      Unsigned multiply (RDX:RAX = RAX ∗ r/m64).
  3562  	//
  3563  	// Performs an unsigned multiplication of the first operand (destination
  3564  	// operand) and the second operand (source operand) and stores the result in
  3565  	// the destination operand.
  3566  	// One-operand form.
  3567  	y := f.useArg(inst.Arg(0))
  3568  	size := f.l.sizeOfType(y.Type())
  3569  	var x value.Value
  3570  	var dst value.Value
  3571  	switch size {
  3572  	case 1:
  3573  		x = f.useReg(x86.AL)
  3574  		dst = f.reg(x86asm.AX)
  3575  	case 2:
  3576  		x = f.useReg(x86.AX)
  3577  		dst = f.reg(x86.X86asm_DX_AX)
  3578  	case 3:
  3579  		x = f.useReg(x86.EAX)
  3580  		dst = f.reg(x86.X86asm_EDX_EAX)
  3581  	case 4:
  3582  		x = f.useReg(x86.RAX)
  3583  		dst = f.reg(x86.X86asm_RDX_RAX)
  3584  	default:
  3585  		panic(fmt.Errorf("support for operand type of byte size %d not yet implemented", size))
  3586  	}
  3587  	result := f.cur.NewMul(x, y)
  3588  	f.cur.NewStore(result, dst)
  3589  	return nil
  3590  }
  3591  
  3592  // --- [ MULPD ] ---------------------------------------------------------------
  3593  
  3594  // liftInstMULPD lifts the given x86 MULPD instruction to LLVM IR, emitting code
  3595  // to f.
  3596  func (f *Func) liftInstMULPD(inst *x86.Inst) error {
  3597  	pretty.Println("inst:", inst)
  3598  	panic("emitInstMULPD: not yet implemented")
  3599  }
  3600  
  3601  // --- [ MULPS ] ---------------------------------------------------------------
  3602  
  3603  // liftInstMULPS lifts the given x86 MULPS instruction to LLVM IR, emitting code
  3604  // to f.
  3605  func (f *Func) liftInstMULPS(inst *x86.Inst) error {
  3606  	pretty.Println("inst:", inst)
  3607  	panic("emitInstMULPS: not yet implemented")
  3608  }
  3609  
  3610  // --- [ MULSD ] ---------------------------------------------------------------
  3611  
  3612  // liftInstMULSD lifts the given x86 MULSD instruction to LLVM IR, emitting code
  3613  // to f.
  3614  func (f *Func) liftInstMULSD(inst *x86.Inst) error {
  3615  	pretty.Println("inst:", inst)
  3616  	panic("emitInstMULSD: not yet implemented")
  3617  }
  3618  
  3619  // --- [ MULSS ] ---------------------------------------------------------------
  3620  
  3621  // liftInstMULSS lifts the given x86 MULSS instruction to LLVM IR, emitting code
  3622  // to f.
  3623  func (f *Func) liftInstMULSS(inst *x86.Inst) error {
  3624  	pretty.Println("inst:", inst)
  3625  	panic("emitInstMULSS: not yet implemented")
  3626  }
  3627  
  3628  // --- [ MWAIT ] ---------------------------------------------------------------
  3629  
  3630  // liftInstMWAIT lifts the given x86 MWAIT instruction to LLVM IR, emitting code
  3631  // to f.
  3632  func (f *Func) liftInstMWAIT(inst *x86.Inst) error {
  3633  	pretty.Println("inst:", inst)
  3634  	panic("emitInstMWAIT: not yet implemented")
  3635  }
  3636  
  3637  // --- [ NEG ] -----------------------------------------------------------------
  3638  
  3639  // liftInstNEG lifts the given x86 NEG instruction to LLVM IR, emitting code to
  3640  // f.
  3641  func (f *Func) liftInstNEG(inst *x86.Inst) error {
  3642  	x := f.useArg(inst.Arg(0))
  3643  	zero := constant.NewInt(x.Type().(*types.IntType), 0)
  3644  	result := f.cur.NewSub(zero, x)
  3645  	f.defArg(inst.Arg(0), result)
  3646  	return nil
  3647  }
  3648  
  3649  // --- [ NOP ] -----------------------------------------------------------------
  3650  
  3651  // liftInstNOP lifts the given x86 NOP instruction to LLVM IR, emitting code to
  3652  // f.
  3653  func (f *Func) liftInstNOP(inst *x86.Inst) error {
  3654  	return nil
  3655  }
  3656  
  3657  // --- [ NOT ] -----------------------------------------------------------------
  3658  
  3659  // liftInstNOT lifts the given x86 NOT instruction to LLVM IR, emitting code to
  3660  // f.
  3661  func (f *Func) liftInstNOT(inst *x86.Inst) error {
  3662  	x := f.useArg(inst.Arg(0))
  3663  	var mask value.Value
  3664  	typ, ok := x.Type().(*types.IntType)
  3665  	if !ok {
  3666  		panic(fmt.Errorf("invalid NOT operand type; expected *types.IntType, got %T", x.Type()))
  3667  	}
  3668  	switch typ.BitSize {
  3669  	case 8:
  3670  		mask = constant.NewInt(types.I8, 0xFF)
  3671  	case 16:
  3672  		mask = constant.NewInt(types.I16, 0xFFFF)
  3673  	case 32:
  3674  		mask = constant.NewInt(types.I32, 0xFFFFFFFF)
  3675  	case 64:
  3676  		v, err := constant.NewIntFromString(types.I64, "0xFFFFFFFFFFFFFFFF")
  3677  		if err != nil {
  3678  			panic(fmt.Errorf("unable to parse integer constant; %v", err))
  3679  		}
  3680  		mask = v
  3681  	default:
  3682  		panic(fmt.Errorf("support for operand bit size %d not yet implemented", typ.BitSize))
  3683  	}
  3684  	result := f.cur.NewXor(x, mask)
  3685  	f.defArg(inst.Arg(0), result)
  3686  	return nil
  3687  }
  3688  
  3689  // --- [ OR ] ------------------------------------------------------------------
  3690  
  3691  // liftInstOR lifts the given x86 OR instruction to LLVM IR, emitting code to f.
  3692  func (f *Func) liftInstOR(inst *x86.Inst) error {
  3693  	x, y := f.useArg(inst.Arg(0)), f.useArg(inst.Arg(1))
  3694  	result := f.cur.NewOr(x, y)
  3695  	f.defArg(inst.Arg(0), result)
  3696  	return nil
  3697  }
  3698  
  3699  // --- [ ORPD ] ----------------------------------------------------------------
  3700  
  3701  // liftInstORPD lifts the given x86 ORPD instruction to LLVM IR, emitting code
  3702  // to f.
  3703  func (f *Func) liftInstORPD(inst *x86.Inst) error {
  3704  	pretty.Println("inst:", inst)
  3705  	panic("emitInstORPD: not yet implemented")
  3706  }
  3707  
  3708  // --- [ ORPS ] ----------------------------------------------------------------
  3709  
  3710  // liftInstORPS lifts the given x86 ORPS instruction to LLVM IR, emitting code
  3711  // to f.
  3712  func (f *Func) liftInstORPS(inst *x86.Inst) error {
  3713  	pretty.Println("inst:", inst)
  3714  	panic("emitInstORPS: not yet implemented")
  3715  }
  3716  
  3717  // --- [ OUT ] -----------------------------------------------------------------
  3718  
  3719  // liftInstOUT lifts the given x86 OUT instruction to LLVM IR, emitting code to
  3720  // f.
  3721  func (f *Func) liftInstOUT(inst *x86.Inst) error {
  3722  	pretty.Println("inst:", inst)
  3723  	panic("emitInstOUT: not yet implemented")
  3724  }
  3725  
  3726  // --- [ OUTSB ] ---------------------------------------------------------------
  3727  
  3728  // liftInstOUTSB lifts the given x86 OUTSB instruction to LLVM IR, emitting code
  3729  // to f.
  3730  func (f *Func) liftInstOUTSB(inst *x86.Inst) error {
  3731  	pretty.Println("inst:", inst)
  3732  	panic("emitInstOUTSB: not yet implemented")
  3733  }
  3734  
  3735  // --- [ OUTSD ] ---------------------------------------------------------------
  3736  
  3737  // liftInstOUTSD lifts the given x86 OUTSD instruction to LLVM IR, emitting code
  3738  // to f.
  3739  func (f *Func) liftInstOUTSD(inst *x86.Inst) error {
  3740  	pretty.Println("inst:", inst)
  3741  	panic("emitInstOUTSD: not yet implemented")
  3742  }
  3743  
  3744  // --- [ OUTSW ] ---------------------------------------------------------------
  3745  
  3746  // liftInstOUTSW lifts the given x86 OUTSW instruction to LLVM IR, emitting code
  3747  // to f.
  3748  func (f *Func) liftInstOUTSW(inst *x86.Inst) error {
  3749  	pretty.Println("inst:", inst)
  3750  	panic("emitInstOUTSW: not yet implemented")
  3751  }
  3752  
  3753  // --- [ PABSB ] ---------------------------------------------------------------
  3754  
  3755  // liftInstPABSB lifts the given x86 PABSB instruction to LLVM IR, emitting code
  3756  // to f.
  3757  func (f *Func) liftInstPABSB(inst *x86.Inst) error {
  3758  	pretty.Println("inst:", inst)
  3759  	panic("emitInstPABSB: not yet implemented")
  3760  }
  3761  
  3762  // --- [ PABSD ] ---------------------------------------------------------------
  3763  
  3764  // liftInstPABSD lifts the given x86 PABSD instruction to LLVM IR, emitting code
  3765  // to f.
  3766  func (f *Func) liftInstPABSD(inst *x86.Inst) error {
  3767  	pretty.Println("inst:", inst)
  3768  	panic("emitInstPABSD: not yet implemented")
  3769  }
  3770  
  3771  // --- [ PABSW ] ---------------------------------------------------------------
  3772  
  3773  // liftInstPABSW lifts the given x86 PABSW instruction to LLVM IR, emitting code
  3774  // to f.
  3775  func (f *Func) liftInstPABSW(inst *x86.Inst) error {
  3776  	pretty.Println("inst:", inst)
  3777  	panic("emitInstPABSW: not yet implemented")
  3778  }
  3779  
  3780  // --- [ PACKSSDW ] ------------------------------------------------------------
  3781  
  3782  // liftInstPACKSSDW lifts the given x86 PACKSSDW instruction to LLVM IR,
  3783  // emitting code to f.
  3784  func (f *Func) liftInstPACKSSDW(inst *x86.Inst) error {
  3785  	pretty.Println("inst:", inst)
  3786  	panic("emitInstPACKSSDW: not yet implemented")
  3787  }
  3788  
  3789  // --- [ PACKSSWB ] ------------------------------------------------------------
  3790  
  3791  // liftInstPACKSSWB lifts the given x86 PACKSSWB instruction to LLVM IR,
  3792  // emitting code to f.
  3793  func (f *Func) liftInstPACKSSWB(inst *x86.Inst) error {
  3794  	pretty.Println("inst:", inst)
  3795  	panic("emitInstPACKSSWB: not yet implemented")
  3796  }
  3797  
  3798  // --- [ PACKUSDW ] ------------------------------------------------------------
  3799  
  3800  // liftInstPACKUSDW lifts the given x86 PACKUSDW instruction to LLVM IR,
  3801  // emitting code to f.
  3802  func (f *Func) liftInstPACKUSDW(inst *x86.Inst) error {
  3803  	pretty.Println("inst:", inst)
  3804  	panic("emitInstPACKUSDW: not yet implemented")
  3805  }
  3806  
  3807  // --- [ PACKUSWB ] ------------------------------------------------------------
  3808  
  3809  // liftInstPACKUSWB lifts the given x86 PACKUSWB instruction to LLVM IR,
  3810  // emitting code to f.
  3811  func (f *Func) liftInstPACKUSWB(inst *x86.Inst) error {
  3812  	pretty.Println("inst:", inst)
  3813  	panic("emitInstPACKUSWB: not yet implemented")
  3814  }
  3815  
  3816  // --- [ PADDB ] ---------------------------------------------------------------
  3817  
  3818  // liftInstPADDB lifts the given x86 PADDB instruction to LLVM IR, emitting code
  3819  // to f.
  3820  func (f *Func) liftInstPADDB(inst *x86.Inst) error {
  3821  	pretty.Println("inst:", inst)
  3822  	panic("emitInstPADDB: not yet implemented")
  3823  }
  3824  
  3825  // --- [ PADDD ] ---------------------------------------------------------------
  3826  
  3827  // liftInstPADDD lifts the given x86 PADDD instruction to LLVM IR, emitting code
  3828  // to f.
  3829  func (f *Func) liftInstPADDD(inst *x86.Inst) error {
  3830  	pretty.Println("inst:", inst)
  3831  	panic("emitInstPADDD: not yet implemented")
  3832  }
  3833  
  3834  // --- [ PADDQ ] ---------------------------------------------------------------
  3835  
  3836  // liftInstPADDQ lifts the given x86 PADDQ instruction to LLVM IR, emitting code
  3837  // to f.
  3838  func (f *Func) liftInstPADDQ(inst *x86.Inst) error {
  3839  	pretty.Println("inst:", inst)
  3840  	panic("emitInstPADDQ: not yet implemented")
  3841  }
  3842  
  3843  // --- [ PADDSB ] --------------------------------------------------------------
  3844  
  3845  // liftInstPADDSB lifts the given x86 PADDSB instruction to LLVM IR, emitting
  3846  // code to f.
  3847  func (f *Func) liftInstPADDSB(inst *x86.Inst) error {
  3848  	pretty.Println("inst:", inst)
  3849  	panic("emitInstPADDSB: not yet implemented")
  3850  }
  3851  
  3852  // --- [ PADDSW ] --------------------------------------------------------------
  3853  
  3854  // liftInstPADDSW lifts the given x86 PADDSW instruction to LLVM IR, emitting
  3855  // code to f.
  3856  func (f *Func) liftInstPADDSW(inst *x86.Inst) error {
  3857  	pretty.Println("inst:", inst)
  3858  	panic("emitInstPADDSW: not yet implemented")
  3859  }
  3860  
  3861  // --- [ PADDUSB ] -------------------------------------------------------------
  3862  
  3863  // liftInstPADDUSB lifts the given x86 PADDUSB instruction to LLVM IR, emitting
  3864  // code to f.
  3865  func (f *Func) liftInstPADDUSB(inst *x86.Inst) error {
  3866  	pretty.Println("inst:", inst)
  3867  	panic("emitInstPADDUSB: not yet implemented")
  3868  }
  3869  
  3870  // --- [ PADDUSW ] -------------------------------------------------------------
  3871  
  3872  // liftInstPADDUSW lifts the given x86 PADDUSW instruction to LLVM IR, emitting
  3873  // code to f.
  3874  func (f *Func) liftInstPADDUSW(inst *x86.Inst) error {
  3875  	pretty.Println("inst:", inst)
  3876  	panic("emitInstPADDUSW: not yet implemented")
  3877  }
  3878  
  3879  // --- [ PADDW ] ---------------------------------------------------------------
  3880  
  3881  // liftInstPADDW lifts the given x86 PADDW instruction to LLVM IR, emitting code
  3882  // to f.
  3883  func (f *Func) liftInstPADDW(inst *x86.Inst) error {
  3884  	pretty.Println("inst:", inst)
  3885  	panic("emitInstPADDW: not yet implemented")
  3886  }
  3887  
  3888  // --- [ PALIGNR ] -------------------------------------------------------------
  3889  
  3890  // liftInstPALIGNR lifts the given x86 PALIGNR instruction to LLVM IR, emitting
  3891  // code to f.
  3892  func (f *Func) liftInstPALIGNR(inst *x86.Inst) error {
  3893  	pretty.Println("inst:", inst)
  3894  	panic("emitInstPALIGNR: not yet implemented")
  3895  }
  3896  
  3897  // --- [ PAND ] ----------------------------------------------------------------
  3898  
  3899  // liftInstPAND lifts the given x86 PAND instruction to LLVM IR, emitting code
  3900  // to f.
  3901  func (f *Func) liftInstPAND(inst *x86.Inst) error {
  3902  	pretty.Println("inst:", inst)
  3903  	panic("emitInstPAND: not yet implemented")
  3904  }
  3905  
  3906  // --- [ PANDN ] ---------------------------------------------------------------
  3907  
  3908  // liftInstPANDN lifts the given x86 PANDN instruction to LLVM IR, emitting code
  3909  // to f.
  3910  func (f *Func) liftInstPANDN(inst *x86.Inst) error {
  3911  	pretty.Println("inst:", inst)
  3912  	panic("emitInstPANDN: not yet implemented")
  3913  }
  3914  
  3915  // --- [ PAUSE ] ---------------------------------------------------------------
  3916  
  3917  // liftInstPAUSE lifts the given x86 PAUSE instruction to LLVM IR, emitting code
  3918  // to f.
  3919  func (f *Func) liftInstPAUSE(inst *x86.Inst) error {
  3920  	pretty.Println("inst:", inst)
  3921  	panic("emitInstPAUSE: not yet implemented")
  3922  }
  3923  
  3924  // --- [ PAVGB ] ---------------------------------------------------------------
  3925  
  3926  // liftInstPAVGB lifts the given x86 PAVGB instruction to LLVM IR, emitting code
  3927  // to f.
  3928  func (f *Func) liftInstPAVGB(inst *x86.Inst) error {
  3929  	pretty.Println("inst:", inst)
  3930  	panic("emitInstPAVGB: not yet implemented")
  3931  }
  3932  
  3933  // --- [ PAVGW ] ---------------------------------------------------------------
  3934  
  3935  // liftInstPAVGW lifts the given x86 PAVGW instruction to LLVM IR, emitting code
  3936  // to f.
  3937  func (f *Func) liftInstPAVGW(inst *x86.Inst) error {
  3938  	pretty.Println("inst:", inst)
  3939  	panic("emitInstPAVGW: not yet implemented")
  3940  }
  3941  
  3942  // --- [ PBLENDVB ] ------------------------------------------------------------
  3943  
  3944  // liftInstPBLENDVB lifts the given x86 PBLENDVB instruction to LLVM IR,
  3945  // emitting code to f.
  3946  func (f *Func) liftInstPBLENDVB(inst *x86.Inst) error {
  3947  	pretty.Println("inst:", inst)
  3948  	panic("emitInstPBLENDVB: not yet implemented")
  3949  }
  3950  
  3951  // --- [ PBLENDW ] -------------------------------------------------------------
  3952  
  3953  // liftInstPBLENDW lifts the given x86 PBLENDW instruction to LLVM IR, emitting
  3954  // code to f.
  3955  func (f *Func) liftInstPBLENDW(inst *x86.Inst) error {
  3956  	pretty.Println("inst:", inst)
  3957  	panic("emitInstPBLENDW: not yet implemented")
  3958  }
  3959  
  3960  // --- [ PCLMULQDQ ] -----------------------------------------------------------
  3961  
  3962  // liftInstPCLMULQDQ lifts the given x86 PCLMULQDQ instruction to LLVM IR,
  3963  // emitting code to f.
  3964  func (f *Func) liftInstPCLMULQDQ(inst *x86.Inst) error {
  3965  	pretty.Println("inst:", inst)
  3966  	panic("emitInstPCLMULQDQ: not yet implemented")
  3967  }
  3968  
  3969  // --- [ PCMPEQB ] -------------------------------------------------------------
  3970  
  3971  // liftInstPCMPEQB lifts the given x86 PCMPEQB instruction to LLVM IR, emitting
  3972  // code to f.
  3973  func (f *Func) liftInstPCMPEQB(inst *x86.Inst) error {
  3974  	pretty.Println("inst:", inst)
  3975  	panic("emitInstPCMPEQB: not yet implemented")
  3976  }
  3977  
  3978  // --- [ PCMPEQD ] -------------------------------------------------------------
  3979  
  3980  // liftInstPCMPEQD lifts the given x86 PCMPEQD instruction to LLVM IR, emitting
  3981  // code to f.
  3982  func (f *Func) liftInstPCMPEQD(inst *x86.Inst) error {
  3983  	pretty.Println("inst:", inst)
  3984  	panic("emitInstPCMPEQD: not yet implemented")
  3985  }
  3986  
  3987  // --- [ PCMPEQQ ] -------------------------------------------------------------
  3988  
  3989  // liftInstPCMPEQQ lifts the given x86 PCMPEQQ instruction to LLVM IR, emitting
  3990  // code to f.
  3991  func (f *Func) liftInstPCMPEQQ(inst *x86.Inst) error {
  3992  	pretty.Println("inst:", inst)
  3993  	panic("emitInstPCMPEQQ: not yet implemented")
  3994  }
  3995  
  3996  // --- [ PCMPEQW ] -------------------------------------------------------------
  3997  
  3998  // liftInstPCMPEQW lifts the given x86 PCMPEQW instruction to LLVM IR, emitting
  3999  // code to f.
  4000  func (f *Func) liftInstPCMPEQW(inst *x86.Inst) error {
  4001  	pretty.Println("inst:", inst)
  4002  	panic("emitInstPCMPEQW: not yet implemented")
  4003  }
  4004  
  4005  // --- [ PCMPESTRI ] -----------------------------------------------------------
  4006  
  4007  // liftInstPCMPESTRI lifts the given x86 PCMPESTRI instruction to LLVM IR,
  4008  // emitting code to f.
  4009  func (f *Func) liftInstPCMPESTRI(inst *x86.Inst) error {
  4010  	pretty.Println("inst:", inst)
  4011  	panic("emitInstPCMPESTRI: not yet implemented")
  4012  }
  4013  
  4014  // --- [ PCMPESTRM ] -----------------------------------------------------------
  4015  
  4016  // liftInstPCMPESTRM lifts the given x86 PCMPESTRM instruction to LLVM IR,
  4017  // emitting code to f.
  4018  func (f *Func) liftInstPCMPESTRM(inst *x86.Inst) error {
  4019  	pretty.Println("inst:", inst)
  4020  	panic("emitInstPCMPESTRM: not yet implemented")
  4021  }
  4022  
  4023  // --- [ PCMPGTB ] -------------------------------------------------------------
  4024  
  4025  // liftInstPCMPGTB lifts the given x86 PCMPGTB instruction to LLVM IR, emitting
  4026  // code to f.
  4027  func (f *Func) liftInstPCMPGTB(inst *x86.Inst) error {
  4028  	pretty.Println("inst:", inst)
  4029  	panic("emitInstPCMPGTB: not yet implemented")
  4030  }
  4031  
  4032  // --- [ PCMPGTD ] -------------------------------------------------------------
  4033  
  4034  // liftInstPCMPGTD lifts the given x86 PCMPGTD instruction to LLVM IR, emitting
  4035  // code to f.
  4036  func (f *Func) liftInstPCMPGTD(inst *x86.Inst) error {
  4037  	pretty.Println("inst:", inst)
  4038  	panic("emitInstPCMPGTD: not yet implemented")
  4039  }
  4040  
  4041  // --- [ PCMPGTQ ] -------------------------------------------------------------
  4042  
  4043  // liftInstPCMPGTQ lifts the given x86 PCMPGTQ instruction to LLVM IR, emitting
  4044  // code to f.
  4045  func (f *Func) liftInstPCMPGTQ(inst *x86.Inst) error {
  4046  	pretty.Println("inst:", inst)
  4047  	panic("emitInstPCMPGTQ: not yet implemented")
  4048  }
  4049  
  4050  // --- [ PCMPGTW ] -------------------------------------------------------------
  4051  
  4052  // liftInstPCMPGTW lifts the given x86 PCMPGTW instruction to LLVM IR, emitting
  4053  // code to f.
  4054  func (f *Func) liftInstPCMPGTW(inst *x86.Inst) error {
  4055  	pretty.Println("inst:", inst)
  4056  	panic("emitInstPCMPGTW: not yet implemented")
  4057  }
  4058  
  4059  // --- [ PCMPISTRI ] -----------------------------------------------------------
  4060  
  4061  // liftInstPCMPISTRI lifts the given x86 PCMPISTRI instruction to LLVM IR,
  4062  // emitting code to f.
  4063  func (f *Func) liftInstPCMPISTRI(inst *x86.Inst) error {
  4064  	pretty.Println("inst:", inst)
  4065  	panic("emitInstPCMPISTRI: not yet implemented")
  4066  }
  4067  
  4068  // --- [ PCMPISTRM ] -----------------------------------------------------------
  4069  
  4070  // liftInstPCMPISTRM lifts the given x86 PCMPISTRM instruction to LLVM IR,
  4071  // emitting code to f.
  4072  func (f *Func) liftInstPCMPISTRM(inst *x86.Inst) error {
  4073  	pretty.Println("inst:", inst)
  4074  	panic("emitInstPCMPISTRM: not yet implemented")
  4075  }
  4076  
  4077  // --- [ PEXTRB ] --------------------------------------------------------------
  4078  
  4079  // liftInstPEXTRB lifts the given x86 PEXTRB instruction to LLVM IR, emitting
  4080  // code to f.
  4081  func (f *Func) liftInstPEXTRB(inst *x86.Inst) error {
  4082  	pretty.Println("inst:", inst)
  4083  	panic("emitInstPEXTRB: not yet implemented")
  4084  }
  4085  
  4086  // --- [ PEXTRD ] --------------------------------------------------------------
  4087  
  4088  // liftInstPEXTRD lifts the given x86 PEXTRD instruction to LLVM IR, emitting
  4089  // code to f.
  4090  func (f *Func) liftInstPEXTRD(inst *x86.Inst) error {
  4091  	pretty.Println("inst:", inst)
  4092  	panic("emitInstPEXTRD: not yet implemented")
  4093  }
  4094  
  4095  // --- [ PEXTRQ ] --------------------------------------------------------------
  4096  
  4097  // liftInstPEXTRQ lifts the given x86 PEXTRQ instruction to LLVM IR, emitting
  4098  // code to f.
  4099  func (f *Func) liftInstPEXTRQ(inst *x86.Inst) error {
  4100  	pretty.Println("inst:", inst)
  4101  	panic("emitInstPEXTRQ: not yet implemented")
  4102  }
  4103  
  4104  // --- [ PEXTRW ] --------------------------------------------------------------
  4105  
  4106  // liftInstPEXTRW lifts the given x86 PEXTRW instruction to LLVM IR, emitting
  4107  // code to f.
  4108  func (f *Func) liftInstPEXTRW(inst *x86.Inst) error {
  4109  	pretty.Println("inst:", inst)
  4110  	panic("emitInstPEXTRW: not yet implemented")
  4111  }
  4112  
  4113  // --- [ PHADDD ] --------------------------------------------------------------
  4114  
  4115  // liftInstPHADDD lifts the given x86 PHADDD instruction to LLVM IR, emitting
  4116  // code to f.
  4117  func (f *Func) liftInstPHADDD(inst *x86.Inst) error {
  4118  	pretty.Println("inst:", inst)
  4119  	panic("emitInstPHADDD: not yet implemented")
  4120  }
  4121  
  4122  // --- [ PHADDSW ] -------------------------------------------------------------
  4123  
  4124  // liftInstPHADDSW lifts the given x86 PHADDSW instruction to LLVM IR, emitting
  4125  // code to f.
  4126  func (f *Func) liftInstPHADDSW(inst *x86.Inst) error {
  4127  	pretty.Println("inst:", inst)
  4128  	panic("emitInstPHADDSW: not yet implemented")
  4129  }
  4130  
  4131  // --- [ PHADDW ] --------------------------------------------------------------
  4132  
  4133  // liftInstPHADDW lifts the given x86 PHADDW instruction to LLVM IR, emitting
  4134  // code to f.
  4135  func (f *Func) liftInstPHADDW(inst *x86.Inst) error {
  4136  	pretty.Println("inst:", inst)
  4137  	panic("emitInstPHADDW: not yet implemented")
  4138  }
  4139  
  4140  // --- [ PHMINPOSUW ] ----------------------------------------------------------
  4141  
  4142  // liftInstPHMINPOSUW lifts the given x86 PHMINPOSUW instruction to LLVM IR,
  4143  // emitting code to f.
  4144  func (f *Func) liftInstPHMINPOSUW(inst *x86.Inst) error {
  4145  	pretty.Println("inst:", inst)
  4146  	panic("emitInstPHMINPOSUW: not yet implemented")
  4147  }
  4148  
  4149  // --- [ PHSUBD ] --------------------------------------------------------------
  4150  
  4151  // liftInstPHSUBD lifts the given x86 PHSUBD instruction to LLVM IR, emitting
  4152  // code to f.
  4153  func (f *Func) liftInstPHSUBD(inst *x86.Inst) error {
  4154  	pretty.Println("inst:", inst)
  4155  	panic("emitInstPHSUBD: not yet implemented")
  4156  }
  4157  
  4158  // --- [ PHSUBSW ] -------------------------------------------------------------
  4159  
  4160  // liftInstPHSUBSW lifts the given x86 PHSUBSW instruction to LLVM IR, emitting
  4161  // code to f.
  4162  func (f *Func) liftInstPHSUBSW(inst *x86.Inst) error {
  4163  	pretty.Println("inst:", inst)
  4164  	panic("emitInstPHSUBSW: not yet implemented")
  4165  }
  4166  
  4167  // --- [ PHSUBW ] --------------------------------------------------------------
  4168  
  4169  // liftInstPHSUBW lifts the given x86 PHSUBW instruction to LLVM IR, emitting
  4170  // code to f.
  4171  func (f *Func) liftInstPHSUBW(inst *x86.Inst) error {
  4172  	pretty.Println("inst:", inst)
  4173  	panic("emitInstPHSUBW: not yet implemented")
  4174  }
  4175  
  4176  // --- [ PINSRB ] --------------------------------------------------------------
  4177  
  4178  // liftInstPINSRB lifts the given x86 PINSRB instruction to LLVM IR, emitting
  4179  // code to f.
  4180  func (f *Func) liftInstPINSRB(inst *x86.Inst) error {
  4181  	pretty.Println("inst:", inst)
  4182  	panic("emitInstPINSRB: not yet implemented")
  4183  }
  4184  
  4185  // --- [ PINSRD ] --------------------------------------------------------------
  4186  
  4187  // liftInstPINSRD lifts the given x86 PINSRD instruction to LLVM IR, emitting
  4188  // code to f.
  4189  func (f *Func) liftInstPINSRD(inst *x86.Inst) error {
  4190  	pretty.Println("inst:", inst)
  4191  	panic("emitInstPINSRD: not yet implemented")
  4192  }
  4193  
  4194  // --- [ PINSRQ ] --------------------------------------------------------------
  4195  
  4196  // liftInstPINSRQ lifts the given x86 PINSRQ instruction to LLVM IR, emitting
  4197  // code to f.
  4198  func (f *Func) liftInstPINSRQ(inst *x86.Inst) error {
  4199  	pretty.Println("inst:", inst)
  4200  	panic("emitInstPINSRQ: not yet implemented")
  4201  }
  4202  
  4203  // --- [ PINSRW ] --------------------------------------------------------------
  4204  
  4205  // liftInstPINSRW lifts the given x86 PINSRW instruction to LLVM IR, emitting
  4206  // code to f.
  4207  func (f *Func) liftInstPINSRW(inst *x86.Inst) error {
  4208  	pretty.Println("inst:", inst)
  4209  	panic("emitInstPINSRW: not yet implemented")
  4210  }
  4211  
  4212  // --- [ PMADDUBSW ] -----------------------------------------------------------
  4213  
  4214  // liftInstPMADDUBSW lifts the given x86 PMADDUBSW instruction to LLVM IR,
  4215  // emitting code to f.
  4216  func (f *Func) liftInstPMADDUBSW(inst *x86.Inst) error {
  4217  	pretty.Println("inst:", inst)
  4218  	panic("emitInstPMADDUBSW: not yet implemented")
  4219  }
  4220  
  4221  // --- [ PMADDWD ] -------------------------------------------------------------
  4222  
  4223  // liftInstPMADDWD lifts the given x86 PMADDWD instruction to LLVM IR, emitting
  4224  // code to f.
  4225  func (f *Func) liftInstPMADDWD(inst *x86.Inst) error {
  4226  	pretty.Println("inst:", inst)
  4227  	panic("emitInstPMADDWD: not yet implemented")
  4228  }
  4229  
  4230  // --- [ PMAXSB ] --------------------------------------------------------------
  4231  
  4232  // liftInstPMAXSB lifts the given x86 PMAXSB instruction to LLVM IR, emitting
  4233  // code to f.
  4234  func (f *Func) liftInstPMAXSB(inst *x86.Inst) error {
  4235  	pretty.Println("inst:", inst)
  4236  	panic("emitInstPMAXSB: not yet implemented")
  4237  }
  4238  
  4239  // --- [ PMAXSD ] --------------------------------------------------------------
  4240  
  4241  // liftInstPMAXSD lifts the given x86 PMAXSD instruction to LLVM IR, emitting
  4242  // code to f.
  4243  func (f *Func) liftInstPMAXSD(inst *x86.Inst) error {
  4244  	pretty.Println("inst:", inst)
  4245  	panic("emitInstPMAXSD: not yet implemented")
  4246  }
  4247  
  4248  // --- [ PMAXSW ] --------------------------------------------------------------
  4249  
  4250  // liftInstPMAXSW lifts the given x86 PMAXSW instruction to LLVM IR, emitting
  4251  // code to f.
  4252  func (f *Func) liftInstPMAXSW(inst *x86.Inst) error {
  4253  	pretty.Println("inst:", inst)
  4254  	panic("emitInstPMAXSW: not yet implemented")
  4255  }
  4256  
  4257  // --- [ PMAXUB ] --------------------------------------------------------------
  4258  
  4259  // liftInstPMAXUB lifts the given x86 PMAXUB instruction to LLVM IR, emitting
  4260  // code to f.
  4261  func (f *Func) liftInstPMAXUB(inst *x86.Inst) error {
  4262  	pretty.Println("inst:", inst)
  4263  	panic("emitInstPMAXUB: not yet implemented")
  4264  }
  4265  
  4266  // --- [ PMAXUD ] --------------------------------------------------------------
  4267  
  4268  // liftInstPMAXUD lifts the given x86 PMAXUD instruction to LLVM IR, emitting
  4269  // code to f.
  4270  func (f *Func) liftInstPMAXUD(inst *x86.Inst) error {
  4271  	pretty.Println("inst:", inst)
  4272  	panic("emitInstPMAXUD: not yet implemented")
  4273  }
  4274  
  4275  // --- [ PMAXUW ] --------------------------------------------------------------
  4276  
  4277  // liftInstPMAXUW lifts the given x86 PMAXUW instruction to LLVM IR, emitting
  4278  // code to f.
  4279  func (f *Func) liftInstPMAXUW(inst *x86.Inst) error {
  4280  	pretty.Println("inst:", inst)
  4281  	panic("emitInstPMAXUW: not yet implemented")
  4282  }
  4283  
  4284  // --- [ PMINSB ] --------------------------------------------------------------
  4285  
  4286  // liftInstPMINSB lifts the given x86 PMINSB instruction to LLVM IR, emitting
  4287  // code to f.
  4288  func (f *Func) liftInstPMINSB(inst *x86.Inst) error {
  4289  	pretty.Println("inst:", inst)
  4290  	panic("emitInstPMINSB: not yet implemented")
  4291  }
  4292  
  4293  // --- [ PMINSD ] --------------------------------------------------------------
  4294  
  4295  // liftInstPMINSD lifts the given x86 PMINSD instruction to LLVM IR, emitting
  4296  // code to f.
  4297  func (f *Func) liftInstPMINSD(inst *x86.Inst) error {
  4298  	pretty.Println("inst:", inst)
  4299  	panic("emitInstPMINSD: not yet implemented")
  4300  }
  4301  
  4302  // --- [ PMINSW ] --------------------------------------------------------------
  4303  
  4304  // liftInstPMINSW lifts the given x86 PMINSW instruction to LLVM IR, emitting
  4305  // code to f.
  4306  func (f *Func) liftInstPMINSW(inst *x86.Inst) error {
  4307  	pretty.Println("inst:", inst)
  4308  	panic("emitInstPMINSW: not yet implemented")
  4309  }
  4310  
  4311  // --- [ PMINUB ] --------------------------------------------------------------
  4312  
  4313  // liftInstPMINUB lifts the given x86 PMINUB instruction to LLVM IR, emitting
  4314  // code to f.
  4315  func (f *Func) liftInstPMINUB(inst *x86.Inst) error {
  4316  	pretty.Println("inst:", inst)
  4317  	panic("emitInstPMINUB: not yet implemented")
  4318  }
  4319  
  4320  // --- [ PMINUD ] --------------------------------------------------------------
  4321  
  4322  // liftInstPMINUD lifts the given x86 PMINUD instruction to LLVM IR, emitting
  4323  // code to f.
  4324  func (f *Func) liftInstPMINUD(inst *x86.Inst) error {
  4325  	pretty.Println("inst:", inst)
  4326  	panic("emitInstPMINUD: not yet implemented")
  4327  }
  4328  
  4329  // --- [ PMINUW ] --------------------------------------------------------------
  4330  
  4331  // liftInstPMINUW lifts the given x86 PMINUW instruction to LLVM IR, emitting
  4332  // code to f.
  4333  func (f *Func) liftInstPMINUW(inst *x86.Inst) error {
  4334  	pretty.Println("inst:", inst)
  4335  	panic("emitInstPMINUW: not yet implemented")
  4336  }
  4337  
  4338  // --- [ PMOVMSKB ] ------------------------------------------------------------
  4339  
  4340  // liftInstPMOVMSKB lifts the given x86 PMOVMSKB instruction to LLVM IR,
  4341  // emitting code to f.
  4342  func (f *Func) liftInstPMOVMSKB(inst *x86.Inst) error {
  4343  	pretty.Println("inst:", inst)
  4344  	panic("emitInstPMOVMSKB: not yet implemented")
  4345  }
  4346  
  4347  // --- [ PMOVSXBD ] ------------------------------------------------------------
  4348  
  4349  // liftInstPMOVSXBD lifts the given x86 PMOVSXBD instruction to LLVM IR,
  4350  // emitting code to f.
  4351  func (f *Func) liftInstPMOVSXBD(inst *x86.Inst) error {
  4352  	pretty.Println("inst:", inst)
  4353  	panic("emitInstPMOVSXBD: not yet implemented")
  4354  }
  4355  
  4356  // --- [ PMOVSXBQ ] ------------------------------------------------------------
  4357  
  4358  // liftInstPMOVSXBQ lifts the given x86 PMOVSXBQ instruction to LLVM IR,
  4359  // emitting code to f.
  4360  func (f *Func) liftInstPMOVSXBQ(inst *x86.Inst) error {
  4361  	pretty.Println("inst:", inst)
  4362  	panic("emitInstPMOVSXBQ: not yet implemented")
  4363  }
  4364  
  4365  // --- [ PMOVSXBW ] ------------------------------------------------------------
  4366  
  4367  // liftInstPMOVSXBW lifts the given x86 PMOVSXBW instruction to LLVM IR,
  4368  // emitting code to f.
  4369  func (f *Func) liftInstPMOVSXBW(inst *x86.Inst) error {
  4370  	pretty.Println("inst:", inst)
  4371  	panic("emitInstPMOVSXBW: not yet implemented")
  4372  }
  4373  
  4374  // --- [ PMOVSXDQ ] ------------------------------------------------------------
  4375  
  4376  // liftInstPMOVSXDQ lifts the given x86 PMOVSXDQ instruction to LLVM IR,
  4377  // emitting code to f.
  4378  func (f *Func) liftInstPMOVSXDQ(inst *x86.Inst) error {
  4379  	pretty.Println("inst:", inst)
  4380  	panic("emitInstPMOVSXDQ: not yet implemented")
  4381  }
  4382  
  4383  // --- [ PMOVSXWD ] ------------------------------------------------------------
  4384  
  4385  // liftInstPMOVSXWD lifts the given x86 PMOVSXWD instruction to LLVM IR,
  4386  // emitting code to f.
  4387  func (f *Func) liftInstPMOVSXWD(inst *x86.Inst) error {
  4388  	pretty.Println("inst:", inst)
  4389  	panic("emitInstPMOVSXWD: not yet implemented")
  4390  }
  4391  
  4392  // --- [ PMOVSXWQ ] ------------------------------------------------------------
  4393  
  4394  // liftInstPMOVSXWQ lifts the given x86 PMOVSXWQ instruction to LLVM IR,
  4395  // emitting code to f.
  4396  func (f *Func) liftInstPMOVSXWQ(inst *x86.Inst) error {
  4397  	pretty.Println("inst:", inst)
  4398  	panic("emitInstPMOVSXWQ: not yet implemented")
  4399  }
  4400  
  4401  // --- [ PMOVZXBD ] ------------------------------------------------------------
  4402  
  4403  // liftInstPMOVZXBD lifts the given x86 PMOVZXBD instruction to LLVM IR,
  4404  // emitting code to f.
  4405  func (f *Func) liftInstPMOVZXBD(inst *x86.Inst) error {
  4406  	pretty.Println("inst:", inst)
  4407  	panic("emitInstPMOVZXBD: not yet implemented")
  4408  }
  4409  
  4410  // --- [ PMOVZXBQ ] ------------------------------------------------------------
  4411  
  4412  // liftInstPMOVZXBQ lifts the given x86 PMOVZXBQ instruction to LLVM IR,
  4413  // emitting code to f.
  4414  func (f *Func) liftInstPMOVZXBQ(inst *x86.Inst) error {
  4415  	pretty.Println("inst:", inst)
  4416  	panic("emitInstPMOVZXBQ: not yet implemented")
  4417  }
  4418  
  4419  // --- [ PMOVZXBW ] ------------------------------------------------------------
  4420  
  4421  // liftInstPMOVZXBW lifts the given x86 PMOVZXBW instruction to LLVM IR,
  4422  // emitting code to f.
  4423  func (f *Func) liftInstPMOVZXBW(inst *x86.Inst) error {
  4424  	pretty.Println("inst:", inst)
  4425  	panic("emitInstPMOVZXBW: not yet implemented")
  4426  }
  4427  
  4428  // --- [ PMOVZXDQ ] ------------------------------------------------------------
  4429  
  4430  // liftInstPMOVZXDQ lifts the given x86 PMOVZXDQ instruction to LLVM IR,
  4431  // emitting code to f.
  4432  func (f *Func) liftInstPMOVZXDQ(inst *x86.Inst) error {
  4433  	pretty.Println("inst:", inst)
  4434  	panic("emitInstPMOVZXDQ: not yet implemented")
  4435  }
  4436  
  4437  // --- [ PMOVZXWD ] ------------------------------------------------------------
  4438  
  4439  // liftInstPMOVZXWD lifts the given x86 PMOVZXWD instruction to LLVM IR,
  4440  // emitting code to f.
  4441  func (f *Func) liftInstPMOVZXWD(inst *x86.Inst) error {
  4442  	pretty.Println("inst:", inst)
  4443  	panic("emitInstPMOVZXWD: not yet implemented")
  4444  }
  4445  
  4446  // --- [ PMOVZXWQ ] ------------------------------------------------------------
  4447  
  4448  // liftInstPMOVZXWQ lifts the given x86 PMOVZXWQ instruction to LLVM IR,
  4449  // emitting code to f.
  4450  func (f *Func) liftInstPMOVZXWQ(inst *x86.Inst) error {
  4451  	pretty.Println("inst:", inst)
  4452  	panic("emitInstPMOVZXWQ: not yet implemented")
  4453  }
  4454  
  4455  // --- [ PMULDQ ] --------------------------------------------------------------
  4456  
  4457  // liftInstPMULDQ lifts the given x86 PMULDQ instruction to LLVM IR, emitting
  4458  // code to f.
  4459  func (f *Func) liftInstPMULDQ(inst *x86.Inst) error {
  4460  	pretty.Println("inst:", inst)
  4461  	panic("emitInstPMULDQ: not yet implemented")
  4462  }
  4463  
  4464  // --- [ PMULHRSW ] ------------------------------------------------------------
  4465  
  4466  // liftInstPMULHRSW lifts the given x86 PMULHRSW instruction to LLVM IR,
  4467  // emitting code to f.
  4468  func (f *Func) liftInstPMULHRSW(inst *x86.Inst) error {
  4469  	pretty.Println("inst:", inst)
  4470  	panic("emitInstPMULHRSW: not yet implemented")
  4471  }
  4472  
  4473  // --- [ PMULHUW ] -------------------------------------------------------------
  4474  
  4475  // liftInstPMULHUW lifts the given x86 PMULHUW instruction to LLVM IR, emitting
  4476  // code to f.
  4477  func (f *Func) liftInstPMULHUW(inst *x86.Inst) error {
  4478  	pretty.Println("inst:", inst)
  4479  	panic("emitInstPMULHUW: not yet implemented")
  4480  }
  4481  
  4482  // --- [ PMULHW ] --------------------------------------------------------------
  4483  
  4484  // liftInstPMULHW lifts the given x86 PMULHW instruction to LLVM IR, emitting
  4485  // code to f.
  4486  func (f *Func) liftInstPMULHW(inst *x86.Inst) error {
  4487  	pretty.Println("inst:", inst)
  4488  	panic("emitInstPMULHW: not yet implemented")
  4489  }
  4490  
  4491  // --- [ PMULLD ] --------------------------------------------------------------
  4492  
  4493  // liftInstPMULLD lifts the given x86 PMULLD instruction to LLVM IR, emitting
  4494  // code to f.
  4495  func (f *Func) liftInstPMULLD(inst *x86.Inst) error {
  4496  	pretty.Println("inst:", inst)
  4497  	panic("emitInstPMULLD: not yet implemented")
  4498  }
  4499  
  4500  // --- [ PMULLW ] --------------------------------------------------------------
  4501  
  4502  // liftInstPMULLW lifts the given x86 PMULLW instruction to LLVM IR, emitting
  4503  // code to f.
  4504  func (f *Func) liftInstPMULLW(inst *x86.Inst) error {
  4505  	pretty.Println("inst:", inst)
  4506  	panic("emitInstPMULLW: not yet implemented")
  4507  }
  4508  
  4509  // --- [ PMULUDQ ] -------------------------------------------------------------
  4510  
  4511  // liftInstPMULUDQ lifts the given x86 PMULUDQ instruction to LLVM IR, emitting
  4512  // code to f.
  4513  func (f *Func) liftInstPMULUDQ(inst *x86.Inst) error {
  4514  	pretty.Println("inst:", inst)
  4515  	panic("emitInstPMULUDQ: not yet implemented")
  4516  }
  4517  
  4518  // --- [ POP ] -----------------------------------------------------------------
  4519  
  4520  // liftInstPOP lifts the given x86 POP instruction to LLVM IR, emitting code to
  4521  // f.
  4522  func (f *Func) liftInstPOP(inst *x86.Inst) error {
  4523  	v := f.pop()
  4524  	f.defArg(inst.Arg(0), v)
  4525  	return nil
  4526  }
  4527  
  4528  // pop pops a value from the top of the stack of the function, emitting code to
  4529  // f.
  4530  func (f *Func) pop() value.Named {
  4531  	m := x86asm.Mem{
  4532  		Base: x86asm.ESP,
  4533  	}
  4534  	mem := x86.NewMem(m, nil)
  4535  	v := f.useMem(mem)
  4536  	f.espDisp += 4
  4537  	return v
  4538  }
  4539  
  4540  // --- [ POPA ] ----------------------------------------------------------------
  4541  
  4542  // liftInstPOPA lifts the given x86 POPA instruction to LLVM IR, emitting code
  4543  // to f.
  4544  func (f *Func) liftInstPOPA(inst *x86.Inst) error {
  4545  	pretty.Println("inst:", inst)
  4546  	panic("emitInstPOPA: not yet implemented")
  4547  }
  4548  
  4549  // --- [ POPAD ] ---------------------------------------------------------------
  4550  
  4551  // liftInstPOPAD lifts the given x86 POPAD instruction to LLVM IR, emitting code
  4552  // to f.
  4553  func (f *Func) liftInstPOPAD(inst *x86.Inst) error {
  4554  	pretty.Println("inst:", inst)
  4555  	panic("emitInstPOPAD: not yet implemented")
  4556  }
  4557  
  4558  // --- [ POPCNT ] --------------------------------------------------------------
  4559  
  4560  // liftInstPOPCNT lifts the given x86 POPCNT instruction to LLVM IR, emitting
  4561  // code to f.
  4562  func (f *Func) liftInstPOPCNT(inst *x86.Inst) error {
  4563  	pretty.Println("inst:", inst)
  4564  	panic("emitInstPOPCNT: not yet implemented")
  4565  }
  4566  
  4567  // --- [ POPF ] ----------------------------------------------------------------
  4568  
  4569  // liftInstPOPF lifts the given x86 POPF instruction to LLVM IR, emitting code
  4570  // to f.
  4571  func (f *Func) liftInstPOPF(inst *x86.Inst) error {
  4572  	pretty.Println("inst:", inst)
  4573  	panic("emitInstPOPF: not yet implemented")
  4574  }
  4575  
  4576  // --- [ POPFD ] ---------------------------------------------------------------
  4577  
  4578  // liftInstPOPFD lifts the given x86 POPFD instruction to LLVM IR, emitting code
  4579  // to f.
  4580  func (f *Func) liftInstPOPFD(inst *x86.Inst) error {
  4581  	pretty.Println("inst:", inst)
  4582  	panic("emitInstPOPFD: not yet implemented")
  4583  }
  4584  
  4585  // --- [ POPFQ ] ---------------------------------------------------------------
  4586  
  4587  // liftInstPOPFQ lifts the given x86 POPFQ instruction to LLVM IR, emitting code
  4588  // to f.
  4589  func (f *Func) liftInstPOPFQ(inst *x86.Inst) error {
  4590  	pretty.Println("inst:", inst)
  4591  	panic("emitInstPOPFQ: not yet implemented")
  4592  }
  4593  
  4594  // --- [ POR ] -----------------------------------------------------------------
  4595  
  4596  // liftInstPOR lifts the given x86 POR instruction to LLVM IR, emitting code to
  4597  // f.
  4598  func (f *Func) liftInstPOR(inst *x86.Inst) error {
  4599  	pretty.Println("inst:", inst)
  4600  	panic("emitInstPOR: not yet implemented")
  4601  }
  4602  
  4603  // --- [ PREFETCHNTA ] ---------------------------------------------------------
  4604  
  4605  // liftInstPREFETCHNTA lifts the given x86 PREFETCHNTA instruction to LLVM IR,
  4606  // emitting code to f.
  4607  func (f *Func) liftInstPREFETCHNTA(inst *x86.Inst) error {
  4608  	pretty.Println("inst:", inst)
  4609  	panic("emitInstPREFETCHNTA: not yet implemented")
  4610  }
  4611  
  4612  // --- [ PREFETCHT0 ] ----------------------------------------------------------
  4613  
  4614  // liftInstPREFETCHT0 lifts the given x86 PREFETCHT0 instruction to LLVM IR,
  4615  // emitting code to f.
  4616  func (f *Func) liftInstPREFETCHT0(inst *x86.Inst) error {
  4617  	pretty.Println("inst:", inst)
  4618  	panic("emitInstPREFETCHT0: not yet implemented")
  4619  }
  4620  
  4621  // --- [ PREFETCHT1 ] ----------------------------------------------------------
  4622  
  4623  // liftInstPREFETCHT1 lifts the given x86 PREFETCHT1 instruction to LLVM IR,
  4624  // emitting code to f.
  4625  func (f *Func) liftInstPREFETCHT1(inst *x86.Inst) error {
  4626  	pretty.Println("inst:", inst)
  4627  	panic("emitInstPREFETCHT1: not yet implemented")
  4628  }
  4629  
  4630  // --- [ PREFETCHT2 ] ----------------------------------------------------------
  4631  
  4632  // liftInstPREFETCHT2 lifts the given x86 PREFETCHT2 instruction to LLVM IR,
  4633  // emitting code to f.
  4634  func (f *Func) liftInstPREFETCHT2(inst *x86.Inst) error {
  4635  	pretty.Println("inst:", inst)
  4636  	panic("emitInstPREFETCHT2: not yet implemented")
  4637  }
  4638  
  4639  // --- [ PREFETCHW ] -----------------------------------------------------------
  4640  
  4641  // liftInstPREFETCHW lifts the given x86 PREFETCHW instruction to LLVM IR,
  4642  // emitting code to f.
  4643  func (f *Func) liftInstPREFETCHW(inst *x86.Inst) error {
  4644  	pretty.Println("inst:", inst)
  4645  	panic("emitInstPREFETCHW: not yet implemented")
  4646  }
  4647  
  4648  // --- [ PSADBW ] --------------------------------------------------------------
  4649  
  4650  // liftInstPSADBW lifts the given x86 PSADBW instruction to LLVM IR, emitting
  4651  // code to f.
  4652  func (f *Func) liftInstPSADBW(inst *x86.Inst) error {
  4653  	pretty.Println("inst:", inst)
  4654  	panic("emitInstPSADBW: not yet implemented")
  4655  }
  4656  
  4657  // --- [ PSHUFB ] --------------------------------------------------------------
  4658  
  4659  // liftInstPSHUFB lifts the given x86 PSHUFB instruction to LLVM IR, emitting
  4660  // code to f.
  4661  func (f *Func) liftInstPSHUFB(inst *x86.Inst) error {
  4662  	pretty.Println("inst:", inst)
  4663  	panic("emitInstPSHUFB: not yet implemented")
  4664  }
  4665  
  4666  // --- [ PSHUFD ] --------------------------------------------------------------
  4667  
  4668  // liftInstPSHUFD lifts the given x86 PSHUFD instruction to LLVM IR, emitting
  4669  // code to f.
  4670  func (f *Func) liftInstPSHUFD(inst *x86.Inst) error {
  4671  	pretty.Println("inst:", inst)
  4672  	panic("emitInstPSHUFD: not yet implemented")
  4673  }
  4674  
  4675  // --- [ PSHUFHW ] -------------------------------------------------------------
  4676  
  4677  // liftInstPSHUFHW lifts the given x86 PSHUFHW instruction to LLVM IR, emitting
  4678  // code to f.
  4679  func (f *Func) liftInstPSHUFHW(inst *x86.Inst) error {
  4680  	pretty.Println("inst:", inst)
  4681  	panic("emitInstPSHUFHW: not yet implemented")
  4682  }
  4683  
  4684  // --- [ PSHUFLW ] -------------------------------------------------------------
  4685  
  4686  // liftInstPSHUFLW lifts the given x86 PSHUFLW instruction to LLVM IR, emitting
  4687  // code to f.
  4688  func (f *Func) liftInstPSHUFLW(inst *x86.Inst) error {
  4689  	pretty.Println("inst:", inst)
  4690  	panic("emitInstPSHUFLW: not yet implemented")
  4691  }
  4692  
  4693  // --- [ PSHUFW ] --------------------------------------------------------------
  4694  
  4695  // liftInstPSHUFW lifts the given x86 PSHUFW instruction to LLVM IR, emitting
  4696  // code to f.
  4697  func (f *Func) liftInstPSHUFW(inst *x86.Inst) error {
  4698  	pretty.Println("inst:", inst)
  4699  	panic("emitInstPSHUFW: not yet implemented")
  4700  }
  4701  
  4702  // --- [ PSIGNB ] --------------------------------------------------------------
  4703  
  4704  // liftInstPSIGNB lifts the given x86 PSIGNB instruction to LLVM IR, emitting
  4705  // code to f.
  4706  func (f *Func) liftInstPSIGNB(inst *x86.Inst) error {
  4707  	pretty.Println("inst:", inst)
  4708  	panic("emitInstPSIGNB: not yet implemented")
  4709  }
  4710  
  4711  // --- [ PSIGND ] --------------------------------------------------------------
  4712  
  4713  // liftInstPSIGND lifts the given x86 PSIGND instruction to LLVM IR, emitting
  4714  // code to f.
  4715  func (f *Func) liftInstPSIGND(inst *x86.Inst) error {
  4716  	pretty.Println("inst:", inst)
  4717  	panic("emitInstPSIGND: not yet implemented")
  4718  }
  4719  
  4720  // --- [ PSIGNW ] --------------------------------------------------------------
  4721  
  4722  // liftInstPSIGNW lifts the given x86 PSIGNW instruction to LLVM IR, emitting
  4723  // code to f.
  4724  func (f *Func) liftInstPSIGNW(inst *x86.Inst) error {
  4725  	pretty.Println("inst:", inst)
  4726  	panic("emitInstPSIGNW: not yet implemented")
  4727  }
  4728  
  4729  // --- [ PSLLD ] ---------------------------------------------------------------
  4730  
  4731  // liftInstPSLLD lifts the given x86 PSLLD instruction to LLVM IR, emitting code
  4732  // to f.
  4733  func (f *Func) liftInstPSLLD(inst *x86.Inst) error {
  4734  	pretty.Println("inst:", inst)
  4735  	panic("emitInstPSLLD: not yet implemented")
  4736  }
  4737  
  4738  // --- [ PSLLDQ ] --------------------------------------------------------------
  4739  
  4740  // liftInstPSLLDQ lifts the given x86 PSLLDQ instruction to LLVM IR, emitting
  4741  // code to f.
  4742  func (f *Func) liftInstPSLLDQ(inst *x86.Inst) error {
  4743  	pretty.Println("inst:", inst)
  4744  	panic("emitInstPSLLDQ: not yet implemented")
  4745  }
  4746  
  4747  // --- [ PSLLQ ] ---------------------------------------------------------------
  4748  
  4749  // liftInstPSLLQ lifts the given x86 PSLLQ instruction to LLVM IR, emitting code
  4750  // to f.
  4751  func (f *Func) liftInstPSLLQ(inst *x86.Inst) error {
  4752  	pretty.Println("inst:", inst)
  4753  	panic("emitInstPSLLQ: not yet implemented")
  4754  }
  4755  
  4756  // --- [ PSLLW ] ---------------------------------------------------------------
  4757  
  4758  // liftInstPSLLW lifts the given x86 PSLLW instruction to LLVM IR, emitting code
  4759  // to f.
  4760  func (f *Func) liftInstPSLLW(inst *x86.Inst) error {
  4761  	pretty.Println("inst:", inst)
  4762  	panic("emitInstPSLLW: not yet implemented")
  4763  }
  4764  
  4765  // --- [ PSRAD ] ---------------------------------------------------------------
  4766  
  4767  // liftInstPSRAD lifts the given x86 PSRAD instruction to LLVM IR, emitting code
  4768  // to f.
  4769  func (f *Func) liftInstPSRAD(inst *x86.Inst) error {
  4770  	pretty.Println("inst:", inst)
  4771  	panic("emitInstPSRAD: not yet implemented")
  4772  }
  4773  
  4774  // --- [ PSRAW ] ---------------------------------------------------------------
  4775  
  4776  // liftInstPSRAW lifts the given x86 PSRAW instruction to LLVM IR, emitting code
  4777  // to f.
  4778  func (f *Func) liftInstPSRAW(inst *x86.Inst) error {
  4779  	pretty.Println("inst:", inst)
  4780  	panic("emitInstPSRAW: not yet implemented")
  4781  }
  4782  
  4783  // --- [ PSRLD ] ---------------------------------------------------------------
  4784  
  4785  // liftInstPSRLD lifts the given x86 PSRLD instruction to LLVM IR, emitting code
  4786  // to f.
  4787  func (f *Func) liftInstPSRLD(inst *x86.Inst) error {
  4788  	pretty.Println("inst:", inst)
  4789  	panic("emitInstPSRLD: not yet implemented")
  4790  }
  4791  
  4792  // --- [ PSRLDQ ] --------------------------------------------------------------
  4793  
  4794  // liftInstPSRLDQ lifts the given x86 PSRLDQ instruction to LLVM IR, emitting
  4795  // code to f.
  4796  func (f *Func) liftInstPSRLDQ(inst *x86.Inst) error {
  4797  	pretty.Println("inst:", inst)
  4798  	panic("emitInstPSRLDQ: not yet implemented")
  4799  }
  4800  
  4801  // --- [ PSRLQ ] ---------------------------------------------------------------
  4802  
  4803  // liftInstPSRLQ lifts the given x86 PSRLQ instruction to LLVM IR, emitting code
  4804  // to f.
  4805  func (f *Func) liftInstPSRLQ(inst *x86.Inst) error {
  4806  	pretty.Println("inst:", inst)
  4807  	panic("emitInstPSRLQ: not yet implemented")
  4808  }
  4809  
  4810  // --- [ PSRLW ] ---------------------------------------------------------------
  4811  
  4812  // liftInstPSRLW lifts the given x86 PSRLW instruction to LLVM IR, emitting code
  4813  // to f.
  4814  func (f *Func) liftInstPSRLW(inst *x86.Inst) error {
  4815  	pretty.Println("inst:", inst)
  4816  	panic("emitInstPSRLW: not yet implemented")
  4817  }
  4818  
  4819  // --- [ PSUBB ] ---------------------------------------------------------------
  4820  
  4821  // liftInstPSUBB lifts the given x86 PSUBB instruction to LLVM IR, emitting code
  4822  // to f.
  4823  func (f *Func) liftInstPSUBB(inst *x86.Inst) error {
  4824  	pretty.Println("inst:", inst)
  4825  	panic("emitInstPSUBB: not yet implemented")
  4826  }
  4827  
  4828  // --- [ PSUBD ] ---------------------------------------------------------------
  4829  
  4830  // liftInstPSUBD lifts the given x86 PSUBD instruction to LLVM IR, emitting code
  4831  // to f.
  4832  func (f *Func) liftInstPSUBD(inst *x86.Inst) error {
  4833  	pretty.Println("inst:", inst)
  4834  	panic("emitInstPSUBD: not yet implemented")
  4835  }
  4836  
  4837  // --- [ PSUBQ ] ---------------------------------------------------------------
  4838  
  4839  // liftInstPSUBQ lifts the given x86 PSUBQ instruction to LLVM IR, emitting code
  4840  // to f.
  4841  func (f *Func) liftInstPSUBQ(inst *x86.Inst) error {
  4842  	pretty.Println("inst:", inst)
  4843  	panic("emitInstPSUBQ: not yet implemented")
  4844  }
  4845  
  4846  // --- [ PSUBSB ] --------------------------------------------------------------
  4847  
  4848  // liftInstPSUBSB lifts the given x86 PSUBSB instruction to LLVM IR, emitting
  4849  // code to f.
  4850  func (f *Func) liftInstPSUBSB(inst *x86.Inst) error {
  4851  	pretty.Println("inst:", inst)
  4852  	panic("emitInstPSUBSB: not yet implemented")
  4853  }
  4854  
  4855  // --- [ PSUBSW ] --------------------------------------------------------------
  4856  
  4857  // liftInstPSUBSW lifts the given x86 PSUBSW instruction to LLVM IR, emitting
  4858  // code to f.
  4859  func (f *Func) liftInstPSUBSW(inst *x86.Inst) error {
  4860  	pretty.Println("inst:", inst)
  4861  	panic("emitInstPSUBSW: not yet implemented")
  4862  }
  4863  
  4864  // --- [ PSUBUSB ] -------------------------------------------------------------
  4865  
  4866  // liftInstPSUBUSB lifts the given x86 PSUBUSB instruction to LLVM IR, emitting
  4867  // code to f.
  4868  func (f *Func) liftInstPSUBUSB(inst *x86.Inst) error {
  4869  	pretty.Println("inst:", inst)
  4870  	panic("emitInstPSUBUSB: not yet implemented")
  4871  }
  4872  
  4873  // --- [ PSUBUSW ] -------------------------------------------------------------
  4874  
  4875  // liftInstPSUBUSW lifts the given x86 PSUBUSW instruction to LLVM IR, emitting
  4876  // code to f.
  4877  func (f *Func) liftInstPSUBUSW(inst *x86.Inst) error {
  4878  	pretty.Println("inst:", inst)
  4879  	panic("emitInstPSUBUSW: not yet implemented")
  4880  }
  4881  
  4882  // --- [ PSUBW ] ---------------------------------------------------------------
  4883  
  4884  // liftInstPSUBW lifts the given x86 PSUBW instruction to LLVM IR, emitting code
  4885  // to f.
  4886  func (f *Func) liftInstPSUBW(inst *x86.Inst) error {
  4887  	pretty.Println("inst:", inst)
  4888  	panic("emitInstPSUBW: not yet implemented")
  4889  }
  4890  
  4891  // --- [ PTEST ] ---------------------------------------------------------------
  4892  
  4893  // liftInstPTEST lifts the given x86 PTEST instruction to LLVM IR, emitting code
  4894  // to f.
  4895  func (f *Func) liftInstPTEST(inst *x86.Inst) error {
  4896  	pretty.Println("inst:", inst)
  4897  	panic("emitInstPTEST: not yet implemented")
  4898  }
  4899  
  4900  // --- [ PUNPCKHBW ] -----------------------------------------------------------
  4901  
  4902  // liftInstPUNPCKHBW lifts the given x86 PUNPCKHBW instruction to LLVM IR,
  4903  // emitting code to f.
  4904  func (f *Func) liftInstPUNPCKHBW(inst *x86.Inst) error {
  4905  	pretty.Println("inst:", inst)
  4906  	panic("emitInstPUNPCKHBW: not yet implemented")
  4907  }
  4908  
  4909  // --- [ PUNPCKHDQ ] -----------------------------------------------------------
  4910  
  4911  // liftInstPUNPCKHDQ lifts the given x86 PUNPCKHDQ instruction to LLVM IR,
  4912  // emitting code to f.
  4913  func (f *Func) liftInstPUNPCKHDQ(inst *x86.Inst) error {
  4914  	pretty.Println("inst:", inst)
  4915  	panic("emitInstPUNPCKHDQ: not yet implemented")
  4916  }
  4917  
  4918  // --- [ PUNPCKHQDQ ] ----------------------------------------------------------
  4919  
  4920  // liftInstPUNPCKHQDQ lifts the given x86 PUNPCKHQDQ instruction to LLVM IR,
  4921  // emitting code to f.
  4922  func (f *Func) liftInstPUNPCKHQDQ(inst *x86.Inst) error {
  4923  	pretty.Println("inst:", inst)
  4924  	panic("emitInstPUNPCKHQDQ: not yet implemented")
  4925  }
  4926  
  4927  // --- [ PUNPCKHWD ] -----------------------------------------------------------
  4928  
  4929  // liftInstPUNPCKHWD lifts the given x86 PUNPCKHWD instruction to LLVM IR,
  4930  // emitting code to f.
  4931  func (f *Func) liftInstPUNPCKHWD(inst *x86.Inst) error {
  4932  	pretty.Println("inst:", inst)
  4933  	panic("emitInstPUNPCKHWD: not yet implemented")
  4934  }
  4935  
  4936  // --- [ PUNPCKLBW ] -----------------------------------------------------------
  4937  
  4938  // liftInstPUNPCKLBW lifts the given x86 PUNPCKLBW instruction to LLVM IR,
  4939  // emitting code to f.
  4940  func (f *Func) liftInstPUNPCKLBW(inst *x86.Inst) error {
  4941  	pretty.Println("inst:", inst)
  4942  	panic("emitInstPUNPCKLBW: not yet implemented")
  4943  }
  4944  
  4945  // --- [ PUNPCKLDQ ] -----------------------------------------------------------
  4946  
  4947  // liftInstPUNPCKLDQ lifts the given x86 PUNPCKLDQ instruction to LLVM IR,
  4948  // emitting code to f.
  4949  func (f *Func) liftInstPUNPCKLDQ(inst *x86.Inst) error {
  4950  	pretty.Println("inst:", inst)
  4951  	panic("emitInstPUNPCKLDQ: not yet implemented")
  4952  }
  4953  
  4954  // --- [ PUNPCKLQDQ ] ----------------------------------------------------------
  4955  
  4956  // liftInstPUNPCKLQDQ lifts the given x86 PUNPCKLQDQ instruction to LLVM IR,
  4957  // emitting code to f.
  4958  func (f *Func) liftInstPUNPCKLQDQ(inst *x86.Inst) error {
  4959  	pretty.Println("inst:", inst)
  4960  	panic("emitInstPUNPCKLQDQ: not yet implemented")
  4961  }
  4962  
  4963  // --- [ PUNPCKLWD ] -----------------------------------------------------------
  4964  
  4965  // liftInstPUNPCKLWD lifts the given x86 PUNPCKLWD instruction to LLVM IR,
  4966  // emitting code to f.
  4967  func (f *Func) liftInstPUNPCKLWD(inst *x86.Inst) error {
  4968  	pretty.Println("inst:", inst)
  4969  	panic("emitInstPUNPCKLWD: not yet implemented")
  4970  }
  4971  
  4972  // --- [ PUSH ] ----------------------------------------------------------------
  4973  
  4974  // liftInstPUSH lifts the given x86 PUSH instruction to LLVM IR, emitting code
  4975  // to f.
  4976  func (f *Func) liftInstPUSH(inst *x86.Inst) error {
  4977  	v := f.useArg(inst.Arg(0))
  4978  	f.push(v)
  4979  	return nil
  4980  }
  4981  
  4982  // push pushes the given value onto the top of the stack of the function,
  4983  // emitting code to f.
  4984  func (f *Func) push(v value.Value) {
  4985  	m := x86asm.Mem{
  4986  		Base: x86asm.ESP,
  4987  		Disp: -4,
  4988  	}
  4989  	mem := x86.NewMem(m, nil)
  4990  	f.defMem(mem, v)
  4991  	f.espDisp -= 4
  4992  }
  4993  
  4994  // --- [ PUSHA ] ---------------------------------------------------------------
  4995  
  4996  // liftInstPUSHA lifts the given x86 PUSHA instruction to LLVM IR, emitting code
  4997  // to f.
  4998  func (f *Func) liftInstPUSHA(inst *x86.Inst) error {
  4999  	pretty.Println("inst:", inst)
  5000  	panic("emitInstPUSHA: not yet implemented")
  5001  }
  5002  
  5003  // --- [ PUSHAD ] --------------------------------------------------------------
  5004  
  5005  // liftInstPUSHAD lifts the given x86 PUSHAD instruction to LLVM IR, emitting
  5006  // code to f.
  5007  func (f *Func) liftInstPUSHAD(inst *x86.Inst) error {
  5008  	pretty.Println("inst:", inst)
  5009  	panic("emitInstPUSHAD: not yet implemented")
  5010  }
  5011  
  5012  // --- [ PUSHF ] ---------------------------------------------------------------
  5013  
  5014  // liftInstPUSHF lifts the given x86 PUSHF instruction to LLVM IR, emitting code
  5015  // to f.
  5016  func (f *Func) liftInstPUSHF(inst *x86.Inst) error {
  5017  	pretty.Println("inst:", inst)
  5018  	panic("emitInstPUSHF: not yet implemented")
  5019  }
  5020  
  5021  // --- [ PUSHFD ] --------------------------------------------------------------
  5022  
  5023  // liftInstPUSHFD lifts the given x86 PUSHFD instruction to LLVM IR, emitting
  5024  // code to f.
  5025  func (f *Func) liftInstPUSHFD(inst *x86.Inst) error {
  5026  	pretty.Println("inst:", inst)
  5027  	panic("emitInstPUSHFD: not yet implemented")
  5028  }
  5029  
  5030  // --- [ PUSHFQ ] --------------------------------------------------------------
  5031  
  5032  // liftInstPUSHFQ lifts the given x86 PUSHFQ instruction to LLVM IR, emitting
  5033  // code to f.
  5034  func (f *Func) liftInstPUSHFQ(inst *x86.Inst) error {
  5035  	pretty.Println("inst:", inst)
  5036  	panic("emitInstPUSHFQ: not yet implemented")
  5037  }
  5038  
  5039  // --- [ PXOR ] ----------------------------------------------------------------
  5040  
  5041  // liftInstPXOR lifts the given x86 PXOR instruction to LLVM IR, emitting code
  5042  // to f.
  5043  func (f *Func) liftInstPXOR(inst *x86.Inst) error {
  5044  	pretty.Println("inst:", inst)
  5045  	panic("emitInstPXOR: not yet implemented")
  5046  }
  5047  
  5048  // --- [ RCL ] -----------------------------------------------------------------
  5049  
  5050  // liftInstRCL lifts the given x86 RCL instruction to LLVM IR, emitting code to
  5051  // f.
  5052  func (f *Func) liftInstRCL(inst *x86.Inst) error {
  5053  	pretty.Println("inst:", inst)
  5054  	panic("emitInstRCL: not yet implemented")
  5055  }
  5056  
  5057  // --- [ RCPPS ] ---------------------------------------------------------------
  5058  
  5059  // liftInstRCPPS lifts the given x86 RCPPS instruction to LLVM IR, emitting code
  5060  // to f.
  5061  func (f *Func) liftInstRCPPS(inst *x86.Inst) error {
  5062  	pretty.Println("inst:", inst)
  5063  	panic("emitInstRCPPS: not yet implemented")
  5064  }
  5065  
  5066  // --- [ RCPSS ] ---------------------------------------------------------------
  5067  
  5068  // liftInstRCPSS lifts the given x86 RCPSS instruction to LLVM IR, emitting code
  5069  // to f.
  5070  func (f *Func) liftInstRCPSS(inst *x86.Inst) error {
  5071  	pretty.Println("inst:", inst)
  5072  	panic("emitInstRCPSS: not yet implemented")
  5073  }
  5074  
  5075  // --- [ RCR ] -----------------------------------------------------------------
  5076  
  5077  // liftInstRCR lifts the given x86 RCR instruction to LLVM IR, emitting code to
  5078  // f.
  5079  func (f *Func) liftInstRCR(inst *x86.Inst) error {
  5080  	pretty.Println("inst:", inst)
  5081  	panic("emitInstRCR: not yet implemented")
  5082  }
  5083  
  5084  // --- [ RDFSBASE ] ------------------------------------------------------------
  5085  
  5086  // liftInstRDFSBASE lifts the given x86 RDFSBASE instruction to LLVM IR,
  5087  // emitting code to f.
  5088  func (f *Func) liftInstRDFSBASE(inst *x86.Inst) error {
  5089  	pretty.Println("inst:", inst)
  5090  	panic("emitInstRDFSBASE: not yet implemented")
  5091  }
  5092  
  5093  // --- [ RDGSBASE ] ------------------------------------------------------------
  5094  
  5095  // liftInstRDGSBASE lifts the given x86 RDGSBASE instruction to LLVM IR,
  5096  // emitting code to f.
  5097  func (f *Func) liftInstRDGSBASE(inst *x86.Inst) error {
  5098  	pretty.Println("inst:", inst)
  5099  	panic("emitInstRDGSBASE: not yet implemented")
  5100  }
  5101  
  5102  // --- [ RDMSR ] ---------------------------------------------------------------
  5103  
  5104  // liftInstRDMSR lifts the given x86 RDMSR instruction to LLVM IR, emitting code
  5105  // to f.
  5106  func (f *Func) liftInstRDMSR(inst *x86.Inst) error {
  5107  	pretty.Println("inst:", inst)
  5108  	panic("emitInstRDMSR: not yet implemented")
  5109  }
  5110  
  5111  // --- [ RDPMC ] ---------------------------------------------------------------
  5112  
  5113  // liftInstRDPMC lifts the given x86 RDPMC instruction to LLVM IR, emitting code
  5114  // to f.
  5115  func (f *Func) liftInstRDPMC(inst *x86.Inst) error {
  5116  	pretty.Println("inst:", inst)
  5117  	panic("emitInstRDPMC: not yet implemented")
  5118  }
  5119  
  5120  // --- [ RDRAND ] --------------------------------------------------------------
  5121  
  5122  // liftInstRDRAND lifts the given x86 RDRAND instruction to LLVM IR, emitting
  5123  // code to f.
  5124  func (f *Func) liftInstRDRAND(inst *x86.Inst) error {
  5125  	pretty.Println("inst:", inst)
  5126  	panic("emitInstRDRAND: not yet implemented")
  5127  }
  5128  
  5129  // --- [ RDTSC ] ---------------------------------------------------------------
  5130  
  5131  // liftInstRDTSC lifts the given x86 RDTSC instruction to LLVM IR, emitting code
  5132  // to f.
  5133  func (f *Func) liftInstRDTSC(inst *x86.Inst) error {
  5134  	pretty.Println("inst:", inst)
  5135  	panic("emitInstRDTSC: not yet implemented")
  5136  }
  5137  
  5138  // --- [ RDTSCP ] --------------------------------------------------------------
  5139  
  5140  // liftInstRDTSCP lifts the given x86 RDTSCP instruction to LLVM IR, emitting
  5141  // code to f.
  5142  func (f *Func) liftInstRDTSCP(inst *x86.Inst) error {
  5143  	pretty.Println("inst:", inst)
  5144  	panic("emitInstRDTSCP: not yet implemented")
  5145  }
  5146  
  5147  // --- [ ROL ] -----------------------------------------------------------------
  5148  
  5149  // liftInstROL lifts the given x86 ROL instruction to LLVM IR, emitting code to
  5150  // f.
  5151  func (f *Func) liftInstROL(inst *x86.Inst) error {
  5152  	// rotate left (ROL)
  5153  	x, y := f.useArg(inst.Arg(0)), f.useArg(inst.Arg(1))
  5154  	high := f.cur.NewShl(x, y)
  5155  	typ, ok := y.Type().(*types.IntType)
  5156  	if !ok {
  5157  		panic(fmt.Errorf("invalid count operand type; expected *types.IntType, got %T", y.Type()))
  5158  	}
  5159  	bits := constant.NewInt(typ, int64(typ.BitSize))
  5160  	shift := f.cur.NewSub(bits, y)
  5161  	low := f.cur.NewLShr(x, shift)
  5162  	result := f.cur.NewOr(low, high)
  5163  	f.defArg(inst.Arg(0), result)
  5164  	return nil
  5165  }
  5166  
  5167  // --- [ ROR ] -----------------------------------------------------------------
  5168  
  5169  // liftInstROR lifts the given x86 ROR instruction to LLVM IR, emitting code to
  5170  // f.
  5171  func (f *Func) liftInstROR(inst *x86.Inst) error {
  5172  	// rotate right (ROR)
  5173  	x, y := f.useArg(inst.Arg(0)), f.useArg(inst.Arg(1))
  5174  	low := f.cur.NewLShr(x, y)
  5175  	typ, ok := y.Type().(*types.IntType)
  5176  	if !ok {
  5177  		panic(fmt.Errorf("invalid count operand type; expected *types.IntType, got %T", y.Type()))
  5178  	}
  5179  	bits := constant.NewInt(typ, int64(typ.BitSize))
  5180  	shift := f.cur.NewSub(bits, y)
  5181  	high := f.cur.NewShl(x, shift)
  5182  	result := f.cur.NewOr(low, high)
  5183  	f.defArg(inst.Arg(0), result)
  5184  	return nil
  5185  }
  5186  
  5187  // --- [ ROUNDPD ] -------------------------------------------------------------
  5188  
  5189  // liftInstROUNDPD lifts the given x86 ROUNDPD instruction to LLVM IR, emitting
  5190  // code to f.
  5191  func (f *Func) liftInstROUNDPD(inst *x86.Inst) error {
  5192  	pretty.Println("inst:", inst)
  5193  	panic("emitInstROUNDPD: not yet implemented")
  5194  }
  5195  
  5196  // --- [ ROUNDPS ] -------------------------------------------------------------
  5197  
  5198  // liftInstROUNDPS lifts the given x86 ROUNDPS instruction to LLVM IR, emitting
  5199  // code to f.
  5200  func (f *Func) liftInstROUNDPS(inst *x86.Inst) error {
  5201  	pretty.Println("inst:", inst)
  5202  	panic("emitInstROUNDPS: not yet implemented")
  5203  }
  5204  
  5205  // --- [ ROUNDSD ] -------------------------------------------------------------
  5206  
  5207  // liftInstROUNDSD lifts the given x86 ROUNDSD instruction to LLVM IR, emitting
  5208  // code to f.
  5209  func (f *Func) liftInstROUNDSD(inst *x86.Inst) error {
  5210  	pretty.Println("inst:", inst)
  5211  	panic("emitInstROUNDSD: not yet implemented")
  5212  }
  5213  
  5214  // --- [ ROUNDSS ] -------------------------------------------------------------
  5215  
  5216  // liftInstROUNDSS lifts the given x86 ROUNDSS instruction to LLVM IR, emitting
  5217  // code to f.
  5218  func (f *Func) liftInstROUNDSS(inst *x86.Inst) error {
  5219  	pretty.Println("inst:", inst)
  5220  	panic("emitInstROUNDSS: not yet implemented")
  5221  }
  5222  
  5223  // --- [ RSM ] -----------------------------------------------------------------
  5224  
  5225  // liftInstRSM lifts the given x86 RSM instruction to LLVM IR, emitting code to
  5226  // f.
  5227  func (f *Func) liftInstRSM(inst *x86.Inst) error {
  5228  	pretty.Println("inst:", inst)
  5229  	panic("emitInstRSM: not yet implemented")
  5230  }
  5231  
  5232  // --- [ RSQRTPS ] -------------------------------------------------------------
  5233  
  5234  // liftInstRSQRTPS lifts the given x86 RSQRTPS instruction to LLVM IR, emitting
  5235  // code to f.
  5236  func (f *Func) liftInstRSQRTPS(inst *x86.Inst) error {
  5237  	pretty.Println("inst:", inst)
  5238  	panic("emitInstRSQRTPS: not yet implemented")
  5239  }
  5240  
  5241  // --- [ RSQRTSS ] -------------------------------------------------------------
  5242  
  5243  // liftInstRSQRTSS lifts the given x86 RSQRTSS instruction to LLVM IR, emitting
  5244  // code to f.
  5245  func (f *Func) liftInstRSQRTSS(inst *x86.Inst) error {
  5246  	pretty.Println("inst:", inst)
  5247  	panic("emitInstRSQRTSS: not yet implemented")
  5248  }
  5249  
  5250  // --- [ SAHF ] ----------------------------------------------------------------
  5251  
  5252  // liftInstSAHF lifts the given x86 SAHF instruction to LLVM IR, emitting code
  5253  // to f.
  5254  func (f *Func) liftInstSAHF(inst *x86.Inst) error {
  5255  	pretty.Println("inst:", inst)
  5256  	panic("emitInstSAHF: not yet implemented")
  5257  }
  5258  
  5259  // --- [ SAR ] -----------------------------------------------------------------
  5260  
  5261  // liftInstSAR lifts the given x86 SAR instruction to LLVM IR, emitting code to
  5262  // f.
  5263  func (f *Func) liftInstSAR(inst *x86.Inst) error {
  5264  	// shift arithmetic right (SAR)
  5265  	x, y := f.useArg(inst.Arg(0)), f.useArg(inst.Arg(1))
  5266  	result := f.cur.NewAShr(x, y)
  5267  	f.defArg(inst.Arg(0), result)
  5268  	return nil
  5269  }
  5270  
  5271  // --- [ SBB ] -----------------------------------------------------------------
  5272  
  5273  // liftInstSBB lifts the given x86 SBB instruction to LLVM IR, emitting code to
  5274  // f.
  5275  func (f *Func) liftInstSBB(inst *x86.Inst) error {
  5276  	// SBB - Integer Subtraction with Borrow.
  5277  	//
  5278  	//    SBB AL, imm8        Subtract with borrow imm8 from AL.
  5279  	//    SBB AX, imm16       Subtract with borrow imm16 from AX.
  5280  	//    SBB EAX, imm32      Subtract with borrow imm32 from EAX.
  5281  	//    SBB RAX, imm32      Subtract with borrow sign-extended imm.32 to 64-bits from RAX.
  5282  	//    SBB r/m8, imm8      Subtract with borrow imm8 from r/m8.
  5283  	//    SBB r/m8*, imm8     Subtract with borrow imm8 from r/m8.
  5284  	//    SBB r/m16, imm16    Subtract with borrow imm16 from r/m16.
  5285  	//    SBB r/m32, imm32    Subtract with borrow imm32 from r/m32.
  5286  	//    SBB r/m64, imm32    Subtract with borrow sign-extended imm32 to 64-bits from r/m64.
  5287  	//    SBB r/m16, imm8     Subtract with borrow sign-extended imm8 from r/m16.
  5288  	//    SBB r/m32, imm8     Subtract with borrow sign-extended imm8 from r/m32.
  5289  	//    SBB r/m64, imm8     Subtract with borrow sign-extended imm8 from r/m64.
  5290  	//    SBB r/m8, r8        Subtract with borrow r8 from r/m8.
  5291  	//    SBB r/m8*, r8       Subtract with borrow r8 from r/m8.
  5292  	//    SBB r/m16, r16      Subtract with borrow r16 from r/m16.
  5293  	//    SBB r/m32, r32      Subtract with borrow r32 from r/m32.
  5294  	//    SBB r/m64, r64      Subtract with borrow r64 from r/m64.
  5295  	//    SBB r8, r/m8        Subtract with borrow r/m8 from r8.
  5296  	//    SBB r8*, r/m8*      Subtract with borrow r/m8 from r8.
  5297  	//    SBB r16, r/m16      Subtract with borrow r/m16 from r16.
  5298  	//    SBB r32, r/m32      Subtract with borrow r/m32 from r32.
  5299  	//    SBB r64, r/m64      Subtract with borrow r/m64 from r64.
  5300  	//
  5301  	// Adds the source operand (second operand) and the carry (CF) flag, and
  5302  	// subtracts the result from the destination operand (first operand). The
  5303  	// result of the subtraction is stored in the destination operand.
  5304  	dst := f.useArg(inst.Arg(0))
  5305  	src := f.useArg(inst.Arg(1))
  5306  	cf := f.useStatus(CF)
  5307  	v := f.cur.NewAdd(src, cf)
  5308  	result := f.cur.NewSub(dst, v)
  5309  	f.defArg(inst.Arg(0), result)
  5310  	return nil
  5311  }
  5312  
  5313  // --- [ SCASB ] ---------------------------------------------------------------
  5314  
  5315  // liftInstSCASB lifts the given x86 SCASB instruction to LLVM IR, emitting code
  5316  // to f.
  5317  func (f *Func) liftInstSCASB(inst *x86.Inst) error {
  5318  	pretty.Println("inst:", inst)
  5319  	panic("emitInstSCASB: not yet implemented")
  5320  }
  5321  
  5322  // --- [ SCASD ] ---------------------------------------------------------------
  5323  
  5324  // liftInstSCASD lifts the given x86 SCASD instruction to LLVM IR, emitting code
  5325  // to f.
  5326  func (f *Func) liftInstSCASD(inst *x86.Inst) error {
  5327  	pretty.Println("inst:", inst)
  5328  	panic("emitInstSCASD: not yet implemented")
  5329  }
  5330  
  5331  // --- [ SCASQ ] ---------------------------------------------------------------
  5332  
  5333  // liftInstSCASQ lifts the given x86 SCASQ instruction to LLVM IR, emitting code
  5334  // to f.
  5335  func (f *Func) liftInstSCASQ(inst *x86.Inst) error {
  5336  	pretty.Println("inst:", inst)
  5337  	panic("emitInstSCASQ: not yet implemented")
  5338  }
  5339  
  5340  // --- [ SCASW ] ---------------------------------------------------------------
  5341  
  5342  // liftInstSCASW lifts the given x86 SCASW instruction to LLVM IR, emitting code
  5343  // to f.
  5344  func (f *Func) liftInstSCASW(inst *x86.Inst) error {
  5345  	pretty.Println("inst:", inst)
  5346  	panic("emitInstSCASW: not yet implemented")
  5347  }
  5348  
  5349  // --- [ SFENCE ] --------------------------------------------------------------
  5350  
  5351  // liftInstSFENCE lifts the given x86 SFENCE instruction to LLVM IR, emitting
  5352  // code to f.
  5353  func (f *Func) liftInstSFENCE(inst *x86.Inst) error {
  5354  	pretty.Println("inst:", inst)
  5355  	panic("emitInstSFENCE: not yet implemented")
  5356  }
  5357  
  5358  // --- [ SGDT ] ----------------------------------------------------------------
  5359  
  5360  // liftInstSGDT lifts the given x86 SGDT instruction to LLVM IR, emitting code
  5361  // to f.
  5362  func (f *Func) liftInstSGDT(inst *x86.Inst) error {
  5363  	pretty.Println("inst:", inst)
  5364  	panic("emitInstSGDT: not yet implemented")
  5365  }
  5366  
  5367  // --- [ SHL ] -----------------------------------------------------------------
  5368  
  5369  // liftInstSHL lifts the given x86 SHL instruction to LLVM IR, emitting code to
  5370  // f.
  5371  func (f *Func) liftInstSHL(inst *x86.Inst) error {
  5372  	// shift logical left (SHL)
  5373  	x, y := f.useArg(inst.Arg(0)), f.useArg(inst.Arg(1))
  5374  	result := f.cur.NewShl(x, y)
  5375  	f.defArg(inst.Arg(0), result)
  5376  	return nil
  5377  }
  5378  
  5379  // --- [ SHLD ] ----------------------------------------------------------------
  5380  
  5381  // liftInstSHLD lifts the given x86 SHLD instruction to LLVM IR, emitting code
  5382  // to f.
  5383  func (f *Func) liftInstSHLD(inst *x86.Inst) error {
  5384  	// SHLD - Double Precision Shift Left
  5385  	//
  5386  	//    SHLD a1, a2, a3
  5387  	//
  5388  	// Shift a1 to left a3 places while shifting bits from a2 in from the right.
  5389  	a1, a2, a3 := f.useArg(inst.Arg(0)), f.useArg(inst.Arg(1)), f.useArg(inst.Arg(2))
  5390  	tmp1 := f.cur.NewZExt(a1, types.I64)
  5391  	n32 := constant.NewInt(types.I64, 32)
  5392  	high := f.cur.NewShl(tmp1, n32)
  5393  	low := f.cur.NewZExt(a2, types.I64)
  5394  	tmp3 := f.cur.NewOr(high, low)
  5395  	tmp4 := f.cur.NewShl(tmp3, a3)
  5396  	tmp5 := f.cur.NewLShr(tmp4, n32)
  5397  	result := f.cur.NewTrunc(tmp5, types.I32)
  5398  	f.defArg(inst.Arg(0), result)
  5399  	return nil
  5400  }
  5401  
  5402  // --- [ SHR ] -----------------------------------------------------------------
  5403  
  5404  // liftInstSHR lifts the given x86 SHR instruction to LLVM IR, emitting code to
  5405  // f.
  5406  func (f *Func) liftInstSHR(inst *x86.Inst) error {
  5407  	// shift logical right (SHR)
  5408  	x, y := f.useArg(inst.Arg(0)), f.useArg(inst.Arg(1))
  5409  	result := f.cur.NewLShr(x, y)
  5410  	f.defArg(inst.Arg(0), result)
  5411  	return nil
  5412  }
  5413  
  5414  // --- [ SHRD ] ----------------------------------------------------------------
  5415  
  5416  // liftInstSHRD lifts the given x86 SHRD instruction to LLVM IR, emitting code
  5417  // to f.
  5418  func (f *Func) liftInstSHRD(inst *x86.Inst) error {
  5419  	pretty.Println("inst:", inst)
  5420  	panic("emitInstSHRD: not yet implemented")
  5421  }
  5422  
  5423  // --- [ SHUFPD ] --------------------------------------------------------------
  5424  
  5425  // liftInstSHUFPD lifts the given x86 SHUFPD instruction to LLVM IR, emitting
  5426  // code to f.
  5427  func (f *Func) liftInstSHUFPD(inst *x86.Inst) error {
  5428  	pretty.Println("inst:", inst)
  5429  	panic("emitInstSHUFPD: not yet implemented")
  5430  }
  5431  
  5432  // --- [ SHUFPS ] --------------------------------------------------------------
  5433  
  5434  // liftInstSHUFPS lifts the given x86 SHUFPS instruction to LLVM IR, emitting
  5435  // code to f.
  5436  func (f *Func) liftInstSHUFPS(inst *x86.Inst) error {
  5437  	pretty.Println("inst:", inst)
  5438  	panic("emitInstSHUFPS: not yet implemented")
  5439  }
  5440  
  5441  // --- [ SIDT ] ----------------------------------------------------------------
  5442  
  5443  // liftInstSIDT lifts the given x86 SIDT instruction to LLVM IR, emitting code
  5444  // to f.
  5445  func (f *Func) liftInstSIDT(inst *x86.Inst) error {
  5446  	pretty.Println("inst:", inst)
  5447  	panic("emitInstSIDT: not yet implemented")
  5448  }
  5449  
  5450  // --- [ SLDT ] ----------------------------------------------------------------
  5451  
  5452  // liftInstSLDT lifts the given x86 SLDT instruction to LLVM IR, emitting code
  5453  // to f.
  5454  func (f *Func) liftInstSLDT(inst *x86.Inst) error {
  5455  	pretty.Println("inst:", inst)
  5456  	panic("emitInstSLDT: not yet implemented")
  5457  }
  5458  
  5459  // --- [ SMSW ] ----------------------------------------------------------------
  5460  
  5461  // liftInstSMSW lifts the given x86 SMSW instruction to LLVM IR, emitting code
  5462  // to f.
  5463  func (f *Func) liftInstSMSW(inst *x86.Inst) error {
  5464  	pretty.Println("inst:", inst)
  5465  	panic("emitInstSMSW: not yet implemented")
  5466  }
  5467  
  5468  // --- [ SQRTPD ] --------------------------------------------------------------
  5469  
  5470  // liftInstSQRTPD lifts the given x86 SQRTPD instruction to LLVM IR, emitting
  5471  // code to f.
  5472  func (f *Func) liftInstSQRTPD(inst *x86.Inst) error {
  5473  	pretty.Println("inst:", inst)
  5474  	panic("emitInstSQRTPD: not yet implemented")
  5475  }
  5476  
  5477  // --- [ SQRTPS ] --------------------------------------------------------------
  5478  
  5479  // liftInstSQRTPS lifts the given x86 SQRTPS instruction to LLVM IR, emitting
  5480  // code to f.
  5481  func (f *Func) liftInstSQRTPS(inst *x86.Inst) error {
  5482  	pretty.Println("inst:", inst)
  5483  	panic("emitInstSQRTPS: not yet implemented")
  5484  }
  5485  
  5486  // --- [ SQRTSD ] --------------------------------------------------------------
  5487  
  5488  // liftInstSQRTSD lifts the given x86 SQRTSD instruction to LLVM IR, emitting
  5489  // code to f.
  5490  func (f *Func) liftInstSQRTSD(inst *x86.Inst) error {
  5491  	pretty.Println("inst:", inst)
  5492  	panic("emitInstSQRTSD: not yet implemented")
  5493  }
  5494  
  5495  // --- [ SQRTSS ] --------------------------------------------------------------
  5496  
  5497  // liftInstSQRTSS lifts the given x86 SQRTSS instruction to LLVM IR, emitting
  5498  // code to f.
  5499  func (f *Func) liftInstSQRTSS(inst *x86.Inst) error {
  5500  	pretty.Println("inst:", inst)
  5501  	panic("emitInstSQRTSS: not yet implemented")
  5502  }
  5503  
  5504  // --- [ STC ] -----------------------------------------------------------------
  5505  
  5506  // liftInstSTC lifts the given x86 STC instruction to LLVM IR, emitting code to
  5507  // f.
  5508  func (f *Func) liftInstSTC(inst *x86.Inst) error {
  5509  	pretty.Println("inst:", inst)
  5510  	panic("emitInstSTC: not yet implemented")
  5511  }
  5512  
  5513  // --- [ STD ] -----------------------------------------------------------------
  5514  
  5515  // liftInstSTD lifts the given x86 STD instruction to LLVM IR, emitting code to
  5516  // f.
  5517  func (f *Func) liftInstSTD(inst *x86.Inst) error {
  5518  	pretty.Println("inst:", inst)
  5519  	panic("emitInstSTD: not yet implemented")
  5520  }
  5521  
  5522  // --- [ STI ] -----------------------------------------------------------------
  5523  
  5524  // liftInstSTI lifts the given x86 STI instruction to LLVM IR, emitting code to
  5525  // f.
  5526  func (f *Func) liftInstSTI(inst *x86.Inst) error {
  5527  	pretty.Println("inst:", inst)
  5528  	panic("emitInstSTI: not yet implemented")
  5529  }
  5530  
  5531  // --- [ STMXCSR ] -------------------------------------------------------------
  5532  
  5533  // liftInstSTMXCSR lifts the given x86 STMXCSR instruction to LLVM IR, emitting
  5534  // code to f.
  5535  func (f *Func) liftInstSTMXCSR(inst *x86.Inst) error {
  5536  	pretty.Println("inst:", inst)
  5537  	panic("emitInstSTMXCSR: not yet implemented")
  5538  }
  5539  
  5540  // --- [ STOSB ] ---------------------------------------------------------------
  5541  
  5542  // liftInstSTOSB lifts the given x86 STOSB instruction to LLVM IR, emitting code
  5543  // to f.
  5544  func (f *Func) liftInstSTOSB(inst *x86.Inst) error {
  5545  	src := f.useArg(inst.Arg(1))
  5546  	f.defArgElem(inst.Arg(0), src, types.I8)
  5547  	return nil
  5548  }
  5549  
  5550  // --- [ STOSD ] ---------------------------------------------------------------
  5551  
  5552  // liftInstSTOSD lifts the given x86 STOSD instruction to LLVM IR, emitting code
  5553  // to f.
  5554  func (f *Func) liftInstSTOSD(inst *x86.Inst) error {
  5555  	src := f.useArg(inst.Arg(1))
  5556  	f.defArgElem(inst.Arg(0), src, types.I32)
  5557  	return nil
  5558  }
  5559  
  5560  // --- [ STOSQ ] ---------------------------------------------------------------
  5561  
  5562  // liftInstSTOSQ lifts the given x86 STOSQ instruction to LLVM IR, emitting code
  5563  // to f.
  5564  func (f *Func) liftInstSTOSQ(inst *x86.Inst) error {
  5565  	src := f.useArg(inst.Arg(1))
  5566  	f.defArgElem(inst.Arg(0), src, types.I64)
  5567  	return nil
  5568  }
  5569  
  5570  // --- [ STOSW ] ---------------------------------------------------------------
  5571  
  5572  // liftInstSTOSW lifts the given x86 STOSW instruction to LLVM IR, emitting code
  5573  // to f.
  5574  func (f *Func) liftInstSTOSW(inst *x86.Inst) error {
  5575  	src := f.useArg(inst.Arg(1))
  5576  	f.defArgElem(inst.Arg(0), src, types.I16)
  5577  	return nil
  5578  }
  5579  
  5580  // --- [ STR ] -----------------------------------------------------------------
  5581  
  5582  // liftInstSTR lifts the given x86 STR instruction to LLVM IR, emitting code to
  5583  // f.
  5584  func (f *Func) liftInstSTR(inst *x86.Inst) error {
  5585  	pretty.Println("inst:", inst)
  5586  	panic("emitInstSTR: not yet implemented")
  5587  }
  5588  
  5589  // --- [ SUB ] -----------------------------------------------------------------
  5590  
  5591  // liftInstSUB lifts the given x86 SUB instruction to LLVM IR, emitting code to
  5592  // f.
  5593  func (f *Func) liftInstSUB(inst *x86.Inst) error {
  5594  	x, y := f.useArg(inst.Arg(0)), f.useArg(inst.Arg(1))
  5595  	result := f.cur.NewSub(x, y)
  5596  	f.defArg(inst.Arg(0), result)
  5597  	return nil
  5598  }
  5599  
  5600  // --- [ SUBPD ] ---------------------------------------------------------------
  5601  
  5602  // liftInstSUBPD lifts the given x86 SUBPD instruction to LLVM IR, emitting code
  5603  // to f.
  5604  func (f *Func) liftInstSUBPD(inst *x86.Inst) error {
  5605  	pretty.Println("inst:", inst)
  5606  	panic("emitInstSUBPD: not yet implemented")
  5607  }
  5608  
  5609  // --- [ SUBPS ] ---------------------------------------------------------------
  5610  
  5611  // liftInstSUBPS lifts the given x86 SUBPS instruction to LLVM IR, emitting code
  5612  // to f.
  5613  func (f *Func) liftInstSUBPS(inst *x86.Inst) error {
  5614  	pretty.Println("inst:", inst)
  5615  	panic("emitInstSUBPS: not yet implemented")
  5616  }
  5617  
  5618  // --- [ SUBSD ] ---------------------------------------------------------------
  5619  
  5620  // liftInstSUBSD lifts the given x86 SUBSD instruction to LLVM IR, emitting code
  5621  // to f.
  5622  func (f *Func) liftInstSUBSD(inst *x86.Inst) error {
  5623  	pretty.Println("inst:", inst)
  5624  	panic("emitInstSUBSD: not yet implemented")
  5625  }
  5626  
  5627  // --- [ SUBSS ] ---------------------------------------------------------------
  5628  
  5629  // liftInstSUBSS lifts the given x86 SUBSS instruction to LLVM IR, emitting code
  5630  // to f.
  5631  func (f *Func) liftInstSUBSS(inst *x86.Inst) error {
  5632  	pretty.Println("inst:", inst)
  5633  	panic("emitInstSUBSS: not yet implemented")
  5634  }
  5635  
  5636  // --- [ SWAPGS ] --------------------------------------------------------------
  5637  
  5638  // liftInstSWAPGS lifts the given x86 SWAPGS instruction to LLVM IR, emitting
  5639  // code to f.
  5640  func (f *Func) liftInstSWAPGS(inst *x86.Inst) error {
  5641  	pretty.Println("inst:", inst)
  5642  	panic("emitInstSWAPGS: not yet implemented")
  5643  }
  5644  
  5645  // --- [ SYSCALL ] -------------------------------------------------------------
  5646  
  5647  // liftInstSYSCALL lifts the given x86 SYSCALL instruction to LLVM IR, emitting
  5648  // code to f.
  5649  func (f *Func) liftInstSYSCALL(inst *x86.Inst) error {
  5650  	pretty.Println("inst:", inst)
  5651  	panic("emitInstSYSCALL: not yet implemented")
  5652  }
  5653  
  5654  // --- [ SYSENTER ] ------------------------------------------------------------
  5655  
  5656  // liftInstSYSENTER lifts the given x86 SYSENTER instruction to LLVM IR,
  5657  // emitting code to f.
  5658  func (f *Func) liftInstSYSENTER(inst *x86.Inst) error {
  5659  	pretty.Println("inst:", inst)
  5660  	panic("emitInstSYSENTER: not yet implemented")
  5661  }
  5662  
  5663  // --- [ SYSEXIT ] -------------------------------------------------------------
  5664  
  5665  // liftInstSYSEXIT lifts the given x86 SYSEXIT instruction to LLVM IR, emitting
  5666  // code to f.
  5667  func (f *Func) liftInstSYSEXIT(inst *x86.Inst) error {
  5668  	pretty.Println("inst:", inst)
  5669  	panic("emitInstSYSEXIT: not yet implemented")
  5670  }
  5671  
  5672  // --- [ SYSRET ] --------------------------------------------------------------
  5673  
  5674  // liftInstSYSRET lifts the given x86 SYSRET instruction to LLVM IR, emitting
  5675  // code to f.
  5676  func (f *Func) liftInstSYSRET(inst *x86.Inst) error {
  5677  	pretty.Println("inst:", inst)
  5678  	panic("emitInstSYSRET: not yet implemented")
  5679  }
  5680  
  5681  // --- [ TEST ] ----------------------------------------------------------------
  5682  
  5683  // liftInstTEST lifts the given x86 TEST instruction to LLVM IR, emitting code
  5684  // to f.
  5685  func (f *Func) liftInstTEST(inst *x86.Inst) error {
  5686  	// result = x AND y; set PF, ZF, and SF according to result.
  5687  	x, y := f.useArg(inst.Arg(0)), f.useArg(inst.Arg(1))
  5688  	result := f.cur.NewAnd(x, y)
  5689  
  5690  	// PF (bit 2) Parity flag - Set if the least-significant byte of the result
  5691  	// contains an even number of 1 bits; cleared otherwise.
  5692  
  5693  	// TODO: Add support for the PF status flag.
  5694  
  5695  	// ZF (bit 6) Zero flag - Set if the result is zero; cleared otherwise.
  5696  	zero := constant.NewInt(types.I32, 0)
  5697  	zf := f.cur.NewICmp(enum.IPredEQ, result, zero)
  5698  	f.defStatus(ZF, zf)
  5699  
  5700  	// SF (bit 7) Sign flag - Set equal to the most-significant bit of the
  5701  	// result, which is the sign bit of a signed integer. (0 indicates a positive
  5702  	// value and 1 indicates a negative value.)
  5703  
  5704  	// TODO: Add support for the SF flag.
  5705  
  5706  	return nil
  5707  
  5708  }
  5709  
  5710  // --- [ TZCNT ] ---------------------------------------------------------------
  5711  
  5712  // liftInstTZCNT lifts the given x86 TZCNT instruction to LLVM IR, emitting code
  5713  // to f.
  5714  func (f *Func) liftInstTZCNT(inst *x86.Inst) error {
  5715  	pretty.Println("inst:", inst)
  5716  	panic("emitInstTZCNT: not yet implemented")
  5717  }
  5718  
  5719  // --- [ UCOMISD ] -------------------------------------------------------------
  5720  
  5721  // liftInstUCOMISD lifts the given x86 UCOMISD instruction to LLVM IR, emitting
  5722  // code to f.
  5723  func (f *Func) liftInstUCOMISD(inst *x86.Inst) error {
  5724  	pretty.Println("inst:", inst)
  5725  	panic("emitInstUCOMISD: not yet implemented")
  5726  }
  5727  
  5728  // --- [ UCOMISS ] -------------------------------------------------------------
  5729  
  5730  // liftInstUCOMISS lifts the given x86 UCOMISS instruction to LLVM IR, emitting
  5731  // code to f.
  5732  func (f *Func) liftInstUCOMISS(inst *x86.Inst) error {
  5733  	pretty.Println("inst:", inst)
  5734  	panic("emitInstUCOMISS: not yet implemented")
  5735  }
  5736  
  5737  // --- [ UD1 ] -----------------------------------------------------------------
  5738  
  5739  // liftInstUD1 lifts the given x86 UD1 instruction to LLVM IR, emitting code to
  5740  // f.
  5741  func (f *Func) liftInstUD1(inst *x86.Inst) error {
  5742  	pretty.Println("inst:", inst)
  5743  	panic("emitInstUD1: not yet implemented")
  5744  }
  5745  
  5746  // --- [ UD2 ] -----------------------------------------------------------------
  5747  
  5748  // liftInstUD2 lifts the given x86 UD2 instruction to LLVM IR, emitting code to
  5749  // f.
  5750  func (f *Func) liftInstUD2(inst *x86.Inst) error {
  5751  	pretty.Println("inst:", inst)
  5752  	panic("emitInstUD2: not yet implemented")
  5753  }
  5754  
  5755  // --- [ UNPCKHPD ] ------------------------------------------------------------
  5756  
  5757  // liftInstUNPCKHPD lifts the given x86 UNPCKHPD instruction to LLVM IR,
  5758  // emitting code to f.
  5759  func (f *Func) liftInstUNPCKHPD(inst *x86.Inst) error {
  5760  	pretty.Println("inst:", inst)
  5761  	panic("emitInstUNPCKHPD: not yet implemented")
  5762  }
  5763  
  5764  // --- [ UNPCKHPS ] ------------------------------------------------------------
  5765  
  5766  // liftInstUNPCKHPS lifts the given x86 UNPCKHPS instruction to LLVM IR,
  5767  // emitting code to f.
  5768  func (f *Func) liftInstUNPCKHPS(inst *x86.Inst) error {
  5769  	pretty.Println("inst:", inst)
  5770  	panic("emitInstUNPCKHPS: not yet implemented")
  5771  }
  5772  
  5773  // --- [ UNPCKLPD ] ------------------------------------------------------------
  5774  
  5775  // liftInstUNPCKLPD lifts the given x86 UNPCKLPD instruction to LLVM IR,
  5776  // emitting code to f.
  5777  func (f *Func) liftInstUNPCKLPD(inst *x86.Inst) error {
  5778  	pretty.Println("inst:", inst)
  5779  	panic("emitInstUNPCKLPD: not yet implemented")
  5780  }
  5781  
  5782  // --- [ UNPCKLPS ] ------------------------------------------------------------
  5783  
  5784  // liftInstUNPCKLPS lifts the given x86 UNPCKLPS instruction to LLVM IR,
  5785  // emitting code to f.
  5786  func (f *Func) liftInstUNPCKLPS(inst *x86.Inst) error {
  5787  	pretty.Println("inst:", inst)
  5788  	panic("emitInstUNPCKLPS: not yet implemented")
  5789  }
  5790  
  5791  // --- [ VERR ] ----------------------------------------------------------------
  5792  
  5793  // liftInstVERR lifts the given x86 VERR instruction to LLVM IR, emitting code
  5794  // to f.
  5795  func (f *Func) liftInstVERR(inst *x86.Inst) error {
  5796  	pretty.Println("inst:", inst)
  5797  	panic("emitInstVERR: not yet implemented")
  5798  }
  5799  
  5800  // --- [ VERW ] ----------------------------------------------------------------
  5801  
  5802  // liftInstVERW lifts the given x86 VERW instruction to LLVM IR, emitting code
  5803  // to f.
  5804  func (f *Func) liftInstVERW(inst *x86.Inst) error {
  5805  	pretty.Println("inst:", inst)
  5806  	panic("emitInstVERW: not yet implemented")
  5807  }
  5808  
  5809  // --- [ VMOVDQA ] -------------------------------------------------------------
  5810  
  5811  // liftInstVMOVDQA lifts the given x86 VMOVDQA instruction to LLVM IR, emitting
  5812  // code to f.
  5813  func (f *Func) liftInstVMOVDQA(inst *x86.Inst) error {
  5814  	pretty.Println("inst:", inst)
  5815  	panic("emitInstVMOVDQA: not yet implemented")
  5816  }
  5817  
  5818  // --- [ VMOVDQU ] -------------------------------------------------------------
  5819  
  5820  // liftInstVMOVDQU lifts the given x86 VMOVDQU instruction to LLVM IR, emitting
  5821  // code to f.
  5822  func (f *Func) liftInstVMOVDQU(inst *x86.Inst) error {
  5823  	pretty.Println("inst:", inst)
  5824  	panic("emitInstVMOVDQU: not yet implemented")
  5825  }
  5826  
  5827  // --- [ VMOVNTDQ ] ------------------------------------------------------------
  5828  
  5829  // liftInstVMOVNTDQ lifts the given x86 VMOVNTDQ instruction to LLVM IR,
  5830  // emitting code to f.
  5831  func (f *Func) liftInstVMOVNTDQ(inst *x86.Inst) error {
  5832  	pretty.Println("inst:", inst)
  5833  	panic("emitInstVMOVNTDQ: not yet implemented")
  5834  }
  5835  
  5836  // --- [ VMOVNTDQA ] -----------------------------------------------------------
  5837  
  5838  // liftInstVMOVNTDQA lifts the given x86 VMOVNTDQA instruction to LLVM IR,
  5839  // emitting code to f.
  5840  func (f *Func) liftInstVMOVNTDQA(inst *x86.Inst) error {
  5841  	pretty.Println("inst:", inst)
  5842  	panic("emitInstVMOVNTDQA: not yet implemented")
  5843  }
  5844  
  5845  // --- [ VZEROUPPER ] ----------------------------------------------------------
  5846  
  5847  // liftInstVZEROUPPER lifts the given x86 VZEROUPPER instruction to LLVM IR,
  5848  // emitting code to f.
  5849  func (f *Func) liftInstVZEROUPPER(inst *x86.Inst) error {
  5850  	pretty.Println("inst:", inst)
  5851  	panic("emitInstVZEROUPPER: not yet implemented")
  5852  }
  5853  
  5854  // --- [ WBINVD ] --------------------------------------------------------------
  5855  
  5856  // liftInstWBINVD lifts the given x86 WBINVD instruction to LLVM IR, emitting
  5857  // code to f.
  5858  func (f *Func) liftInstWBINVD(inst *x86.Inst) error {
  5859  	pretty.Println("inst:", inst)
  5860  	panic("emitInstWBINVD: not yet implemented")
  5861  }
  5862  
  5863  // --- [ WRFSBASE ] ------------------------------------------------------------
  5864  
  5865  // liftInstWRFSBASE lifts the given x86 WRFSBASE instruction to LLVM IR,
  5866  // emitting code to f.
  5867  func (f *Func) liftInstWRFSBASE(inst *x86.Inst) error {
  5868  	pretty.Println("inst:", inst)
  5869  	panic("emitInstWRFSBASE: not yet implemented")
  5870  }
  5871  
  5872  // --- [ WRGSBASE ] ------------------------------------------------------------
  5873  
  5874  // liftInstWRGSBASE lifts the given x86 WRGSBASE instruction to LLVM IR,
  5875  // emitting code to f.
  5876  func (f *Func) liftInstWRGSBASE(inst *x86.Inst) error {
  5877  	pretty.Println("inst:", inst)
  5878  	panic("emitInstWRGSBASE: not yet implemented")
  5879  }
  5880  
  5881  // --- [ WRMSR ] ---------------------------------------------------------------
  5882  
  5883  // liftInstWRMSR lifts the given x86 WRMSR instruction to LLVM IR, emitting code
  5884  // to f.
  5885  func (f *Func) liftInstWRMSR(inst *x86.Inst) error {
  5886  	pretty.Println("inst:", inst)
  5887  	panic("emitInstWRMSR: not yet implemented")
  5888  }
  5889  
  5890  // --- [ XABORT ] --------------------------------------------------------------
  5891  
  5892  // liftInstXABORT lifts the given x86 XABORT instruction to LLVM IR, emitting
  5893  // code to f.
  5894  func (f *Func) liftInstXABORT(inst *x86.Inst) error {
  5895  	pretty.Println("inst:", inst)
  5896  	panic("emitInstXABORT: not yet implemented")
  5897  }
  5898  
  5899  // --- [ XADD ] ----------------------------------------------------------------
  5900  
  5901  // liftInstXADD lifts the given x86 XADD instruction to LLVM IR, emitting code
  5902  // to f.
  5903  func (f *Func) liftInstXADD(inst *x86.Inst) error {
  5904  	pretty.Println("inst:", inst)
  5905  	panic("emitInstXADD: not yet implemented")
  5906  }
  5907  
  5908  // --- [ XBEGIN ] --------------------------------------------------------------
  5909  
  5910  // liftInstXBEGIN lifts the given x86 XBEGIN instruction to LLVM IR, emitting
  5911  // code to f.
  5912  func (f *Func) liftInstXBEGIN(inst *x86.Inst) error {
  5913  	pretty.Println("inst:", inst)
  5914  	panic("emitInstXBEGIN: not yet implemented")
  5915  }
  5916  
  5917  // --- [ XCHG ] ----------------------------------------------------------------
  5918  
  5919  // liftInstXCHG lifts the given x86 XCHG instruction to LLVM IR, emitting code
  5920  // to f.
  5921  func (f *Func) liftInstXCHG(inst *x86.Inst) error {
  5922  	pretty.Println("inst:", inst)
  5923  	panic("emitInstXCHG: not yet implemented")
  5924  }
  5925  
  5926  // --- [ XEND ] ----------------------------------------------------------------
  5927  
  5928  // liftInstXEND lifts the given x86 XEND instruction to LLVM IR, emitting code
  5929  // to f.
  5930  func (f *Func) liftInstXEND(inst *x86.Inst) error {
  5931  	pretty.Println("inst:", inst)
  5932  	panic("emitInstXEND: not yet implemented")
  5933  }
  5934  
  5935  // --- [ XGETBV ] --------------------------------------------------------------
  5936  
  5937  // liftInstXGETBV lifts the given x86 XGETBV instruction to LLVM IR, emitting
  5938  // code to f.
  5939  func (f *Func) liftInstXGETBV(inst *x86.Inst) error {
  5940  	pretty.Println("inst:", inst)
  5941  	panic("emitInstXGETBV: not yet implemented")
  5942  }
  5943  
  5944  // --- [ XLATB ] ---------------------------------------------------------------
  5945  
  5946  // liftInstXLATB lifts the given x86 XLATB instruction to LLVM IR, emitting code
  5947  // to f.
  5948  func (f *Func) liftInstXLATB(inst *x86.Inst) error {
  5949  	// Set AL to memory byte DS:[(E)BX + unsigned AL].
  5950  	mem := inst.Mem(0)
  5951  	if mem.Mem.Index != 0 {
  5952  		panic(fmt.Errorf("invalid index of XLAT memory reference; expected 0, got %v", mem.Mem.Index))
  5953  	}
  5954  	mem.Mem.Scale = 1
  5955  	mem.Mem.Index = x86asm.AL
  5956  	v := f.useMemElem(mem, types.I8)
  5957  	f.defReg(x86.AL, v)
  5958  	return nil
  5959  }
  5960  
  5961  // --- [ XOR ] -----------------------------------------------------------------
  5962  
  5963  // liftInstXOR lifts the given x86 XOR instruction to LLVM IR, emitting code to
  5964  // f.
  5965  func (f *Func) liftInstXOR(inst *x86.Inst) error {
  5966  	x, y := f.useArg(inst.Arg(0)), f.useArg(inst.Arg(1))
  5967  	result := f.cur.NewXor(x, y)
  5968  	f.defArg(inst.Arg(0), result)
  5969  	return nil
  5970  }
  5971  
  5972  // --- [ XORPD ] ---------------------------------------------------------------
  5973  
  5974  // liftInstXORPD lifts the given x86 XORPD instruction to LLVM IR, emitting code
  5975  // to f.
  5976  func (f *Func) liftInstXORPD(inst *x86.Inst) error {
  5977  	pretty.Println("inst:", inst)
  5978  	panic("emitInstXORPD: not yet implemented")
  5979  }
  5980  
  5981  // --- [ XORPS ] ---------------------------------------------------------------
  5982  
  5983  // liftInstXORPS lifts the given x86 XORPS instruction to LLVM IR, emitting code
  5984  // to f.
  5985  func (f *Func) liftInstXORPS(inst *x86.Inst) error {
  5986  	pretty.Println("inst:", inst)
  5987  	panic("emitInstXORPS: not yet implemented")
  5988  }
  5989  
  5990  // --- [ XRSTOR ] --------------------------------------------------------------
  5991  
  5992  // liftInstXRSTOR lifts the given x86 XRSTOR instruction to LLVM IR, emitting
  5993  // code to f.
  5994  func (f *Func) liftInstXRSTOR(inst *x86.Inst) error {
  5995  	pretty.Println("inst:", inst)
  5996  	panic("emitInstXRSTOR: not yet implemented")
  5997  }
  5998  
  5999  // --- [ XRSTOR64 ] ------------------------------------------------------------
  6000  
  6001  // liftInstXRSTOR64 lifts the given x86 XRSTOR64 instruction to LLVM IR,
  6002  // emitting code to f.
  6003  func (f *Func) liftInstXRSTOR64(inst *x86.Inst) error {
  6004  	pretty.Println("inst:", inst)
  6005  	panic("emitInstXRSTOR64: not yet implemented")
  6006  }
  6007  
  6008  // --- [ XRSTORS ] -------------------------------------------------------------
  6009  
  6010  // liftInstXRSTORS lifts the given x86 XRSTORS instruction to LLVM IR, emitting
  6011  // code to f.
  6012  func (f *Func) liftInstXRSTORS(inst *x86.Inst) error {
  6013  	pretty.Println("inst:", inst)
  6014  	panic("emitInstXRSTORS: not yet implemented")
  6015  }
  6016  
  6017  // --- [ XRSTORS64 ] -----------------------------------------------------------
  6018  
  6019  // liftInstXRSTORS64 lifts the given x86 XRSTORS64 instruction to LLVM IR,
  6020  // emitting code to f.
  6021  func (f *Func) liftInstXRSTORS64(inst *x86.Inst) error {
  6022  	pretty.Println("inst:", inst)
  6023  	panic("emitInstXRSTORS64: not yet implemented")
  6024  }
  6025  
  6026  // --- [ XSAVE ] ---------------------------------------------------------------
  6027  
  6028  // liftInstXSAVE lifts the given x86 XSAVE instruction to LLVM IR, emitting code
  6029  // to f.
  6030  func (f *Func) liftInstXSAVE(inst *x86.Inst) error {
  6031  	pretty.Println("inst:", inst)
  6032  	panic("emitInstXSAVE: not yet implemented")
  6033  }
  6034  
  6035  // --- [ XSAVE64 ] -------------------------------------------------------------
  6036  
  6037  // liftInstXSAVE64 lifts the given x86 XSAVE64 instruction to LLVM IR, emitting
  6038  // code to f.
  6039  func (f *Func) liftInstXSAVE64(inst *x86.Inst) error {
  6040  	pretty.Println("inst:", inst)
  6041  	panic("emitInstXSAVE64: not yet implemented")
  6042  }
  6043  
  6044  // --- [ XSAVEC ] --------------------------------------------------------------
  6045  
  6046  // liftInstXSAVEC lifts the given x86 XSAVEC instruction to LLVM IR, emitting
  6047  // code to f.
  6048  func (f *Func) liftInstXSAVEC(inst *x86.Inst) error {
  6049  	pretty.Println("inst:", inst)
  6050  	panic("emitInstXSAVEC: not yet implemented")
  6051  }
  6052  
  6053  // --- [ XSAVEC64 ] ------------------------------------------------------------
  6054  
  6055  // liftInstXSAVEC64 lifts the given x86 XSAVEC64 instruction to LLVM IR,
  6056  // emitting code to f.
  6057  func (f *Func) liftInstXSAVEC64(inst *x86.Inst) error {
  6058  	pretty.Println("inst:", inst)
  6059  	panic("emitInstXSAVEC64: not yet implemented")
  6060  }
  6061  
  6062  // --- [ XSAVEOPT ] ------------------------------------------------------------
  6063  
  6064  // liftInstXSAVEOPT lifts the given x86 XSAVEOPT instruction to LLVM IR,
  6065  // emitting code to f.
  6066  func (f *Func) liftInstXSAVEOPT(inst *x86.Inst) error {
  6067  	pretty.Println("inst:", inst)
  6068  	panic("emitInstXSAVEOPT: not yet implemented")
  6069  }
  6070  
  6071  // --- [ XSAVEOPT64 ] ----------------------------------------------------------
  6072  
  6073  // liftInstXSAVEOPT64 lifts the given x86 XSAVEOPT64 instruction to LLVM IR,
  6074  // emitting code to f.
  6075  func (f *Func) liftInstXSAVEOPT64(inst *x86.Inst) error {
  6076  	pretty.Println("inst:", inst)
  6077  	panic("emitInstXSAVEOPT64: not yet implemented")
  6078  }
  6079  
  6080  // --- [ XSAVES ] --------------------------------------------------------------
  6081  
  6082  // liftInstXSAVES lifts the given x86 XSAVES instruction to LLVM IR, emitting
  6083  // code to f.
  6084  func (f *Func) liftInstXSAVES(inst *x86.Inst) error {
  6085  	pretty.Println("inst:", inst)
  6086  	panic("emitInstXSAVES: not yet implemented")
  6087  }
  6088  
  6089  // --- [ XSAVES64 ] ------------------------------------------------------------
  6090  
  6091  // liftInstXSAVES64 lifts the given x86 XSAVES64 instruction to LLVM IR,
  6092  // emitting code to f.
  6093  func (f *Func) liftInstXSAVES64(inst *x86.Inst) error {
  6094  	pretty.Println("inst:", inst)
  6095  	panic("emitInstXSAVES64: not yet implemented")
  6096  }
  6097  
  6098  // --- [ XSETBV ] --------------------------------------------------------------
  6099  
  6100  // liftInstXSETBV lifts the given x86 XSETBV instruction to LLVM IR, emitting
  6101  // code to f.
  6102  func (f *Func) liftInstXSETBV(inst *x86.Inst) error {
  6103  	pretty.Println("inst:", inst)
  6104  	panic("emitInstXSETBV: not yet implemented")
  6105  }
  6106  
  6107  // --- [ XTEST ] ---------------------------------------------------------------
  6108  
  6109  // liftInstXTEST lifts the given x86 XTEST instruction to LLVM IR, emitting code
  6110  // to f.
  6111  func (f *Func) liftInstXTEST(inst *x86.Inst) error {
  6112  	pretty.Println("inst:", inst)
  6113  	panic("emitInstXTEST: not yet implemented")
  6114  }