Support fields in optimizing compiler.

- Required support for temporaries, to be only used by baseline compiler.
- Also fixed a few invalid assumptions around locations and instructions
  that don't need materialization. These instructions should not have an Out.

Change-Id: Idc4a30dd95dd18015137300d36bec55fc024cf62
diff --git a/compiler/optimizing/builder.h b/compiler/optimizing/builder.h
index ee32ca8..f94b8e8 100644
--- a/compiler/optimizing/builder.h
+++ b/compiler/optimizing/builder.h
@@ -18,6 +18,7 @@
 #define ART_COMPILER_OPTIMIZING_BUILDER_H_
 
 #include "dex_file.h"
+#include "driver/compiler_driver.h"
 #include "driver/dex_compilation_unit.h"
 #include "primitive.h"
 #include "utils/allocation.h"
@@ -32,7 +33,8 @@
  public:
   HGraphBuilder(ArenaAllocator* arena,
                 DexCompilationUnit* dex_compilation_unit = nullptr,
-                const DexFile* dex_file = nullptr)
+                const DexFile* dex_file = nullptr,
+                CompilerDriver* driver = nullptr)
       : arena_(arena),
         branch_targets_(arena, 0),
         locals_(arena, 0),
@@ -43,7 +45,8 @@
         constant0_(nullptr),
         constant1_(nullptr),
         dex_file_(dex_file),
-        dex_compilation_unit_(dex_compilation_unit) { }
+        dex_compilation_unit_(dex_compilation_unit),
+        compiler_driver_(driver) {}
 
   HGraph* BuildGraph(const DexFile::CodeItem& code);
 
@@ -84,11 +87,13 @@
   template<typename T>
   void Binop_22s(const Instruction& instruction, bool reverse);
 
-  template<typename T> void If_21t(const Instruction& instruction, int32_t dex_offset);
-  template<typename T> void If_22t(const Instruction& instruction, int32_t dex_offset);
+  template<typename T> void If_21t(const Instruction& instruction, uint32_t dex_offset);
+  template<typename T> void If_22t(const Instruction& instruction, uint32_t dex_offset);
 
   void BuildReturn(const Instruction& instruction, Primitive::Type type);
 
+  bool BuildFieldAccess(const Instruction& instruction, uint32_t dex_offset, bool is_get);
+
   // Builds an invocation node and returns whether the instruction is supported.
   bool BuildInvoke(const Instruction& instruction,
                    uint32_t dex_offset,
@@ -117,6 +122,7 @@
 
   const DexFile* const dex_file_;
   DexCompilationUnit* const dex_compilation_unit_;
+  CompilerDriver* const compiler_driver_;
 
   DISALLOW_COPY_AND_ASSIGN(HGraphBuilder);
 };