ART: Introduce compiler data type.
Replace most uses of the runtime's Primitive in compiler
with a new class DataType. This prepares for introducing
new types, such as Uint8, that the runtime does not need
to know about.
Test: m test-art-host-gtest
Test: testrunner.py --host
Bug: 23964345
Change-Id: Iec2ad82454eec678fffcd8279a9746b90feb9b0c
diff --git a/compiler/optimizing/load_store_analysis_test.cc b/compiler/optimizing/load_store_analysis_test.cc
index 81344b5..0df2f27 100644
--- a/compiler/optimizing/load_store_analysis_test.cc
+++ b/compiler/optimizing/load_store_analysis_test.cc
@@ -49,16 +49,17 @@
// array_set1 ArraySet [array, c1, c3]
// array_set2 ArraySet [array, index, c3]
HInstruction* array = new (&allocator_) HParameterValue(
- graph_->GetDexFile(), dex::TypeIndex(0), 0, Primitive::kPrimNot);
+ graph_->GetDexFile(), dex::TypeIndex(0), 0, DataType::Type::kReference);
HInstruction* index = new (&allocator_) HParameterValue(
- graph_->GetDexFile(), dex::TypeIndex(1), 1, Primitive::kPrimInt);
+ graph_->GetDexFile(), dex::TypeIndex(1), 1, DataType::Type::kInt32);
HInstruction* c1 = graph_->GetIntConstant(1);
HInstruction* c2 = graph_->GetIntConstant(2);
HInstruction* c3 = graph_->GetIntConstant(3);
- HInstruction* array_get1 = new (&allocator_) HArrayGet(array, c1, Primitive::kPrimInt, 0);
- HInstruction* array_get2 = new (&allocator_) HArrayGet(array, c2, Primitive::kPrimInt, 0);
- HInstruction* array_set1 = new (&allocator_) HArraySet(array, c1, c3, Primitive::kPrimInt, 0);
- HInstruction* array_set2 = new (&allocator_) HArraySet(array, index, c3, Primitive::kPrimInt, 0);
+ HInstruction* array_get1 = new (&allocator_) HArrayGet(array, c1, DataType::Type::kInt32, 0);
+ HInstruction* array_get2 = new (&allocator_) HArrayGet(array, c2, DataType::Type::kInt32, 0);
+ HInstruction* array_set1 = new (&allocator_) HArraySet(array, c1, c3, DataType::Type::kInt32, 0);
+ HInstruction* array_set2 =
+ new (&allocator_) HArraySet(array, index, c3, DataType::Type::kInt32, 0);
entry->AddInstruction(array);
entry->AddInstruction(index);
entry->AddInstruction(array_get1);
@@ -121,11 +122,11 @@
HInstruction* object = new (&allocator_) HParameterValue(graph_->GetDexFile(),
dex::TypeIndex(0),
0,
- Primitive::kPrimNot);
+ DataType::Type::kReference);
HInstanceFieldSet* set_field10 = new (&allocator_) HInstanceFieldSet(object,
c1,
nullptr,
- Primitive::kPrimInt,
+ DataType::Type::kInt32,
MemberOffset(10),
false,
kUnknownFieldIndex,
@@ -134,7 +135,7 @@
0);
HInstanceFieldGet* get_field10 = new (&allocator_) HInstanceFieldGet(object,
nullptr,
- Primitive::kPrimInt,
+ DataType::Type::kInt32,
MemberOffset(10),
false,
kUnknownFieldIndex,
@@ -143,7 +144,7 @@
0);
HInstanceFieldGet* get_field20 = new (&allocator_) HInstanceFieldGet(object,
nullptr,
- Primitive::kPrimInt,
+ DataType::Type::kInt32,
MemberOffset(20),
false,
kUnknownFieldIndex,
@@ -191,26 +192,28 @@
graph_->BuildDominatorTree();
HInstruction* array = new (&allocator_) HParameterValue(
- graph_->GetDexFile(), dex::TypeIndex(0), 0, Primitive::kPrimNot);
+ graph_->GetDexFile(), dex::TypeIndex(0), 0, DataType::Type::kReference);
HInstruction* index = new (&allocator_) HParameterValue(
- graph_->GetDexFile(), dex::TypeIndex(1), 1, Primitive::kPrimInt);
+ graph_->GetDexFile(), dex::TypeIndex(1), 1, DataType::Type::kInt32);
HInstruction* c0 = graph_->GetIntConstant(0);
HInstruction* c1 = graph_->GetIntConstant(1);
HInstruction* c_neg1 = graph_->GetIntConstant(-1);
- HInstruction* add0 = new (&allocator_) HAdd(Primitive::kPrimInt, index, c0);
- HInstruction* add1 = new (&allocator_) HAdd(Primitive::kPrimInt, index, c1);
- HInstruction* sub0 = new (&allocator_) HSub(Primitive::kPrimInt, index, c0);
- HInstruction* sub1 = new (&allocator_) HSub(Primitive::kPrimInt, index, c1);
- HInstruction* sub_neg1 = new (&allocator_) HSub(Primitive::kPrimInt, index, c_neg1);
- HInstruction* rev_sub1 = new (&allocator_) HSub(Primitive::kPrimInt, c1, index);
- HInstruction* arr_set1 = new (&allocator_) HArraySet(array, c0, c0, Primitive::kPrimInt, 0);
- HInstruction* arr_set2 = new (&allocator_) HArraySet(array, c1, c0, Primitive::kPrimInt, 0);
- HInstruction* arr_set3 = new (&allocator_) HArraySet(array, add0, c0, Primitive::kPrimInt, 0);
- HInstruction* arr_set4 = new (&allocator_) HArraySet(array, add1, c0, Primitive::kPrimInt, 0);
- HInstruction* arr_set5 = new (&allocator_) HArraySet(array, sub0, c0, Primitive::kPrimInt, 0);
- HInstruction* arr_set6 = new (&allocator_) HArraySet(array, sub1, c0, Primitive::kPrimInt, 0);
- HInstruction* arr_set7 = new (&allocator_) HArraySet(array, rev_sub1, c0, Primitive::kPrimInt, 0);
- HInstruction* arr_set8 = new (&allocator_) HArraySet(array, sub_neg1, c0, Primitive::kPrimInt, 0);
+ HInstruction* add0 = new (&allocator_) HAdd(DataType::Type::kInt32, index, c0);
+ HInstruction* add1 = new (&allocator_) HAdd(DataType::Type::kInt32, index, c1);
+ HInstruction* sub0 = new (&allocator_) HSub(DataType::Type::kInt32, index, c0);
+ HInstruction* sub1 = new (&allocator_) HSub(DataType::Type::kInt32, index, c1);
+ HInstruction* sub_neg1 = new (&allocator_) HSub(DataType::Type::kInt32, index, c_neg1);
+ HInstruction* rev_sub1 = new (&allocator_) HSub(DataType::Type::kInt32, c1, index);
+ HInstruction* arr_set1 = new (&allocator_) HArraySet(array, c0, c0, DataType::Type::kInt32, 0);
+ HInstruction* arr_set2 = new (&allocator_) HArraySet(array, c1, c0, DataType::Type::kInt32, 0);
+ HInstruction* arr_set3 = new (&allocator_) HArraySet(array, add0, c0, DataType::Type::kInt32, 0);
+ HInstruction* arr_set4 = new (&allocator_) HArraySet(array, add1, c0, DataType::Type::kInt32, 0);
+ HInstruction* arr_set5 = new (&allocator_) HArraySet(array, sub0, c0, DataType::Type::kInt32, 0);
+ HInstruction* arr_set6 = new (&allocator_) HArraySet(array, sub1, c0, DataType::Type::kInt32, 0);
+ HInstruction* arr_set7 =
+ new (&allocator_) HArraySet(array, rev_sub1, c0, DataType::Type::kInt32, 0);
+ HInstruction* arr_set8 =
+ new (&allocator_) HArraySet(array, sub_neg1, c0, DataType::Type::kInt32, 0);
entry->AddInstruction(array);
entry->AddInstruction(index);
@@ -275,9 +278,9 @@
graph_->BuildDominatorTree();
HInstruction* array = new (&allocator_) HParameterValue(
- graph_->GetDexFile(), dex::TypeIndex(0), 0, Primitive::kPrimNot);
+ graph_->GetDexFile(), dex::TypeIndex(0), 0, DataType::Type::kReference);
HInstruction* index = new (&allocator_) HParameterValue(
- graph_->GetDexFile(), dex::TypeIndex(1), 1, Primitive::kPrimInt);
+ graph_->GetDexFile(), dex::TypeIndex(1), 1, DataType::Type::kInt32);
HInstruction* c0 = graph_->GetIntConstant(0);
HInstruction* c_0x80000000 = graph_->GetIntConstant(0x80000000);
@@ -287,34 +290,41 @@
HInstruction* c_0x80000001 = graph_->GetIntConstant(0x80000001);
// `index+0x80000000` and `index-0x80000000` array indices MAY alias.
- HInstruction* add_0x80000000 = new (&allocator_) HAdd(Primitive::kPrimInt, index, c_0x80000000);
- HInstruction* sub_0x80000000 = new (&allocator_) HSub(Primitive::kPrimInt, index, c_0x80000000);
+ HInstruction* add_0x80000000 = new (&allocator_) HAdd(
+ DataType::Type::kInt32, index, c_0x80000000);
+ HInstruction* sub_0x80000000 = new (&allocator_) HSub(
+ DataType::Type::kInt32, index, c_0x80000000);
HInstruction* arr_set_1 = new (&allocator_) HArraySet(
- array, add_0x80000000, c0, Primitive::kPrimInt, 0);
+ array, add_0x80000000, c0, DataType::Type::kInt32, 0);
HInstruction* arr_set_2 = new (&allocator_) HArraySet(
- array, sub_0x80000000, c0, Primitive::kPrimInt, 0);
+ array, sub_0x80000000, c0, DataType::Type::kInt32, 0);
// `index+0x10` and `index-0xFFFFFFF0` array indices MAY alias.
- HInstruction* add_0x10 = new (&allocator_) HAdd(Primitive::kPrimInt, index, c_0x10);
- HInstruction* sub_0xFFFFFFF0 = new (&allocator_) HSub(Primitive::kPrimInt, index, c_0xFFFFFFF0);
+ HInstruction* add_0x10 = new (&allocator_) HAdd(DataType::Type::kInt32, index, c_0x10);
+ HInstruction* sub_0xFFFFFFF0 = new (&allocator_) HSub(
+ DataType::Type::kInt32, index, c_0xFFFFFFF0);
HInstruction* arr_set_3 = new (&allocator_) HArraySet(
- array, add_0x10, c0, Primitive::kPrimInt, 0);
+ array, add_0x10, c0, DataType::Type::kInt32, 0);
HInstruction* arr_set_4 = new (&allocator_) HArraySet(
- array, sub_0xFFFFFFF0, c0, Primitive::kPrimInt, 0);
+ array, sub_0xFFFFFFF0, c0, DataType::Type::kInt32, 0);
// `index+0x7FFFFFFF` and `index-0x80000001` array indices MAY alias.
- HInstruction* add_0x7FFFFFFF = new (&allocator_) HAdd(Primitive::kPrimInt, index, c_0x7FFFFFFF);
- HInstruction* sub_0x80000001 = new (&allocator_) HSub(Primitive::kPrimInt, index, c_0x80000001);
+ HInstruction* add_0x7FFFFFFF = new (&allocator_) HAdd(
+ DataType::Type::kInt32, index, c_0x7FFFFFFF);
+ HInstruction* sub_0x80000001 = new (&allocator_) HSub(
+ DataType::Type::kInt32, index, c_0x80000001);
HInstruction* arr_set_5 = new (&allocator_) HArraySet(
- array, add_0x7FFFFFFF, c0, Primitive::kPrimInt, 0);
+ array, add_0x7FFFFFFF, c0, DataType::Type::kInt32, 0);
HInstruction* arr_set_6 = new (&allocator_) HArraySet(
- array, sub_0x80000001, c0, Primitive::kPrimInt, 0);
+ array, sub_0x80000001, c0, DataType::Type::kInt32, 0);
// `index+0` and `index-0` array indices MAY alias.
- HInstruction* add_0 = new (&allocator_) HAdd(Primitive::kPrimInt, index, c0);
- HInstruction* sub_0 = new (&allocator_) HSub(Primitive::kPrimInt, index, c0);
- HInstruction* arr_set_7 = new (&allocator_) HArraySet(array, add_0, c0, Primitive::kPrimInt, 0);
- HInstruction* arr_set_8 = new (&allocator_) HArraySet(array, sub_0, c0, Primitive::kPrimInt, 0);
+ HInstruction* add_0 = new (&allocator_) HAdd(DataType::Type::kInt32, index, c0);
+ HInstruction* sub_0 = new (&allocator_) HSub(DataType::Type::kInt32, index, c0);
+ HInstruction* arr_set_7 = new (&allocator_) HArraySet(
+ array, add_0, c0, DataType::Type::kInt32, 0);
+ HInstruction* arr_set_8 = new (&allocator_) HArraySet(
+ array, sub_0, c0, DataType::Type::kInt32, 0);
entry->AddInstruction(array);
entry->AddInstruction(index);