Skip to content
Draft
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
22 changes: 22 additions & 0 deletions llvm/test/MC/SBF/sbf-include-basic.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# RUN: llvm-mc %s -triple=sbf-solana-solana -filetype=obj -I %p -o %t.o
# RUN: llvm-objdump -d %t.o | FileCheck %s --check-prefix=CHECK-OBJ

# Test basic .include directive functionality for SBF

.include "sbf-include-helper.s"

.text
.globl entrypoint
entrypoint:
call custom_log
exit

# CHECK-OBJ: lddw
# CHECK-OBJ: r1
# CHECK-OBJ: lddw
# CHECK-OBJ: r2, 0xe
# CHECK-OBJ: call
# CHECK-OBJ: exit
# CHECK-OBJ: <entrypoint>:
# CHECK-OBJ: call
# CHECK-OBJ: exit
9 changes: 9 additions & 0 deletions llvm/test/MC/SBF/sbf-include-globl-helper.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Helper file for sbf-include-no-globl.s
# This file contains a .globl directive which should produce an error
# when included

.text
.globl helper_fn
helper_fn:
mov64 r0, 0
exit
11 changes: 11 additions & 0 deletions llvm/test/MC/SBF/sbf-include-helper.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Helper file for sbf-include-basic.s
# This file defines a simple function that can be included

custom_log:
lddw r1, message
lddw r2, 14
call sol_log_
exit

.rodata
message: .ascii "Hello, Solana!"
15 changes: 15 additions & 0 deletions llvm/test/MC/SBF/sbf-include-missing.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# RUN: not llvm-mc %s -triple=sbf-solana-solana -filetype=obj -I %p 2>&1 \
# RUN: | FileCheck %s --check-prefix=CHECK

# Test that including a non-existent file produces an error

# CHECK: error:
# CHECK: Could not find include file
# CHECK: nonexistent_file.s

.include "nonexistent_file.s"

.text
.globl entrypoint
entrypoint:
exit
11 changes: 11 additions & 0 deletions llvm/test/MC/SBF/sbf-include-nested-inner.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Inner file for nested include test
# This file is included by sbf-include-nested-middle.s

custom_log:
lddw r1, message
lddw r2, 7
call sol_log_
exit

.rodata
message: .ascii "Nested!"
4 changes: 4 additions & 0 deletions llvm/test/MC/SBF/sbf-include-nested-middle.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Middle file for nested include test
# This file is included by sbf-include-nested.s and includes the inner file

.include "sbf-include-nested-inner.s"
22 changes: 22 additions & 0 deletions llvm/test/MC/SBF/sbf-include-nested.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# RUN: llvm-mc %s -triple=sbf-solana-solana -filetype=obj -I %p -o %t.o
# RUN: llvm-objdump -d %t.o | FileCheck %s --check-prefix=CHECK-OBJ

# Test nested .include directive functionality for SBF

.include "sbf-include-nested-middle.s"

.text
.globl entrypoint
entrypoint:
call custom_log
exit

# CHECK-OBJ: lddw
# CHECK-OBJ: r1
# CHECK-OBJ: lddw
# CHECK-OBJ: r2, 0x7
# CHECK-OBJ: call
# CHECK-OBJ: exit
# CHECK-OBJ: <entrypoint>:
# CHECK-OBJ: call
# CHECK-OBJ: exit
16 changes: 16 additions & 0 deletions llvm/test/MC/SBF/sbf-include-no-globl.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# RUN: not llvm-mc %s -triple=sbf-solana-solana -filetype=obj -I %p 2>&1 \
# RUN: | FileCheck %s --check-prefix=CHECK

# Test that .globl in an included file produces an error for SBF

# CHECK: error:
# CHECK: .globl 'helper_fn' is not allowed in included files
# CHECK: Only the main entrypoint file should declare .globl symbols

.include "sbf-include-globl-helper.s"

.text
.globl entrypoint
entrypoint:
call helper_fn
exit
Loading