Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: src/compiler/ia32/code-generator-ia32.cc

Issue 613643002: [turbofan] add new ia32 addressing modes (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/compiler/ia32/instruction-codes-ia32.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/code-generator.h" 5 #include "src/compiler/code-generator.h"
6 6
7 #include "src/compiler/code-generator-impl.h" 7 #include "src/compiler/code-generator-impl.h"
8 #include "src/compiler/gap-resolver.h" 8 #include "src/compiler/gap-resolver.h"
9 #include "src/compiler/node-matchers.h" 9 #include "src/compiler/node-matchers.h"
10 #include "src/compiler/node-properties-inl.h" 10 #include "src/compiler/node-properties-inl.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 return Immediate(constant.ToExternalReference()); 69 return Immediate(constant.ToExternalReference());
70 case Constant::kHeapObject: 70 case Constant::kHeapObject:
71 return Immediate(constant.ToHeapObject()); 71 return Immediate(constant.ToHeapObject());
72 case Constant::kInt64: 72 case Constant::kInt64:
73 break; 73 break;
74 } 74 }
75 UNREACHABLE(); 75 UNREACHABLE();
76 return Immediate(-1); 76 return Immediate(-1);
77 } 77 }
78 78
79 Operand MemoryOperand(int* first_input) { 79 static int NextOffset(int* offset) {
80 const int offset = *first_input; 80 int i = *offset;
81 switch (AddressingModeField::decode(instr_->opcode())) { 81 (*offset)++;
82 return i;
83 }
84
85 static ScaleFactor ScaleFor(AddressingMode one, AddressingMode mode) {
86 STATIC_ASSERT(0 == static_cast<int>(times_1));
87 STATIC_ASSERT(1 == static_cast<int>(times_2));
88 STATIC_ASSERT(2 == static_cast<int>(times_4));
89 STATIC_ASSERT(3 == static_cast<int>(times_8));
90 int scale = static_cast<int>(mode - one);
91 DCHECK(scale >= 0 && scale < 4);
92 return static_cast<ScaleFactor>(scale);
93 }
94
95 Operand MemoryOperand(int* offset) {
96 AddressingMode mode = AddressingModeField::decode(instr_->opcode());
97 switch (mode) {
98 case kMode_MR: {
99 Register base = InputRegister(NextOffset(offset));
100 int32_t disp = 0;
101 return Operand(base, disp);
102 }
103 case kMode_MRI: {
104 Register base = InputRegister(NextOffset(offset));
105 int32_t disp = InputInt32(NextOffset(offset));
106 return Operand(base, disp);
107 }
108 case kMode_MR1:
109 case kMode_MR2:
110 case kMode_MR4:
111 case kMode_MR8: {
112 Register base = InputRegister(NextOffset(offset));
113 Register index = InputRegister(NextOffset(offset));
114 ScaleFactor scale = ScaleFor(kMode_MR1, mode);
115 int32_t disp = 0;
116 return Operand(base, index, scale, disp);
117 }
82 case kMode_MR1I: 118 case kMode_MR1I:
83 *first_input += 2; 119 case kMode_MR2I:
84 return Operand(InputRegister(offset + 0), InputRegister(offset + 1), 120 case kMode_MR4I:
85 times_1, 121 case kMode_MR8I: {
86 0); // TODO(dcarney): K != 0 122 Register base = InputRegister(NextOffset(offset));
87 case kMode_MRI: 123 Register index = InputRegister(NextOffset(offset));
88 *first_input += 2; 124 ScaleFactor scale = ScaleFor(kMode_MR1I, mode);
89 return Operand::ForRegisterPlusImmediate(InputRegister(offset + 0), 125 int32_t disp = InputInt32(NextOffset(offset));
90 InputImmediate(offset + 1)); 126 return Operand(base, index, scale, disp);
91 case kMode_MI: 127 }
92 *first_input += 1; 128 case kMode_M1:
93 return Operand(InputImmediate(offset + 0)); 129 case kMode_M2:
94 default: 130 case kMode_M4:
131 case kMode_M8: {
132 Register index = InputRegister(NextOffset(offset));
133 ScaleFactor scale = ScaleFor(kMode_M1, mode);
134 int32_t disp = 0;
135 return Operand(index, scale, disp);
136 }
137 case kMode_M1I:
138 case kMode_M2I:
139 case kMode_M4I:
140 case kMode_M8I: {
141 Register index = InputRegister(NextOffset(offset));
142 ScaleFactor scale = ScaleFor(kMode_M1I, mode);
143 int32_t disp = InputInt32(NextOffset(offset));
144 return Operand(index, scale, disp);
145 }
146 case kMode_MI: {
147 int32_t disp = InputInt32(NextOffset(offset));
148 return Operand(Immediate(disp));
149 }
150 case kMode_None:
95 UNREACHABLE(); 151 UNREACHABLE();
96 return Operand(no_reg); 152 return Operand(no_reg, 0);
97 } 153 }
154 UNREACHABLE();
155 return Operand(no_reg, 0);
98 } 156 }
99 157
100 Operand MemoryOperand() { 158 Operand MemoryOperand() {
101 int first_input = 0; 159 int first_input = 0;
102 return MemoryOperand(&first_input); 160 return MemoryOperand(&first_input);
103 } 161 }
104 }; 162 };
105 163
106 164
107 static bool HasImmediateInput(Instruction* instr, int index) { 165 static bool HasImmediateInput(Instruction* instr, int index) {
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 } 1029 }
972 } 1030 }
973 MarkLazyDeoptSite(); 1031 MarkLazyDeoptSite();
974 } 1032 }
975 1033
976 #undef __ 1034 #undef __
977 1035
978 } // namespace compiler 1036 } // namespace compiler
979 } // namespace internal 1037 } // namespace internal
980 } // namespace v8 1038 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/ia32/instruction-codes-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698