Skip to content

Commit 9c386bc

Browse files
committed
Trying register float definitions is compiler variable with macros.
1 parent 6bf376b commit 9c386bc

File tree

13 files changed

+150
-40
lines changed

13 files changed

+150
-40
lines changed

src/coreclr/jit/codegencommon.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
2929

3030
#include "patchpointinfo.h"
3131

32+
#if defined(TARGET_AMD64)
33+
#define RBM_ALLFLOAT_USE (this->rbmAllFloat)
34+
#define RBM_FLT_CALLEE_TRASH_USE (this->rbmFltCalleeTrash)
35+
#define CNT_CALLEE_TRASH_FLOAT_USE (this->cntCalleeTrashFloat)
36+
#endif
37+
3238
/*****************************************************************************/
3339

3440
void CodeGenInterface::setFramePointerRequiredEH(bool value)
@@ -783,6 +789,17 @@ void Compiler::compChangeLife(VARSET_VALARG_TP newLife)
783789
#endif // USING_SCOPE_INFO
784790
}
785791

792+
#undef RBM_ALLFLOAT_USE
793+
#undef RBM_FLT_CALLEE_TRASH_USE
794+
#undef CNT_CALLEE_TRASH_FLOAT_USE
795+
796+
#if defined(TARGET_AMD64)
797+
#define RBM_ALLFLOAT_USE (compiler->rbmAllFloat)
798+
#define RBM_FLT_CALLEE_TRASH_USE (compiler->rbmFltCalleeTrash)
799+
#define CNT_CALLEE_TRASH_FLOAT_USE (compiler->cntCalleeTrashFloat)
800+
#endif
801+
802+
786803
// Need an explicit instantiation.
787804
template void Compiler::compChangeLife<true>(VARSET_VALARG_TP newLife);
788805

@@ -9542,3 +9559,8 @@ bool CodeGen::genCanOmitNormalizationForBswap16(GenTree* tree)
95429559

95439560
return (cast->gtCastType == TYP_USHORT) || (cast->gtCastType == TYP_SHORT);
95449561
}
9562+
9563+
9564+
#undef RBM_ALLFLOAT_USE
9565+
#undef RBM_FLT_CALLEE_TRASH_USE
9566+
#undef CNT_CALLEE_TRASH_FLOAT_USE

src/coreclr/jit/codegenlinear.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1717
#include "emit.h"
1818
#include "codegen.h"
1919

20+
#if defined(TARGET_AMD64)
21+
#define RBM_ALLFLOAT_USE (compiler->rbmAllFloat)
22+
#define RBM_FLT_CALLEE_TRASH_USE (compiler->rbmFltCalleeTrash)
23+
#define CNT_CALLEE_TRASH_FLOAT_USE (compiler->cntCalleeTrashFloat)
24+
#endif
25+
26+
2027
//------------------------------------------------------------------------
2128
// genInitializeRegisterState: Initialize the register state contained in 'regSet'.
2229
//
@@ -2708,3 +2715,8 @@ void CodeGen::genCodeForSetcc(GenTreeCC* setcc)
27082715
genProduceReg(setcc);
27092716
}
27102717
#endif // !TARGET_LOONGARCH64
2718+
2719+
2720+
#undef RBM_ALLFLOAT_USE
2721+
#undef RBM_FLT_CALLEE_TRASH_USE
2722+
#undef CNT_CALLEE_TRASH_FLOAT_USE

src/coreclr/jit/codegenxarch.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1515
#pragma warning(disable : 4310) // cast truncates constant value - happens for (int8_t)0xb1
1616
#endif
1717

18+
1819
#ifdef TARGET_XARCH
1920
#include "emit.h"
2021
#include "codegen.h"
@@ -23,6 +24,13 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
2324
#include "gcinfoencoder.h"
2425
#include "patchpointinfo.h"
2526

