@@ -1778,21 +1778,25 @@ void CodeGen::genSetRegToConst(regNumber targetReg, var_types targetType, GenTre
1778
1778
{
1779
1779
// relocatable values tend to come down as a CNS_INT of native int type
1780
1780
// so the line between these two opcodes is kind of blurry
1781
- GenTreeIntConCommon * con = tree->AsIntConCommon ();
1782
- ssize_t cnsVal = con->IconValue ();
1781
+ GenTreeIntCon * con = tree->AsIntCon ();
1782
+ ssize_t cnsVal = con->IconValue ();
1783
1783
1784
- // if (con->ImmedValNeedsReloc(compiler))
1785
- if (con->ImmedValNeedsReloc (compiler) && compiler->opts .compReloc )
1784
+ emitAttr attr = emitActualTypeSize (targetType);
1785
+ // TODO-CQ: Currently we cannot do this for all handles because of
1786
+ // https://github.com/dotnet/runtime/issues/60712
1787
+ if (con->ImmedValNeedsReloc (compiler))
1786
1788
{
1787
- // instGen_Set_Reg_To_Imm(EA_HANDLE_CNS_RELOC, targetReg, cnsVal);
1788
- assert (compiler->opts .compReloc );
1789
- GetEmitter ()->emitIns_R_AI (INS_bl, EA_HANDLE_CNS_RELOC, targetReg, cnsVal);
1790
- regSet.verifyRegUsed (targetReg);
1789
+ attr = EA_SET_FLG (attr, EA_CNS_RELOC_FLG);
1791
1790
}
1792
- else
1791
+
1792
+ if (targetType == TYP_BYREF)
1793
1793
{
1794
- genSetRegToIcon (targetReg, cnsVal, targetType );
1794
+ attr = EA_SET_FLG (attr, EA_BYREF_FLG );
1795
1795
}
1796
+
1797
+ instGen_Set_Reg_To_Imm (attr, targetReg, cnsVal,
1798
+ INS_FLAGS_DONT_CARE DEBUGARG (con->gtTargetHandle ) DEBUGARG (con->gtFlags ));
1799
+ regSet.verifyRegUsed (targetReg);
1796
1800
}
1797
1801
break ;
1798
1802
@@ -2366,7 +2370,7 @@ void CodeGen::genLclHeap(GenTree* tree)
2366
2370
{
2367
2371
regCnt = tree->ExtractTempReg ();
2368
2372
}
2369
- genSetRegToIcon (regCnt, amount, ((unsigned int )amount == amount) ? TYP_INT : TYP_LONG );
2373
+ instGen_Set_Reg_To_Imm ( ((unsigned int )amount == amount) ? EA_4BYTE : EA_8BYTE, regCnt, amount );
2370
2374
}
2371
2375
2372
2376
if (compiler->info .compInitMem )
@@ -5662,23 +5666,6 @@ void CodeGen::genCodeForTreeNode(GenTree* treeNode)
5662
5666
}
5663
5667
}
5664
5668
5665
- // ------------------------------------------------------------------------
5666
- // genSetRegToIcon: Generate code that will set the given register to the integer constant.
5667
- //
5668
- void CodeGen::genSetRegToIcon (regNumber reg, ssize_t val, var_types type)
5669
- {
5670
- // Reg cannot be a FP reg
5671
- assert (!genIsValidFloatReg (reg));
5672
-
5673
- // The only TYP_REF constant that can come this path is a managed 'null' since it is not
5674
- // relocatable. Other ref type constants (e.g. string objects) go through a different
5675
- // code path.
5676
- noway_assert ((type != TYP_REF) || (val == 0 ));
5677
-
5678
- GetEmitter ()->emitIns_I_la (emitActualTypeSize (type), reg, val);
5679
- regSet.verifyRegUsed (reg);
5680
- }
5681
-
5682
5669
// ---------------------------------------------------------------------
5683
5670
// genSetGSSecurityCookie: Set the "GS" security cookie in the prolog.
5684
5671
//
@@ -5703,7 +5690,8 @@ void CodeGen::genSetGSSecurityCookie(regNumber initReg, bool* pInitRegZeroed)
5703
5690
{
5704
5691
noway_assert (compiler->gsGlobalSecurityCookieVal != 0 );
5705
5692
// initReg = #GlobalSecurityCookieVal; [frame.GSSecurityCookie] = initReg
5706
- genSetRegToIcon (initReg, compiler->gsGlobalSecurityCookieVal , TYP_I_IMPL);
5693
+ instGen_Set_Reg_To_Imm (EA_PTRSIZE, initReg, compiler->gsGlobalSecurityCookieVal );
5694
+
5707
5695
GetEmitter ()->emitIns_S_R (INS_st_d, EA_PTRSIZE, initReg, compiler->lvaGSSecurityCookie , 0 );
5708
5696
}
5709
5697
else
@@ -5762,7 +5750,7 @@ void CodeGen::genEmitGSCookieCheck(bool pushReg)
5762
5750
{
5763
5751
// load the GS cookie constant into a reg
5764
5752
//
5765
- genSetRegToIcon ( regGSConst, compiler->gsGlobalSecurityCookieVal , TYP_I_IMPL );
5753
+ instGen_Set_Reg_To_Imm (EA_PTRSIZE, regGSConst, compiler->gsGlobalSecurityCookieVal );
5766
5754
}
5767
5755
else
5768
5756
{
@@ -6780,7 +6768,7 @@ void CodeGen::genCodeForIndexAddr(GenTreeIndexAddr* node)
6780
6768
else // we have to load the element size and use a MADD (multiply-add) instruction
6781
6769
{
6782
6770
// REG_R21 = element size
6783
- CodeGen::genSetRegToIcon ( REG_R21, (ssize_t )node->gtElemSize , TYP_INT );
6771
+ instGen_Set_Reg_To_Imm (EA_4BYTE, REG_R21, (ssize_t )node->gtElemSize );
6784
6772
6785
6773
// dest = index * REG_R21 + base
6786
6774
instruction ins;
0 commit comments