From 6d9a1821bcc67e41299b0af03714b6f29c6b30e9 Mon Sep 17 00:00:00 2001 From: Lucas Date: Tue, 17 Dec 2024 17:50:25 -0300 Subject: [PATCH] Finish tests --- llvm/lib/Target/SBF/Disassembler/SBFDisassembler.cpp | 4 +++- llvm/test/MC/Disassembler/SBF/sbf-jmp.txt | 6 ++++++ llvm/test/MC/SBF/sbf-return-syscall.s | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Target/SBF/Disassembler/SBFDisassembler.cpp b/llvm/lib/Target/SBF/Disassembler/SBFDisassembler.cpp index f9489bc85df3eb3..327b6a9b8588a8c 100644 --- a/llvm/lib/Target/SBF/Disassembler/SBFDisassembler.cpp +++ b/llvm/lib/Target/SBF/Disassembler/SBFDisassembler.cpp @@ -69,6 +69,7 @@ class SBFDisassembler : public MCDisassembler { uint8_t getInstMode(uint64_t Inst) const { return (Inst >> 61) & 0x7; }; bool isMov32(uint64_t Inst) const { return (Inst >> 56) == 0xb4; } bool isNewMem(uint64_t Inst) const; + bool isSyscallOrExit(uint64_t Inst) const { return (Inst >> 56) == 0x95; } }; } // end anonymous namespace @@ -202,7 +203,8 @@ DecodeStatus SBFDisassembler::getInstruction(MCInst &Instr, uint64_t &Size, Result = decodeInstruction(DecoderTableSBFALU32MEMv264, Instr, Insn, Address, this, STI); - else if (isNewMem(Insn) && STI.hasFeature(SBF::FeatureNewMemEncoding)) + else if ((isNewMem(Insn) && STI.hasFeature(SBF::FeatureNewMemEncoding)) || + (isSyscallOrExit(Insn) && STI.hasFeature(SBF::FeatureStaticSyscalls))) Result = decodeInstruction(DecoderTableSBFv264, Instr, Insn, Address, this, STI); diff --git a/llvm/test/MC/Disassembler/SBF/sbf-jmp.txt b/llvm/test/MC/Disassembler/SBF/sbf-jmp.txt index 278ed8d3774da3e..a51c1230ea43089 100644 --- a/llvm/test/MC/Disassembler/SBF/sbf-jmp.txt +++ b/llvm/test/MC/Disassembler/SBF/sbf-jmp.txt @@ -1,5 +1,7 @@ # RUN: llvm-mc --disassemble %s -triple=sbf-solana-solana \ # RUN: | FileCheck %s --check-prefix=CHECK-NEW +# RUN: llvm-mc --disassemble %s -triple=sbf-solana-solana -mattr=+static-syscalls \ +# RUN: | FileCheck %s --check-prefix=CHECK-V2 # TODO: Test immediate field ranges. @@ -109,5 +111,9 @@ # CHECK-NEW: exit 0x95,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +# CHECK-V2: syscall 5 +0x95,0x00,0x00,0x00,0x05,0x00,0x00,0x00 + + # CHECK-NEW: return 0x9d,0x00,0x00,0x00,0x00,0x00,0x00,0x00 diff --git a/llvm/test/MC/SBF/sbf-return-syscall.s b/llvm/test/MC/SBF/sbf-return-syscall.s index 7ac3233c8b78a97..9f3b9ca00004aae 100644 --- a/llvm/test/MC/SBF/sbf-return-syscall.s +++ b/llvm/test/MC/SBF/sbf-return-syscall.s @@ -4,5 +4,5 @@ syscall 9 return -// CHECK: 95 00 00 00 09 00 00 00 syscall 9 +// CHECK: 95 00 00 00 09 00 00 00 syscall 0x9 // CHECK: 9d 00 00 00 00 00 00 00 return \ No newline at end of file