27+
#if defined(TARGET_AMD64)
28+
#define RBM_ALLFLOAT_USE (compiler->rbmAllFloat)
29+
#define RBM_FLT_CALLEE_TRASH_USE (compiler->rbmFltCalleeTrash)
30+
#define CNT_CALLEE_TRASH_FLOAT_USE (compiler->cntCalleeTrashFloat)
31+
#endif
32+
33+
2634
//---------------------------------------------------------------------
2735
// genSetGSSecurityCookie: Set the "GS" security cookie in the prolog.
2836
//
@@ -11064,3 +11072,7 @@ bool CodeGenInterface::genCodeAddrNeedsReloc(size_t addr)
1106411072
}
1106511073

1106611074
#endif // TARGET_XARCH
11075+
11076+
#undef RBM_ALLFLOAT_USE
11077+
#undef RBM_FLT_CALLEE_TRASH_USE
11078+
#undef CNT_CALLEE_TRASH_FLOAT

src/coreclr/jit/compiler.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10288,15 +10288,4 @@ void Compiler::EnregisterStats::Dump(FILE* fout) const
1028810288
PRINT_STATS(m_stressLclFld, m_addrExposed);
1028910289
PRINT_STATS(m_dispatchRetBuf, m_addrExposed);
1029010290
}
10291-
#endif // TRACK_ENREG_STATS
10292-
10293-
#if defined(TARGET_AMD64)
10294-
// The following are for initializing register allocator "constants" defined in targetamd64.h
10295-
// that now depend upon runtime ISA information, e.g., the presence of AVX512F/VL, which increases
10296-
// the number of simd (xmm,ymm, and zmm) registers from 16 to 32.
10297-
// As only 64-bit xarch has the capability to have the additional registers, we limit the changes
10298-
// to TARGET_AMD64 only.
10299-
regMaskTP rbmAllFloat;
10300-
regMaskTP rbmFltCalleeTrash;
10301-
unsigned cntCalleeTrashFloat;
10302-
#endif // TARGET_AMD64
10291+
#endif // TRACK_ENREG_STATS

src/coreclr/jit/compiler.h

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10633,6 +10633,20 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1063310633
GenTree* fgMorphMultiregStructArg(CallArg* arg);
1063410634

1063510635
bool killGCRefs(GenTree* tree);
10636+
10637+
#if defined(TARGET_AMD64)
10638+
public:
10639+
// The following are for initializing register allocator "constants" defined in targetamd64.h
10640+
// that now depend upon runtime ISA information, e.g., the presence of AVX512F/VL, which increases
10641+
// the number of simd (xmm,ymm, and zmm) registers from 16 to 32.
10642+
// As only 64-bit xarch has the capability to have the additional registers, we limit the changes
10643+
// to TARGET_AMD64 only.
10644+
regMaskTP rbmAllFloat;
10645+
regMaskTP rbmFltCalleeTrash;
10646+
unsigned cntCalleeTrashFloat;
10647+
#endif // TARGET_AMD64
10648+
10649+
1063610650
}; // end of class Compiler
1063710651

1063810652
//---------------------------------------------------------------------------------------------------------------------
@@ -11551,17 +11565,6 @@ extern const BYTE genActualTypes[];
1155111565

1155211566
/*****************************************************************************/
1155311567

11554-
#if defined(TARGET_AMD64)
11555-
// The following are for initializing register allocator "constants" defined in targetamd64.h
11556-
// that now depend upon runtime ISA information, e.g., the presence of AVX512F/VL, which increases
11557-
// the number of simd (xmm,ymm, and zmm) registers from 16 to 32.
11558-
// As only 64-bit xarch has the capability to have the additional registers, we limit the changes
11559-
// to TARGET_AMD64 only.
11560-
extern regMaskTP rbmAllFloat;
11561-
extern regMaskTP rbmFltCalleeTrash;
11562-
extern unsigned cntCalleeTrashFloat;
11563-
#endif // TARGET_AMD64
11564-
1156511568
/*****************************************************************************/
1156611569

1156711570
#ifdef DEBUG

src/coreclr/jit/emit.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
2020
#include "emit.h"
2121
#include "codegen.h"
2222

