-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RISC-V] Add crossgen2 for riscv64 #95188
Conversation
Please update casing from |
@@ -96,6 +96,7 @@ public static TargetArchitecture GetTargetArchitecture(string token) | |||
Architecture.Arm => TargetArchitecture.ARM, | |||
Architecture.Arm64 => TargetArchitecture.ARM64, | |||
Architecture.LoongArch64 => TargetArchitecture.LoongArch64, | |||
(Architecture)9 => TargetArchitecture.Riscv64, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Architecture.RiscV64
is supported from #90203.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll have to wait for new architecture to get to sdk and for this new sdk to be used in main branch build. Currently .net-8.0.1 sdk is used for main branch, so it'll take some time until .net9-preview1 sdk arrives (changes from #90203 are not present in .net8 branch). Maybe I'm wrong here, if so please correct me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake. Thank you!
{ | ||
// ori a4, r0, #index | ||
int index = _containingImportSection.IndexFromBeginningOfArray; | ||
instructionEncoder.EmitMOV(Register.X14, checked((ushort)index)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you use X14
? Isn't T0 (X5)
correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
if (!relocsOnly) | ||
{ | ||
// ori a4, r0, #index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update ori
to addi
and update a4
to T0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
case Kind.DelayLoadHelper: | ||
case Kind.VirtualStubDispatch: | ||
// T8 contains indirection cell |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no T8
in RISCV. Please update to T5
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
// then get the low 12 bits | ||
pcInstr = *(pCode + 1); | ||
imm += (long)(pcInstr & 0xFFFF); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update to 0xFFF
with correct shifts for JALR.
case RelocType.IMAGE_REL_BASED_RISCV64_PC: | ||
case RelocType.IMAGE_REL_BASED_RISCV64_JALR: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think IMAGE_REL_BASED_RISCV64_PC
and IMAGE_REL_BASED_RISCV64_JALR
has the same behavior in RISCV64. IMO, it is better to merge into one such as IMAGE_REL_BASED_RISCV64_AUIPC
You need to update IMAGE_REL_RISCV64_PC and IMAGE_REL_RISCV64_JALR in runtime as well.
Debug.Assert((imm20 & 0x1) == 0); // the low two bits must be zero | ||
|
||
uint auipcInstr = *pCode; | ||
Debug.Assert(auipcInstr == 0x00000297); // must be auipc t0, 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why must it be auipc t0, 0
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed incorrect comment
@@ -317,6 +317,10 @@ public SectionBuilder(TargetDetails target) | |||
_codePadding = 0x002A0005u; | |||
break; | |||
|
|||
case TargetArchitecture.Riscv64: | |||
_codePadding = 0x002A0005u; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain why it is 0x002A0005u
? In other archs, it is break
instruction. Please clarify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
else | ||
{ | ||
//Builder.EmitReloc(symbol, RelocType.IMAGE_REL_BASED_RISCV64_PC); | ||
Builder.EmitUInt(0xffffffff); // bad code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0x00000000
is used for bad code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
public override int PointerSize => 8; | ||
public override int NumArgumentRegisters => 8; | ||
public override int NumCalleeSavedRegisters => 12; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is NumCalleeSavedRegisters
correct number? Please write the comments like other architectures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it
uint auipcInstr = *pCode; | ||
|
||
// first get the high 20 bits, | ||
int imm = (int)(((auipcInstr >> 12) & 0xFFFFF) << 12); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is okay like auipcInstr & 0xFFFFF000
(no shifts)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
// then get the low 12 bits, | ||
auipcInstr = *(pCode + 1); | ||
imm += ((int)(((auipcInstr >> 20) & 0xFFF) << 20)) >> 20; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ((int)(auipcInstr & 0xfff00000)) >> 20
is better.
|
||
int relOff = (int)imm32 & 0x800; | ||
int imm = (int)imm32 + relOff; | ||
relOff = ((imm & 0x7ff) - relOff) & 0xfff; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it good to make codes similar to codes in jit/emitriscv64.cpp
?
runtime/src/coreclr/jit/emitriscv64.cpp
Lines 2423 to 2433 in cc4db9b
code = 0x00000017; | |
*(code_t*)dstRW = code | (code_t)reg1 << 7 | ((imm + 0x800) & 0xfffff000); | |
dstRW += 4; | |
#ifdef DEBUG | |
code = emitInsCode(INS_auipc); | |
assert(code == 0x00000017); | |
code = emitInsCode(INS_addi); | |
assert(code == 0x00000013); | |
#endif | |
ins = INS_addi; | |
*(code_t*)dstRW = 0x00000013 | ((code_t)reg1 << 7) | ((code_t)reg1 << 15) | ((doff & 0xfff) << 20); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Please add commits not force-push when you fixed. |
// ld a0, 16(t0) | ||
EmitLD(Register.X10, Register.X5, 16); | ||
// ld t0, 24(t0) | ||
EmitLD(Register.X5, Register.X5, 24); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain why 24
? It seems like 0
to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it
// auipc t0, 0 | ||
EmitPC(Register.X5); | ||
// ld a0, 16(t0) | ||
EmitLD(Register.X10, Register.X5, 16); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think EmitJMP
jumps to symbol with relocation support. But, it is different. Could you explain why you generate these code?
uint offset = symbol.RepresentsIndirectionCell ? 7u : 2u; | ||
|
||
// bne regSrc, x0, offset | ||
Builder.EmitUInt((uint)(0x00001063 | ((uint)regSrc << 15) | (offset << 31))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Offset is instructions to jump. So offset value in instructions should be 7 * 4(inst size)
or 2 * 4
. So shift for offset is not 31
at all. Maybe 9
? Please check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
instructionEncoder.EmitPC(Register.X6); | ||
|
||
// load Module* -> T1 | ||
instructionEncoder.EmitLD(Register.X6, Register.X6, 0x18); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is wrong. Please update to correct offset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
instructionEncoder.EmitPC(Register.X11); | ||
|
||
// load Module* -> a1 | ||
instructionEncoder.EmitLD(Register.X11, Register.X11, 0x18); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
// Verify that we got a valid offset | ||
Debug.Assert((imm20 >= -0x80000) && (imm20 < 0x80000)); | ||
|
||
Debug.Assert((imm20 & 0x1) == 0); // the low two bits must be zero |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're checking only the lowest bit, which afaik is correct. Pls update comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
public void EmitMOV(Register regDst, ushort imm16) | ||
{ | ||
Debug.Assert((uint)regDst <= 0x1f); | ||
Debug.Assert(imm16 <= 0xfff); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: so it's imm12.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Builder.EmitUInt(0x00100073); | ||
} | ||
|
||
public void EmitMOV(Register regDst, ushort imm16) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: more like EmitLI (load immediate), mov means register move on RISC-V.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
public void EmitRETIfEqual(Register regSrc) | ||
{ | ||
// bne regSrc, x0, 8 | ||
Builder.EmitUInt((uint)(0x00001463 | ((uint)regSrc << 15))); | ||
EmitRET(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: "equal" suggests comparing with sth else. Maybe rename to EmitRETIfZero?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
// We need to trigger the cctor before returning the base. It is stored at the beginning of the non-GC statics region. | ||
encoder.EmitADD(encoder.TargetRegister.Arg3, encoder.TargetRegister.Arg0, -NonGCStaticsNode.GetClassConstructorContextSize(factory.Target)); | ||
encoder.EmitLD(encoder.TargetRegister.Arg2, encoder.TargetRegister.Arg3, 0); | ||
encoder.EmitXOR(encoder.TargetRegister.IntraProcedureCallScratch1, encoder.TargetRegister.Arg2, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an oddly phrased register move (because x ^ 0 == x). Did you mean x ^ 1 like in the rest?
(if you really meant a reg move, 1. it should be addi, 2. IMO it can be elided, the branch below could work on the source register)
auipcInstr = *(pCode + 1); | ||
|
||
// Assemble the pc-relative low 12 bits of 'imm20' into the addi | ||
auipcInstr |= (uint)(relOff << 20); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: it's no longer an auipc. Pls call it e.g. addiInstr and assert it really is an addi.
|
||
encoder.EmitADD(encoder.TargetRegister.Arg2, encoder.TargetRegister.Arg2, -NonGCStaticsNode.GetClassConstructorContextSize(factory.Target)); | ||
encoder.EmitLD(encoder.TargetRegister.Arg3, encoder.TargetRegister.Arg2, factory.Target.PointerSize); | ||
encoder.EmitXOR(encoder.TargetRegister.IntraProcedureCallScratch1, encoder.TargetRegister.Arg3, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain why are you flipping the lowest bit here?
// load Module* -> T1 | ||
instructionEncoder.EmitLD(Register.X6, Register.X6, 0x18); | ||
|
||
// ld_d X6, X6, 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// ld_d X6, X6, 0 | |
// ld X6, X6, 0 |
{ | ||
public enum Registers | ||
{ | ||
R0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's adhere to naming in RISC-V ABI.
R0, | |
Zero, |
Debug.Assert((cbArg % _transitionBlock.PointerSize) == 0); | ||
|
||
int regSlots = ALIGN_UP(cbArg, _transitionBlock.PointerSize) / _transitionBlock.PointerSize; | ||
// Only R4-R11 are valid argument registers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More like x10-x17 on RISC-V
X0 = 0, | ||
X1 = 1, | ||
X2 = 2, | ||
X3 = 3, | ||
X4 = 4, | ||
X5 = 5, | ||
X6 = 6, | ||
X7 = 7, | ||
X8 = 8, | ||
X9 = 9, | ||
X10 = 10, | ||
X11 = 11, | ||
X12 = 12, | ||
X13 = 13, | ||
X14 = 14, | ||
X15 = 15, | ||
X16 = 16, | ||
X17 = 17, | ||
X18 = 18, | ||
X19 = 19, | ||
X20 = 20, | ||
X21 = 21, | ||
X22 = 22, | ||
X23 = 23, | ||
X24 = 24, | ||
X25 = 25, | ||
X26 = 26, | ||
X27 = 27, | ||
X28 = 28, | ||
X29 = 29, | ||
X30 = 30, | ||
|
||
X31 = 31, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for not to use RISC-V ABI registers, that are more readable?
Arg0 = Register.X10; | ||
Arg1 = Register.X11; | ||
Arg2 = Register.X12; | ||
Arg3 = Register.X13; | ||
Arg4 = Register.X14; | ||
Arg5 = Register.X15; | ||
Arg6 = Register.X16; | ||
Arg7 = Register.X17; | ||
IntraProcedureCallScratch1 = Register.X28; | ||
Result = Register.X10; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If your enum Register would be compatible with ABI, then here you wouldn't have less readable Register.Xn
, but instead:
Arg0 = Register.A0;
Arg1 = Register.A1;
Arg2 = Register.A2;
Arg3 = Register.A3;
Arg4 = Register.A4;
Arg5 = Register.A5;
Arg6 = Register.A6;
Arg7 = Register.A7;
IntraProcedureCallScratch1 = Register.T3;
Result = Register.A0;
Please note that these are just initial changes required for crossgen2 and just simple functionality works (both r2r image generation and launch of image are successful with debug/release runtime):
In order to not extend this PR more, further work can be done in separate PRs (if you will see no issues in this code):
|
Thanks a lot for your reviews, they were very useful! @clamp03 @tomeksowi @sirntar |
|
||
switch (fRelocType) | ||
{ | ||
case IMAGE_REL_RISCV64_PC: | ||
return RelocType.IMAGE_REL_BASED_RISCV64_PC; | ||
case IMAGE_REL_RISCV64_JALR: | ||
return RelocType.IMAGE_REL_BASED_RISCV64_JALR; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, these code be updated or removed as well. Please check.
runtime/src/coreclr/jit/emitriscv64.cpp
Line 1546 in 0cf461b
emitRecordRelocation(dst - 4, (BYTE*)addr, IMAGE_REL_RISCV64_JALR); |
runtime/src/coreclr/pal/inc/rt/ntimage.h
Line 1028 in 0cf461b
#define IMAGE_REL_RISCV64_JALR 0x0004 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed the comment. Please update in the next PR. Thank you.
@@ -411,6 +412,47 @@ private static unsafe void PutLoongArch64JIR(uint* pCode, long imm38) | |||
Debug.Assert(GetLoongArch64JIR(pCode) == imm38); | |||
} | |||
|
|||
private static unsafe int GetRiscV64PC12(uint* pCode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I know, PC12 means pcaddu12i in LOONGARCH64. Please update the name to GetRiscV64AUIPC or GetRiscV64PC, Please remove 12 at least.
private static unsafe int GetRiscV64PC12(uint* pCode) | |
private static unsafe int GetRiscV64PC(uint* pCode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I’ll fix this
@@ -319,6 +319,9 @@ public void EmitReloc(ISymbolNode symbol, RelocType relocType, int delta = 0) | |||
|
|||
case RelocType.IMAGE_REL_BASED_LOONGARCH64_PC: | |||
case RelocType.IMAGE_REL_BASED_LOONGARCH64_JIR: | |||
|
|||
//TODO: consider removal of IMAGE_REL_BASED_RISCV64_JIR from runtime too |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update IMAGE_REL_BASED_RISCV64_JIR
to IMAGE_REL_RISCV64_JALR
.
In the runtime, IMAGE_REL_RISCV64_JALR
is used.
// case:EA_PTR_DSP_RELOC | ||
// auipc reg, off-hi-20bits | ||
// ld reg, reg, off-lo-12bits | ||
private static unsafe void PutRiscV64PC12(uint* pCode, long imm32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the name too.
private static unsafe void PutRiscV64PC12(uint* pCode, long imm32) | |
private static unsafe void PutRiscV64PC(uint* pCode, long imm32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I’ll fix this
EmitRET(); | ||
} | ||
|
||
public void EmitJE(Register regSrc, ISymbolNode symbol) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think EmitJNEZ
is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's actually the same as for other arches meaning that we jump over the stuff generated by emitjmp in case condition is reversed (in this case ne
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think EmitJE
naming is for ARM* arch which use flag after cmp
instruction. However, in RISC-V it doesn't compare and jump like ARM*. So I thought it is better if it shows RISC-V's code generation like what you changed EmitRetIfEqual
to EmitRetIfZero
.
I am confusing. I think EmitJEZ
seems right.
This is just my suggestion. You can freely choose. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, my bad, thought about the other thing, yes, you are right :) I meant that it's not EmitJNotfZero
, but EmitJIfZero
uint offset = symbol.RepresentsIndirectionCell ? 14u : 4u; | ||
uint encodedOffset = ((offset & 0x1e) << 7) | ((offset & 0x7e0) << 20) | ((offset & 0x800) >> 4) | ((offset & 0x1000) << 19); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With your encodedOffset logic, offset should be 7 << 2 : 2 << 2. Please check again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
} | ||
|
||
public void EmitLI(Register regDst, ushort imm12) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add assert for imm12.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I’ll fix this
protected override void EmitCode(NodeFactory factory, ref RiscV64Emitter encoder, bool relocsOnly) | ||
{ | ||
// addi a0, a0, sizeof(void*) | ||
encoder.EmitADDI(encoder.TargetRegister.Arg0, encoder.TargetRegister.Arg0, factory.Target.PointerSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Update EmitADDI to EmitLI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is addition with a0, EmitLI does similar thing, but arg is x0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right! Thank you!
private int _riscv64IdxGenReg; // Next general register to be assigned a value | ||
private int _riscv64OfsStack; // Offset of next stack location to be assigned a value | ||
private int _riscv64IdxFPReg; // Next FP register to be assigned a value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adds more spaces for the comments like the others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I’ll fix this
// a0 .. a7 | ||
public override int NumArgumentRegisters => 8; | ||
// fp=x8, ra=x1, s1-s11(R9,R18-R27), tp=x3, gp=x4 | ||
public override int NumCalleeSavedRegisters => 15; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the comment, total fp, ra, s1-s11, tp and gp is 14. Could you check which is correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that both are 15, or am I missing smth? x1, x3, x4, x8, x9, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right! Thank you!
// a0 .. a7 | ||
public override int NumArgumentRegisters => 8; | ||
// fp=x8, ra=x1, s1-s11(R9,R18-R27), tp=x3, gp=x4 | ||
public override int NumCalleeSavedRegisters => 15; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the comment, total fp, ra, s1-s11, tp and gp is 14. Could you check which is correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that both are 15, or am I missing smth? x1, x3, x4, x8, x9, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right! Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Thanks for doing a great job with a difficult task!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I applaud your great PR.
@dotnet/crossgen-contrib Can you please take a look at this pull request and provide feedback? Thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've looked through the changes and they look good to me. In a few weeks I expect that we will have the updated .NET 9 sdk in place. Would you like to merge this change now and then fix the various TODO's around the Machine and Architecture enums once the new SDK is in place? If so, please file an issue to do so. Once that issue is in place, I'm willing to merge this PR.
Also, we need a clean test results before I will merge, so please look into the failures/rerun stuff if necessary. |
@@ -96,6 +96,7 @@ public static TargetArchitecture GetTargetArchitecture(string token) | |||
Architecture.Arm => TargetArchitecture.ARM, | |||
Architecture.Arm64 => TargetArchitecture.ARM64, | |||
Architecture.LoongArch64 => TargetArchitecture.LoongArch64, | |||
(Architecture)9 => TargetArchitecture.RiscV64, /* TODO: update with Architecture.RiscV64 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a tracking work item for this TODO? It would be for the best to keep hard coded numbers like this one for as short as possible.
@@ -6,7 +6,7 @@ | |||
<IsDotNetFrameworkProductAssembly>true</IsDotNetFrameworkProductAssembly> | |||
<TargetFramework>$(NetCoreAppToolCurrent)</TargetFramework> | |||
<DefineConstants>READYTORUN;$(DefineConstants)</DefineConstants> | |||
<Platforms>x64;x86;arm;arm64</Platforms> | |||
<Platforms>x64;x86;arm;arm64;</Platforms> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this ';' added here? Did something change in MSBuild that requires lists to be finished with a semicolon?
@@ -154,6 +154,11 @@ internal GcInfoTypes(Machine machine) | |||
STACK_BASE_REGISTER_ENCBASE = 2; | |||
NUM_REGISTERS_ENCBASE = 3; | |||
break; | |||
case (Machine)0x5064: /* TODO: update with RiscV64 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question as before. Do we have a tracking work item to change these hardcoded values to the respective enum values?
@davidwrighton @ivdiazsa I've created new issue for those todos #96438. @davidwrighton It would be better to merge the change now and fix todos in separate PR. Can you please trigger rerun of CI? @ashaurtaev will get back from vacation only at the beginning of next week. So if CI passes after rerun, please merge this and we'll fix todos next week. |
The easiest way to rerun the CI is to close and reopen the PR. |
@gbalykov Thanks for filing the tracking issue for the TODO's! |
Thank you! |
1 similar comment
Thank you! |
Added crossgen2 for riscv64
Part of #84834
cc @wscho77 @HJLeee @clamp03 @JongHeonChoi @t-mustafin @gbalykov @yurai007 @sirntar @tomeksowi @Bajtazar @brucehoult