Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Unified Diff: src/IceInstX8632.h

Issue 390443005: Lower bitmanip intrinsics, assuming absence of BMI/SSE4.2 for now. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: stuff Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/IceInstX8632.h
diff --git a/src/IceInstX8632.h b/src/IceInstX8632.h
index 25beb6dd93d58dc138109010c1830c3aab27bc05..28173c2a9d1de44b682f439abc00cf3f5b1e36aa 100644
--- a/src/IceInstX8632.h
+++ b/src/IceInstX8632.h
@@ -139,8 +139,11 @@ public:
Addss,
And,
Br,
+ Bsf,
+ Bsr,
Call,
Cdq,
+ Cmov,
Cmpxchg,
Cmpxchg8b,
Cvt,
@@ -188,6 +191,14 @@ public:
Xchg,
Xor
};
+
+ enum BrCond {
+#define X(tag, dump, emit) tag,
+ ICEINSTX8632BR_TABLE
+#undef X
+ Br_None
+ };
+
static const char *getWidthString(Type Ty);
virtual void emit(const Cfg *Func) const = 0;
virtual void dump(const Cfg *Func) const;
@@ -262,13 +273,6 @@ private:
// Conditional and unconditional branch instruction.
class InstX8632Br : public InstX8632 {
public:
- enum BrCond {
-#define X(tag, dump, emit) tag,
- ICEINSTX8632BR_TABLE
-#undef X
- Br_None
- };
-
// Create a conditional branch to a node.
static InstX8632Br *create(Cfg *Func, CfgNode *TargetTrue,
CfgNode *TargetFalse, BrCond Condition) {
@@ -545,6 +549,49 @@ private:
virtual ~InstX8632Shrd() {}
};
+// Bit-scan-{forward,reverse} instructions. Finds the {least,most} significant
+// '1' bit, and stores the 0-based position in the Dest register.
+// If the Source is all zeroes, then the Dest is undefined and the ZF flag
+// is set. Otherwise, the ZF flag is cleared.
+template <InstX8632::InstKindX8632 K>
+class InstX8632BitScan : public InstX8632 {
wala 2014/07/15 00:16:31 The other instruction classes in the file are defi
Jim Stichnoth 2014/07/15 17:15:02 You're right that this is a unary op, but not the
jvoung (off chromium) 2014/07/15 21:30:23 That sounds reasonable. I'll refactor. I think mo
+public:
+ static InstX8632BitScan *create(Cfg *Func, Variable *Dest, Operand *Source) {
+ return new (Func->allocate<InstX8632BitScan>())
+ InstX8632BitScan(Func, Dest, Source);
+ }
+ virtual void emit(const Cfg *Func) const {
+ Ostream &Str = Func->getContext()->getStrEmit();
+ assert(getSrcSize() == 1);
+ Str << "\t" << Opcode << "\t";
+ getDest()->emit(Func);
+ Str << ", ";
+ getSrc(0)->emit(Func);
+ Str << "\n";
+ }
+ virtual void dump(const Cfg *Func) const {
+ Ostream &Str = Func->getContext()->getStrDump();
+ dumpDest(Func);
+ Str << " = " << Opcode << "." << getDest()->getType() << " ";
+ dumpSources(Func);
+ }
+ static bool classof(const Inst *Inst) { return isClassof(Inst, K); }
+
+private:
+ InstX8632BitScan(Cfg *Func, Variable *Dest, Operand *Source)
+ : InstX8632(Func, K, 1, Dest) {
+ addSource(Source);
+ }
+ InstX8632BitScan(const InstX8632BitScan &) LLVM_DELETED_FUNCTION;
+ InstX8632BitScan &operator=(const InstX8632BitScan &) LLVM_DELETED_FUNCTION;
+ virtual ~InstX8632BitScan() {}
+
+ static const char *Opcode;
+};
+
+typedef InstX8632BitScan<InstX8632::Bsf> InstX8632Bsf;
+typedef InstX8632BitScan<InstX8632::Bsr> InstX8632Bsr;
+
// Cdq instruction - sign-extend eax into edx
class InstX8632Cdq : public InstX8632 {
public:
@@ -563,6 +610,27 @@ private:
virtual ~InstX8632Cdq() {}
};
+// Conditional move instruction.
+class InstX8632Cmov : public InstX8632 {
+public:
+ static InstX8632Cmov *create(Cfg *Func, Variable *Dest, Operand *Source,
+ BrCond Cond) {
+ return new (Func->allocate<InstX8632Cmov>())
+ InstX8632Cmov(Func, Dest, Source, Cond);
+ }
+ virtual void emit(const Cfg *Func) const;
+ virtual void dump(const Cfg *Func) const;
+ static bool classof(const Inst *Inst) { return isClassof(Inst, Cmov); }
+
+private:
+ InstX8632Cmov(Cfg *Func, Variable *Dest, Operand *Source, BrCond Cond);
+ InstX8632Cmov(const InstX8632Cmov &) LLVM_DELETED_FUNCTION;
+ InstX8632Cmov &operator=(const InstX8632Cmov &) LLVM_DELETED_FUNCTION;
+ virtual ~InstX8632Cmov() {}
+
+ BrCond Condition;
+};
+
// Cmpxchg instruction - cmpxchg <dest>, <desired> will compare if <dest>
// equals eax. If so, the ZF is set and <desired> is stored in <dest>.
// If not, ZF is cleared and <dest> is copied to eax (or subregister).

Powered by Google App Engine
This is Rietveld 408576698