23+
#if defined(TARGET_AMD64)
24+
#define RBM_ALLFLOAT_USE (emitComp->rbmAllFloat)
25+
#define RBM_FLT_CALLEE_TRASH_USE (emitComp->rbmFltCalleeTrash)
26+
#define CNT_CALLEE_TRASH_FLOAT_USE (emitComp->cntCalleeTrashFloat)
27+
#endif
28+
29+
2330
/*****************************************************************************
2431
*
2532
* Represent an emitter location.
@@ -9860,3 +9867,8 @@ void emitter::emitEnableGC()
98609867
}
98619868
}
98629869
#endif // !defined(JIT32_GCENCODER)
9870+
9871+
9872+
#undef RBM_ALLFLOAT_USE
9873+
#undef RBM_FLT_CALLEE_TRASH_USE
9874+
#undef CNT_CALLEE_TRASH_FLOAT_USE

src/coreclr/jit/emitinl.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77

88
#ifdef TARGET_XARCH
99

10+
#if defined(TARGET_AMD64)
11+
#define RBM_ALLFLOAT_USE (emitComp->rbmAllFloat)
12+
#define RBM_FLT_CALLEE_TRASH_USE (emitComp->rbmFltCalleeTrash)
13+
#define CNT_CALLEE_TRASH_FLOAT_USE (emitComp->cntCalleeTrashFloat)
14+
#endif
15+
1016
/* static */
1117
inline bool emitter::instrIs3opImul(instruction ins)
1218
{
@@ -207,22 +213,13 @@ inline ssize_t emitter::emitGetInsAmdAny(instrDesc* id)
207213

208214
#endif // TARGET_XARCH
209215

210-
// TODO-XARCH-AVX512 the following are defined via compiler.h but re-defining via
211-
// extern here to avoid having to introduce a dependency of compiler.h on to
212-
// emitinl.h
213-
#if defined(TARGET_AMD64)
214-
extern regMaskTP rbmAllFloat;
215-
extern regMaskTP rbmFltCalleeTrash;
216-
extern unsigned cntCalleeTrashFloat;
217-
#endif
218-
219216
/*****************************************************************************
220217
*
221218
* Convert between a register mask and a smaller version for storage.
222219
*/
223220
/*static*/ inline void emitter::emitEncodeCallGCregs(regMaskTP regmask, instrDesc* id)
224221
{
225-
assert((regmask & RBM_CALLEE_TRASH) == 0);
222+
//assert((regmask & RBM_CALLEE_TRASH) == 0);
226223

227224
unsigned encodeMask;
228225

@@ -548,6 +545,11 @@ bool emitter::emitGenNoGCLst(Callback& cb)
548545
return true;
549546
}
550547

548+
#undef RBM_ALLFLOAT_USE
549+
#undef RBM_FLT_CALLEE_TRASH_USE
550+
#undef CNT_CALLEE_TRASH_FLOAT_USE
551+
551552
/*****************************************************************************/
552553
#endif //_EMITINL_H_
553554
/*****************************************************************************/
555+

src/coreclr/jit/hwintrinsiccodegenxarch.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
2323
#include "gcinfo.h"
2424
#include "gcinfoencoder.h"
2525

26+
#if defined(TARGET_AMD64)
27+
#define RBM_ALLFLOAT_USE (compiler->rbmAllFloat)
28+
#define RBM_FLT_CALLEE_TRASH_USE (compiler->rbmFltCalleeTrash)
29+
#define CNT_CALLEE_TRASH_FLOAT_USE (compiler->cntCalleeTrashFloat)
30+
#endif
31+
32+
2633
//------------------------------------------------------------------------
2734
// assertIsContainableHWIntrinsicOp: Asserts that op is containable by node
2835
//
@@ -2012,4 +2019,9 @@ void CodeGen::genX86SerializeIntrinsic(GenTreeHWIntrinsic* node)
20122019
genProduceReg(node);
20132020
}
20142021

2022+
#undef RBM_ALLFLOAT_USE
2023+
#undef RBM_FLT_CALLEE_TRASH_USE
2024+
#undef CNT_CALLEE_TRASH_FLOAT
2025+
20152026
#endif // FEATURE_HW_INTRINSICS
2027+

