@@ -2622,14 +2622,14 @@ emitter::insFormat emitter::emitMapFmtAtoM(insFormat fmt)
2622
2622
}
2623
2623
2624
2624
// ------------------------------------------------------------------------
2625
- // emitHandleMemOp : For a memory operand, fill in the relevant fields of the instrDesc.
2625
+ // emitSetAddrMode : For a memory operand, fill in the relevant fields of the instrDesc.
2626
2626
//
2627
2627
// Arguments:
2628
- // indir - the memory operand.
2629
2628
// id - the instrDesc to fill in.
2629
+ // ins - the instruction we are generating. This might affect the instruction format we choose.
2630
2630
// fmt - the instruction format to use. This must be one of the ARD, AWR, or ARW formats. If necessary (such as for
2631
2631
// GT_CLS_VAR_ADDR), this function will map it to the correct format.
2632
- // ins - the instruction we are generating. This might affect the instruction format we choose.
2632
+ // addr - the address operand of the indir
2633
2633
//
2634
2634
// Assumptions:
2635
2635
// The correctly sized instrDesc must already be created, e.g., via emitNewInstrAmd() or emitNewInstrAmdCns();
@@ -2647,11 +2647,12 @@ emitter::insFormat emitter::emitMapFmtAtoM(insFormat fmt)
2647
2647
//
2648
2648
// idSetIsDspReloc() is called if necessary.
2649
2649
//
2650
- void emitter::emitHandleMemOp (GenTreeIndir* indir, instrDesc* id , insFormat fmt, instruction ins )
2650
+ void emitter::emitSetAddrMode (instrDesc* id, instruction ins , insFormat fmt, GenTree* addr )
2651
2651
{
2652
2652
assert (fmt != IF_NONE);
2653
2653
2654
- GenTree* memBase = indir->Base ();
2654
+ AddressModeInfo amInfo (addr);
2655
+ GenTree* memBase = amInfo.Base ();
2655
2656
2656
2657
if ((memBase != nullptr ) && memBase->isContained () && (memBase->OperGet () == GT_CLS_VAR_ADDR))
2657
2658
{
@@ -2708,20 +2709,20 @@ void emitter::emitHandleMemOp(GenTreeIndir* indir, instrDesc* id, insFormat fmt,
2708
2709
id->idAddr ()->iiaAddrMode .amBaseReg = REG_NA;
2709
2710
}
2710
2711
2711
- if (indir-> HasIndex ())
2712
+ if (amInfo. HasIndex ())
2712
2713
{
2713
- id->idAddr ()->iiaAddrMode .amIndxReg = indir-> Index ()->gtRegNum ;
2714
+ id->idAddr ()->iiaAddrMode .amIndxReg = amInfo. Index ()->gtRegNum ;
2714
2715
}
2715
2716
else
2716
2717
{
2717
2718
id->idAddr ()->iiaAddrMode .amIndxReg = REG_NA;
2718
2719
}
2719
- id->idAddr ()->iiaAddrMode .amScale = emitEncodeScale (indir-> Scale ());
2720
+ id->idAddr ()->iiaAddrMode .amScale = emitEncodeScale (amInfo. Scale ());
2720
2721
2721
2722
id->idInsFmt (emitMapFmtForIns (fmt, ins));
2722
2723
2723
2724
// disp must have already been set in the instrDesc constructor.
2724
- assert (emitGetInsAmdAny (id) == indir-> Offset ()); // make sure "disp" is stored properly
2725
+ assert (emitGetInsAmdAny (id) == amInfo. Offset ()); // make sure "disp" is stored properly
2725
2726
}
2726
2727
}
2727
2728
@@ -2762,21 +2763,16 @@ void emitter::spillIntArgRegsToShadowSlots()
2762
2763
}
2763
2764
2764
2765
// ------------------------------------------------------------------------
2765
- // emitInsLoadInd: Emits a "mov reg, [mem]" (or a variant such as "movzx" or "movss")
2766
- // instruction for a GT_IND node.
2766
+ // emitInsLoad: Emits a "mov reg, [mem]" (or a variant such as "movzx" or "movss").
2767
2767
//
2768
2768
// Arguments:
2769
2769
// ins - the instruction to emit
2770
2770
// attr - the instruction operand size
2771
2771
// dstReg - the destination register
2772
- // mem - the GT_IND node
2772
+ // addr - the address node
2773
2773
//
2774
- void emitter::emitInsLoadInd (instruction ins, emitAttr attr, regNumber dstReg, GenTreeIndir* mem )
2774
+ void emitter::emitInsLoad (instruction ins, emitAttr attr, regNumber dstReg, GenTree* addr )
2775
2775
{
2776
- assert (mem->OperIs (GT_IND));
2777
-
2778
- GenTree* addr = mem->Addr ();
2779
-
2780
2776
if (addr->OperGet () == GT_CLS_VAR_ADDR)
2781
2777
{
2782
2778
emitIns_R_C (ins, attr, dstReg, addr->gtClsVar .gtClsVarHnd , 0 );
@@ -2792,33 +2788,28 @@ void emitter::emitInsLoadInd(instruction ins, emitAttr attr, regNumber dstReg, G
2792
2788
}
2793
2789
2794
2790
assert (addr->OperIsAddrMode () || (addr->IsCnsIntOrI () && addr->isContained ()) || !addr->isContained ());
2795
- ssize_t offset = mem-> Offset ();
2791
+ ssize_t offset = AddressModeInfo (addr). Offset ();
2796
2792
instrDesc* id = emitNewInstrAmd (attr, offset);
2797
2793
id->idIns (ins);
2798
2794
id->idReg1 (dstReg);
2799
- emitHandleMemOp (mem, id , IF_RWR_ARD, ins );
2795
+ emitSetAddrMode (id, ins , IF_RWR_ARD, addr );
2800
2796
UNATIVE_OFFSET sz = emitInsSizeAM (id, insCodeRM (ins));
2801
2797
id->idCodeSize (sz);
2802
2798
dispIns (id);
2803
2799
emitCurIGsize += sz;
2804
2800
}
2805
2801
2806
2802
// ------------------------------------------------------------------------
2807
- // emitInsStoreInd: Emits a "mov [mem], reg/imm" (or a variant such as "movss")
2808
- // instruction for a GT_STOREIND node.
2803
+ // emitInsStore: Emits a "mov [mem], reg/imm" (or a variant such as "movss").
2809
2804
//
2810
2805
// Arguments:
2811
2806
// ins - the instruction to emit
2812
2807
// attr - the instruction operand size
2813
- // mem - the GT_STOREIND node
2808
+ // addr - the address node
2809
+ // data - the data node
2814
2810
//
2815
- void emitter::emitInsStoreInd (instruction ins, emitAttr attr, GenTreeStoreInd* mem )
2811
+ void emitter::emitInsStore (instruction ins, emitAttr attr, GenTree* addr, GenTree* data )
2816
2812
{
2817
- assert (mem->OperIs (GT_STOREIND));
2818
-
2819
- GenTree* addr = mem->Addr ();
2820
- GenTree* data = mem->Data ();
2821
-
2822
2813
if (addr->OperGet () == GT_CLS_VAR_ADDR)
2823
2814
{
2824
2815
if (data->isContainedIntOrIImmed ())
@@ -2849,7 +2840,7 @@ void emitter::emitInsStoreInd(instruction ins, emitAttr attr, GenTreeStoreInd* m
2849
2840
return ;
2850
2841
}
2851
2842
2852
- ssize_t offset = mem-> Offset ();
2843
+ ssize_t offset = AddressModeInfo (addr). Offset ();
2853
2844
UNATIVE_OFFSET sz;
2854
2845
instrDesc* id;
2855
2846
@@ -2858,7 +2849,7 @@ void emitter::emitInsStoreInd(instruction ins, emitAttr attr, GenTreeStoreInd* m
2858
2849
int icon = (int )data->AsIntConCommon ()->IconValue ();
2859
2850
id = emitNewInstrAmdCns (attr, offset, icon);
2860
2851
id->idIns (ins);
2861
- emitHandleMemOp (mem, id , IF_AWR_CNS, ins );
2852
+ emitSetAddrMode (id, ins , IF_AWR_CNS, addr );
2862
2853
sz = emitInsSizeAM (id, insCodeMI (ins), icon);
2863
2854
id->idCodeSize (sz);
2864
2855
}
@@ -2867,7 +2858,7 @@ void emitter::emitInsStoreInd(instruction ins, emitAttr attr, GenTreeStoreInd* m
2867
2858
assert (!data->isContained ());
2868
2859
id = emitNewInstrAmd (attr, offset);
2869
2860
id->idIns (ins);
2870
- emitHandleMemOp (mem, id , IF_AWR_RRD, ins );
2861
+ emitSetAddrMode (id, ins , IF_AWR_RRD, addr );
2871
2862
id->idReg1 (data->gtRegNum );
2872
2863
sz = emitInsSizeAM (id, insCodeMR (ins));
2873
2864
id->idCodeSize (sz);
@@ -3144,7 +3135,7 @@ regNumber emitter::emitInsBinary(instruction ins, emitAttr attr, GenTree* dst, G
3144
3135
}
3145
3136
}
3146
3137
assert (fmt != IF_NONE);
3147
- emitHandleMemOp (memIndir, id , fmt, ins );
3138
+ emitSetAddrMode (id, ins , fmt, memIndir-> Addr () );
3148
3139
3149
3140
// Determine the instruction size
3150
3141
UNATIVE_OFFSET sz = 0 ;
@@ -3366,7 +3357,7 @@ void emitter::emitInsRMW(instruction ins, emitAttr attr, GenTreeStoreInd* storeI
3366
3357
}
3367
3358
3368
3359
id = emitNewInstrAmdCns (attr, offset, iconVal);
3369
- emitHandleMemOp (storeInd, id , IF_ARW_CNS, ins );
3360
+ emitSetAddrMode (id, ins , IF_ARW_CNS, storeInd-> Addr () );
3370
3361
id->idIns (ins);
3371
3362
sz = emitInsSizeAM (id, insCodeMI (ins), iconVal);
3372
3363
}
@@ -3376,7 +3367,7 @@ void emitter::emitInsRMW(instruction ins, emitAttr attr, GenTreeStoreInd* storeI
3376
3367
3377
3368
// ind, reg
3378
3369
id = emitNewInstrAmd (attr, offset);
3379
- emitHandleMemOp (storeInd, id , IF_ARW_RRD, ins );
3370
+ emitSetAddrMode (id, ins , IF_ARW_RRD, storeInd-> Addr () );
3380
3371
id->idReg1 (src->gtRegNum );
3381
3372
id->idIns (ins);
3382
3373
sz = emitInsSizeAM (id, insCodeMR (ins));
@@ -3424,7 +3415,7 @@ void emitter::emitInsRMW(instruction ins, emitAttr attr, GenTreeStoreInd* storeI
3424
3415
}
3425
3416
3426
3417
instrDesc* id = emitNewInstrAmd (attr, offset);
3427
- emitHandleMemOp (storeInd, id , IF_ARW, ins );
3418
+ emitSetAddrMode (id, ins , IF_ARW, storeInd-> Addr () );
3428
3419
id->idIns (ins);
3429
3420
UNATIVE_OFFSET sz = emitInsSizeAM (id, insCodeMR (ins));
3430
3421
id->idCodeSize (sz);
@@ -3983,7 +3974,7 @@ void emitter::emitIns_R_A(instruction ins, emitAttr attr, regNumber reg1, GenTre
3983
3974
id->idIns (ins);
3984
3975
id->idReg1 (reg1);
3985
3976
3986
- emitHandleMemOp (indir, id , IF_RRW_ARD, ins );
3977
+ emitSetAddrMode (id, ins , IF_RRW_ARD, indir-> Addr () );
3987
3978
3988
3979
UNATIVE_OFFSET sz = emitInsSizeAM (id, insCodeRM (ins));
3989
3980
id->idCodeSize (sz);
@@ -4003,7 +3994,7 @@ void emitter::emitIns_R_A_I(instruction ins, emitAttr attr, regNumber reg1, GenT
4003
3994
id->idIns (ins);
4004
3995
id->idReg1 (reg1);
4005
3996
4006
- emitHandleMemOp (indir, id , IF_RRW_ARD_CNS, ins );
3997
+ emitSetAddrMode (id, ins , IF_RRW_ARD_CNS, indir-> Addr () );
4007
3998
4008
3999
UNATIVE_OFFSET sz = emitInsSizeAM (id, insCodeRM (ins), ival);
4009
4000
@@ -4122,7 +4113,7 @@ void emitter::emitIns_R_R_A(instruction ins, emitAttr attr, regNumber reg1, regN
4122
4113
id->idReg1 (reg1);
4123
4114
id->idReg2 (reg2);
4124
4115
4125
- emitHandleMemOp (indir, id , IF_RWR_RRD_ARD, ins );
4116
+ emitSetAddrMode (id, ins , IF_RWR_RRD_ARD, indir-> Addr () );
4126
4117
4127
4118
UNATIVE_OFFSET sz = emitInsSizeAM (id, insCodeRM (ins));
4128
4119
id->idCodeSize (sz);
@@ -4311,7 +4302,7 @@ void emitter::emitIns_R_R_A_I(
4311
4302
id->idReg1 (reg1);
4312
4303
id->idReg2 (reg2);
4313
4304
4314
- emitHandleMemOp (indir, id , fmt, ins );
4305
+ emitSetAddrMode (id, ins , fmt, indir-> Addr () );
4315
4306
4316
4307
UNATIVE_OFFSET sz = emitInsSizeAM (id, insCodeRM (ins), ival);
4317
4308
id->idCodeSize (sz);
@@ -4477,7 +4468,7 @@ void emitter::emitIns_R_R_A_R(
4477
4468
id->idReg1 (targetReg);
4478
4469
id->idReg2 (op1Reg);
4479
4470
4480
- emitHandleMemOp (indir, id , IF_RWR_RRD_ARD_RRD, ins );
4471
+ emitSetAddrMode (id, ins , IF_RWR_RRD_ARD_RRD, indir-> Addr () );
4481
4472
4482
4473
UNATIVE_OFFSET sz = emitInsSizeAM (id, insCodeRM (ins), ival);
4483
4474
id->idCodeSize (sz);
0 commit comments