summaryrefslogtreecommitdiff
path: root/compiler/optimizing/nodes.h
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/optimizing/nodes.h')
-rw-r--r--compiler/optimizing/nodes.h83
1 files changed, 78 insertions, 5 deletions
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h
index e74ed827ec..fc67486267 100644
--- a/compiler/optimizing/nodes.h
+++ b/compiler/optimizing/nodes.h
@@ -180,11 +180,13 @@ class HBasicBlock : public ArenaObject {
};
#define FOR_EACH_INSTRUCTION(M) \
+ M(Add) \
M(Equal) \
M(Exit) \
M(Goto) \
M(If) \
M(IntConstant) \
+ M(InvokeStatic) \
M(LoadLocal) \
M(Local) \
M(Return) \
@@ -476,14 +478,36 @@ class HIf : public HTemplateInstruction<1> {
DISALLOW_COPY_AND_ASSIGN(HIf);
};
-// Instruction to check if two inputs are equal to each other.
-class HEqual : public HTemplateInstruction<2> {
+class HBinaryOperation : public HTemplateInstruction<2> {
public:
- HEqual(HInstruction* first, HInstruction* second) {
- SetRawInputAt(0, first);
- SetRawInputAt(1, second);
+ HBinaryOperation(Primitive::Type result_type,
+ HInstruction* left,
+ HInstruction* right) : result_type_(result_type) {
+ SetRawInputAt(0, left);
+ SetRawInputAt(1, right);
}
+ HInstruction* GetLeft() const { return InputAt(0); }
+ HInstruction* GetRight() const { return InputAt(1); }
+ Primitive::Type GetResultType() const { return result_type_; }
+
+ virtual bool IsCommutative() { return false; }
+
+ private:
+ const Primitive::Type result_type_;
+
+ DISALLOW_COPY_AND_ASSIGN(HBinaryOperation);
+};
+
+
+// Instruction to check if two inputs are equal to each other.
+class HEqual : public HBinaryOperation {
+ public:
+ HEqual(HInstruction* first, HInstruction* second)
+ : HBinaryOperation(Primitive::kPrimBoolean, first, second) {}
+
+ virtual bool IsCommutative() { return true; }
+
DECLARE_INSTRUCTION(Equal)
private:
@@ -554,6 +578,55 @@ class HIntConstant : public HTemplateInstruction<0> {
DISALLOW_COPY_AND_ASSIGN(HIntConstant);
};
+class HInvoke : public HInstruction {
+ public:
+ HInvoke(ArenaAllocator* arena, uint32_t number_of_arguments, int32_t dex_pc)
+ : inputs_(arena, number_of_arguments),
+ dex_pc_(dex_pc) {
+ inputs_.SetSize(number_of_arguments);
+ }
+
+ virtual intptr_t InputCount() const { return inputs_.Size(); }
+ virtual HInstruction* InputAt(intptr_t i) const { return inputs_.Get(i); }
+
+ int32_t GetDexPc() const { return dex_pc_; }
+
+ protected:
+ GrowableArray<HInstruction*> inputs_;
+ const int32_t dex_pc_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(HInvoke);
+};
+
+class HInvokeStatic : public HInvoke {
+ public:
+ HInvokeStatic(ArenaAllocator* arena, uint32_t number_of_arguments, int32_t dex_pc, int32_t index_in_dex_cache)
+ : HInvoke(arena, number_of_arguments, dex_pc), index_in_dex_cache_(index_in_dex_cache) { }
+
+ uint32_t GetIndexInDexCache() const { return index_in_dex_cache_; }
+
+ DECLARE_INSTRUCTION(InvokeStatic)
+
+ private:
+ uint32_t index_in_dex_cache_;
+
+ DISALLOW_COPY_AND_ASSIGN(HInvokeStatic);
+};
+
+class HAdd : public HBinaryOperation {
+ public:
+ HAdd(Primitive::Type result_type, HInstruction* left, HInstruction* right)
+ : HBinaryOperation(result_type, left, right) {}
+
+ virtual bool IsCommutative() { return true; }
+
+ DECLARE_INSTRUCTION(Add);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(HAdd);
+};
+
class HGraphVisitor : public ValueObject {
public:
explicit HGraphVisitor(HGraph* graph) : graph_(graph) { }