diff options
author | Nicolas Geoffray <ngeoffray@google.com> | 2014-03-28 15:43:40 +0000 |
---|---|---|
committer | Nicolas Geoffray <ngeoffray@google.com> | 2014-03-31 11:41:39 +0100 |
commit | d8ee737fdbf380c5bb90c9270c8d1087ac23e76c (patch) | |
tree | becdbf2b4e2a3c84952bd7b1db60a2daccd47206 /compiler/optimizing/nodes.h | |
parent | 7f466c08888129a9923cb973a4dc73ee4a71574e (diff) | |
download | art-d8ee737fdbf380c5bb90c9270c8d1087ac23e76c.zip art-d8ee737fdbf380c5bb90c9270c8d1087ac23e76c.tar.gz art-d8ee737fdbf380c5bb90c9270c8d1087ac23e76c.tar.bz2 |
Add support for adding two integers in optimizing compiler.
Change-Id: I5524e193cd07f2692a57c6b4f8069904471b2928
Diffstat (limited to 'compiler/optimizing/nodes.h')
-rw-r--r-- | compiler/optimizing/nodes.h | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 50d5c59..fc67486 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -180,6 +180,7 @@ class HBasicBlock : public ArenaObject { }; #define FOR_EACH_INSTRUCTION(M) \ + M(Add) \ M(Equal) \ M(Exit) \ M(Goto) \ @@ -477,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: @@ -591,6 +614,19 @@ class HInvokeStatic : public HInvoke { 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) { } |