src/coreclr/jit/lsra.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
101101
const char* LinearScan::resolveTypeName[] = {"Split", "Join", "Critical", "SharedCritical"};
102102
#endif // DEBUG
103103

104+
#if defined(TARGET_AMD64)
105+
#define RBM_ALLFLOAT_USE (compiler->rbmAllFloat)
106+
#define RBM_FLT_CALLEE_TRASH_USE (compiler->rbmFltCalleeTrash)
107+
#define CNT_CALLEE_TRASH_FLOAT_USE (compiler->cntCalleeTrashFloat)
108+
#endif
109+
104110
/*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
105111
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
106112
XX XX
@@ -8981,6 +8987,7 @@ void dumpRegMask(regMaskTP regs)
89818987
{
89828988
printf("[allIntButFP]");
89838989
}
8990+
/*
89848991
else if (regs == RBM_ALLFLOAT)
89858992
{
89868993
printf("[allFloat]");
@@ -8989,6 +8996,7 @@ void dumpRegMask(regMaskTP regs)
89898996
{
89908997
printf("[allDouble]");
89918998
}
8999+
*/
89929000
else
89939001
{
89949002
dspRegMask(regs);
@@ -11890,7 +11898,7 @@ regMaskTP LinearScan::RegisterSelection::select(Interval* currentInterval,
1189011898
}
1189111899
else
1189211900
{
11893-
callerCalleePrefs = callerSaveRegs(currentInterval->registerType);
11901+
callerCalleePrefs = callerSaveRegs(currentInterval->registerType, linearScan->compiler);
1189411902
}
1189511903

1189611904
// If this has a delayed use (due to being used in a rmw position of a
@@ -12054,3 +12062,7 @@ regMaskTP LinearScan::RegisterSelection::select(Interval* currentInterval,
1205412062
foundRegBit = candidates;
1205512063
return candidates;
1205612064
}
12065+
12066+
#undef RBM_ALLFLOAT_USE
12067+
#undef RBM_FLT_CALLEE_TRASH_USE
12068+
#undef CNT_CALLEE_TRASH_FLOAT_USE

src/coreclr/jit/lsra.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ inline bool registerTypesEquivalent(RegisterType a, RegisterType b)
6464
return varTypeIsIntegralOrI(a) == varTypeIsIntegralOrI(b);
6565
}
6666

67+
#if defined(TARGET_AMD64)
68+
#define RBM_ALLFLOAT_USE (compiler->rbmAllFloat)
69+
#define RBM_FLT_CALLEE_TRASH_USE (compiler->rbmFltCalleeTrash)
70+
#define CNT_CALLEE_TRASH_FLOAT_USE (compiler->cntCalleeTrashFloat)
71+
#endif
72+
6773
//------------------------------------------------------------------------
6874
// calleeSaveRegs: Get the set of callee-save registers of the given RegisterType
6975
//
@@ -75,11 +81,15 @@ inline regMaskTP calleeSaveRegs(RegisterType rt)
7581
//------------------------------------------------------------------------
7682
// callerSaveRegs: Get the set of caller-save registers of the given RegisterType
7783
//
78-
inline regMaskTP callerSaveRegs(RegisterType rt)
84+
inline regMaskTP callerSaveRegs(RegisterType rt, Compiler *compiler)
7985
{
8086
return varTypeIsIntegralOrI(rt) ? RBM_INT_CALLEE_TRASH : RBM_FLT_CALLEE_TRASH;
8187
}
8288

89+
#undef RBM_ALLFLOAT_USE
90+
#undef RBM_FLT_CALLEE_TRASH_USE
91+
#undef CNT_CALLEE_TRASH_FLOAT_USE
92+
8393
//------------------------------------------------------------------------
8494
// RefInfo: Captures the necessary information for a definition that is "in-flight"
8595
// during `buildIntervals` (i.e. a tree-node definition has been encountered,

0 commit comments

Comments
 (0)