diff --git a/llvm/lib/Target/SBF/SBFInstrInfo.td b/llvm/lib/Target/SBF/SBFInstrInfo.td index 057c92327a9297..b9e667070d9b55 100644 --- a/llvm/lib/Target/SBF/SBFInstrInfo.td +++ b/llvm/lib/Target/SBF/SBFInstrInfo.td @@ -69,6 +69,8 @@ def SBFExplicitSignExt : Predicate<"Subtarget->getHasExplicitSignExt()">; def SBFNoExplicitSignExt : Predicate<"!Subtarget->getHasExplicitSignExt()">; def SBFNewMemEncoding : Predicate<"Subtarget->getNewMemEncoding()">, AssemblerPredicate<(all_of FeatureNewMemEncoding)>; def SBFOldMemEncoding : Predicate<"!Subtarget->getNewMemEncoding()">; +def SBFHasStaticSyscalls : Predicate<"Subtarget->getHasStaticSyscalls()">; +def SBFNoStaticSyscalls : Predicate<"!Subtarget->getHasStaticSyscalls()">; def brtarget : Operand { let PrintMethod = "printBrTargetOperand"; @@ -854,7 +856,7 @@ class NOP_I let hasSideEffects = 0, isCodeGenOnly = 1 in def NOP : NOP_I<"nop">; -class RET +class EXIT : TYPE_ALU_JMP } let isReturn = 1, isTerminator = 1, hasDelaySlot=0, isBarrier = 1, - isNotDuplicable = 1 in { - def RET : RET<"exit">; + isNotDuplicable = 1, Predicates = [SBFNoStaticSyscalls] in { + def EXIT : EXIT<"exit">; +} + +class RETURN + : TYPE_ALU_JMP { + let Inst{31-0} = 0; + let SBFClass = SBF_JMP; +} + +let isReturn = 1, isTerminator = 1, hasDelaySlot=0, isBarrier = 1, + isNotDuplicable = 1, Predicates = [SBFHasStaticSyscalls] in { + def RETURN : RETURN<"return">; } // ADJCALLSTACKDOWN/UP pseudo insns diff --git a/llvm/lib/Target/SBF/SBFSubtarget.h b/llvm/lib/Target/SBF/SBFSubtarget.h index f30fcf51607097..518ca7e2e193c8 100644 --- a/llvm/lib/Target/SBF/SBFSubtarget.h +++ b/llvm/lib/Target/SBF/SBFSubtarget.h @@ -107,6 +107,7 @@ class SBFSubtarget : public SBFGenSubtargetInfo { bool getHasStoreImm() const { return HasStoreImm; } bool getHasExplicitSignExt() const { return HasExplicitSignExt; } bool getNewMemEncoding() const { return NewMemEncoding; } + bool getHasStaticSyscalls() const { return HasStaticSyscalls; } const SBFInstrInfo *getInstrInfo() const override { return &InstrInfo; } const SBFFrameLowering *getFrameLowering() const override { return &FrameLowering; diff --git a/llvm/test/CodeGen/SBF/objdump_cond_op.ll b/llvm/test/CodeGen/SBF/objdump_cond_op.ll index d753f24656512f..ecabfee937e28f 100644 --- a/llvm/test/CodeGen/SBF/objdump_cond_op.ll +++ b/llvm/test/CodeGen/SBF/objdump_cond_op.ll @@ -67,6 +67,6 @@ define i32 @test(i32, i32) local_unnamed_addr #0 { %16 = phi i32 [ %14, %13 ], [ %10, %8 ] ret i32 %16 ; CHECK-LABEL: : -; CHECK: exit +; CHECK: return } attributes #0 = { norecurse nounwind } diff --git a/llvm/test/CodeGen/SBF/objdump_cond_op_2.ll b/llvm/test/CodeGen/SBF/objdump_cond_op_2.ll index a887dc2d8f38a5..085d617baa7922 100644 --- a/llvm/test/CodeGen/SBF/objdump_cond_op_2.ll +++ b/llvm/test/CodeGen/SBF/objdump_cond_op_2.ll @@ -33,6 +33,6 @@ define i32 @test(i32, i32) local_unnamed_addr #0 { %14 = phi i32 [ 0, %2 ], [ %9, %5 ] ret i32 %14 ; CHECK-LABEL: : -; CHECK: exit +; CHECK: return } attributes #0 = { norecurse nounwind readnone } diff --git a/llvm/test/CodeGen/SBF/objdump_static_var.ll b/llvm/test/CodeGen/SBF/objdump_static_var.ll index 26d645ae8147fa..f65e775e3afc7d 100644 --- a/llvm/test/CodeGen/SBF/objdump_static_var.ll +++ b/llvm/test/CodeGen/SBF/objdump_static_var.ll @@ -23,7 +23,7 @@ define dso_local i32 @test() local_unnamed_addr #0 { %4 = add i32 %2, %3 ; CHECK: add64 r0, r1 ret i32 %4 -; CHECK: exit +; CHECK: return } attributes #0 = { norecurse nounwind } diff --git a/llvm/test/CodeGen/SBF/objdump_trivial.ll b/llvm/test/CodeGen/SBF/objdump_trivial.ll index ba3006923e5a5f..4cc21401983383 100644 --- a/llvm/test/CodeGen/SBF/objdump_trivial.ll +++ b/llvm/test/CodeGen/SBF/objdump_trivial.ll @@ -2,9 +2,9 @@ ; CHECK: jsgt r2, r1, ; CHECK: call 0x1 -; CHECK: exit +; CHECK: return ; CHECK: call 0x2 -; CHECK: exit +; CHECK: return define void @foo(i32 %a) { %b = icmp sgt i32 %a, -1 diff --git a/llvm/test/CodeGen/SBF/return_instr.ll b/llvm/test/CodeGen/SBF/return_instr.ll new file mode 100644 index 00000000000000..b3dcd72410142a --- /dev/null +++ b/llvm/test/CodeGen/SBF/return_instr.ll @@ -0,0 +1,14 @@ +; RUN: llc < %s -march=sbf -show-mc-encoding | FileCheck --check-prefix=CHECK-V1 %s +; RUN: llc < %s -march=sbf -mattr=+static-syscalls -show-mc-encoding | FileCheck --check-prefix=CHECK-V2 %s + +define dso_local i64 @rem(i64 %a) local_unnamed_addr #0 { +entry: +; CHECK-LABEL: rem + %rem = urem i64 %a, 15 + +; CHECK-V1: exit # encoding: [0x95,0x00,0x00,0x00,0x00,0x00,0x00,0x00] +; CHECK-V2: return # encoding: [0x9d,0x00,0x00,0x00,0x00,0x00,0x00,0x00] + + + ret i64 %rem +} \ No newline at end of file diff --git a/llvm/test/MC/Disassembler/SBF/sbf-jmp.txt b/llvm/test/MC/Disassembler/SBF/sbf-jmp.txt index 33a35d36a7a63d..278ed8d3774da3 100644 --- a/llvm/test/MC/Disassembler/SBF/sbf-jmp.txt +++ b/llvm/test/MC/Disassembler/SBF/sbf-jmp.txt @@ -108,3 +108,6 @@ # CHECK-NEW: exit 0x95,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + +# CHECK-NEW: return +0x9d,0x00,0x00,0x00,0x00,0x00,0x00,0x00 diff --git a/llvm/test/MC/SBF/sbf-return.s b/llvm/test/MC/SBF/sbf-return.s new file mode 100644 index 00000000000000..11e333f76983ef --- /dev/null +++ b/llvm/test/MC/SBF/sbf-return.s @@ -0,0 +1,6 @@ +# RUN: llvm-mc -triple=sbf-solana-solana --mcpu=sbfv2 -filetype=obj -o %t %s +# RUN: llvm-objdump -d -r %t | FileCheck --check-prefix=CHECK %s + +return + +// CHECK: 9d 00 00 00 00 00 00 00 return \ No newline at end of file