148 public static class StoreOp extends PTXLIRInstruction {
149
150 @Use({COMPOSITE}) protected PTXAddressValue address;
151 @Use({REG}) protected AllocatableValue input;
152 @State protected LIRFrameState state;
153
154 public StoreOp(PTXAddressValue address, AllocatableValue input, LIRFrameState state) {
155 this.address = address;
156 this.input = input;
157 this.state = state;
158 }
159
160 @Override
161 public void emitCode(TargetMethodAssembler tasm, PTXAssembler masm) {
162 assert isRegister(input);
163 PTXAddress addr = address.toAddress();
164 switch (address.getKind()) {
165 case Int:
166 masm.st_global_s32(addr.getBase(), addr.getDisplacement(), asRegister(input));
167 break;
168 default:
169 throw GraalInternalError.shouldNotReachHere();
170 }
171 }
172 }
173
174 public static class LeaOp extends PTXLIRInstruction {
175
176 @Def({REG}) protected AllocatableValue result;
177 @Use({COMPOSITE, UNINITIALIZED}) protected PTXAddressValue address;
178
179 public LeaOp(AllocatableValue result, PTXAddressValue address) {
180 this.result = result;
181 this.address = address;
182 }
183
184 @Override
185 public void emitCode(TargetMethodAssembler tasm, PTXAssembler masm) {
186 throw new InternalError("NYI");
187 }
188 }
233 }
234 } else if (isConstant(input)) {
235 if (isRegister(result)) {
236 const2reg(tasm, masm, result, (Constant) input);
237 } else {
238 throw GraalInternalError.shouldNotReachHere();
239 }
240 } else {
241 throw GraalInternalError.shouldNotReachHere();
242 }
243 }
244
245 private static void reg2reg(PTXAssembler masm, Value result, Value input) {
246 if (asRegister(input).equals(asRegister(result))) {
247 return;
248 }
249 switch (input.getKind()) {
250 case Int:
251 masm.mov_s32(asRegister(result), asRegister(input));
252 break;
253 case Object:
254 masm.mov_u64(asRegister(result), asRegister(input));
255 break;
256 default:
257 throw GraalInternalError.shouldNotReachHere("kind=" + result.getKind());
258 }
259 }
260
261 private static void const2reg(TargetMethodAssembler tasm, PTXAssembler masm, Value result, Constant input) {
262 switch (input.getKind().getStackKind()) {
263 case Int:
264 if (tasm.runtime.needsDataPatch(input)) {
265 tasm.recordDataReferenceInCode(input, 0, true);
266 }
267 masm.mov_s32(asRegister(result), input.asInt());
268 break;
269 default:
270 throw GraalInternalError.shouldNotReachHere();
271 }
272 }
273
274 @SuppressWarnings("unused")
275 protected static void compareAndSwap(TargetMethodAssembler tasm, PTXAssembler masm, AllocatableValue result, PTXAddressValue address, AllocatableValue cmpValue, AllocatableValue newValue) {
276 throw new InternalError("NYI");
277 }
278 }
|
148 public static class StoreOp extends PTXLIRInstruction {
149
150 @Use({COMPOSITE}) protected PTXAddressValue address;
151 @Use({REG}) protected AllocatableValue input;
152 @State protected LIRFrameState state;
153
154 public StoreOp(PTXAddressValue address, AllocatableValue input, LIRFrameState state) {
155 this.address = address;
156 this.input = input;
157 this.state = state;
158 }
159
160 @Override
161 public void emitCode(TargetMethodAssembler tasm, PTXAssembler masm) {
162 assert isRegister(input);
163 PTXAddress addr = address.toAddress();
164 switch (address.getKind()) {
165 case Int:
166 masm.st_global_s32(addr.getBase(), addr.getDisplacement(), asRegister(input));
167 break;
168 case Byte:
169 masm.st_global_s8(addr.getBase(), addr.getDisplacement(), asRegister(input));
170 break;
171 case Object:
172 masm.st_global_s32(addr.getBase(), addr.getDisplacement(), asRegister(input));
173 break;
174 default:
175 System.err.println("missing: " + address.getKind());
176 throw GraalInternalError.shouldNotReachHere();
177 }
178 }
179 }
180
181 public static class LeaOp extends PTXLIRInstruction {
182
183 @Def({REG}) protected AllocatableValue result;
184 @Use({COMPOSITE, UNINITIALIZED}) protected PTXAddressValue address;
185
186 public LeaOp(AllocatableValue result, PTXAddressValue address) {
187 this.result = result;
188 this.address = address;
189 }
190
191 @Override
192 public void emitCode(TargetMethodAssembler tasm, PTXAssembler masm) {
193 throw new InternalError("NYI");
194 }
195 }
240 }
241 } else if (isConstant(input)) {
242 if (isRegister(result)) {
243 const2reg(tasm, masm, result, (Constant) input);
244 } else {
245 throw GraalInternalError.shouldNotReachHere();
246 }
247 } else {
248 throw GraalInternalError.shouldNotReachHere();
249 }
250 }
251
252 private static void reg2reg(PTXAssembler masm, Value result, Value input) {
253 if (asRegister(input).equals(asRegister(result))) {
254 return;
255 }
256 switch (input.getKind()) {
257 case Int:
258 masm.mov_s32(asRegister(result), asRegister(input));
259 break;
260 case Long:
261 masm.mov_s64(asRegister(result), asRegister(input));
262 break;
263 case Float:
264 masm.mov_f32(asRegister(result), asRegister(input));
265 break;
266 case Double:
267 masm.mov_f64(asRegister(result), asRegister(input));
268 break;
269 case Object:
270 masm.mov_u64(asRegister(result), asRegister(input));
271 break;
272 default:
273 System.err.println("missing: " + input.getKind());
274 throw GraalInternalError.shouldNotReachHere("kind=" + result.getKind());
275 }
276 }
277
278 private static void const2reg(TargetMethodAssembler tasm, PTXAssembler masm, Value result, Constant input) {
279 switch (input.getKind().getStackKind()) {
280 case Int:
281 if (tasm.runtime.needsDataPatch(input)) {
282 tasm.recordDataReferenceInCode(input, 0, true);
283 }
284 masm.mov_s32(asRegister(result), input.asInt());
285 break;
286 case Long:
287 if (tasm.runtime.needsDataPatch(input)) {
288 tasm.recordDataReferenceInCode(input, 0, true);
289 }
290 masm.mov_s64(asRegister(result), input.asLong());
291 break;
292 case Object:
293 if (input.isNull()) {
294 masm.mov_u64(asRegister(result), 0x0L);
295 } else if (tasm.target.inlineObjects) {
296 tasm.recordDataReferenceInCode(input, 0, true);
297 masm.mov_u64(asRegister(result), 0xDEADDEADDEADDEADL);
298 } else {
299 System.out.println("OA: " + tasm.recordDataReferenceInCode(input, 0, false).getClass().getName());
300 // masm.mov_u64(asRegister(result), tasm.recordDataReferenceInCode(input, 0, false));
301 }
302 break;
303 default:
304 System.err.println("missing: " + input.getKind());
305 throw GraalInternalError.shouldNotReachHere();
306 }
307 }
308
309 protected static void compareAndSwap(TargetMethodAssembler tasm, PTXAssembler masm, AllocatableValue result, PTXAddressValue address, AllocatableValue cmpValue, AllocatableValue newValue) {
310 throw new InternalError("NYI");
311 }
312 }
|