Commit 51e8cfba by Matt Wala

Subzero: Make InstX8632Cbwdq a UnaryOp.

After the changes in CL 443203003, InstX8632Cbwdq fits the template for a UnaryOp, so change it to be in instance of this class. BUG=none R=stichnot@chromium.org Review URL: https://codereview.chromium.org/452143003
parent afeaee41
...@@ -136,11 +136,6 @@ InstX8632Call::InstX8632Call(Cfg *Func, Variable *Dest, Operand *CallTarget) ...@@ -136,11 +136,6 @@ InstX8632Call::InstX8632Call(Cfg *Func, Variable *Dest, Operand *CallTarget)
addSource(CallTarget); addSource(CallTarget);
} }
InstX8632Cbwdq::InstX8632Cbwdq(Cfg *Func, Variable *Dest, Operand *Source)
: InstX8632(Func, InstX8632::Cbwdq, 1, Dest) {
addSource(Source);
}
InstX8632Cmov::InstX8632Cmov(Cfg *Func, Variable *Dest, Operand *Source, InstX8632Cmov::InstX8632Cmov(Cfg *Func, Variable *Dest, Operand *Source,
InstX8632::BrCond Condition) InstX8632::BrCond Condition)
: InstX8632(Func, InstX8632::Cmov, 2, Dest), Condition(Condition) { : InstX8632(Func, InstX8632::Cmov, 2, Dest), Condition(Condition) {
...@@ -452,6 +447,7 @@ template <> const char *InstX8632Bsr::Opcode = "bsr"; ...@@ -452,6 +447,7 @@ template <> const char *InstX8632Bsr::Opcode = "bsr";
template <> const char *InstX8632Lea::Opcode = "lea"; template <> const char *InstX8632Lea::Opcode = "lea";
template <> const char *InstX8632Movd::Opcode = "movd"; template <> const char *InstX8632Movd::Opcode = "movd";
template <> const char *InstX8632Sqrtss::Opcode = "sqrtss"; template <> const char *InstX8632Sqrtss::Opcode = "sqrtss";
template <> const char *InstX8632Cbwdq::Opcode = "cbw/cwd/cdq";
// Binary ops // Binary ops
template <> const char *InstX8632Add::Opcode = "add"; template <> const char *InstX8632Add::Opcode = "add";
template <> const char *InstX8632Addps::Opcode = "addps"; template <> const char *InstX8632Addps::Opcode = "addps";
...@@ -647,6 +643,31 @@ template <> void InstX8632Imul::emit(const Cfg *Func) const { ...@@ -647,6 +643,31 @@ template <> void InstX8632Imul::emit(const Cfg *Func) const {
} }
} }
template <> void InstX8632Cbwdq::emit(const Cfg *Func) const {
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1);
Operand *Src0 = getSrc(0);
assert(llvm::isa<Variable>(Src0));
assert(llvm::cast<Variable>(Src0)->getRegNum() == TargetX8632::Reg_eax);
switch (Src0->getType()) {
default:
llvm_unreachable("unexpected source type!");
break;
case IceType_i8:
assert(getDest()->getRegNum() == TargetX8632::Reg_eax);
Str << "\tcbw\n";
break;
case IceType_i16:
assert(getDest()->getRegNum() == TargetX8632::Reg_edx);
Str << "\tcwd\n";
break;
case IceType_i32:
assert(getDest()->getRegNum() == TargetX8632::Reg_edx);
Str << "\tcdq\n";
break;
}
}
void InstX8632Mul::emit(const Cfg *Func) const { void InstX8632Mul::emit(const Cfg *Func) const {
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2); assert(getSrcSize() == 2);
...@@ -718,38 +739,6 @@ void InstX8632Shrd::dump(const Cfg *Func) const { ...@@ -718,38 +739,6 @@ void InstX8632Shrd::dump(const Cfg *Func) const {
dumpSources(Func); dumpSources(Func);
} }
void InstX8632Cbwdq::emit(const Cfg *Func) const {
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1);
Operand *Src0 = getSrc(0);
assert(llvm::isa<Variable>(Src0));
assert(llvm::cast<Variable>(Src0)->getRegNum() == TargetX8632::Reg_eax);
switch (Src0->getType()) {
default:
llvm_unreachable("unexpected source type!");
break;
case IceType_i8:
assert(getDest()->getRegNum() == TargetX8632::Reg_eax);
Str << "\tcbw\n";
break;
case IceType_i16:
assert(getDest()->getRegNum() == TargetX8632::Reg_edx);
Str << "\tcwd\n";
break;
case IceType_i32:
assert(getDest()->getRegNum() == TargetX8632::Reg_edx);
Str << "\tcdq\n";
break;
}
}
void InstX8632Cbwdq::dump(const Cfg *Func) const {
Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func);
Str << " = cbw/cwd/cdq." << getSrc(0)->getType() << " ";
dumpSources(Func);
}
void InstX8632Cmov::emit(const Cfg *Func) const { void InstX8632Cmov::emit(const Cfg *Func) const {
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
Str << "\t"; Str << "\t";
......
...@@ -556,6 +556,8 @@ typedef InstX8632Unaryop<InstX8632::Bsr> InstX8632Bsr; ...@@ -556,6 +556,8 @@ typedef InstX8632Unaryop<InstX8632::Bsr> InstX8632Bsr;
typedef InstX8632Unaryop<InstX8632::Lea> InstX8632Lea; typedef InstX8632Unaryop<InstX8632::Lea> InstX8632Lea;
typedef InstX8632Unaryop<InstX8632::Movd> InstX8632Movd; typedef InstX8632Unaryop<InstX8632::Movd> InstX8632Movd;
typedef InstX8632Unaryop<InstX8632::Sqrtss> InstX8632Sqrtss; typedef InstX8632Unaryop<InstX8632::Sqrtss> InstX8632Sqrtss;
// Cbwdq instruction - wrapper for cbw, cwd, and cdq
typedef InstX8632Unaryop<InstX8632::Cbwdq> InstX8632Cbwdq;
typedef InstX8632Binop<InstX8632::Add> InstX8632Add; typedef InstX8632Binop<InstX8632::Add> InstX8632Add;
typedef InstX8632Binop<InstX8632::Addps> InstX8632Addps; typedef InstX8632Binop<InstX8632::Addps> InstX8632Addps;
typedef InstX8632Binop<InstX8632::Adc> InstX8632Adc; typedef InstX8632Binop<InstX8632::Adc> InstX8632Adc;
...@@ -689,24 +691,6 @@ private: ...@@ -689,24 +691,6 @@ private:
virtual ~InstX8632Shrd() {} virtual ~InstX8632Shrd() {}
}; };
// Cbdwq instruction - wrapper for cbw, cwd, or cdq
class InstX8632Cbwdq : public InstX8632 {
public:
static InstX8632Cbwdq *create(Cfg *Func, Variable *Dest, Operand *Source) {
return new (Func->allocate<InstX8632Cbwdq>())
InstX8632Cbwdq(Func, Dest, Source);
}
virtual void emit(const Cfg *Func) const;
virtual void dump(const Cfg *Func) const;
static bool classof(const Inst *Inst) { return isClassof(Inst, Cbwdq); }
private:
InstX8632Cbwdq(Cfg *Func, Variable *Dest, Operand *Source);
InstX8632Cbwdq(const InstX8632Cbwdq &) LLVM_DELETED_FUNCTION;
InstX8632Cbwdq &operator=(const InstX8632Cbwdq &) LLVM_DELETED_FUNCTION;
virtual ~InstX8632Cbwdq() {}
};
// Conditional move instruction. // Conditional move instruction.
class InstX8632Cmov : public InstX8632 { class InstX8632Cmov : public InstX8632 {
public: public:
...@@ -1195,6 +1179,7 @@ private: ...@@ -1195,6 +1179,7 @@ private:
// possibility of ODR violations and link errors. // possibility of ODR violations and link errors.
template <> void InstX8632Addss::emit(const Cfg *Func) const; template <> void InstX8632Addss::emit(const Cfg *Func) const;
template <> void InstX8632Blendvps::emit(const Cfg *Func) const; template <> void InstX8632Blendvps::emit(const Cfg *Func) const;
template <> void InstX8632Cbwdq::emit(const Cfg *Func) const;
template <> void InstX8632Div::emit(const Cfg *Func) const; template <> void InstX8632Div::emit(const Cfg *Func) const;
template <> void InstX8632Divss::emit(const Cfg *Func) const; template <> void InstX8632Divss::emit(const Cfg *Func) const;
template <> void InstX8632Idiv::emit(const Cfg *Func) const; template <> void InstX8632Idiv::emit(const Cfg *Func) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment