| Mark Mendell | 0616ae0 | 2015-04-17 12:49:27 -0400 | [diff] [blame] | 1 | /* | 
 | 2 |  * Copyright (C) 2015 The Android Open Source Project | 
 | 3 |  * | 
 | 4 |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
 | 5 |  * you may not use this file except in compliance with the License. | 
 | 6 |  * You may obtain a copy of the License at | 
 | 7 |  * | 
 | 8 |  *      http://www.apache.org/licenses/LICENSE-2.0 | 
 | 9 |  * | 
 | 10 |  * Unless required by applicable law or agreed to in writing, software | 
 | 11 |  * distributed under the License is distributed on an "AS IS" BASIS, | 
 | 12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
 | 13 |  * See the License for the specific language governing permissions and | 
 | 14 |  * limitations under the License. | 
 | 15 |  */ | 
 | 16 |  | 
 | 17 | #ifndef ART_COMPILER_OPTIMIZING_NODES_X86_H_ | 
 | 18 | #define ART_COMPILER_OPTIMIZING_NODES_X86_H_ | 
 | 19 |  | 
 | 20 | namespace art { | 
 | 21 |  | 
 | 22 | // Compute the address of the method for X86 Constant area support. | 
| Vladimir Marko | fcb503c | 2016-05-18 12:48:17 +0100 | [diff] [blame] | 23 | class HX86ComputeBaseMethodAddress FINAL : public HExpression<0> { | 
| Mark Mendell | 0616ae0 | 2015-04-17 12:49:27 -0400 | [diff] [blame] | 24 |  public: | 
 | 25 |   // Treat the value as an int32_t, but it is really a 32 bit native pointer. | 
| Calin Juravle | 154746b | 2015-10-06 15:46:54 +0100 | [diff] [blame] | 26 |   HX86ComputeBaseMethodAddress() | 
 | 27 |       : HExpression(Primitive::kPrimInt, SideEffects::None(), kNoDexPc) {} | 
| Mark Mendell | 0616ae0 | 2015-04-17 12:49:27 -0400 | [diff] [blame] | 28 |  | 
| David Brazdil | d6c205e | 2016-06-07 14:20:52 +0100 | [diff] [blame] | 29 |   bool CanBeMoved() const OVERRIDE { return true; } | 
 | 30 |  | 
| Mark Mendell | 0616ae0 | 2015-04-17 12:49:27 -0400 | [diff] [blame] | 31 |   DECLARE_INSTRUCTION(X86ComputeBaseMethodAddress); | 
 | 32 |  | 
 | 33 |  private: | 
 | 34 |   DISALLOW_COPY_AND_ASSIGN(HX86ComputeBaseMethodAddress); | 
 | 35 | }; | 
 | 36 |  | 
 | 37 | // Load a constant value from the constant table. | 
| Vladimir Marko | fcb503c | 2016-05-18 12:48:17 +0100 | [diff] [blame] | 38 | class HX86LoadFromConstantTable FINAL : public HExpression<2> { | 
| Mark Mendell | 0616ae0 | 2015-04-17 12:49:27 -0400 | [diff] [blame] | 39 |  public: | 
 | 40 |   HX86LoadFromConstantTable(HX86ComputeBaseMethodAddress* method_base, | 
| David Brazdil | b3e773e | 2016-01-26 11:28:37 +0000 | [diff] [blame] | 41 |                             HConstant* constant) | 
 | 42 |       : HExpression(constant->GetType(), SideEffects::None(), kNoDexPc) { | 
| Mark Mendell | 0616ae0 | 2015-04-17 12:49:27 -0400 | [diff] [blame] | 43 |     SetRawInputAt(0, method_base); | 
 | 44 |     SetRawInputAt(1, constant); | 
 | 45 |   } | 
 | 46 |  | 
| Mark Mendell | 0616ae0 | 2015-04-17 12:49:27 -0400 | [diff] [blame] | 47 |   HX86ComputeBaseMethodAddress* GetBaseMethodAddress() const { | 
 | 48 |     return InputAt(0)->AsX86ComputeBaseMethodAddress(); | 
 | 49 |   } | 
 | 50 |  | 
 | 51 |   HConstant* GetConstant() const { | 
 | 52 |     return InputAt(1)->AsConstant(); | 
 | 53 |   } | 
 | 54 |  | 
 | 55 |   DECLARE_INSTRUCTION(X86LoadFromConstantTable); | 
 | 56 |  | 
 | 57 |  private: | 
| Mark Mendell | 0616ae0 | 2015-04-17 12:49:27 -0400 | [diff] [blame] | 58 |   DISALLOW_COPY_AND_ASSIGN(HX86LoadFromConstantTable); | 
 | 59 | }; | 
 | 60 |  | 
| Mark P Mendell | 2f10a5f | 2016-01-25 14:47:50 +0000 | [diff] [blame] | 61 | // Version of HNeg with access to the constant table for FP types. | 
| Vladimir Marko | fcb503c | 2016-05-18 12:48:17 +0100 | [diff] [blame] | 62 | class HX86FPNeg FINAL : public HExpression<2> { | 
| Mark P Mendell | 2f10a5f | 2016-01-25 14:47:50 +0000 | [diff] [blame] | 63 |  public: | 
 | 64 |   HX86FPNeg(Primitive::Type result_type, | 
 | 65 |             HInstruction* input, | 
 | 66 |             HX86ComputeBaseMethodAddress* method_base, | 
 | 67 |             uint32_t dex_pc) | 
 | 68 |       : HExpression(result_type, SideEffects::None(), dex_pc) { | 
 | 69 |     DCHECK(Primitive::IsFloatingPointType(result_type)); | 
 | 70 |     SetRawInputAt(0, input); | 
 | 71 |     SetRawInputAt(1, method_base); | 
 | 72 |   } | 
 | 73 |  | 
| Nicolas Geoffray | 133719e | 2017-01-22 15:44:39 +0000 | [diff] [blame] | 74 |   HX86ComputeBaseMethodAddress* GetBaseMethodAddress() const { | 
 | 75 |     return InputAt(1)->AsX86ComputeBaseMethodAddress(); | 
 | 76 |   } | 
 | 77 |  | 
| Mark P Mendell | 2f10a5f | 2016-01-25 14:47:50 +0000 | [diff] [blame] | 78 |   DECLARE_INSTRUCTION(X86FPNeg); | 
 | 79 |  | 
 | 80 |  private: | 
 | 81 |   DISALLOW_COPY_AND_ASSIGN(HX86FPNeg); | 
 | 82 | }; | 
 | 83 |  | 
| Mark Mendell | 805b3b5 | 2015-09-18 14:10:29 -0400 | [diff] [blame] | 84 | // X86 version of HPackedSwitch that holds a pointer to the base method address. | 
| Vladimir Marko | fcb503c | 2016-05-18 12:48:17 +0100 | [diff] [blame] | 85 | class HX86PackedSwitch FINAL : public HTemplateInstruction<2> { | 
| Mark Mendell | 805b3b5 | 2015-09-18 14:10:29 -0400 | [diff] [blame] | 86 |  public: | 
 | 87 |   HX86PackedSwitch(int32_t start_value, | 
 | 88 |                    int32_t num_entries, | 
 | 89 |                    HInstruction* input, | 
 | 90 |                    HX86ComputeBaseMethodAddress* method_base, | 
 | 91 |                    uint32_t dex_pc) | 
 | 92 |     : HTemplateInstruction(SideEffects::None(), dex_pc), | 
 | 93 |       start_value_(start_value), | 
 | 94 |       num_entries_(num_entries) { | 
 | 95 |     SetRawInputAt(0, input); | 
 | 96 |     SetRawInputAt(1, method_base); | 
 | 97 |   } | 
 | 98 |  | 
 | 99 |   bool IsControlFlow() const OVERRIDE { return true; } | 
 | 100 |  | 
 | 101 |   int32_t GetStartValue() const { return start_value_; } | 
 | 102 |  | 
 | 103 |   int32_t GetNumEntries() const { return num_entries_; } | 
 | 104 |  | 
 | 105 |   HX86ComputeBaseMethodAddress* GetBaseMethodAddress() const { | 
 | 106 |     return InputAt(1)->AsX86ComputeBaseMethodAddress(); | 
 | 107 |   } | 
 | 108 |  | 
 | 109 |   HBasicBlock* GetDefaultBlock() const { | 
 | 110 |     // Last entry is the default block. | 
 | 111 |     return GetBlock()->GetSuccessors()[num_entries_]; | 
 | 112 |   } | 
 | 113 |  | 
 | 114 |   DECLARE_INSTRUCTION(X86PackedSwitch); | 
 | 115 |  | 
 | 116 |  private: | 
 | 117 |   const int32_t start_value_; | 
 | 118 |   const int32_t num_entries_; | 
 | 119 |  | 
 | 120 |   DISALLOW_COPY_AND_ASSIGN(HX86PackedSwitch); | 
 | 121 | }; | 
 | 122 |  | 
| Mark Mendell | 0616ae0 | 2015-04-17 12:49:27 -0400 | [diff] [blame] | 123 | }  // namespace art | 
 | 124 |  | 
 | 125 | #endif  // ART_COMPILER_OPTIMIZING_NODES_X86_H_ |