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

Unified Diff: src/IceOperand.h

Issue 1961583002: Subzero WASM: avoid needless comparisons, add bounds check flag option (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review feedback Created 4 years, 7 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/IceOperand.h
diff --git a/src/IceOperand.h b/src/IceOperand.h
index 26630dfb7584c929b10730a5cd9d5545c04a411f..b3e0f5f027a8a80c8a84f094d4a2d20f4b98d3df 100644
--- a/src/IceOperand.h
+++ b/src/IceOperand.h
@@ -51,6 +51,7 @@ public:
kConst_Max = kConst_Target + MaxTargetKinds,
kVariable,
kVariable64On32,
+ kVariableBoolean,
kVariable_Target, // leave space for target-specific variable kinds
kVariable_Max = kVariable_Target + MaxTargetKinds,
// Target-specific operand classes use kTarget as the starting point for
@@ -95,6 +96,8 @@ public:
virtual ~Operand() = default;
+ virtual Variable *asBoolean() { return nullptr; }
+
protected:
Operand(OperandKind Kind, Type Ty) : Ty(Ty), Kind(Kind) {
// It is undefined behavior to have a larger value in the enum
@@ -984,6 +987,35 @@ private:
const static InstDefList NoDefinitions;
};
+/// BooleanVariable represents a variable that was the zero-extended result of a
+/// comparison. It maintains a pointer to its original i1 source so that the
+/// WASM frontend can avoid adding needless comparisons.
+class BooleanVariable : public Variable {
+ BooleanVariable() = delete;
+ BooleanVariable(const BooleanVariable &) = delete;
+ BooleanVariable &operator=(const BooleanVariable &) = delete;
+
+ BooleanVariable(const Cfg *Func, OperandKind K, Type Ty, SizeT Index)
+ : Variable(Func, K, Ty, Index) {}
+
+public:
+ static BooleanVariable *create(Cfg *Func, Type Ty, SizeT Index) {
+ return new (Func->allocate<BooleanVariable>())
+ BooleanVariable(Func, kVariable, Ty, Index);
+ }
+
+ virtual Variable *asBoolean() { return BoolSource; }
+
+ void setBoolSource(Variable *Src) { BoolSource = Src; }
+
+ static bool classof(const Operand *Operand) {
+ return Operand->getKind() == kVariableBoolean;
+ }
+
+private:
+ Variable *BoolSource = nullptr;
+};
+
} // end of namespace Ice
#endif // SUBZERO_SRC_ICEOPERAND_H

Powered by Google App Engine
This is Rietveld 408576698