graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILMove.java

Print this page




 112             this.result = result;
 113             this.input = input;
 114         }
 115 
 116         @Override
 117         public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) {
 118             move(tasm, masm, getResult(), getInput());
 119         }
 120 
 121         @Override
 122         public Value getInput() {
 123             return input;
 124         }
 125 
 126         @Override
 127         public AllocatableValue getResult() {
 128             return result;
 129         }
 130     }
 131 
 132     public static class LoadOp extends HSAILLIRInstruction {
 133 
 134         @SuppressWarnings("unused") private final Kind kind;
 135         @Def({REG}) protected AllocatableValue result;

 136         @Use({COMPOSITE}) protected HSAILAddressValue address;
 137         @State protected LIRFrameState state;
 138 
 139         public LoadOp(Kind kind, AllocatableValue result, HSAILAddressValue address, LIRFrameState state) {
 140             this.kind = kind;
 141             this.result = result;
 142             this.address = address;
 143             this.state = state;
 144         }
 145 


 146         @Override
 147         public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) {



















 148             HSAILAddress addr = address.toAddress();
 149             masm.emitLoad(result, addr);
 150         }
 151     }
 152 
 153     public static class StoreOp extends HSAILLIRInstruction {
 154 
 155         @SuppressWarnings("unused") private final Kind kind;
 156         @Use({COMPOSITE}) protected HSAILAddressValue address;
 157         @Use({REG}) protected AllocatableValue input;
 158         @State protected LIRFrameState state;
 159 
 160         public StoreOp(Kind kind, HSAILAddressValue address, AllocatableValue input, LIRFrameState state) {
 161             this.kind = kind;
 162             this.address = address;
 163             this.input = input;
 164             this.state = state;
 165         }
 166 
 167         @Override
 168         public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) {
 169             assert isRegister(input);
 170             HSAILAddress addr = address.toAddress();
 171             masm.emitStore(input, addr);
 172         }
 173     }



















































































 174 
 175     public static class LeaOp extends HSAILLIRInstruction {
 176 
 177         @Def({REG}) protected AllocatableValue result;
 178         @Use({COMPOSITE, UNINITIALIZED}) protected HSAILAddressValue address;
 179 
 180         public LeaOp(AllocatableValue result, HSAILAddressValue address) {
 181             this.result = result;
 182             this.address = address;
 183         }
 184 
 185         @Override
 186         public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) {
 187             throw new InternalError("NYI");
 188         }
 189     }
 190 
 191     public static class StackLeaOp extends HSAILLIRInstruction {
 192 
 193         @Def({REG}) protected AllocatableValue result;




 112             this.result = result;
 113             this.input = input;
 114         }
 115 
 116         @Override
 117         public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) {
 118             move(tasm, masm, getResult(), getInput());
 119         }
 120 
 121         @Override
 122         public Value getInput() {
 123             return input;
 124         }
 125 
 126         @Override
 127         public AllocatableValue getResult() {
 128             return result;
 129         }
 130     }
 131 

 132 
 133     public abstract static class MemOp extends HSAILLIRInstruction {
 134 
 135         protected final Kind kind;
 136         @Use({COMPOSITE}) protected HSAILAddressValue address;
 137         @State protected LIRFrameState state;
 138 
 139         public MemOp(Kind kind, HSAILAddressValue address, LIRFrameState state) {
 140             this.kind = kind;

 141             this.address = address;
 142             this.state = state;
 143         }
 144 
 145         protected abstract void emitMemAccess(HSAILAssembler masm);
 146 
 147         @Override
 148         public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) {
 149             if (state != null) {
 150                 // tasm.recordImplicitException(masm.codeBuffer.position(), state);
 151                 throw new InternalError("NYI");
 152             }
 153             emitMemAccess(masm);
 154         }
 155     }
 156 
 157     public static class LoadOp extends MemOp {
 158 
 159         @Def({REG}) protected AllocatableValue result;
 160 
 161         public LoadOp(Kind kind, AllocatableValue result, HSAILAddressValue address, LIRFrameState state) {
 162             super(kind, address, state);
 163             this.result = result;
 164         }
 165 
 166         @Override
 167         public void emitMemAccess(HSAILAssembler masm) {
 168             HSAILAddress addr = address.toAddress();
 169             masm.emitLoad(result, addr);
 170         }
 171     }
 172 
 173     public static class StoreOp extends MemOp {
 174 


 175         @Use({REG}) protected AllocatableValue input;

 176 
 177         public StoreOp(Kind kind, HSAILAddressValue address, AllocatableValue input, LIRFrameState state) {
 178             super(kind, address, state);

 179             this.input = input;

 180         }
 181 
 182         @Override
 183         public void emitMemAccess(HSAILAssembler masm) {
 184             assert isRegister(input);
 185             HSAILAddress addr = address.toAddress();
 186             masm.emitStore(input, addr);
 187         }
 188     }
 189 
 190     public static class LoadCompressedPointer extends LoadOp {
 191 
 192         private long narrowOopBase;
 193         private int narrowOopShift;
 194         private int logMinObjAlignment;
 195         @Temp({REG}) private AllocatableValue scratch;
 196 
 197         public LoadCompressedPointer(Kind kind, AllocatableValue result, AllocatableValue scratch, HSAILAddressValue address, LIRFrameState state, long narrowOopBase, int narrowOopShift,
 198                         int logMinObjAlignment) {
 199             super(kind, result, address, state);
 200             this.narrowOopBase = narrowOopBase;
 201             this.narrowOopShift = narrowOopShift;
 202             this.logMinObjAlignment = logMinObjAlignment;
 203             this.scratch = scratch;
 204             assert kind == Kind.Object;
 205         }
 206 
 207         @Override
 208         public void emitMemAccess(HSAILAssembler masm) {
 209             // we will do a 32 bit load, zero extending into a 64 bit register
 210             masm.emitLoad(result, address.toAddress(), "u32");
 211             decodePointer(masm, result, narrowOopBase, narrowOopShift, logMinObjAlignment);
 212         }
 213     }
 214 
 215     public static class StoreCompressedPointer extends HSAILLIRInstruction {
 216 
 217         protected final Kind kind;
 218         private long narrowOopBase;
 219         private int narrowOopShift;
 220         private int logMinObjAlignment;
 221         @Temp({REG}) private AllocatableValue scratch;
 222         @Alive({REG}) protected AllocatableValue input;
 223         @Alive({COMPOSITE}) protected HSAILAddressValue address;
 224         @State protected LIRFrameState state;
 225 
 226         public StoreCompressedPointer(Kind kind, HSAILAddressValue address, AllocatableValue input, AllocatableValue scratch, LIRFrameState state, long narrowOopBase, int narrowOopShift,
 227                         int logMinObjAlignment) {
 228             this.narrowOopBase = narrowOopBase;
 229             this.narrowOopShift = narrowOopShift;
 230             this.logMinObjAlignment = logMinObjAlignment;
 231             this.scratch = scratch;
 232             this.kind = kind;
 233             this.address = address;
 234             this.state = state;
 235             this.input = input;
 236             assert kind == Kind.Object;
 237         }
 238 
 239         @Override
 240         public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) {
 241             masm.emitMov(scratch, input);
 242             encodePointer(masm, scratch, narrowOopBase, narrowOopShift, logMinObjAlignment);
 243             if (state != null) {
 244                 throw new InternalError("NYI");
 245                 // tasm.recordImplicitException(masm.codeBuffer.position(), state);
 246             }
 247             masm.emitStore(scratch, address.toAddress(), "u32");
 248         }
 249     }
 250 
 251     private static void encodePointer(HSAILAssembler masm, Value scratch, long narrowOopBase, int narrowOopShift, int logMinObjAlignment) {
 252         if (narrowOopBase == 0 && narrowOopShift == 0) {
 253             return;
 254         }
 255         if (narrowOopShift != 0) {
 256             assert logMinObjAlignment == narrowOopShift : "Encode algorithm is wrong";
 257         }
 258         masm.emitCompressedOopEncode(scratch, narrowOopBase, narrowOopShift);
 259     }
 260 
 261     private static void decodePointer(HSAILAssembler masm, Value result, long narrowOopBase, int narrowOopShift, int logMinObjAlignment) {
 262         if (narrowOopBase == 0 && narrowOopShift == 0) {
 263             return;
 264         }
 265         if (narrowOopShift != 0) {
 266             assert logMinObjAlignment == narrowOopShift : "Decode algorithm is wrong";
 267         }
 268         masm.emitCompressedOopDecode(result, narrowOopBase, narrowOopShift);
 269     }
 270 
 271 
 272 
 273     public static class LeaOp extends HSAILLIRInstruction {
 274 
 275         @Def({REG}) protected AllocatableValue result;
 276         @Use({COMPOSITE, UNINITIALIZED}) protected HSAILAddressValue address;
 277 
 278         public LeaOp(AllocatableValue result, HSAILAddressValue address) {
 279             this.result = result;
 280             this.address = address;
 281         }
 282 
 283         @Override
 284         public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) {
 285             throw new InternalError("NYI");
 286         }
 287     }
 288 
 289     public static class StackLeaOp extends HSAILLIRInstruction {
 290 
 291         @Def({REG}) protected AllocatableValue result;