diff options
author | Bruce Forstall <brucefo@microsoft.com> | 2017-06-07 14:39:24 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-07 14:39:24 -0700 |
commit | ef1cb89d9ddb8427d0c906a2c86ea39a579d9e53 (patch) | |
tree | 7ad942d341c8fb3d6cb4ba197dad84195585ab59 /src | |
parent | cd5de7576d93f6006c4ef1659e3760488e159e82 (diff) | |
download | coreclr-ef1cb89d9ddb8427d0c906a2c86ea39a579d9e53.tar.gz coreclr-ef1cb89d9ddb8427d0c906a2c86ea39a579d9e53.tar.bz2 coreclr-ef1cb89d9ddb8427d0c906a2c86ea39a579d9e53.zip |
Simplify genRegArgNext() (#12124)
* Simplify genRegArgNext()
There is no need to check the register type before calling REG_NEXT.
* Rewrite using `switch`
* Fix genRegArgNext for Linux x64
Diffstat (limited to 'src')
-rw-r--r-- | src/jit/regset.cpp | 60 |
1 files changed, 22 insertions, 38 deletions
diff --git a/src/jit/regset.cpp b/src/jit/regset.cpp index 24c9bf9e19..dd48ff0f10 100644 --- a/src/jit/regset.cpp +++ b/src/jit/regset.cpp @@ -3570,52 +3570,36 @@ bool genIsProperRegPair(regPairNo regPair) regNumber genRegArgNext(regNumber argReg) { - regNumber result = REG_NA; + assert(isValidIntArgReg(argReg) || isValidFloatArgReg(argReg)); - if (isValidFloatArgReg(argReg)) + switch (argReg) { - // We can iterate the floating point argument registers by using +1 - result = REG_NEXT(argReg); - } - else - { - assert(isValidIntArgReg(argReg)); #ifdef _TARGET_AMD64_ #ifdef UNIX_AMD64_ABI - // Windows X64 ABI: - // REG_EDI, REG_ESI, REG_ECX, REG_EDX, REG_R8, REG_R9 - // - if (argReg == REG_ARG_1) // REG_ESI - { - result = REG_ARG_2; // REG_ECX - } - else if (argReg == REG_ARG_3) // REG_EDX - { - result = REG_ARG_4; // REG_R8 - } -#else // Windows ABI - // Windows X64 ABI: - // REG_ECX, REG_EDX, REG_R8, REG_R9 - // - if (argReg == REG_ARG_1) // REG_EDX - { - result = REG_ARG_2; // REG_R8 - } -#endif // UNIX or Windows ABI + + // Linux x64 ABI: REG_RDI, REG_RSI, REG_RDX, REG_RCX, REG_R8, REG_R9 + case REG_ARG_0: // REG_RDI + return REG_ARG_1; // REG_RSI + case REG_ARG_1: // REG_RSI + return REG_ARG_2; // REG_RDX + case REG_ARG_2: // REG_RDX + return REG_ARG_3; // REG_RCX + case REG_ARG_3: // REG_RCX + return REG_ARG_4; // REG_R8 + +#else // !UNIX_AMD64_ABI + + // Windows x64 ABI: REG_RCX, REG_RDX, REG_R8, REG_R9 + case REG_ARG_1: // REG_RDX + return REG_ARG_2; // REG_R8 + +#endif // !UNIX_AMD64_ABI #endif // _TARGET_AMD64_ - // If we didn't set 'result' to valid register above - // then we will just iterate 'argReg' using REG_NEXT - // - if (result == REG_NA) - { - // Otherwise we just iterate the argument registers by using REG_NEXT - result = REG_NEXT(argReg); - } + default: + return REG_NEXT(argReg); } - - return result; } /***************************************************************************** |