HELLO·Android
系统源代码
IT资讯
技术文章
我的收藏
注册
登录
-
我收藏的文章
创建代码块
我的代码块
我的账号
Android 10
|
10.0.0_r6
下载
查看原文件
收藏
根目录
external
swiftshader
third_party
subzero
src
IceInstX86Base.h
//===- subzero/src/IceInstX86Base.h - Generic x86 instructions -*- C++ -*--===// // // The Subzero Code Generator // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// /// /// \file /// \brief This file defines the InstX86Base template class, as well as the /// generic X86 Instruction class hierarchy. /// /// Only X86 instructions common across all/most X86 targets should be defined /// here, with target-specific instructions declared in the target's traits. /// //===----------------------------------------------------------------------===// #ifndef SUBZERO_SRC_ICEINSTX86BASE_H #define SUBZERO_SRC_ICEINSTX86BASE_H #include "IceDefs.h" #include "IceInst.h" #include "IceOperand.h" namespace Ice { #ifndef X86NAMESPACE #error "You must define the X86 Target namespace." #endif namespace X86NAMESPACE { template
struct InstImpl { using Traits = TraitsType; using Assembler = typename Traits::Assembler; using AssemblerLabel = typename Assembler::Label; using AssemblerImmediate = typename Assembler::Immediate; using TargetLowering = typename Traits::TargetLowering; using Address = typename Traits::Address; using X86Operand = typename Traits::X86Operand; using X86OperandMem = typename Traits::X86OperandMem; using VariableSplit = typename Traits::VariableSplit; using GPRRegister = typename Traits::RegisterSet::GPRRegister; using RegisterSet = typename Traits::RegisterSet; using XmmRegister = typename Traits::RegisterSet::XmmRegister; using Cond = typename Traits::Cond; using BrCond = typename Traits::Cond::BrCond; using CmppsCond = typename Traits::Cond::CmppsCond; template
using CastEmitterRegOp = typename Traits::Assembler::template CastEmitterRegOp
; template
using ThreeOpImmEmitter = typename Traits::Assembler::template ThreeOpImmEmitter
; using GPREmitterAddrOp = typename Traits::Assembler::GPREmitterAddrOp; using GPREmitterRegOp = typename Traits::Assembler::GPREmitterRegOp; using GPREmitterShiftD = typename Traits::Assembler::GPREmitterShiftD; using GPREmitterShiftOp = typename Traits::Assembler::GPREmitterShiftOp; using GPREmitterOneOp = typename Traits::Assembler::GPREmitterOneOp; using XmmEmitterRegOp = typename Traits::Assembler::XmmEmitterRegOp; using XmmEmitterShiftOp = typename Traits::Assembler::XmmEmitterShiftOp; using XmmEmitterMovOps = typename Traits::Assembler::XmmEmitterMovOps; class InstX86Base : public InstTarget { InstX86Base() = delete; InstX86Base(const InstX86Base &) = delete; InstX86Base &operator=(const InstX86Base &) = delete; public: enum InstKindX86 { k__Start = Inst::Target, Adc, AdcRMW, Add, AddRMW, Addps, Addss, And, Andnps, Andps, AndRMW, Blendvps, Br, Bsf, Bsr, Bswap, Call, Cbwdq, Cmov, Cmpps, Cmpxchg, Cmpxchg8b, Cvt, Div, Divps, Divss, FakeRMW, Fld, Fstp, GetIP, Icmp, Idiv, Imul, ImulImm, Insertps, Int3, Jmp, Label, Lea, Load, Mfence, Minps, Maxps, Minss, Maxss, Mov, Movd, Movmsk, Movp, Movq, MovssRegs, Movsx, Movzx, Mul, Mulps, Mulss, Neg, Nop, Or, Orps, OrRMW, Padd, Padds, Paddus, Pand, Pandn, Pblendvb, Pcmpeq, Pcmpgt, Pextr, Pinsr, Pmull, Pmulhw, Pmulhuw, Pmaddwd, Pmuludq, Pop, Por, Pshufb, Pshufd, Punpckl, Punpckh, Packss, Packus, Psll, Psra, Psrl, Psub, Psubs, Psubus, Push, Pxor, Ret, Rol, Round, Sar, Sbb, SbbRMW, Setcc, Shl, Shld, Shr, Shrd, Shufps, Sqrt, Store, StoreP, StoreQ, StoreD, Sub, SubRMW, Subps, Subss, Test, Ucomiss, UD2, Xadd, Xchg, Xor, Xorps, XorRMW, /// Intel Architecture Code Analyzer markers. These are not executable so /// must only be used for analysis. IacaStart, IacaEnd }; enum SseSuffix { None, Packed, Unpack, Scalar, Integral, Pack }; static const char *getWidthString(Type Ty); static const char *getFldString(Type Ty); static BrCond getOppositeCondition(BrCond Cond); void dump(const Cfg *Func) const override; // Shared emit routines for common forms of instructions. void emitTwoAddress(const Cfg *Func, const char *Opcode, const char *Suffix = "") const; static TargetLowering *getTarget(const Cfg *Func) { return static_cast
(Func->getTarget()); } protected: InstX86Base(Cfg *Func, InstKindX86 Kind, SizeT Maxsrcs, Variable *Dest) : InstTarget(Func, static_cast
(Kind), Maxsrcs, Dest) {} static bool isClassof(const Inst *Instr, InstKindX86 MyKind) { return Instr->getKind() == static_cast
(MyKind); } // Most instructions that operate on vector arguments require vector memory // operands to be fully aligned (16-byte alignment for PNaCl vector types). // The stack frame layout and call ABI ensure proper alignment for stack // operands, but memory operands (originating from load/store bitcode // instructions) only have element-size alignment guarantees. This function // validates that none of the operands is a memory operand of vector type, // calling report_fatal_error() if one is found. This function should be // called during emission, and maybe also in the ctor (as long as that fits // the lowering style). void validateVectorAddrMode() const { if (this->getDest()) this->validateVectorAddrModeOpnd(this->getDest()); for (SizeT i = 0; i < this->getSrcSize(); ++i) { this->validateVectorAddrModeOpnd(this->getSrc(i)); } } private: static void validateVectorAddrModeOpnd(const Operand *Opnd) { if (llvm::isa
(Opnd) && isVectorType(Opnd->getType())) { llvm::report_fatal_error("Possible misaligned vector memory operation"); } } }; /// InstX86FakeRMW represents a non-atomic read-modify-write operation on a /// memory location. An InstX86FakeRMW is a "fake" instruction in that it /// still needs to be lowered to some actual RMW instruction. /// /// If A is some memory address, D is some data value to apply, and OP is an /// arithmetic operator, the instruction operates as: (*A) = (*A) OP D class InstX86FakeRMW final : public InstX86Base { InstX86FakeRMW() = delete; InstX86FakeRMW(const InstX86FakeRMW &) = delete; InstX86FakeRMW &operator=(const InstX86FakeRMW &) = delete; public: static InstX86FakeRMW *create(Cfg *Func, Operand *Data, Operand *Addr, Variable *Beacon, InstArithmetic::OpKind Op, uint32_t Align = 1) { // TODO(stichnot): Stop ignoring alignment specification. (void)Align; return new (Func->allocate
()) InstX86FakeRMW(Func, Data, Addr, Op, Beacon); } Operand *getAddr() const { return this->getSrc(1); } Operand *getData() const { return this->getSrc(0); } InstArithmetic::OpKind getOp() const { return Op; } Variable *getBeacon() const { return llvm::cast
(this->getSrc(2)); } void dump(const Cfg *Func) const override; static bool classof(const Inst *Instr) { return InstX86Base::isClassof(Instr, InstX86Base::FakeRMW); } private: InstArithmetic::OpKind Op; InstX86FakeRMW(Cfg *Func, Operand *Data, Operand *Addr, InstArithmetic::OpKind Op, Variable *Beacon); }; class InstX86GetIP final : public InstX86Base { InstX86GetIP() = delete; InstX86GetIP(const InstX86GetIP &) = delete; InstX86GetIP &operator=(const InstX86GetIP &) = delete; public: static InstX86GetIP *create(Cfg *Func, Variable *Dest) { return new (Func->allocate
()) InstX86GetIP(Func, Dest); } void emit(const Cfg *Func) const override; void emitIAS(const Cfg *Func) const override; void dump(const Cfg *Func) const override; static bool classof(const Inst *Instr) { return InstX86Base::isClassof(Instr, InstX86Base::GetIP); } private: InstX86GetIP(Cfg *Func, Variable *Dest); }; /// InstX86Label represents an intra-block label that is the target of an /// intra-block branch. The offset between the label and the branch must be /// fit into one byte (considered "near"). These are used for lowering i1 /// calculations, Select instructions, and 64-bit compares on a 32-bit /// architecture, without basic block splitting. Basic block splitting is not /// so desirable for several reasons, one of which is the impact on decisions /// based on whether a variable's live range spans multiple basic blocks. /// /// Intra-block control flow must be used with caution. Consider the sequence /// for "c = (a >= b ? x : y)". /// cmp a, b /// br lt, L1 /// mov c, x /// jmp L2 /// L1: /// mov c, y /// L2: /// /// Labels L1 and L2 are intra-block labels. Without knowledge of the /// intra-block control flow, liveness analysis will determine the "mov c, x" /// instruction to be dead. One way to prevent this is to insert a /// "FakeUse(c)" instruction anywhere between the two "mov c, ..." /// instructions, e.g.: /// /// cmp a, b /// br lt, L1 /// mov c, x /// jmp L2 /// FakeUse(c) /// L1: /// mov c, y /// L2: /// /// The down-side is that "mov c, x" can never be dead-code eliminated even if /// there are no uses of c. As unlikely as this situation is, it may be /// prevented by running dead code elimination before lowering. class InstX86Label final : public InstX86Base { InstX86Label() = delete; InstX86Label(const InstX86Label &) = delete; InstX86Label &operator=(const InstX86Label &) = delete; public: static InstX86Label *create(Cfg *Func, TargetLowering *Target) { return new (Func->allocate
()) InstX86Label(Func, Target); } uint32_t getEmitInstCount() const override { return 0; } GlobalString getLabelName() const { return Name; } SizeT getLabelNumber() const { return LabelNumber; } bool isLabel() const override { return true; } void emit(const Cfg *Func) const override; void emitIAS(const Cfg *Func) const override; void dump(const Cfg *Func) const override; void setRelocOffset(RelocOffset *Value) { OffsetReloc = Value; } private: InstX86Label(Cfg *Func, TargetLowering *Target); SizeT LabelNumber; // used for unique label generation. RelocOffset *OffsetReloc = nullptr; GlobalString Name; }; /// Conditional and unconditional branch instruction. class InstX86Br final : public InstX86Base { InstX86Br() = delete; InstX86Br(const InstX86Br &) = delete; InstX86Br &operator=(const InstX86Br &) = delete; public: enum Mode { Near, Far }; /// Create a conditional branch to a node. static InstX86Br *create(Cfg *Func, CfgNode *TargetTrue, CfgNode *TargetFalse, BrCond Condition, Mode Kind) { assert(Condition != Cond::Br_None); constexpr InstX86Label *NoLabel = nullptr; return new (Func->allocate
()) InstX86Br(Func, TargetTrue, TargetFalse, NoLabel, Condition, Kind); } /// Create an unconditional branch to a node. static InstX86Br *create(Cfg *Func, CfgNode *Target, Mode Kind) { constexpr CfgNode *NoCondTarget = nullptr; constexpr InstX86Label *NoLabel = nullptr; return new (Func->allocate
()) InstX86Br(Func, NoCondTarget, Target, NoLabel, Cond::Br_None, Kind); } /// Create a non-terminator conditional branch to a node, with a fallthrough /// to the next instruction in the current node. This is used for switch /// lowering. static InstX86Br *create(Cfg *Func, CfgNode *Target, BrCond Condition, Mode Kind) { assert(Condition != Cond::Br_None); constexpr CfgNode *NoUncondTarget = nullptr; constexpr InstX86Label *NoLabel = nullptr; return new (Func->allocate
()) InstX86Br(Func, Target, NoUncondTarget, NoLabel, Condition, Kind); } /// Create a conditional intra-block branch (or unconditional, if /// Condition==Br_None) to a label in the current block. static InstX86Br *create(Cfg *Func, InstX86Label *Label, BrCond Condition, Mode Kind) { constexpr CfgNode *NoCondTarget = nullptr; constexpr CfgNode *NoUncondTarget = nullptr; return new (Func->allocate
()) InstX86Br(Func, NoCondTarget, NoUncondTarget, Label, Condition, Kind); } const CfgNode *getTargetTrue() const { return TargetTrue; } const CfgNode *getTargetFalse() const { return TargetFalse; } bool isNear() const { return Kind == Near; } bool optimizeBranch(const CfgNode *NextNode); uint32_t getEmitInstCount() const override { uint32_t Sum = 0; if (Label) ++Sum; if (getTargetTrue()) ++Sum; if (getTargetFalse()) ++Sum; return Sum; } bool isUnconditionalBranch() const override { return !Label && Condition == Cond::Br_None; } const Inst *getIntraBlockBranchTarget() const override { return Label; } bool repointEdges(CfgNode *OldNode, CfgNode *NewNode) override; void emit(const Cfg *Func) const override; void emitIAS(const Cfg *Func) const override; void dump(const Cfg *Func) const override; static bool classof(const Inst *Instr) { return InstX86Base::isClassof(Instr, InstX86Base::Br); } private: InstX86Br(Cfg *Func, const CfgNode *TargetTrue, const CfgNode *TargetFalse, const InstX86Label *Label, BrCond Condition, Mode Kind); BrCond Condition; const CfgNode *TargetTrue; const CfgNode *TargetFalse; const InstX86Label *Label; // Intra-block branch target const Mode Kind; }; /// Jump to a target outside this function, such as tailcall, nacljump, /// naclret, unreachable. This is different from a Branch instruction in that /// there is no intra-function control flow to represent. class InstX86Jmp final : public InstX86Base { InstX86Jmp() = delete; InstX86Jmp(const InstX86Jmp &) = delete; InstX86Jmp &operator=(const InstX86Jmp &) = delete; public: static InstX86Jmp *create(Cfg *Func, Operand *Target) { return new (Func->allocate
()) InstX86Jmp(Func, Target); } Operand *getJmpTarget() const { return this->getSrc(0); } void emit(const Cfg *Func) const override; void emitIAS(const Cfg *Func) const override; void dump(const Cfg *Func) const override; static bool classof(const Inst *Instr) { return InstX86Base::isClassof(Instr, InstX86Base::Jmp); } private: InstX86Jmp(Cfg *Func, Operand *Target); }; /// Call instruction. Arguments should have already been pushed. class InstX86Call final : public InstX86Base { InstX86Call() = delete; InstX86Call(const InstX86Call &) = delete; InstX86Call &operator=(const InstX86Call &) = delete; public: static InstX86Call *create(Cfg *Func, Variable *Dest, Operand *CallTarget) { return new (Func->allocate
()) InstX86Call(Func, Dest, CallTarget); } Operand *getCallTarget() const { return this->getSrc(0); } void emit(const Cfg *Func) const override; void emitIAS(const Cfg *Func) const override; void dump(const Cfg *Func) const override; static bool classof(const Inst *Instr) { return InstX86Base::isClassof(Instr, InstX86Base::Call); } private: InstX86Call(Cfg *Func, Variable *Dest, Operand *CallTarget); }; /// Emit a one-operand (GPR) instruction. static void emitIASOpTyGPR(const Cfg *Func, Type Ty, const Operand *Var, const GPREmitterOneOp &Emitter); static void emitIASAsAddrOpTyGPR(const Cfg *Func, Type Ty, const Operand *Op0, const Operand *Op1, const GPREmitterAddrOp &Emitter); static void emitIASGPRShift(const Cfg *Func, Type Ty, const Variable *Var, const Operand *Src, const GPREmitterShiftOp &Emitter); static void emitIASAddrOpTyGPR(const Cfg *Func, Type Ty, const Address &Addr, const Operand *Src, const GPREmitterAddrOp &Emitter); static void emitIASRegOpTyXMM(const Cfg *Func, Type Ty, const Variable *Var, const Operand *Src, const XmmEmitterRegOp &Emitter); static void emitIASGPRShiftDouble(const Cfg *Func, const Variable *Dest, const Operand *Src1Op, const Operand *Src2Op, const GPREmitterShiftD &Emitter); template
static void emitIASCastRegOp(const Cfg *Func, Type DestTy, const Variable *Dest, Type SrcTy, const Operand *Src, const CastEmitterRegOp
&Emitter); template
static void emitIASThreeOpImmOps(const Cfg *Func, Type DispatchTy, const Variable *Dest, const Operand *Src0, const Operand *Src1, const ThreeOpImmEmitter
Emitter); static void emitIASMovlikeXMM(const Cfg *Func, const Variable *Dest, const Operand *Src, const XmmEmitterMovOps Emitter); static void emitVariableBlendInst(const char *Opcode, const Inst *Instr, const Cfg *Func); static void emitIASVariableBlendInst(const Inst *Instr, const Cfg *Func, const XmmEmitterRegOp &Emitter); static void emitIASXmmShift(const Cfg *Func, Type Ty, const Variable *Var, const Operand *Src, const XmmEmitterShiftOp &Emitter); /// Emit a two-operand (GPR) instruction, where the dest operand is a Variable /// that's guaranteed to be a register. template
static void emitIASRegOpTyGPR(const Cfg *Func, bool IsLea, Type Ty, const Variable *Dst, const Operand *Src, const GPREmitterRegOp &Emitter); /// Instructions of the form x := op(x). template
class InstX86BaseInplaceopGPR : public InstX86Base { InstX86BaseInplaceopGPR() = delete; InstX86BaseInplaceopGPR(const InstX86BaseInplaceopGPR &) = delete; InstX86BaseInplaceopGPR & operator=(const InstX86BaseInplaceopGPR &) = delete; public: using Base = InstX86BaseInplaceopGPR
; void emit(const Cfg *Func) const override { if (!BuildDefs::dump()) return; Ostream &Str = Func->getContext()->getStrEmit(); assert(this->getSrcSize() == 1); Str << "\t" << Opcode << "\t"; this->getSrc(0)->emit(Func); } void emitIAS(const Cfg *Func) const override { assert(this->getSrcSize() == 1); const Variable *Var = this->getDest(); Type Ty = Var->getType(); emitIASOpTyGPR(Func, Ty, Var, Emitter); } void dump(const Cfg *Func) const override { if (!BuildDefs::dump()) return; Ostream &Str = Func->getContext()->getStrDump(); this->dumpDest(Func); Str << " = " << Opcode << "." << this->getDest()->getType() << " "; this->dumpSources(Func); } static bool classof(const Inst *Instr) { return InstX86Base::isClassof(Instr, InstX86Base::K); } protected: InstX86BaseInplaceopGPR(Cfg *Func, Operand *SrcDest) : InstX86Base(Func, K, 1, llvm::dyn_cast
(SrcDest)) { this->addSource(SrcDest); } private: static const char *Opcode; static const GPREmitterOneOp Emitter; }; /// Instructions of the form x := op(y). template
class InstX86BaseUnaryopGPR : public InstX86Base { InstX86BaseUnaryopGPR() = delete; InstX86BaseUnaryopGPR(const InstX86BaseUnaryopGPR &) = delete; InstX86BaseUnaryopGPR &operator=(const InstX86BaseUnaryopGPR &) = delete; public: using Base = InstX86BaseUnaryopGPR
; void emit(const Cfg *Func) const override { if (!BuildDefs::dump()) return; Ostream &Str = Func->getContext()->getStrEmit(); assert(this->getSrcSize() == 1); Type SrcTy = this->getSrc(0)->getType(); Type DestTy = this->getDest()->getType(); Str << "\t" << Opcode << this->getWidthString(SrcTy); // Movsx and movzx need both the source and dest type width letter to // define the operation. The other unary operations have the same source // and dest type and as a result need only one letter. if (SrcTy != DestTy) Str << this->getWidthString(DestTy); Str << "\t"; this->getSrc(0)->emit(Func); Str << ", "; this->getDest()->emit(Func); } void emitIAS(const Cfg *Func) const override { assert(this->getSrcSize() == 1); const Variable *Var = this->getDest(); Type Ty = Var->getType(); const Operand *Src = this->getSrc(0); constexpr bool IsLea = K == InstX86Base::Lea; if (IsLea) { if (auto *Add = deoptLeaToAddOrNull(Func)) { Add->emitIAS(Func); return; } } emitIASRegOpTyGPR(Func, IsLea, Ty, Var, Src, Emitter); } void dump(const Cfg *Func) const override { if (!BuildDefs::dump()) return; Ostream &Str = Func->getContext()->getStrDump(); this->dumpDest(Func); Str << " = " << Opcode << "." << this->getSrc(0)->getType() << " "; this->dumpSources(Func); } static bool classof(const Inst *Instr) { return InstX86Base::isClassof(Instr, InstX86Base::K); } protected: InstX86BaseUnaryopGPR(Cfg *Func, Variable *Dest, Operand *Src) : InstX86Base(Func, K, 1, Dest) { this->addSource(Src); } Inst *deoptLeaToAddOrNull(const Cfg *Func) const { // Revert back to Add when the Lea is a 2-address instruction. // Caller has to emit, this just produces the add instruction. if (auto *MemOp = llvm::dyn_cast
(this->getSrc(0))) { if (getFlags().getAggressiveLea() && MemOp->getBase()->getRegNum() == this->getDest()->getRegNum() && MemOp->getIndex() == nullptr && MemOp->getShift() == 0) { auto *Add = InstImpl
::InstX86Add::create( const_cast
(Func), this->getDest(), MemOp->getOffset()); // TODO(manasijm): Remove const_cast by emitting code for add // directly. return Add; } } return nullptr; } static const char *Opcode; static const GPREmitterRegOp Emitter; }; template
class InstX86BaseUnaryopXmm : public InstX86Base { InstX86BaseUnaryopXmm() = delete; InstX86BaseUnaryopXmm(const InstX86BaseUnaryopXmm &) = delete; InstX86BaseUnaryopXmm &operator=(const InstX86BaseUnaryopXmm &) = delete; public: using Base = InstX86BaseUnaryopXmm
; void emit(const Cfg *Func) const override { if (!BuildDefs::dump()) return; Ostream &Str = Func->getContext()->getStrEmit(); assert(this->getSrcSize() == 1); Str << "\t" << Opcode << "\t"; this->getSrc(0)->emit(Func); Str << ", "; this->getDest()->emit(Func); } void emitIAS(const Cfg *Func) const override { Type Ty = this->getDest()->getType(); assert(this->getSrcSize() == 1); emitIASRegOpTyXMM(Func, Ty, this->getDest(), this->getSrc(0), Emitter); } void dump(const Cfg *Func) const override { if (!BuildDefs::dump()) return; Ostream &Str = Func->getContext()->getStrDump(); this->dumpDest(Func); Str << " = " << Opcode << "." << this->getDest()->getType() << " "; this->dumpSources(Func); } static bool classof(const Inst *Instr) { return InstX86Base::isClassof(Instr, InstX86Base::K); } protected: InstX86BaseUnaryopXmm(Cfg *Func, Variable *Dest, Operand *Src) : InstX86Base(Func, K, 1, Dest) { this->addSource(Src); } static const char *Opcode; static const XmmEmitterRegOp Emitter; }; template
class InstX86BaseBinopGPRShift : public InstX86Base { InstX86BaseBinopGPRShift() = delete; InstX86BaseBinopGPRShift(const InstX86BaseBinopGPRShift &) = delete; InstX86BaseBinopGPRShift & operator=(const InstX86BaseBinopGPRShift &) = delete; public: using Base = InstX86BaseBinopGPRShift
; void emit(const Cfg *Func) const override { if (!BuildDefs::dump()) return; this->emitTwoAddress(Func, Opcode); } void emitIAS(const Cfg *Func) const override { Type Ty = this->getDest()->getType(); assert(this->getSrcSize() == 2); emitIASGPRShift(Func, Ty, this->getDest(), this->getSrc(1), Emitter); } void dump(const Cfg *Func) const override { if (!BuildDefs::dump()) return; Ostream &Str = Func->getContext()->getStrDump(); this->dumpDest(Func); Str << " = " << Opcode << "." << this->getDest()->getType() << " "; this->dumpSources(Func); } static bool classof(const Inst *Instr) { return InstX86Base::isClassof(Instr, InstX86Base::K); } protected: InstX86BaseBinopGPRShift(Cfg *Func, Variable *Dest, Operand *Source) : InstX86Base(Func, K, 2, Dest) { this->addSource(Dest); this->addSource(Source); } static const char *Opcode; static const GPREmitterShiftOp Emitter; }; template
class InstX86BaseBinopGPR : public InstX86Base { InstX86BaseBinopGPR() = delete; InstX86BaseBinopGPR(const InstX86BaseBinopGPR &) = delete; InstX86BaseBinopGPR &operator=(const InstX86BaseBinopGPR &) = delete; public: using Base = InstX86BaseBinopGPR
; void emit(const Cfg *Func) const override { if (!BuildDefs::dump()) return; this->emitTwoAddress(Func, Opcode); } void emitIAS(const Cfg *Func) const override { Type Ty = this->getDest()->getType(); assert(this->getSrcSize() == 2); constexpr bool ThisIsLEA = K == InstX86Base::Lea; static_assert(!ThisIsLEA, "Lea should be a unaryop."); emitIASRegOpTyGPR(Func, !ThisIsLEA, Ty, this->getDest(), this->getSrc(1), Emitter); } void dump(const Cfg *Func) const override { if (!BuildDefs::dump()) return; Ostream &Str = Func->getContext()->getStrDump(); this->dumpDest(Func); Str << " = " << Opcode << "." << this->getDest()->getType() << " "; this->dumpSources(Func); } static bool classof(const Inst *Instr) { return InstX86Base::isClassof(Instr, InstX86Base::K); } protected: InstX86BaseBinopGPR(Cfg *Func, Variable *Dest, Operand *Source) : InstX86Base(Func, K, 2, Dest) { this->addSource(Dest); this->addSource(Source); } static const char *Opcode; static const GPREmitterRegOp Emitter; }; template
class InstX86BaseBinopRMW : public InstX86Base { InstX86BaseBinopRMW() = delete; InstX86BaseBinopRMW(const InstX86BaseBinopRMW &) = delete; InstX86BaseBinopRMW &operator=(const InstX86BaseBinopRMW &) = delete; public: using Base = InstX86BaseBinopRMW
; void emit(const Cfg *Func) const override { if (!BuildDefs::dump()) return; this->emitTwoAddress(Func, Opcode); } void emitIAS(const Cfg *Func) const override { Type Ty = this->getSrc(0)->getType(); assert(this->getSrcSize() == 2); emitIASAsAddrOpTyGPR(Func, Ty, this->getSrc(0), this->getSrc(1), Emitter); } void dump(const Cfg *Func) const override { if (!BuildDefs::dump()) return; Ostream &Str = Func->getContext()->getStrDump(); Str << Opcode << "." << this->getSrc(0)->getType() << " "; this->dumpSources(Func); } static bool classof(const Inst *Instr) { return InstX86Base::isClassof(Instr, InstX86Base::K); } protected: InstX86BaseBinopRMW(Cfg *Func, X86OperandMem *DestSrc0, Operand *Src1) : InstX86Base(Func, K, 2, nullptr) { this->addSource(DestSrc0); this->addSource(Src1); } static const char *Opcode; static const GPREmitterAddrOp Emitter; }; template
class InstX86BaseBinopXmm : public InstX86Base { InstX86BaseBinopXmm() = delete; InstX86BaseBinopXmm(const InstX86BaseBinopXmm &) = delete; InstX86BaseBinopXmm &operator=(const InstX86BaseBinopXmm &) = delete; public: using Base = InstX86BaseBinopXmm
; void emit(const Cfg *Func) const override { if (!BuildDefs::dump()) return; this->validateVectorAddrMode(); const Type DestTy = ArithmeticTypeOverride == IceType_void ? this->getDest()->getType() : ArithmeticTypeOverride; const char *SuffixString = ""; switch (Suffix) { case InstX86Base::SseSuffix::None: break; case InstX86Base::SseSuffix::Packed: SuffixString = Traits::TypeAttributes[DestTy].PdPsString; break; case InstX86Base::SseSuffix::Unpack: SuffixString = Traits::TypeAttributes[DestTy].UnpackString; break; case InstX86Base::SseSuffix::Scalar: SuffixString = Traits::TypeAttributes[DestTy].SdSsString; break; case InstX86Base::SseSuffix::Integral: SuffixString = Traits::TypeAttributes[DestTy].IntegralString; break; case InstX86Base::SseSuffix::Pack: SuffixString = Traits::TypeAttributes[DestTy].PackString; break; } this->emitTwoAddress(Func, Opcode, SuffixString); } void emitIAS(const Cfg *Func) const override { this->validateVectorAddrMode(); Type Ty = this->getDest()->getType(); if (NeedsElementType) Ty = typeElementType(Ty); assert(this->getSrcSize() == 2); emitIASRegOpTyXMM(Func, Ty, this->getDest(), this->getSrc(1), Emitter); } void dump(const Cfg *Func) const override { if (!BuildDefs::dump()) return; Ostream &Str = Func->getContext()->getStrDump(); this->dumpDest(Func); Str << " = " << Opcode << "." << this->getDest()->getType() << " "; this->dumpSources(Func); } static bool classof(const Inst *Instr) { return InstX86Base::isClassof(Instr, InstX86Base::K); } protected: InstX86BaseBinopXmm(Cfg *Func, Variable *Dest, Operand *Source, Type ArithmeticTypeOverride = IceType_void) : InstX86Base(Func, K, 2, Dest), ArithmeticTypeOverride(ArithmeticTypeOverride) { this->addSource(Dest); this->addSource(Source); } const Type ArithmeticTypeOverride; static const char *Opcode; static const XmmEmitterRegOp Emitter; }; template
class InstX86BaseBinopXmmShift : public InstX86Base { InstX86BaseBinopXmmShift() = delete; InstX86BaseBinopXmmShift(const InstX86BaseBinopXmmShift &) = delete; InstX86BaseBinopXmmShift & operator=(const InstX86BaseBinopXmmShift &) = delete; public: using Base = InstX86BaseBinopXmmShift
; void emit(const Cfg *Func) const override { if (!BuildDefs::dump()) return; this->validateVectorAddrMode(); // Shift operations are always integral, and hence always need a suffix. const Type DestTy = this->getDest()->getType(); this->emitTwoAddress(Func, this->Opcode, Traits::TypeAttributes[DestTy].IntegralString); } void emitIAS(const Cfg *Func) const override { this->validateVectorAddrMode(); Type Ty = this->getDest()->getType(); assert(AllowAllTypes || isVectorType(Ty)); Type ElementTy = typeElementType(Ty); assert(this->getSrcSize() == 2); emitIASXmmShift(Func, ElementTy, this->getDest(), this->getSrc(1), Emitter); } void dump(const Cfg *Func) const override { if (!BuildDefs::dump()) return; Ostream &Str = Func->getContext()->getStrDump(); this->dumpDest(Func); Str << " = " << Opcode << "." << this->getDest()->getType() << " "; this->dumpSources(Func); } static bool classof(const Inst *Instr) { return InstX86Base::isClassof(Instr, InstX86Base::K); } protected: InstX86BaseBinopXmmShift(Cfg *Func, Variable *Dest, Operand *Source) : InstX86Base(Func, K, 2, Dest) { this->addSource(Dest); this->addSource(Source); } static const char *Opcode; static const XmmEmitterShiftOp Emitter; }; template
class InstX86BaseTernop : public InstX86Base { InstX86BaseTernop() = delete; InstX86BaseTernop(const InstX86BaseTernop &) = delete; InstX86BaseTernop &operator=(const InstX86BaseTernop &) = delete; public: using Base = InstX86BaseTernop
; void emit(const Cfg *Func) const override { if (!BuildDefs::dump()) return; Ostream &Str = Func->getContext()->getStrEmit(); assert(this->getSrcSize() == 3); Str << "\t" << Opcode << "\t"; this->getSrc(2)->emit(Func); Str << ", "; this->getSrc(1)->emit(Func); Str << ", "; this->getDest()->emit(Func); } void dump(const Cfg *Func) const override { if (!BuildDefs::dump()) return; Ostream &Str = Func->getContext()->getStrDump(); this->dumpDest(Func); Str << " = " << Opcode << "." << this->getDest()->getType() << " "; this->dumpSources(Func); } static bool classof(const Inst *Instr) { return InstX86Base::isClassof(Instr, InstX86Base::K); } protected: InstX86BaseTernop(Cfg *Func, Variable *Dest, Operand *Source1, Operand *Source2) : InstX86Base(Func, K, 3, Dest) { this->addSource(Dest); this->addSource(Source1); this->addSource(Source2); } static const char *Opcode; }; // Instructions of the form x := y op z template
class InstX86BaseThreeAddressop : public InstX86Base { InstX86BaseThreeAddressop() = delete; InstX86BaseThreeAddressop(const InstX86BaseThreeAddressop &) = delete; InstX86BaseThreeAddressop & operator=(const InstX86BaseThreeAddressop &) = delete; public: using Base = InstX86BaseThreeAddressop
; void emit(const Cfg *Func) const override { if (!BuildDefs::dump()) return; Ostream &Str = Func->getContext()->getStrEmit(); assert(this->getSrcSize() == 2); Str << "\t" << Opcode << "\t"; this->getSrc(1)->emit(Func); Str << ", "; this->getSrc(0)->emit(Func); Str << ", "; this->getDest()->emit(Func); } void dump(const Cfg *Func) const override { if (!BuildDefs::dump()) return; Ostream &Str = Func->getContext()->getStrDump(); this->dumpDest(Func); Str << " = " << Opcode << "." << this->getDest()->getType() << " "; this->dumpSources(Func); } static bool classof(const Inst *Instr) { return InstX86Base::isClassof(Instr, InstX86Base::K); } protected: InstX86BaseThreeAddressop(Cfg *Func, Variable *Dest, Operand *Source0, Operand *Source1) : InstX86Base(Func, K, 2, Dest) { this->addSource(Source0); this->addSource(Source1); } static const char *Opcode; }; /// Base class for assignment instructions template
class InstX86BaseMovlike : public InstX86Base { InstX86BaseMovlike() = delete; InstX86BaseMovlike(const InstX86BaseMovlike &) = delete; InstX86BaseMovlike &operator=(const InstX86BaseMovlike &) = delete; public: using Base = InstX86BaseMovlike
; bool isRedundantAssign() const override { if (const auto *SrcVar = llvm::dyn_cast
(this->getSrc(0))) { if (SrcVar->hasReg() && this->Dest->hasReg()) { // An assignment between physical registers is considered redundant if // they have the same base register and the same encoding. E.g.: // mov cl, ecx ==> redundant // mov ch, ecx ==> not redundant due to different encodings // mov ch, ebp ==> not redundant due to different base registers // mov ecx, ecx ==> redundant, and dangerous in x86-64. i64 zexting // is handled by Inst86Zext. const auto SrcReg = SrcVar->getRegNum(); const auto DestReg = this->Dest->getRegNum(); return (Traits::getEncoding(SrcReg) == Traits::getEncoding(DestReg)) && (Traits::getBaseReg(SrcReg) == Traits::getBaseReg(DestReg)); } } return checkForRedundantAssign(this->getDest(), this->getSrc(0)); } bool isVarAssign() const override { return llvm::isa
(this->getSrc(0)); } void dump(const Cfg *Func) const override { if (!BuildDefs::dump()) return; Ostream &Str = Func->getContext()->getStrDump(); Str << Opcode << "." << this->getDest()->getType() << " "; this->dumpDest(Func); Str << ", "; this->dumpSources(Func); } static bool classof(const Inst *Instr) { return InstX86Base::isClassof(Instr, InstX86Base::K); } protected: InstX86BaseMovlike(Cfg *Func, Variable *Dest, Operand *Source) : InstX86Base(Func, K, 1, Dest) { this->addSource(Source); // For an integer assignment, make sure it's either a same-type assignment // or a truncation. assert(!isScalarIntegerType(Dest->getType()) || (typeWidthInBytes(Dest->getType()) <= typeWidthInBytes(Source->getType()))); } static const char *Opcode; }; class InstX86Bswap : public InstX86BaseInplaceopGPR
{ public: static InstX86Bswap *create(Cfg *Func, Operand *SrcDest) { return new (Func->allocate
()) InstX86Bswap(Func, SrcDest); } private: InstX86Bswap(Cfg *Func, Operand *SrcDest) : InstX86BaseInplaceopGPR
(Func, SrcDest) {} }; class InstX86Neg : public InstX86BaseInplaceopGPR
{ public: static InstX86Neg *create(Cfg *Func, Operand *SrcDest) { return new (Func->allocate
()) InstX86Neg(Func, SrcDest); } private: InstX86Neg(Cfg *Func, Operand *SrcDest) : InstX86BaseInplaceopGPR
(Func, SrcDest) {} }; class InstX86Bsf : public InstX86BaseUnaryopGPR
{ public: static InstX86Bsf *create(Cfg *Func, Variable *Dest, Operand *Src) { return new (Func->allocate
()) InstX86Bsf(Func, Dest, Src); } private: InstX86Bsf(Cfg *Func, Variable *Dest, Operand *Src) : InstX86BaseUnaryopGPR
(Func, Dest, Src) {} }; class InstX86Bsr : public InstX86BaseUnaryopGPR
{ public: static InstX86Bsr *create(Cfg *Func, Variable *Dest, Operand *Src) { return new (Func->allocate
()) InstX86Bsr(Func, Dest, Src); } private: InstX86Bsr(Cfg *Func, Variable *Dest, Operand *Src) : InstX86BaseUnaryopGPR
(Func, Dest, Src) {} }; class InstX86Lea : public InstX86BaseUnaryopGPR
{ public: static InstX86Lea *create(Cfg *Func, Variable *Dest, Operand *Src) { return new (Func->allocate
()) InstX86Lea(Func, Dest, Src); } void emit(const Cfg *Func) const override; private: InstX86Lea(Cfg *Func, Variable *Dest, Operand *Src) : InstX86BaseUnaryopGPR
(Func, Dest, Src) {} }; // Cbwdq instruction - wrapper for cbw, cwd, and cdq class InstX86Cbwdq : public InstX86BaseUnaryopGPR
{ public: static InstX86Cbwdq *create(Cfg *Func, Variable *Dest, Operand *Src) { return new (Func->allocate
()) InstX86Cbwdq(Func, Dest, Src); } void emit(const Cfg *Func) const override; void emitIAS(const Cfg *Func) const override; private: InstX86Cbwdq(Cfg *Func, Variable *Dest, Operand *Src) : InstX86BaseUnaryopGPR
(Func, Dest, Src) {} }; class InstX86Movsx : public InstX86BaseUnaryopGPR
{ public: static InstX86Movsx *create(Cfg *Func, Variable *Dest, Operand *Src) { assert(typeWidthInBytes(Dest->getType()) > typeWidthInBytes(Src->getType())); return new (Func->allocate
()) InstX86Movsx(Func, Dest, Src); } void emitIAS(const Cfg *Func) const override; private: InstX86Movsx(Cfg *Func, Variable *Dest, Operand *Src) : InstX86BaseUnaryopGPR
(Func, Dest, Src) {} }; class InstX86Movzx : public InstX86BaseUnaryopGPR
{ public: static InstX86Movzx *create(Cfg *Func, Variable *Dest, Operand *Src) { assert(typeWidthInBytes(Dest->getType()) > typeWidthInBytes(Src->getType())); return new (Func->allocate
()) InstX86Movzx(Func, Dest, Src); } void emit(const Cfg *Func) const override; void emitIAS(const Cfg *Func) const override; void setMustKeep() { MustKeep = true; } private: bool MustKeep = false; InstX86Movzx(Cfg *Func, Variable *Dest, Operand *Src) : InstX86BaseUnaryopGPR
(Func, Dest, Src) {} bool mayBeElided(const Variable *Dest, const Operand *Src) const; }; class InstX86Movd : public InstX86BaseUnaryopXmm
{ public: static InstX86Movd *create(Cfg *Func, Variable *Dest, Operand *Src) { return new (Func->allocate
()) InstX86Movd(Func, Dest, Src); } void emit(const Cfg *Func) const override; void emitIAS(const Cfg *Func) const override; private: InstX86Movd(Cfg *Func, Variable *Dest, Operand *Src) : InstX86BaseUnaryopXmm
(Func, Dest, Src) {} }; class InstX86Movmsk final : public InstX86Base { InstX86Movmsk() = delete; InstX86Movmsk(const InstX86Movmsk &) = delete; InstX86Movmsk &operator=(const InstX86Movmsk &) = delete; public: static InstX86Movmsk *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Movmsk(Func, Dest, Source); } void emit(const Cfg *Func) const override; void emitIAS(const Cfg *Func) const override; void dump(const Cfg *Func) const override; static bool classof(const Inst *Instr) { return InstX86Base::isClassof(Instr, InstX86Base::InstX86Movmsk); } private: InstX86Movmsk(Cfg *Func, Variable *Dest, Operand *Source); }; class InstX86Sqrt : public InstX86BaseUnaryopXmm
{ public: static InstX86Sqrt *create(Cfg *Func, Variable *Dest, Operand *Src) { return new (Func->allocate
()) InstX86Sqrt(Func, Dest, Src); } virtual void emit(const Cfg *Func) const override; private: InstX86Sqrt(Cfg *Func, Variable *Dest, Operand *Src) : InstX86BaseUnaryopXmm
(Func, Dest, Src) {} }; /// Move/assignment instruction - wrapper for mov/movss/movsd. class InstX86Mov : public InstX86BaseMovlike
{ public: static InstX86Mov *create(Cfg *Func, Variable *Dest, Operand *Source) { assert(!isScalarIntegerType(Dest->getType()) || (typeWidthInBytes(Dest->getType()) <= typeWidthInBytes(Source->getType()))); return new (Func->allocate
()) InstX86Mov(Func, Dest, Source); } void emit(const Cfg *Func) const override; void emitIAS(const Cfg *Func) const override; private: InstX86Mov(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseMovlike
(Func, Dest, Source) {} }; /// Move packed - copy 128 bit values between XMM registers, or mem128 and XMM /// registers. class InstX86Movp : public InstX86BaseMovlike
{ public: static InstX86Movp *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Movp(Func, Dest, Source); } void emit(const Cfg *Func) const override; void emitIAS(const Cfg *Func) const override; private: InstX86Movp(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseMovlike
(Func, Dest, Source) {} }; /// Movq - copy between XMM registers, or mem64 and XMM registers. class InstX86Movq : public InstX86BaseMovlike
{ public: static InstX86Movq *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Movq(Func, Dest, Source); } void emit(const Cfg *Func) const override; void emitIAS(const Cfg *Func) const override; private: InstX86Movq(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseMovlike
(Func, Dest, Source) {} }; class InstX86Add : public InstX86BaseBinopGPR
{ public: static InstX86Add *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Add(Func, Dest, Source); } private: InstX86Add(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopGPR
(Func, Dest, Source) {} }; class InstX86AddRMW : public InstX86BaseBinopRMW
{ public: static InstX86AddRMW *create(Cfg *Func, X86OperandMem *DestSrc0, Operand *Src1) { return new (Func->allocate
()) InstX86AddRMW(Func, DestSrc0, Src1); } private: InstX86AddRMW(Cfg *Func, X86OperandMem *DestSrc0, Operand *Src1) : InstX86BaseBinopRMW
(Func, DestSrc0, Src1) {} }; class InstX86Addps : public InstX86BaseBinopXmm
{ public: static InstX86Addps *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Addps(Func, Dest, Source); } private: InstX86Addps(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Adc : public InstX86BaseBinopGPR
{ public: static InstX86Adc *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Adc(Func, Dest, Source); } private: InstX86Adc(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopGPR
(Func, Dest, Source) {} }; class InstX86AdcRMW : public InstX86BaseBinopRMW
{ public: static InstX86AdcRMW *create(Cfg *Func, X86OperandMem *DestSrc0, Operand *Src1) { return new (Func->allocate
()) InstX86AdcRMW(Func, DestSrc0, Src1); } private: InstX86AdcRMW(Cfg *Func, X86OperandMem *DestSrc0, Operand *Src1) : InstX86BaseBinopRMW
(Func, DestSrc0, Src1) {} }; class InstX86Addss : public InstX86BaseBinopXmm
{ public: static InstX86Addss *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Addss(Func, Dest, Source); } private: InstX86Addss(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Padd : public InstX86BaseBinopXmm
{ public: static InstX86Padd *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Padd(Func, Dest, Source); } private: InstX86Padd(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Padds : public InstX86BaseBinopXmm
{ public: static InstX86Padds *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Padds(Func, Dest, Source); } private: InstX86Padds(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Paddus : public InstX86BaseBinopXmm
{ public: static InstX86Paddus *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Paddus(Func, Dest, Source); } private: InstX86Paddus(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Sub : public InstX86BaseBinopGPR
{ public: static InstX86Sub *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Sub(Func, Dest, Source); } private: InstX86Sub(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopGPR
(Func, Dest, Source) {} }; class InstX86SubRMW : public InstX86BaseBinopRMW
{ public: static InstX86SubRMW *create(Cfg *Func, X86OperandMem *DestSrc0, Operand *Src1) { return new (Func->allocate
()) InstX86SubRMW(Func, DestSrc0, Src1); } private: InstX86SubRMW(Cfg *Func, X86OperandMem *DestSrc0, Operand *Src1) : InstX86BaseBinopRMW
(Func, DestSrc0, Src1) {} }; class InstX86Subps : public InstX86BaseBinopXmm
{ public: static InstX86Subps *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Subps(Func, Dest, Source); } private: InstX86Subps(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Subss : public InstX86BaseBinopXmm
{ public: static InstX86Subss *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Subss(Func, Dest, Source); } private: InstX86Subss(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Sbb : public InstX86BaseBinopGPR
{ public: static InstX86Sbb *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Sbb(Func, Dest, Source); } private: InstX86Sbb(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopGPR
(Func, Dest, Source) {} }; class InstX86SbbRMW : public InstX86BaseBinopRMW
{ public: static InstX86SbbRMW *create(Cfg *Func, X86OperandMem *DestSrc0, Operand *Src1) { return new (Func->allocate
()) InstX86SbbRMW(Func, DestSrc0, Src1); } private: InstX86SbbRMW(Cfg *Func, X86OperandMem *DestSrc0, Operand *Src1) : InstX86BaseBinopRMW
(Func, DestSrc0, Src1) {} }; class InstX86Psub : public InstX86BaseBinopXmm
{ public: static InstX86Psub *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Psub(Func, Dest, Source); } private: InstX86Psub(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Psubs : public InstX86BaseBinopXmm
{ public: static InstX86Psubs *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Psubs(Func, Dest, Source); } private: InstX86Psubs(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Psubus : public InstX86BaseBinopXmm
{ public: static InstX86Psubus *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Psubus(Func, Dest, Source); } private: InstX86Psubus(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86And : public InstX86BaseBinopGPR
{ public: static InstX86And *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86And(Func, Dest, Source); } private: InstX86And(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopGPR
(Func, Dest, Source) {} }; class InstX86Andnps : public InstX86BaseBinopXmm
{ public: static InstX86Andnps *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Andnps(Func, Dest, Source); } private: InstX86Andnps(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Andps : public InstX86BaseBinopXmm
{ public: static InstX86Andps *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Andps(Func, Dest, Source); } private: InstX86Andps(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86AndRMW : public InstX86BaseBinopRMW
{ public: static InstX86AndRMW *create(Cfg *Func, X86OperandMem *DestSrc0, Operand *Src1) { return new (Func->allocate
()) InstX86AndRMW(Func, DestSrc0, Src1); } private: InstX86AndRMW(Cfg *Func, X86OperandMem *DestSrc0, Operand *Src1) : InstX86BaseBinopRMW
(Func, DestSrc0, Src1) {} }; class InstX86Pand : public InstX86BaseBinopXmm
{ public: static InstX86Pand *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Pand(Func, Dest, Source); } private: InstX86Pand(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Pandn : public InstX86BaseBinopXmm
{ public: static InstX86Pandn *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Pandn(Func, Dest, Source); } private: InstX86Pandn(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Maxss : public InstX86BaseBinopXmm
{ public: static InstX86Maxss *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Maxss(Func, Dest, Source); } private: InstX86Maxss(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Minss : public InstX86BaseBinopXmm
{ public: static InstX86Minss *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Minss(Func, Dest, Source); } private: InstX86Minss(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Maxps : public InstX86BaseBinopXmm
{ public: static InstX86Maxps *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Maxps(Func, Dest, Source); } private: InstX86Maxps(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Minps : public InstX86BaseBinopXmm
{ public: static InstX86Minps *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Minps(Func, Dest, Source); } private: InstX86Minps(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Or : public InstX86BaseBinopGPR
{ public: static InstX86Or *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Or(Func, Dest, Source); } private: InstX86Or(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopGPR
(Func, Dest, Source) {} }; class InstX86Orps : public InstX86BaseBinopXmm
{ public: static InstX86Orps *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Orps(Func, Dest, Source); } private: InstX86Orps(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86OrRMW : public InstX86BaseBinopRMW
{ public: static InstX86OrRMW *create(Cfg *Func, X86OperandMem *DestSrc0, Operand *Src1) { return new (Func->allocate
()) InstX86OrRMW(Func, DestSrc0, Src1); } private: InstX86OrRMW(Cfg *Func, X86OperandMem *DestSrc0, Operand *Src1) : InstX86BaseBinopRMW
(Func, DestSrc0, Src1) {} }; class InstX86Por : public InstX86BaseBinopXmm
{ public: static InstX86Por *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Por(Func, Dest, Source); } private: InstX86Por(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Xor : public InstX86BaseBinopGPR
{ public: static InstX86Xor *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Xor(Func, Dest, Source); } private: InstX86Xor(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopGPR
(Func, Dest, Source) {} }; class InstX86Xorps : public InstX86BaseBinopXmm
{ public: static InstX86Xorps *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Xorps(Func, Dest, Source); } private: InstX86Xorps(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86XorRMW : public InstX86BaseBinopRMW
{ public: static InstX86XorRMW *create(Cfg *Func, X86OperandMem *DestSrc0, Operand *Src1) { return new (Func->allocate
()) InstX86XorRMW(Func, DestSrc0, Src1); } private: InstX86XorRMW(Cfg *Func, X86OperandMem *DestSrc0, Operand *Src1) : InstX86BaseBinopRMW
(Func, DestSrc0, Src1) {} }; class InstX86Pxor : public InstX86BaseBinopXmm
{ public: static InstX86Pxor *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Pxor(Func, Dest, Source); } private: InstX86Pxor(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Imul : public InstX86BaseBinopGPR
{ public: static InstX86Imul *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Imul(Func, Dest, Source); } void emit(const Cfg *Func) const override; void emitIAS(const Cfg *Func) const override; private: InstX86Imul(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopGPR
(Func, Dest, Source) {} }; class InstX86ImulImm : public InstX86BaseThreeAddressop
{ public: static InstX86ImulImm *create(Cfg *Func, Variable *Dest, Operand *Source0, Operand *Source1) { return new (Func->allocate
()) InstX86ImulImm(Func, Dest, Source0, Source1); } void emit(const Cfg *Func) const override; void emitIAS(const Cfg *Func) const override; private: InstX86ImulImm(Cfg *Func, Variable *Dest, Operand *Source0, Operand *Source1) : InstX86BaseThreeAddressop
(Func, Dest, Source0, Source1) {} }; class InstX86Mulps : public InstX86BaseBinopXmm
{ public: static InstX86Mulps *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Mulps(Func, Dest, Source); } private: InstX86Mulps(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Mulss : public InstX86BaseBinopXmm
{ public: static InstX86Mulss *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Mulss(Func, Dest, Source); } private: InstX86Mulss(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Pmull : public InstX86BaseBinopXmm
{ public: static InstX86Pmull *create(Cfg *Func, Variable *Dest, Operand *Source) { bool TypesAreValid = Dest->getType() == IceType_v4i32 || Dest->getType() == IceType_v8i16; auto *Target = InstX86Base::getTarget(Func); bool InstructionSetIsValid = Dest->getType() == IceType_v8i16 || Target->getInstructionSet() >= Traits::SSE4_1; (void)TypesAreValid; (void)InstructionSetIsValid; assert(TypesAreValid); assert(InstructionSetIsValid); return new (Func->allocate
()) InstX86Pmull(Func, Dest, Source); } private: InstX86Pmull(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Pmulhw : public InstX86BaseBinopXmm
{ public: static InstX86Pmulhw *create(Cfg *Func, Variable *Dest, Operand *Source) { assert(Dest->getType() == IceType_v8i16 && Source->getType() == IceType_v8i16); return new (Func->allocate
()) InstX86Pmulhw(Func, Dest, Source); } private: InstX86Pmulhw(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Pmulhuw : public InstX86BaseBinopXmm
{ public: static InstX86Pmulhuw *create(Cfg *Func, Variable *Dest, Operand *Source) { assert(Dest->getType() == IceType_v8i16 && Source->getType() == IceType_v8i16); return new (Func->allocate
()) InstX86Pmulhuw(Func, Dest, Source); } private: InstX86Pmulhuw(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Pmaddwd : public InstX86BaseBinopXmm
{ public: static InstX86Pmaddwd *create(Cfg *Func, Variable *Dest, Operand *Source) { assert(Dest->getType() == IceType_v8i16 && Source->getType() == IceType_v8i16); return new (Func->allocate
()) InstX86Pmaddwd(Func, Dest, Source); } private: InstX86Pmaddwd(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Pmuludq : public InstX86BaseBinopXmm
{ public: static InstX86Pmuludq *create(Cfg *Func, Variable *Dest, Operand *Source) { assert(Dest->getType() == IceType_v4i32 && Source->getType() == IceType_v4i32); return new (Func->allocate
()) InstX86Pmuludq(Func, Dest, Source); } private: InstX86Pmuludq(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Divps : public InstX86BaseBinopXmm
{ public: static InstX86Divps *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Divps(Func, Dest, Source); } private: InstX86Divps(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Divss : public InstX86BaseBinopXmm
{ public: static InstX86Divss *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Divss(Func, Dest, Source); } private: InstX86Divss(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmm
(Func, Dest, Source) {} }; class InstX86Rol : public InstX86BaseBinopGPRShift
{ public: static InstX86Rol *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Rol(Func, Dest, Source); } private: InstX86Rol(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopGPRShift
(Func, Dest, Source) {} }; class InstX86Shl : public InstX86BaseBinopGPRShift
{ public: static InstX86Shl *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Shl(Func, Dest, Source); } private: InstX86Shl(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopGPRShift
(Func, Dest, Source) {} }; class InstX86Psll : public InstX86BaseBinopXmmShift
{ public: static InstX86Psll *create(Cfg *Func, Variable *Dest, Operand *Source) { assert( Dest->getType() == IceType_v8i16 || Dest->getType() == IceType_v8i1 || Dest->getType() == IceType_v4i32 || Dest->getType() == IceType_v4i1); return new (Func->allocate
()) InstX86Psll(Func, Dest, Source); } private: InstX86Psll(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmmShift
(Func, Dest, Source) {} }; class InstX86Psrl : public InstX86BaseBinopXmmShift
{ public: static InstX86Psrl *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Psrl(Func, Dest, Source); } private: InstX86Psrl(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmmShift
(Func, Dest, Source) {} }; class InstX86Shr : public InstX86BaseBinopGPRShift
{ public: static InstX86Shr *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Shr(Func, Dest, Source); } private: InstX86Shr(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopGPRShift
(Func, Dest, Source) {} }; class InstX86Sar : public InstX86BaseBinopGPRShift
{ public: static InstX86Sar *create(Cfg *Func, Variable *Dest, Operand *Source) { return new (Func->allocate
()) InstX86Sar(Func, Dest, Source); } private: InstX86Sar(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopGPRShift
(Func, Dest, Source) {} }; class InstX86Psra : public InstX86BaseBinopXmmShift
{ public: static InstX86Psra *create(Cfg *Func, Variable *Dest, Operand *Source) { assert( Dest->getType() == IceType_v8i16 || Dest->getType() == IceType_v8i1 || Dest->getType() == IceType_v4i32 || Dest->getType() == IceType_v4i1); return new (Func->allocate
()) InstX86Psra(Func, Dest, Source); } private: InstX86Psra(Cfg *Func, Variable *Dest, Operand *Source) : InstX86BaseBinopXmmShift