Skip to content
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

AEON: bn.bnei immediate is signed #1329

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Arch/OpenRISC/Aeon/AeonDisassembler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ private static Decoder<AeonDisassembler, Mnemonic, AeonInstruction> Create24bitI
// branch if reg == imm
Instr(Mnemonic.bn_beqi__, InstrClass.ConditionalTransfer, R13, simm10_3, disp2_8), // guess
Instr(Mnemonic.bn_bf, InstrClass.ConditionalTransfer, disp2_16), // chenxing(mod), source
Instr(Mnemonic.bn_bnei__, InstrClass.ConditionalTransfer, R13, uimm10_3, disp2_8),
Instr(Mnemonic.bn_bnei__, InstrClass.ConditionalTransfer, R13, simm10_3, disp2_8),
Instr(Mnemonic.bn_bnf__, InstrClass.ConditionalTransfer, disp2_16));

var decode001001 = Mask(0, 2, " 9",
Expand Down
2 changes: 1 addition & 1 deletion src/Arch/OpenRISC/Aeon/Assembler/AeonAssembler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void bn_bnei(RegisterStorage reg, ParsedOperand imm, ParsedOperand displa
{
var opcode = (0b001000u << 18) | 0b10;
opcode |= R(reg, 13);
opcode |= U(imm, 10, 3);
opcode |= S(imm, 10, 3);
opcode |= S(displacement, 2, 8);
EmitUInt24(opcode);
}
Expand Down
20 changes: 17 additions & 3 deletions src/Arch/OpenRISC/Aeon/Assembler/AeonTextAssembler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private void ProcessLine(CDirectiveLexer lex, AeonAssembler asm)
R_R_UImm(lex, asm, 0, AeonAssembler.RT_AEON_BG_LO16_0, asm.bg_andi);
break;
case "beqi":
R_I_Disp(lex, asm, AeonAssembler.RT_AEON_BG_DISP13_3, asm.bg_beqi);
R_UImm_Disp(lex, asm, AeonAssembler.RT_AEON_BG_DISP13_3, asm.bg_beqi);
break;
case "sb":
M_R(lex, asm, PrimitiveType.Byte, AeonAssembler.RT_AEON_BG_LO16_0, asm.bg_sb);
Expand All @@ -143,7 +143,7 @@ private void ProcessLine(CDirectiveLexer lex, AeonAssembler asm)
switch (mnemonic)
{
case "bnei":
R_I_Disp(lex, asm, AeonAssembler.RT_AEON_BN_DISP8_2, asm.bn_bnei);
R_SImm_Disp(lex, asm, AeonAssembler.RT_AEON_BN_DISP8_2, asm.bn_bnei);
break;
case "j":
Disp(lex, asm, AeonAssembler.RT_AEON_BN_DISP18, asm.bn_j);
Expand Down Expand Up @@ -335,7 +335,7 @@ private void Disp(
assemble(disp);
}

private void R_I_Disp(
private void R_UImm_Disp(
CDirectiveLexer lex,
AeonAssembler asm,
int relocationType,
Expand All @@ -349,6 +349,20 @@ private void R_I_Disp(
assemble(rsrc1, immop, disp);
}

private void R_SImm_Disp(
CDirectiveLexer lex,
AeonAssembler asm,
int relocationType,
Action<RegisterStorage, ParsedOperand, ParsedOperand> assemble)
{
var rsrc1 = ExpectRegister(lex);
Expect(lex, CTokenType.Comma);
var immop = ParseSImmediateOperand(lex);
Expect(lex, CTokenType.Comma);
var disp = ParseDisplacement(lex, asm, relocationType);
assemble(rsrc1, immop, disp);
}

private bool PeekAndDiscard(CDirectiveLexer lex, CTokenType tokenType)
{
var t = Peek(lex);
Expand Down
6 changes: 6 additions & 0 deletions src/UnitTests/Arch/OpenRISC/AeonAssemblerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ public void AeonAsm_bn_bnei()
AssertAsm("bn.bnei\tr6,0x0,0x00100017", "20 C0 5E");
}

[Test]
public void AeonAsm_bn_bnei_signed()
{
AssertAsm("bn.bnei\tr13,-1,0x00FFFFE0", "21 BF 82");
}

[Test]
public void AeonAsm_bn_j()
{
Expand Down
2 changes: 1 addition & 1 deletion src/UnitTests/Arch/OpenRISC/AeonRewriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public void AeonRw_bn_bnei__()
Given_HexString("21 4D B6");
AssertCode( // bn.bnei? r10,0x3,0010006D
"0|T--|00100000(3): 1 instructions",
"1|T--|if (r10 != 3<32>) branch 0010006D");
"1|T--|if (r10 != 3<i32>) branch 0010006D");
}

[Test]
Expand Down
Loading