Advertisement
Guest User

Untitled

a guest
May 6th, 2015
1,036
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 5.82 KB | None | 0 0
  1. From 291efc39eb7d939c1cd9ce5f964ce5dafd8d9bca Mon Sep 17 00:00:00 2001
  2. From: sorg <xxx@xxx.com>
  3. Date: Wed, 6 May 2015 20:58:08 +0800
  4. Subject: [PATCH] Zenfone2 art compiler compatibility.
  5.  
  6. ---
  7. compiler/common_compiler_test.cc |   16 +++++++++
  8.  dex2oat/dex2oat.cc               |   18 ++++++++++
  9.  runtime/instruction_set.cc       |   29 ++++++++++++++-
  10.  runtime/instruction_set.h        |   72 ++++++++++++++++++++++++++++++++++++++
  11.  4 files changed, 134 insertions(+), 1 deletion(-)
  12.  
  13. diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc
  14. index 86167ec..2b28731 100644
  15. --- a/compiler/common_compiler_test.cc
  16. +++ b/compiler/common_compiler_test.cc
  17. @@ -131,6 +131,22 @@ static InstructionSetFeatures ParseFeatureList(std::string str) {
  18.      } else if (feature == "nodiv") {
  19.        // Turn off support for divide instruction.
  20.        result.SetHasDivideInstruction(false);
  21. +    } else if (feature == "ssse3") {
  22. +      result.SetHasSSSE3();
  23. +    } else if (feature == "sse4_1") {
  24. +      result.SetHasSSE4_1();
  25. +    } else if (feature == "sse4_2") {
  26. +      result.SetHasSSE4_2();
  27. +    } else if (feature == "avx") {
  28. +      result.SetHasAVX();
  29. +    } else if (feature == "avx2") {
  30. +      result.SetHasAVX2();
  31. +    } else if (feature == "aes_in") {
  32. +      result.SetHasAES_IN();
  33. +    } else if (feature == "popcnt") {
  34. +      result.SetHasPOPCNT();
  35. +    } else if (feature == "movbe") {
  36. +      result.SetHasMOVBE();
  37.      } else {
  38.        LOG(FATAL) << "Unknown instruction set feature: '" << feature << "'";
  39.      }
  40. diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
  41. index 14d454b..b1622d6 100644
  42. --- a/dex2oat/dex2oat.cc
  43. +++ b/dex2oat/dex2oat.cc
  44. @@ -768,6 +768,22 @@ static InstructionSetFeatures ParseFeatureList(std::string str) {
  45.      } else if (feature == "nolpae") {
  46.        // Turn off support for Large Physical Address Extension.
  47.        result.SetHasLpae(false);
  48. +    } else if (feature == "ssse3") {
  49. +      result.SetHasSSSE3();
  50. +    } else if (feature == "sse4_1") {
  51. +      result.SetHasSSE4_1();
  52. +    } else if (feature == "sse4_2") {
  53. +      result.SetHasSSE4_2();
  54. +    } else if (feature == "avx") {
  55. +      result.SetHasAVX();
  56. +    } else if (feature == "avx2") {
  57. +      result.SetHasAVX2();
  58. +    } else if (feature == "aes_in") {
  59. +      result.SetHasAES_IN();
  60. +    } else if (feature == "popcnt") {
  61. +      result.SetHasPOPCNT();
  62. +    } else if (feature == "movbe") {
  63. +      result.SetHasMOVBE();
  64.      } else {
  65.        Usage("Unknown instruction set feature: '%s'", feature.c_str());
  66.      }
  67. @@ -1196,6 +1212,8 @@ static int dex2oat(int argc, char** argv) {
  68.      compiler_filter = CompilerOptions::kBalanced;
  69.    } else if (strcmp(compiler_filter_string, "speed") == 0) {
  70.      compiler_filter = CompilerOptions::kSpeed;
  71. +  } else if (strcmp(compiler_filter_string, "O2") == 0) {
  72. +    compiler_filter = CompilerOptions::kSpeed;
  73.    } else if (strcmp(compiler_filter_string, "everything") == 0) {
  74.      compiler_filter = CompilerOptions::kEverything;
  75.    } else {
  76. diff --git a/runtime/instruction_set.cc b/runtime/instruction_set.cc
  77. index 644e055..1c01060 100644
  78. --- a/runtime/instruction_set.cc
  79. +++ b/runtime/instruction_set.cc
  80. @@ -119,9 +119,36 @@ size_t GetStackOverflowReservedBytes(InstructionSet isa) {
  81.  
  82.  std::string InstructionSetFeatures::GetFeatureString() const {
  83.    std::string result;
  84. -  if ((mask_ & kHwDiv) != 0) {
  85. +  if (HasDivideInstruction()) {
  86.      result += "div";
  87.    }
  88. +  if (HasLpae()) {
  89. +    result += "lpae";
  90. +  }
  91. +  if (HasSSSE3()) {
  92. +    result += "ssse3";
  93. +  }
  94. +  if (HasSSE4_1()) {
  95. +     result += "sse4_1";
  96. +  }
  97. +  if (HasSSE4_2()) {
  98. +     result += "sse4_2";
  99. +  }
  100. +  if (HasAVX()) {
  101. +     result += "avx";
  102. +  }
  103. +  if (HasAVX2()) {
  104. +     result += "avx2";
  105. +  }
  106. +  if (HasAES_IN()) {
  107. +     result += "aes_in";
  108. +  }
  109. +  if (HasPOPCNT()) {
  110. +     result += "popcnt";
  111. +  }
  112. +  if (HasMOVBE()) {
  113. +     result += "movbe";
  114. +  }
  115.    if (result.size() == 0) {
  116.      result = "none";
  117.    }
  118. diff --git a/runtime/instruction_set.h b/runtime/instruction_set.h
  119. index ae8eeac..ea8855b 100644
  120. --- a/runtime/instruction_set.h
  121. +++ b/runtime/instruction_set.h
  122. @@ -176,6 +176,14 @@ size_t GetStackOverflowReservedBytes(InstructionSet isa);
  123.  enum InstructionFeatures {
  124.    kHwDiv  = 0x1,              // Supports hardware divide.
  125.    kHwLpae = 0x2,              // Supports Large Physical Address Extension.
  126. +  kSSSE3  = 0x4,
  127. +  kSSE4_1 = 0xc,
  128. +  kSSE4_2 = 0x1c,
  129. +  kAVX    = 0x3c,
  130. +  kAVX2   = 0x7c,
  131. +  kAES_IN = 0x80,
  132. +  kPOPCNT = 0x100,
  133. +  kMOVBE  = 0x200,
  134.  };
  135.  
  136.  // This is a bitmask of supported features per architecture.
  137. @@ -202,6 +210,70 @@ class PACKED(4) InstructionSetFeatures {
  138.      mask_ = (mask_ & ~kHwLpae) | (v ? kHwLpae : 0);
  139.    }
  140.  
  141. +  bool HasSSSE3() const {
  142. +    return (mask_ & 0x7C) == kSSSE3;
  143. +  }
  144. +
  145. +  void SetHasSSSE3() {
  146. +    mask_ |= kSSSE3;
  147. +  }
  148. +
  149. +  bool HasSSE4_1() const {
  150. +    return (mask_ & 0x7C) == kSSE4_1;
  151. +  }
  152. +
  153. +  void SetHasSSE4_1() {
  154. +    mask_ |= kSSE4_1;
  155. +  }
  156. +
  157. +  bool HasSSE4_2() const {
  158. +    return (mask_ & 0x7C) == kSSE4_2;
  159. +  }
  160. +
  161. +  void SetHasSSE4_2() {
  162. +    mask_ |= kSSE4_2;
  163. +  }
  164. +
  165. +  bool HasAVX() const {
  166. +    return (mask_ & 0x7C) == kAVX;
  167. +  }
  168. +
  169. +  void SetHasAVX() {
  170. +    mask_ |= kAVX;
  171. +  }
  172. +
  173. +  bool HasAVX2() const {
  174. +    return (mask_ & 0x7C) == kAVX2;
  175. +  }
  176. +
  177. +  void SetHasAVX2() {
  178. +    mask_ |= kAVX2;
  179. +  }
  180. +
  181. +  bool HasAES_IN() const {
  182. +    return (mask_ & kAES_IN) != 0;
  183. +  }
  184. +
  185. +  void SetHasAES_IN() {
  186. +    mask_ |= kAES_IN;
  187. +  }
  188. +
  189. +  bool HasPOPCNT() const {
  190. +    return (mask_ & kPOPCNT) != 0;
  191. +  }
  192. +
  193. +  void SetHasPOPCNT() {
  194. +    mask_ |= kPOPCNT;
  195. +  }
  196. +
  197. +  bool HasMOVBE() const {
  198. +    return (mask_ & kMOVBE) != 0;
  199. +  }
  200. +
  201. +  void SetHasMOVBE() {
  202. +    mask_ |= kMOVBE;
  203. +  }
  204. +
  205.    std::string GetFeatureString() const;
  206.  
  207.    // Other features in here.
  208. --
  209. 1.7.9.5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement