Skip to content

Commit

Permalink
[RISC-V] Added designated output instruction emitters (dotnet#96741)
Browse files Browse the repository at this point in the history
* Added declarations and r-type definition with assert helper

* Added insEncodeITypeInstr

* Added definition of S type instr

* Added definition of U type instr

* Added definition of B type instr

* Added definition of J type instr

* Restructurized bit operations

* Improved checks in insEncode functions

* Fixed some of the encoding methods

* Bugfix

* Fixed comparation sign

* Revert "Fixed comparation sign"

This reverts commit c238b82.

* Fixed comparation sign

* Reverted changes in emitOutputInstrJumpDistanceHelper

* Fixed misspell

* Fixes after review

* Fixes in insEncodeJTypeInstr

* Added emitOutput_RTypeInstr

* Added emitOutput_ITypeInstr

* Added emitOutput_STypeInstr

* Added emitOutput_UTypeInstr

* Added emitOutput_BTypeInstr

* Added emitOutput_JTypeInstr

* Fixes in emitOutput_ methods

* Replaced reloc with new code

* Removed invalid code

* Added emit output rellocation

* Minor changes

* Added emitOutputInstr_Addi8

* Implemented further addi32

* Reverted changes from la

* Fixed format bug

* Fixed comment

* Renamed some of the emitters

* Added some comments

* Improved implementation and finished addi32

* Microimprovements

* Quickfix to upperNBitsOfWord

* Finished substituting instr_optsi

* Fixed bug in mask

* Added emitOutputInstr_OptsRcReloc and prelimiary parent function

* Added emitOutput_OptsRcNoReloc

* Improvements in OptsRc

* Fixes and introduced an emitOutputInstr_OptsRc

* Added emitOutputInstr_OptsRl and removed unused args from other functions

* Added emitOutputInstr_OptsRlReloc

* Finished emitOutputInstr_OptsRcNoReloc

* Fixed bugs and finished opts rl

* Added emitOutputInstr_OptsJalr

* Added emitOutputInstr_OptsJalr8

* Added special comparation inverter

* Add emitOutputInstr_OptsJalr24

* Added emitOutputInstr_OptsJalr28

* Improved emitOutputInstr_OptsJalr28

* Enabled new opts jalr impl

* Added emitOutputInstr_OptsJCond

* Added emitOutputInstr_OptsJ

* Replaced old code with the new one

* Added emitOutputInstr_OptsC

* Fixed last piece of switch

* Removed old code

* Simplified code

* Other fixes

* Fixes in emitOutput_* instr

* Fixed bitmask bug

* Added temporary reinforced assers

* Added shift ins

* Improved shift func

* Inserted shift func

* Fixed minor bug

* Other fixes

* Added checks to r type emitter

* Improved sanity checks in the emitOutput_RTypeInstr

* Added ITypeInstr sanity checks

* Moved ITypeInstr_Shift sanity Check

* Added comment to the emitriscv64

* Added S-type sanity checks

* Removed Shift ITypeInstr Variant

* Fixes

* Added BType sanity check

* Added csr operations to sanity checks

* Added ITypeInstr sanity check

* Fixes

* Removed duplicated code

* Fixed bug in noreloc

* Removed dead asserts

* Removed now unused asserts

* Fixed format

* Fixed missing const

* Removed useless ifdef

* Fixed missing asserts

* Added a new assert

* Added zero assert

* Removed useless FALLTHROUGH statements

* Added trimmers

* Added explicit signed integers trimming

* Fixes to prev commit

* Added castFloatOrIntegralReg and fixed invalid asserts

* Renamed upper word helpers

* Spell fix

* Moved castFloat... to the emitter

* Changes after code review

* Removed bitcast

* Added additional check

* Removed unnecessary reinterpret casts

* Removed redundant asserts

---------

Co-authored-by: Grzegorz Czarnecki <[email protected]>
  • Loading branch information
Bajtazar and Grzegorz Czarnecki authored Jan 25, 2024
1 parent b79a1fd commit 77fd98c
Show file tree
Hide file tree
Showing 4 changed files with 1,029 additions and 643 deletions.
6 changes: 3 additions & 3 deletions src/coreclr/jit/emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ void emitLclVarAddr::initLclVarAddr(int varNum, unsigned offset)
}

// Returns the variable to access. Note that it returns a negative number for compiler spill temps.
int emitLclVarAddr::lvaVarNum()
int emitLclVarAddr::lvaVarNum() const
{
switch (_lvaTag)
{
Expand All @@ -721,7 +721,7 @@ int emitLclVarAddr::lvaVarNum()
}
}

unsigned emitLclVarAddr::lvaOffset() // returns the offset into the variable to access
unsigned emitLclVarAddr::lvaOffset() const // returns the offset into the variable to access
{
switch (_lvaTag)
{
Expand Down Expand Up @@ -9777,7 +9777,7 @@ void emitter::emitRemoveLastInstruction()
* emitGetInsSC: Get the instruction's constant value.
*/

cnsval_ssize_t emitter::emitGetInsSC(instrDesc* id)
cnsval_ssize_t emitter::emitGetInsSC(const instrDesc* id) const
{
#ifdef TARGET_ARM // should it be TARGET_ARMARCH? Why do we need this? Note that on ARM64 we store scaled immediates
// for some formats
Expand Down
7 changes: 4 additions & 3 deletions src/coreclr/jit/emit.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,9 @@ struct emitLclVarAddr
// Constructor
void initLclVarAddr(int varNum, unsigned offset);

int lvaVarNum(); // Returns the variable to access. Note that it returns a negative number for compiler spill temps.
unsigned lvaOffset(); // returns the offset into the variable to access
int lvaVarNum() const; // Returns the variable to access. Note that it returns a negative number for compiler spill
// temps.
unsigned lvaOffset() const; // returns the offset into the variable to access

// This struct should be 32 bits in size for the release build.
// We have this constraint because this type is used in a union
Expand Down Expand Up @@ -2164,7 +2165,7 @@ class emitter
static const IS_INFO emitGetSchedInfo(insFormat f);
#endif // TARGET_XARCH

cnsval_ssize_t emitGetInsSC(instrDesc* id);
cnsval_ssize_t emitGetInsSC(const instrDesc* id) const;
unsigned emitInsCount;

/************************************************************************/
Expand Down
Loading

0 comments on commit 77fd98c

Please sign in to comment.