summaryrefslogtreecommitdiffstats
path: root/compiler/dex/mir_graph.h
diff options
context:
space:
mode:
authorJean Christophe Beyler <jean.christophe.beyler@intel.com>2014-05-05 21:09:40 -0700
committerJean Christophe Beyler <jean.christophe.beyler@intel.com>2014-05-22 11:32:37 -0700
commitc3db20b7e6f847339d6ecbd89846c173a7ccc967 (patch)
treeeb65dfbcbf6d06018d7f0f9bc0c14f782497d5d3 /compiler/dex/mir_graph.h
parentb8033db2a8dc6f7c7e29b1552177542964f56e44 (diff)
downloadart-c3db20b7e6f847339d6ecbd89846c173a7ccc967.tar.gz
art-c3db20b7e6f847339d6ecbd89846c173a7ccc967.tar.bz2
art-c3db20b7e6f847339d6ecbd89846c173a7ccc967.zip
ART: API to dex instructions
- Added the GetConstant function call in DecodedInstruction. - Added a few rewriter helper functions for later higher level rewriting. - Added Setter/Getter data and query functions. - Added Clobber memory/Const/Call/Cast data and query functions. - Added expression information (add, multiply, ...). - Added a IsLinear function for additions and subtractions. - Added an empty constructor for the DecodedInstruction: - Useful for the creation of a MIR constructor too. - Added the IsConditionalBranch utility function. Signed-off-by: Jean Christophe Beyler <jean.christophe.beyler@intel.com> Signed-off-by: Razvan A Lupusoru <razvan.a.lupusoru@intel.com> Signed-off-by: Yixin Shou <yixin.shou@intel.com> Signed-off-by: Chao-ying Fu <chao-ying.fu@intel.com> Signed-off-by: Udayan Banerji <udayan.banerji@intel.com> Change-Id: Ie21f2a7779b38c1b383334f04126c2d792cae462
Diffstat (limited to 'compiler/dex/mir_graph.h')
-rw-r--r--compiler/dex/mir_graph.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/compiler/dex/mir_graph.h b/compiler/dex/mir_graph.h
index 0bb82659a2..73260dfce8 100644
--- a/compiler/dex/mir_graph.h
+++ b/compiler/dex/mir_graph.h
@@ -266,6 +266,56 @@ struct MIR {
explicit DecodedInstruction():vA(0), vB(0), vB_wide(0), vC(0), opcode(Instruction::NOP) {
}
+
+ /*
+ * Given a decoded instruction representing a const bytecode, it updates
+ * the out arguments with proper values as dictated by the constant bytecode.
+ */
+ bool GetConstant(int64_t* ptr_value, bool* wide) const;
+
+ bool IsStore() const {
+ return ((Instruction::FlagsOf(opcode) & Instruction::kStore) == Instruction::kStore);
+ }
+
+ bool IsLoad() const {
+ return ((Instruction::FlagsOf(opcode) & Instruction::kLoad) == Instruction::kLoad);
+ }
+
+ bool IsConditionalBranch() const {
+ return (Instruction::FlagsOf(opcode) == (Instruction::kContinue | Instruction::kBranch));
+ }
+
+ /**
+ * @brief Is the register C component of the decoded instruction a constant?
+ */
+ bool IsCFieldOrConstant() const {
+ return ((Instruction::FlagsOf(opcode) & Instruction::kRegCFieldOrConstant) == Instruction::kRegCFieldOrConstant);
+ }
+
+ /**
+ * @brief Is the register C component of the decoded instruction a constant?
+ */
+ bool IsBFieldOrConstant() const {
+ return ((Instruction::FlagsOf(opcode) & Instruction::kRegBFieldOrConstant) == Instruction::kRegBFieldOrConstant);
+ }
+
+ bool IsCast() const {
+ return ((Instruction::FlagsOf(opcode) & Instruction::kCast) == Instruction::kCast);
+ }
+
+ /**
+ * @brief Does the instruction clobber memory?
+ * @details Clobber means that the instruction changes the memory not in a punctual way.
+ * Therefore any supposition on memory aliasing or memory contents should be disregarded
+ * when crossing such an instruction.
+ */
+ bool Clobbers() const {
+ return ((Instruction::FlagsOf(opcode) & Instruction::kClobber) == Instruction::kClobber);
+ }
+
+ bool IsLinear() const {
+ return (Instruction::FlagsOf(opcode) & (Instruction::kAdd | Instruction::kSubtract)) != 0;
+ }
} dalvikInsn;
NarrowDexOffset offset; // Offset of the instruction in code units.