From 5088ee1220a96e5b8f9add31a8b1fe4cc56adad1 Mon Sep 17 00:00:00 2001 From: SingleAccretion Date: Fri, 5 Dec 2025 03:18:36 +0300 Subject: [PATCH 1/2] [RyuJit/WASM] Clean up some code Remove unused register functions. Shrink the instruction format array. --- src/coreclr/jit/emitwasm.cpp | 24 +++++++++++------------- src/coreclr/jit/instrswasm.h | 2 -- src/coreclr/jit/registeropswasm.cpp | 12 ------------ src/coreclr/jit/registeropswasm.h | 2 -- 4 files changed, 11 insertions(+), 29 deletions(-) diff --git a/src/coreclr/jit/emitwasm.cpp b/src/coreclr/jit/emitwasm.cpp index c020eded146558..a3276ef5097cf2 100644 --- a/src/coreclr/jit/emitwasm.cpp +++ b/src/coreclr/jit/emitwasm.cpp @@ -14,12 +14,6 @@ #define INST(id, nm, info, fmt, opcode) info, #include "instrs.h" }; - -static const uint8_t insOpcodes[] -{ - #define INST(id, nm, info, fmt, opcode) static_cast(opcode), - #include "instrs.h" -}; // clang-format on void emitter::emitIns(instruction ins) @@ -93,21 +87,25 @@ bool emitter::emitInsIsStore(instruction ins) emitter::insFormat emitter::emitInsFormat(instruction ins) { - // clang-format off - const static insFormat insFormats[] = - { - #define INST(id, nm, info, fmt, opcode) fmt, - #include "instrs.h" + static_assert(IF_COUNT < 255); + + const static uint8_t insFormats[] = { +#define INST(id, nm, info, fmt, opcode) fmt, +#include "instrs.h" }; - // clang-format on assert(ins < ArrLen(insFormats)); assert((insFormats[ins] != IF_NONE)); - return insFormats[ins]; + return static_cast(insFormats[ins]); } static unsigned GetInsOpcode(instruction ins) { + static const uint8_t insOpcodes[] = { +#define INST(id, nm, info, fmt, opcode) static_cast(opcode), +#include "instrs.h" + }; + assert(ins < ArrLen(insOpcodes)); return insOpcodes[ins]; } diff --git a/src/coreclr/jit/instrswasm.h b/src/coreclr/jit/instrswasm.h index b892290f1ad338..7b204d189a0de1 100644 --- a/src/coreclr/jit/instrswasm.h +++ b/src/coreclr/jit/instrswasm.h @@ -20,8 +20,6 @@ #error INST must be defined before including this file. #endif -// TODO-WASM: fill out with more instructions (and everything else needed). -// // clang-format off // control flow diff --git a/src/coreclr/jit/registeropswasm.cpp b/src/coreclr/jit/registeropswasm.cpp index 8e87aac66b8647..724c69154faf1e 100644 --- a/src/coreclr/jit/registeropswasm.cpp +++ b/src/coreclr/jit/registeropswasm.cpp @@ -124,18 +124,6 @@ bool genIsValidFloatReg(regNumber reg) return (type == WasmValueType::F32) || (type == WasmValueType::F64); } -bool isValidIntArgReg(regNumber reg, CorInfoCallConvExtension callConv) -{ - NYI_WASM("isValidIntArgReg"); - return false; -} - -bool isValidFloatArgReg(regNumber reg) -{ - NYI_WASM("isValidFloatArgReg"); - return false; -} - const char* getRegName(regNumber reg) { if (reg == REG_NA) diff --git a/src/coreclr/jit/registeropswasm.h b/src/coreclr/jit/registeropswasm.h index 1af36e34d316d1..1bb8bd79b016a3 100644 --- a/src/coreclr/jit/registeropswasm.h +++ b/src/coreclr/jit/registeropswasm.h @@ -24,5 +24,3 @@ bool genIsValidReg(regNumber reg); bool genIsValidIntReg(regNumber reg); bool genIsValidIntOrFakeReg(regNumber reg); bool genIsValidFloatReg(regNumber reg); -bool isValidIntArgReg(regNumber reg, CorInfoCallConvExtension callConv); -bool isValidFloatArgReg(regNumber reg); From e63e6af87b479b8397e7ac0b8007749184742c23 Mon Sep 17 00:00:00 2001 From: SingleAccretion Date: Fri, 5 Dec 2025 15:38:50 +0300 Subject: [PATCH 2/2] Remove some dead code while we're here --- src/coreclr/jit/emit.h | 11 ----------- src/coreclr/jit/emitpub.h | 1 - 2 files changed, 12 deletions(-) diff --git a/src/coreclr/jit/emit.h b/src/coreclr/jit/emit.h index 0dc7710dc32124..4418dc4c2e93bb 100644 --- a/src/coreclr/jit/emit.h +++ b/src/coreclr/jit/emit.h @@ -3826,17 +3826,6 @@ inline UNATIVE_OFFSET emitter::emitDataSize() return emitConsDsc.dsdOffs; } -/***************************************************************************** - * - * Return a handle to the current position in the output stream. This can - * be later converted to an actual code offset in bytes. - */ - -inline void* emitter::emitCurBlock() -{ - return emitCurIG; -} - /***************************************************************************** * * The emitCurOffset() method returns a cookie that identifies the current diff --git a/src/coreclr/jit/emitpub.h b/src/coreclr/jit/emitpub.h index 389328b8c4f06d..67876fbf348b98 100644 --- a/src/coreclr/jit/emitpub.h +++ b/src/coreclr/jit/emitpub.h @@ -65,7 +65,6 @@ void emitFinishPrologEpilogGeneration(); /* Record a code position and later convert it to offset */ /************************************************************************/ -void* emitCurBlock(); unsigned emitCurOffset(); unsigned emitSpecifiedOffset(unsigned insCount, unsigned igSize);